DBService extends BasicService { @GET @Path("/users") @Produces(MediaType.APPLICATION_JSON) public List<User> getUsers() { if (!isDBAdmin()) { throwUnauthorized(); } return new UserDAO().getAllDesc("dateModified", false); }  @GET @Path("/users") @Produces(MediaType.APPLICATION_JSON) List<User> getUsers(); @GET @Path("/pages") @Produces(MediaType.APPLICATION_JSON) List<Page> getPages(); @GET @Path("/files") @Produces(MediaType.APPLICATION_JSON) List<File> getFiles(); @GET @Path("/playlists") @Produces(MediaType.APPLICATION_JSON) List<Playlist> getPlaylists(); @GET @Path("/screens") @Produces(MediaType.APPLICATION_JSON) List<Screen> getScreens(); @GET @Path("/owners") @Produces(MediaType.APPLICATION_JSON) List<Owner> getOwners(); @GET @Path("/pagereferences") @Produces(MediaType.APPLICATION_JSON) List<PageReference> getPageReferences();  }
@Test(expected = WebApplicationException.class) public void testUnauthorizedDBAdminUsers() throws Exception { dbService.getUsers(); }
@Test public void testGetUsers() throws Exception { doReturn(true).when(dbService).isDBAdmin(); assertEquals(0, dbService.getUsers().size()); UserUtil.getInstance().getDBUser("u1"); assertEquals(1, dbService.getUsers().size()); }
@Test public void testDeleteUser() throws Exception { doReturn(true).when(dbService).isDBAdmin(); doReturn(true).when(userService).isDBAdmin(); User user = UserUtil.getInstance().getDBUser("u1"); userService.deleteUser(user.getId()); assertEquals(0, dbService.getUsers().size()); }