UserRoleListResource extends AbstractJaxRSResource { @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." ) } ) public RolesWrapper getRolesForUser( @QueryParam( "user" ) String user ) throws Exception { return new RolesWrapper( userRoleListService.doGetRolesForUser( user ) ); } 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 testGetRolesForUser() throws Exception { String user = "user"; String role1 = "role_1"; String role2 = "role_2"; List<String> listRoles = new ArrayList<>(); listRoles.add( role1 ); listRoles.add( role2 ); doReturn( listRoles ).when( userRoleListResource.userRoleListService ).doGetRolesForUser( user ); RolesWrapper rolesWrapper = userRoleListResource.getRolesForUser( user ); assertEquals( listRoles.size(), rolesWrapper.getRoles().size() ); assertEquals( listRoles.get( 0 ), rolesWrapper.getRoles().get( 0 ) ); assertEquals( listRoles.get( 1 ), rolesWrapper.getRoles().get( 1 ) ); verify( userRoleListResource.userRoleListService, times( 1 ) ).doGetRolesForUser( user ); }