File tree Expand file tree Collapse file tree
main/java/com/retailsvc/http
test/java/com/retailsvc/http Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,11 +89,7 @@ public static HttpHandler healthHandler(Supplier<HealthOutcome> probe) {
8989 try (exchange ) {
9090 HealthOutcome outcome ;
9191 try {
92- HealthOutcome result = probe .get ();
93- if (result == null ) {
94- throw new IllegalStateException ("Health probe returned null" );
95- }
96- outcome = result ;
92+ outcome = Objects .requireNonNull (probe .get (), "Health probe returned null" );
9793 } catch (RuntimeException e ) {
9894 LOG .warn ("Health probe failed" , e );
9995 outcome = new HealthOutcome ("Down" , List .of ());
Original file line number Diff line number Diff line change @@ -71,13 +71,12 @@ void headIsAccepted() throws IOException {
7171 HttpExchange ex = newExchange ("HEAD" );
7272 Headers headers = new Headers ();
7373 when (ex .getResponseHeaders ()).thenReturn (headers );
74- when (ex .getResponseBody ()).thenReturn (new ByteArrayOutputStream ());
74+ ByteArrayOutputStream body = new ByteArrayOutputStream ();
75+ when (ex .getResponseBody ()).thenReturn (body );
7576
7677 Handlers .healthHandler (() -> new HealthOutcome ("Up" , List .of ())).handle (ex );
7778
78- verify (ex )
79- .sendResponseHeaders (
80- eq (HTTP_OK ), eq ((long ) "{\" outcome\" :\" Up\" ,\" dependencies\" :[]}" .length ()));
79+ verify (ex ).sendResponseHeaders (eq (HTTP_OK ), eq ((long ) body .size ()));
8180 }
8281
8382 @ Test
You can’t perform that action at this time.
0 commit comments