DBService extends BasicService { @GET @Path("/pages") @Produces(MediaType.APPLICATION_JSON) public List<Page> getPages() { if (!isDBAdmin()) { throwUnauthorized(); } return new PageDAO().getAll("name"); }  @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 testUnauthorizedDBAdminPages() throws Exception { dbService.getPages(); }
@Test public void testGetPages() throws Exception { doReturn(true).when(dbService).isDBAdmin(); assertEquals(0, dbService.getPages().size()); pageService.createPage(new Page("p1")); assertEquals(1, dbService.getPages().size()); }