@Test
public void shouldRejectUnauthenticedUsersFromRestrictedOperation() throws IOException {

    when(requestMock.getMethod()).thenReturn("GET");
    when(requestMock.getPathInfo()).thenReturn("/restricted");
    servlet.service(requestMock, responseMock);
    verify(responseMock).setStatus(401);
    verify(responseMock).setContentType("application/json");
    verify(responseMock).getCharacterEncoding();
    verify(responseMock).setCharacterEncoding(null);
    verify(responseMock).getWriter();
    assertThat(JsonObject.parse(responseBody.toString()).requiredString("message"))
            .isEqualTo("Login required");
}