Skip to content

Commit

Permalink
Simplify lambdas in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rhowe committed Feb 2, 2022
1 parent 350c52f commit 764f2a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void validSetTotalSizeCap() throws IOException, ConfigurationException, NoSuchFi

final FileAppender appender = factory.build(new ResourceConfigurationSourceProvider(), "yaml/appender_file_cap.yaml")
.buildAppender(new LoggerContext());
assertThat(appender).isInstanceOfSatisfying(RollingFileAppender.class, roller -> {
assertThat(appender).isInstanceOfSatisfying(RollingFileAppender.class, roller ->
assertThat(roller.getRollingPolicy()).isInstanceOfSatisfying(SizeAndTimeBasedRollingPolicy.class, policy -> {
try {
assertThat(totalSizeCap.get(policy))
Expand All @@ -358,8 +358,8 @@ void validSetTotalSizeCap() throws IOException, ConfigurationException, NoSuchFi
} catch (IllegalAccessException e) {
throw new RuntimeException("Unexpected illegal access", e);
}
});
});
})
);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@ void writeToShouldThrowWhenNoValidRendererFound() {
when(metricRegistry.timer(anyString())).thenReturn(timer);
when(timer.time()).thenReturn(timerContext);

assertThatExceptionOfType(WebApplicationException.class).isThrownBy(() -> {
writer.writeTo(view, Class.class, Class.class, new Annotation[]{}, new MediaType(),
new MultivaluedHashMap<>(), stream);
}).withCauseExactlyInstanceOf(ViewRenderException.class);
assertThatExceptionOfType(WebApplicationException.class)
.isThrownBy(() -> writer.writeTo(view, Class.class, Class.class, new Annotation[]{}, new MediaType(), new MultivaluedHashMap<>(), stream)).withCauseExactlyInstanceOf(ViewRenderException.class);

verify(timerContext).stop();
}
Expand All @@ -95,10 +93,9 @@ void writeToShouldHandleViewRenderingExceptions() throws IOException {
doReturn(locale).when(writer).detectLocale(any());
writer.setHeaders(mock(HttpHeaders.class));

assertThatExceptionOfType(WebApplicationException.class).isThrownBy(() -> {
writer.writeTo(view, Class.class, Class.class, new Annotation[]{}, new MediaType(),
new MultivaluedHashMap<>(), stream);
}).withCause(exception);
assertThatExceptionOfType(WebApplicationException.class)
.isThrownBy(() -> writer.writeTo(view, Class.class, Class.class, new Annotation[]{}, new MediaType(), new MultivaluedHashMap<>(), stream))
.withCause(exception);

verify(timerContext).stop();
}
Expand All @@ -109,9 +106,8 @@ void detectLocaleShouldHandleBadlyFormedHeader() {

final ViewMessageBodyWriter writer = new ViewMessageBodyWriter(metricRegistry, Collections.emptyList());

assertThatExceptionOfType(WebApplicationException.class).isThrownBy(() -> {
writer.detectLocale(headers);
});
assertThatExceptionOfType(WebApplicationException.class)
.isThrownBy(() -> writer.detectLocale(headers));
}

@Test
Expand Down

0 comments on commit 764f2a5

Please sign in to comment.