|
15 | 15 |
|
16 | 16 | import static org.assertj.core.api.Assertions.assertThat;
|
17 | 17 | import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
18 |
| -import static org.mockito.Mockito.mock; |
19 |
| -import static org.mockito.Mockito.when; |
20 | 18 |
|
21 | 19 | import java.util.Optional;
|
| 20 | +import java.util.function.Supplier; |
22 | 21 | import org.apache.tuweni.bytes.Bytes32;
|
23 | 22 | import org.junit.jupiter.api.Test;
|
24 |
| -import tech.pegasys.teku.infrastructure.async.ExceptionThrowingSupplier; |
25 | 23 | import tech.pegasys.teku.spec.TestSpecFactory;
|
26 | 24 | import tech.pegasys.teku.spec.util.DataStructureUtil;
|
27 | 25 |
|
@@ -59,49 +57,49 @@ void get_shouldBeEmptyWhenBothEmpty() {
|
59 | 57 | }
|
60 | 58 |
|
61 | 59 | @Test
|
62 |
| - @SuppressWarnings("unchecked") |
63 |
| - public void get_shouldDelegateToDefaultProviderWhenStorageProviderFails() throws Throwable { |
64 |
| - final ExceptionThrowingSupplier<Optional<Bytes32>> storageProvider = |
65 |
| - mock(ExceptionThrowingSupplier.class); |
66 |
| - when(storageProvider.get()).thenThrow(new RuntimeException("Error")); |
| 60 | + public void get_shouldDelegateToDefaultProviderWhenStorageProviderFails() { |
| 61 | + final Supplier<Optional<Bytes32>> storageProvider = |
| 62 | + () -> { |
| 63 | + throw new RuntimeException("Error"); |
| 64 | + }; |
67 | 65 |
|
68 | 66 | provider = new UpdatableGraffitiProvider(storageProvider, () -> Optional.of(defaultGraffiti));
|
69 | 67 | assertThat(provider.get()).hasValue(defaultGraffiti);
|
70 | 68 | }
|
71 | 69 |
|
72 | 70 | @Test
|
73 |
| - void getWithThrowable_shouldGetStorageGraffitiWhenAvailable() throws Throwable { |
| 71 | + void getWithThrowable_shouldGetStorageGraffitiWhenAvailable() { |
74 | 72 | provider = new UpdatableGraffitiProvider(() -> Optional.of(storageGraffiti), Optional::empty);
|
75 | 73 | assertThat(provider.getUnsafe()).hasValue(storageGraffiti);
|
76 | 74 | }
|
77 | 75 |
|
78 | 76 | @Test
|
79 |
| - void getWithThrowable_shouldGetStorageGraffitiWhenBothAvailable() throws Throwable { |
| 77 | + void getWithThrowable_shouldGetStorageGraffitiWhenBothAvailable() { |
80 | 78 | provider =
|
81 | 79 | new UpdatableGraffitiProvider(
|
82 | 80 | () -> Optional.of(storageGraffiti), () -> Optional.of(defaultGraffiti));
|
83 | 81 | assertThat(provider.getUnsafe()).hasValue(storageGraffiti);
|
84 | 82 | }
|
85 | 83 |
|
86 | 84 | @Test
|
87 |
| - void getWithThrowable_shouldGetDefaultGraffitiWhenStorageEmpty() throws Throwable { |
| 85 | + void getWithThrowable_shouldGetDefaultGraffitiWhenStorageEmpty() { |
88 | 86 | provider = new UpdatableGraffitiProvider(Optional::empty, () -> Optional.of(defaultGraffiti));
|
89 | 87 | assertThat(provider.getUnsafe()).hasValue(defaultGraffiti);
|
90 | 88 | }
|
91 | 89 |
|
92 | 90 | @Test
|
93 |
| - void getWithThrowable_shouldBeEmptyWhenBothEmpty() throws Throwable { |
| 91 | + void getWithThrowable_shouldBeEmptyWhenBothEmpty() { |
94 | 92 | provider = new UpdatableGraffitiProvider(Optional::empty, Optional::empty);
|
95 | 93 | assertThat(provider.getUnsafe()).isEmpty();
|
96 | 94 | }
|
97 | 95 |
|
98 | 96 | @Test
|
99 |
| - @SuppressWarnings("unchecked") |
100 |
| - public void getWithThrowable_shouldThrowExceptionWhenStorageProviderFails() throws Throwable { |
| 97 | + public void getWithThrowable_shouldThrowExceptionWhenStorageProviderFails() { |
101 | 98 | final RuntimeException exception = new RuntimeException("Error");
|
102 |
| - final ExceptionThrowingSupplier<Optional<Bytes32>> storageProvider = |
103 |
| - mock(ExceptionThrowingSupplier.class); |
104 |
| - when(storageProvider.get()).thenThrow(exception); |
| 99 | + final Supplier<Optional<Bytes32>> storageProvider = |
| 100 | + () -> { |
| 101 | + throw exception; |
| 102 | + }; |
105 | 103 |
|
106 | 104 | provider = new UpdatableGraffitiProvider(storageProvider, () -> Optional.of(defaultGraffiti));
|
107 | 105 | assertThatThrownBy(() -> provider.getUnsafe()).isEqualTo(exception);
|
|
0 commit comments