Skip to content

Commit d9f196e

Browse files
committed
Rename get with throwable
1 parent b2b70a1 commit d9f196e

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

validator/api/src/main/java/tech/pegasys/teku/validator/api/UpdatableGraffitiProvider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private Optional<Bytes32> getFromStorage() {
4141
}
4242
}
4343

44-
public Optional<Bytes32> getWithThrowable() throws Throwable {
44+
public Optional<Bytes32> getUnsafe() throws Throwable {
4545
return storageProvider.get().or(defaultProvider::get);
4646
}
4747
}

validator/api/src/test/java/tech/pegasys/teku/validator/api/UpdatableGraffitiProviderTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,27 @@ public void get_shouldDelegateToDefaultProviderWhenStorageProviderFails() throws
7272
@Test
7373
void getWithThrowable_shouldGetStorageGraffitiWhenAvailable() throws Throwable {
7474
provider = new UpdatableGraffitiProvider(() -> Optional.of(storageGraffiti), Optional::empty);
75-
assertThat(provider.getWithThrowable()).hasValue(storageGraffiti);
75+
assertThat(provider.getUnsafe()).hasValue(storageGraffiti);
7676
}
7777

7878
@Test
7979
void getWithThrowable_shouldGetStorageGraffitiWhenBothAvailable() throws Throwable {
8080
provider =
8181
new UpdatableGraffitiProvider(
8282
() -> Optional.of(storageGraffiti), () -> Optional.of(defaultGraffiti));
83-
assertThat(provider.getWithThrowable()).hasValue(storageGraffiti);
83+
assertThat(provider.getUnsafe()).hasValue(storageGraffiti);
8484
}
8585

8686
@Test
8787
void getWithThrowable_shouldGetDefaultGraffitiWhenStorageEmpty() throws Throwable {
8888
provider = new UpdatableGraffitiProvider(Optional::empty, () -> Optional.of(defaultGraffiti));
89-
assertThat(provider.getWithThrowable()).hasValue(defaultGraffiti);
89+
assertThat(provider.getUnsafe()).hasValue(defaultGraffiti);
9090
}
9191

9292
@Test
9393
void getWithThrowable_shouldBeEmptyWhenBothEmpty() throws Throwable {
9494
provider = new UpdatableGraffitiProvider(Optional::empty, Optional::empty);
95-
assertThat(provider.getWithThrowable()).isEmpty();
95+
assertThat(provider.getUnsafe()).isEmpty();
9696
}
9797

9898
@Test
@@ -104,6 +104,6 @@ public void getWithThrowable_shouldThrowExceptionWhenStorageProviderFails() thro
104104
when(storageProvider.get()).thenThrow(exception);
105105

106106
provider = new UpdatableGraffitiProvider(storageProvider, () -> Optional.of(defaultGraffiti));
107-
assertThatThrownBy(() -> provider.getWithThrowable()).isEqualTo(exception);
107+
assertThatThrownBy(() -> provider.getUnsafe()).isEqualTo(exception);
108108
}
109109
}

validator/client/src/main/java/tech/pegasys/teku/validator/client/restapi/apis/GetGraffiti.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc
9393
try {
9494
final UpdatableGraffitiProvider provider =
9595
(UpdatableGraffitiProvider) maybeValidator.get().getGraffitiProvider();
96-
request.respondOk(new GraffitiResponse(publicKey, provider.getWithThrowable()));
96+
request.respondOk(new GraffitiResponse(publicKey, provider.getUnsafe()));
9797
} catch (Throwable e) {
9898
request.respondError(SC_INTERNAL_SERVER_ERROR, e.getMessage());
9999
}

validator/client/src/test/java/tech/pegasys/teku/validator/client/restapi/apis/GetGraffitiTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void shouldHandleGraffitiManagementException() throws Throwable {
7676
final GraffitiManagementException exception =
7777
new GraffitiManagementException("Unable to retrieve graffiti from storage");
7878
final UpdatableGraffitiProvider provider = mock(UpdatableGraffitiProvider.class);
79-
doThrow(exception).when(provider).getWithThrowable();
79+
doThrow(exception).when(provider).getUnsafe();
8080
final Validator validator = new Validator(publicKey, NO_OP_SIGNER, provider);
8181
when(keyManager.getValidatorByPublicKey(eq(publicKey))).thenReturn(Optional.of(validator));
8282

@@ -85,7 +85,7 @@ void shouldHandleGraffitiManagementException() throws Throwable {
8585
assertThat(request.getResponseCode()).isEqualTo(SC_INTERNAL_SERVER_ERROR);
8686
assertThat(request.getResponseBody())
8787
.isEqualTo(new HttpErrorResponse(SC_INTERNAL_SERVER_ERROR, exception.getMessage()));
88-
verify(provider).getWithThrowable();
88+
verify(provider).getUnsafe();
8989
}
9090

9191
@Test
@@ -133,7 +133,7 @@ void metadata_shouldHandle500() throws JsonProcessingException {
133133

134134
private void checkGraffiti(final Optional<Bytes32> graffiti) throws Throwable {
135135
final UpdatableGraffitiProvider provider = mock(UpdatableGraffitiProvider.class);
136-
when(provider.getWithThrowable()).thenReturn(graffiti);
136+
when(provider.getUnsafe()).thenReturn(graffiti);
137137
final Validator validator = new Validator(publicKey, NO_OP_SIGNER, provider);
138138
when(keyManager.getValidatorByPublicKey(eq(publicKey))).thenReturn(Optional.of(validator));
139139

@@ -143,6 +143,6 @@ private void checkGraffiti(final Optional<Bytes32> graffiti) throws Throwable {
143143
new GetGraffiti.GraffitiResponse(publicKey, graffiti);
144144
assertThat(request.getResponseCode()).isEqualTo(SC_OK);
145145
assertThat(request.getResponseBody()).isEqualTo(expectedResponse);
146-
verify(provider).getWithThrowable();
146+
verify(provider).getUnsafe();
147147
}
148148
}

0 commit comments

Comments
 (0)