use of org.apache.activemq.util.ByteArrayInputStream in project timbuctoo by HuygensING.
the class IntegrationTest method resourceSyncShowsAllThePublicDataSets.
@Test
public void resourceSyncShowsAllThePublicDataSets() throws Exception {
final String dataSetName = "clusius_" + UUID.randomUUID().toString().replace("-", "_");
final String dataSetId = createDataSetId(dataSetName);
Response uploadResponse = multipartPost("/v5/" + PREFIX + "/" + dataSetName + "/upload/rdf?forceCreation=true", new File(getResource(IntegrationTest.class, "bia_clusius.nqud").toURI()), "application/vnd.timbuctoo-rdf.nquads_unified_diff", ImmutableMap.of("encoding", "UTF-8", "uri", "http://example.com/clusius.nqud"));
assertThat(uploadResponse.getStatus(), is(201));
call("/v5/graphql").accept(MediaType.APPLICATION_JSON).post(Entity.entity(jsnO("query", jsn("mutation Publish($dataSetId: String!) {" + " publish(dataSetId: $dataSetId) {" + " dataSetId" + " }" + "}"), "variables", jsnO("dataSetId", jsn(dataSetId))).toString(), MediaType.valueOf("application/json")));
Response checkPublishedCall = callWithoutAuthentication("/v5/graphql").accept(MediaType.APPLICATION_JSON).post(Entity.entity(jsnO("query", jsn("query MetaData($dataSetId: ID!) {" + " dataSetMetadata(dataSetId: $dataSetId) {" + " dataSetId" + " }" + "}"), "variables", jsnO("dataSetId", jsn(dataSetId))).toString(), MediaType.valueOf("application/json")));
assertThat(checkPublishedCall.readEntity(ObjectNode.class), is(jsnO("data", jsnO("dataSetMetadata", jsnO("dataSetId", jsn(dataSetId))))));
Response resourceSyncCall = callWithoutAuthentication("/v5/resourcesync/sourceDescription.xml").get();
ByteArrayInputStream value = new ByteArrayInputStream(resourceSyncCall.readEntity(String.class).getBytes());
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(value);
XPath xpath = XPathFactory.newInstance().newXPath();
NodeList uriNodes = (NodeList) xpath.compile("/urlset/url/loc").evaluate(document, XPathConstants.NODESET);
Set<String> dataSets = new HashSet<>();
for (int i = 0; i < uriNodes.getLength(); i++) {
dataSets.add(uriNodes.item(i).getTextContent());
}
assertThat(dataSets, hasItem(endsWith(dataSetName + "/capabilitylist.xml")));
}
Aggregations