AuthRest { @DELETE @Produces(MediaType.APPLICATION_JSON) @ApiOperation("Logs out of Mobi by setting unauth token") public Response logout() { log.debug("Requested logout. Generating unauthenticated token."); SignedJWT unauthToken = tokenManager.generateUnauthToken(); return createResponse(unauthToken); }  @GET @Produces(MediaType.APPLICATION_JSON) @ApiOperation("Gets the current user token") Response getCurrentUser(@Context ContainerRequestContext context); @POST @Produces(MediaType.APPLICATION_JSON) @ApiOperation("Logs in into Mobi creating a new token") Response login(@Context ContainerRequestContext context,
                   @QueryParam("username") String username,
                   @QueryParam("password") String password); @DELETE @Produces(MediaType.APPLICATION_JSON) @ApiOperation("Logs out of Mobi by setting unauth token") Response logout();  }
@Test public void logoutTest() throws Exception { Response response = target().path("session").request().delete(); assertEquals(response.getStatus(), 200); verify(tokenManager).generateUnauthToken(); Map<String, NewCookie> cookies = response.getCookies(); assertTrue(cookies.containsKey(TOKEN_NAME)); assertEquals(ANON, cookies.get(TOKEN_NAME).getValue()); try { JSONObject result = JSONObject.fromObject(response.readEntity(String.class)); assertEquals(removeWhitespace(ANON_USER), removeWhitespace(result.toString())); } catch (Exception e) { fail("Expected no exception, but got: " + e.getMessage()); } }