UserRoleListService { public UserListWrapper getUsers() { IUserRoleListService service = getUserRoleListService(); List<String> allUsers = service.getAllUsers(); if ( null != userComparator ) { Collections.sort( allUsers, userComparator ); } return new UserListWrapper( allUsers ); }  List<String> doGetRolesForUser( String user ); List<String> doGetUsersInRole( String role ); UserListWrapper getUsers(); RoleListWrapper getRoles(); RoleListWrapper getRoles( boolean includeExtraRoles ); RoleListWrapper getAllRoles(); RoleListWrapper getSystemRoles(); RoleListWrapper getPermissionRoles( String adminRole ); RoleListWrapper getExtraRolesList(); IUserRoleListService getUserRoleListService(); void setExtraRoles( ArrayList<String> extraRoles ); void setSystemRoles( ArrayList<String> systemRoles ); void setRoleComparator( Comparator<String> roleComparator ); void setUserComparator( Comparator<String> userComparator ); ArrayList<String> getExtraRoles();  }
@Test public void testGetUsers() { IUserRoleListService service = mock( IUserRoleListService.class ); doReturn( service ).when( userRoleListService ).getUserRoleListService(); List<String> users = new ArrayList<String>(); users.add( "admin" ); users.add( "joe" ); users.add( "suzy" ); doReturn( users ).when( service ).getAllUsers(); UserListWrapper usersWrapper = userRoleListService.getUsers(); assertTrue( usersWrapper.getUsers().size() == 3 ); }