UserConsoleResource extends AbstractJaxRSResource { @GET @Path ( "/isAuthenticated" ) @StatusCodes ( { @ResponseCode ( code = 200, condition = "Returns the boolean response" ), @ResponseCode ( code = 401, condition = "User is not authenticated" ) } ) public Response isAuthenticated() { return buildOkResponse( String.valueOf( userConsoleService.isAuthenticated() ) ); } UserConsoleResource(); @GET @Path ( "/isAdministrator" ) @StatusCodes ( { @ResponseCode ( code = 200, condition = "Returns the boolean response" ) } ) Response isAdministrator(); @GET @Path ( "/isAuthenticated" ) @StatusCodes ( { @ResponseCode ( code = 200, condition = "Returns the boolean response" ), @ResponseCode ( code = 401, condition = "User is not authenticated" ) } ) Response isAuthenticated(); @GET @Path ( "/getAdminContent" ) @Facet ( name = "Unsupported" ) @Produces ( { APPLICATION_JSON, APPLICATION_XML } ) List<Setting> getAdminContent(); @GET @Path ( "/settings" ) @Produces ( { APPLICATION_JSON, APPLICATION_XML } ) @Facet ( name = "Unsupported" ) List<Setting> getMantleSettings(); @GET @Path ( "/cubes" ) @Facet ( name = "Unsupported" ) @Produces ( { APPLICATION_JSON, APPLICATION_XML } ) List<Cube> getMondrianCatalogs(); @POST @Path ( "/locale" ) @Facet ( name = "Unsupported" ) Response setLocaleOverride( String locale ); @GET @Path ( "/locale" ) @Facet ( name = "Unsupported" ) Response getLocale(); @POST @Path ( "/session-variable" ) @Facet ( name = "Unsupported" ) Response setSessionVariable( @QueryParam ( "key" ) String key, @QueryParam ( "value" ) String value ); @GET @Path ( "/session-variable" ) @Facet ( name = "Unsupported" ) Response getSessionVariable( @QueryParam ( "key" ) String key ); @DELETE @Path ( "/session-variable" ) @Facet ( name = "Unsupported" ) Response clearSessionVariable( @QueryParam ( "key" ) String key ); @GET @Path ( "/registeredPlugins" ) @StatusCodes ( { @ResponseCode ( code = 200, condition = "Returns a list of registered plugins as a list string" ) } ) @Facet ( name = "Unsupported" ) Response registeredPlugins();  }
@Test public void testIsAuthenticated() { boolean isAuthenticated = true; doReturn( isAuthenticated ).when( userConsoleResource.userConsoleService ).isAuthenticated(); Response mockResponse = mock( Response.class ); doReturn( mockResponse ).when( userConsoleResource ).buildOkResponse( String.valueOf( isAuthenticated ) ); Response testResponse = userConsoleResource.isAuthenticated(); assertEquals( mockResponse, testResponse ); verify( userConsoleResource.userConsoleService, times( 1 ) ).isAuthenticated(); verify( userConsoleResource, times( 1 ) ).buildOkResponse( String.valueOf( isAuthenticated ) ); }