WebActionHttpRequestHandler extends WebActionRequestHandler { @Override protected JsonObject createJsonResponse(@Nullable String body, @Nonnull Map<String, String> responseHeaders, @Nonnull StatusType statusType) { requireNonNull(responseHeaders); requireNonNull(statusType); JsonObject response = new JsonObject(); if (body != null) { response.addProperty("body", body); } response.addProperty("statusCode", statusType.getStatusCode()); response.add("headers", GSON.toJsonTree(responseHeaders, Map.class)); return response; }    }
@Test public void createJsonResponse_NullHeadersGiven_ShouldFailNpe() { assertThrows(NullPointerException.class, () -> handler.createJsonResponse(null, null, Status.OK)); }
@Test public void createJsonResponse_NullStatusTypeGiven_ShouldFailNpe() { assertThrows(NullPointerException.class, () -> handler.createJsonResponse(null, Collections.emptyMap(), null)); }