### Question:
CollectionService extends RestService { @GET @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "getCollections: return Collection names registered in the current schema") public Collection<String> getCollections() { DocumentManagement docMgr = getDocManager(); try { return docMgr.getCollections(); } catch (Exception ex) { logger.error("getCollections.error", ex); throw new WebApplicationException(ex, Status.INTERNAL_SERVER_ERROR); } }  @GET @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "getCollections: return Collection names registered in the current schema") Collection<String> getCollections(); @GET @Path("/{name}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "getCollectionDocuments: return Document uris belonging to the specified Collection") Collection<String> getCollectionDocuments(@PathParam("name") String name); @DELETE @Path("/{name}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "deleteCollectionDocuments: delete all Documents belonging to the specified Collection") int deleteCollectionDocuments(@PathParam("name") String name);  }### Answer:
@Test @SuppressWarnings("unchecked") public void testCollectionService() throws Exception { Collection<String> expected = Arrays.asList("customers", "securities", "orders"); when(docMgr.getCollections()).thenReturn(expected); Collection<String> response = target("clns").request(MediaType.APPLICATION_JSON) .cookie(bg_cookie, "client-id").get(Collection.class); assertEquals(expected.size(), response.size()); for (String name: expected) { assertTrue(response.contains(name)); } Properties props = new Properties(); props.setProperty(pn_document_headers, String.valueOf(DocumentAccessor.HDR_URI)); List<DocumentAccessorImpl> results = Arrays.asList( new DocumentAccessorImpl(null, null, null, null, 0L, null, null, 0L, 0L, 0, 0, null, 0L, 0L, "security1500.xml", 0), new DocumentAccessorImpl(null, null, null, null, 0L, null, null, 0L, 0L, 0, 0, null, 0L, 0L, "security5621.xml", 0), new DocumentAccessorImpl(null, null, null, null, 0L, null, null, 0L, 0L, 0, 0, null, 0L, 0L, "security9012.xml", 0)); when(docMgr.getDocuments("collections.contains(securities), txFinish = 0", props)).thenReturn(new FixedCursorImpl(results)); response = target("clns").path("securities").request(MediaType.APPLICATION_JSON) .cookie(bg_cookie, "client-id").get(Collection.class); assertEquals(expected.size(), response.size()); for (DocumentAccessor da: results) { assertTrue(response.contains(da.getUri())); } }