UserRoleListResource extends AbstractJaxRSResource { @GET @Path( "/roles" ) @Produces( { APPLICATION_XML, APPLICATION_JSON } ) @StatusCodes( { @ResponseCode( code = 200, condition = "Successfully retrieved the list of Role objects." ), } ) public RoleListWrapper getRoles( @QueryParam( "addExtraRoles" ) String addExtraRoles ) { boolean includeExtraRoles = true; if ( addExtraRoles != null && addExtraRoles.length() > 0 ) { includeExtraRoles = Boolean.parseBoolean( addExtraRoles ); } return userRoleListService.getRoles( includeExtraRoles ); } UserRoleListResource();  UserRoleListResource( final ArrayList<String> systemRoles, final String adminRole,
      final ArrayList<String> extraRoles );  UserRoleListResource( final ArrayList<String> systemRoles, final String adminRole, final String anonymousRole,
      final ArrayList<String> extraRoles ); @GET @Path( "/permission-users" ) @Produces( { APPLICATION_XML, APPLICATION_JSON } ) @StatusCodes( { @ResponseCode( code = 200, condition = "Successfully retrieved the list of User objects." ), @ResponseCode( code = 500, condition = "Unable to retrieve User objects." ) } ) UserListWrapper getPermissionUsers(); @GET @Path( "/permission-roles" ) @Produces( { APPLICATION_XML, APPLICATION_JSON } ) @StatusCodes( { @ResponseCode( code = 200, condition = "Successfully retrieved the list of permission roles." ) } ) RoleListWrapper getPermissionRoles(); @GET @Path( "/users" ) @Produces( { APPLICATION_XML, APPLICATION_JSON } ) @StatusCodes( { @ResponseCode( code = 200, condition = "Successfully retrieved the list of User objects." ), @ResponseCode( code = 500, condition = "Unable to retrieve User objects." ) } ) UserListWrapper getUsers(); @GET @Path( "/roles" ) @Produces( { APPLICATION_XML, APPLICATION_JSON } ) @StatusCodes( { @ResponseCode( code = 200, condition = "Successfully retrieved the list of Role objects." ), } ) RoleListWrapper getRoles( @QueryParam( "addExtraRoles" ) String addExtraRoles ); @GET @Path( "/allRoles" ) @Produces( { APPLICATION_XML, APPLICATION_JSON } ) @StatusCodes( { @ResponseCode( code = 200, condition = "Successfully retrieved the list of Role objects." ), } ) RoleListWrapper getAllRoles(); @GET @Path( "/systemRoles" ) @Produces( { APPLICATION_XML, APPLICATION_JSON } ) @StatusCodes( { @ResponseCode( code = 200, condition = "Successfully returns system role list." ) } ) RoleListWrapper getSystemRoles(); @GET @Path( "/extraRoles" ) @Produces( { APPLICATION_XML, APPLICATION_JSON } ) @StatusCodes( { @ResponseCode( code = 200, condition = "Successfully returns extra role list." ) } ) RoleListWrapper getExtraRoles(); @GET @Path( "/getRolesForUser" ) @Produces( { APPLICATION_XML, APPLICATION_JSON } ) @StatusCodes( { @ResponseCode( code = 200, condition = "Successfully retrieved the list of Role objects." ), @ResponseCode( code = 500, condition = "Invalid user parameter." ) } ) RolesWrapper getRolesForUser( @QueryParam( "user" ) String user ); @GET @Path( "/getUsersInRole" ) @Produces( { APPLICATION_XML, APPLICATION_JSON } ) @StatusCodes( { @ResponseCode( code = 200, condition = "Successfully retrieved the list of User objects." ), @ResponseCode( code = 500, condition = "Missing the role parameter." ) } ) UsersWrapper getUsersInRole( @QueryParam( "role" ) String role );  }
@Test public void testGetRoles() throws Exception { RoleListWrapper mockWrapper = mock( RoleListWrapper.class ); boolean includeExtraRoles = true; doReturn( mockWrapper ).when( userRoleListResource.userRoleListService ).getRoles( includeExtraRoles ); RoleListWrapper testWrapper = userRoleListResource.getRoles( "true" ); assertEquals( mockWrapper, testWrapper ); verify( userRoleListResource.userRoleListService, times( 1 ) ).getRoles( includeExtraRoles ); }