@Test public void listCollections() throws Exception { String pidString = "uuid:23425234532434"; String url = "https://localhost/services/collection/" + pidString; IRI iri = new IRI(url); Map<?, ?> response = this.generateImmediateChildrenResponse(10); when(tripleStoreQueryService.sendSPARQL(anyString())).thenReturn(response); Feed feed = manager.listCollectionContents(iri, new AuthCredentials("", "", ""), config); assertEquals(feed.getEntries().size(), 10); assertEquals(feed.getLinks().size(), 1); assertTrue(pidString.equals(feed.getId().toString())); }
@Test public void listCollectionsSecondPage() throws Exception { String pidString = "uuid:23425234532434"; String url = "https://localhost/services/collection/" + pidString + "/1"; IRI iri = new IRI(url); Map<?, ?> response = this.generateImmediateChildrenResponse(10); when(tripleStoreQueryService.sendSPARQL(endsWith(" 0"))).thenReturn(null); when(tripleStoreQueryService.sendSPARQL(endsWith(" 10"))).thenReturn(response); Feed feed = manager.listCollectionContents(iri, new AuthCredentials("", "", ""), config); assertEquals(feed.getEntries().size(), 10); assertEquals(feed.getLinks().size(), 1); String nextLink = feed.getLink("next").getHref().toString(); nextLink = nextLink.substring(nextLink.lastIndexOf("/") + 1); assertTrue("2".equals(nextLink)); assertTrue(pidString.equals(feed.getId().toString())); }
private void addAtomManagedDatastream(Feed feed, String contentLocation) throws Exception { String dsId = "DS"; Entry dsEntry = feed.addEntry(); dsEntry.setId(feed.getId().toString() + "/" + dsId); Entry dsvEntry = feed.addEntry(); dsvEntry.setId(dsEntry.getId().toString() + "/" + feed.getUpdatedString()); dsEntry.setTitle(feed.getTitle()); dsEntry.setUpdated(feed.getUpdated()); dsEntry.addLink(dsvEntry.getId().toString(), Link.REL_ALTERNATE); dsEntry.addCategory(MODEL.STATE.uri, "A", null); dsEntry.addCategory(MODEL.CONTROL_GROUP.uri, "M", null); dsEntry.addCategory(MODEL.VERSIONABLE.uri, "true", null); dsvEntry.setTitle(feed.getTitle()); dsvEntry.setUpdated(feed.getUpdated()); ThreadHelper.addInReplyTo(dsvEntry, dsEntry.getId()); dsvEntry.setSummary("summary"); dsvEntry.setContent(new IRI(contentLocation), "text/plain"); }