/** * Check the absense of audit triples. */ @Test @DisplayName("Check the absense of audit triples.") default void testNoAuditTriples() { try (final Response res = target(getResourceLocation()).request().get()) { final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); assertEquals(2L, g.size(), "Check that the graph has 2 triples"); } }
/** * Check the absense of audit triples. */ @Test @DisplayName("Check the absense of audit triples.") default void testNoAuditTriples() { try (final Response res = target(getResourceLocation()).request().get()) { final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); assertEquals(2L, g.size(), "Check that the graph has 2 triples"); } }
private Graph convertToGraph(final Message msg) { try { final String body = ((TextMessage) msg).getText(); return readEntityAsGraph(new ByteArrayInputStream(body.getBytes(UTF_8)), "http://localhost:" + APP.getLocalPort() + "/", JSONLD); } catch (final Exception ex) { LOGGER.error("Error processing message: {}", ex.getMessage()); } return rdf.createGraph(); } }
/** * Check the explicit absense of audit triples. */ @Test @DisplayName("Check the explicit absense of audit triples.") default void testOmitAuditTriples() { try (final Response res = target(getResourceLocation()).request().header("Prefer", "return=representation; omit=\"" + Trellis.PreferAudit.getIRIString() + "\"").get()) { final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); assertEquals(2L, g.size(), "Check that the graph has only 2 triples"); } }
/** * Check the explicit absense of audit triples. */ @Test @DisplayName("Check the explicit absense of audit triples.") default void testOmitAuditTriples() { try (final Response res = target(getResourceLocation()).request().header("Prefer", "return=representation; omit=\"" + Trellis.PreferAudit.getIRIString() + "\"").get()) { final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); assertEquals(2L, g.size(), "Check that the graph has only 2 triples"); } }
/** * Verify that the correct containment triples exist. */ @Test @DisplayName("Verify that the correct containment triples exist") default void testRdfContainment() { final RDF rdf = getInstance(); // Test the root container, verifying that the containment triple exists try (final Response res = target().request().get()) { assertAll("Check a container resource", checkRdfResponse(res, LDP.BasicContainer, TEXT_TURTLE_TYPE)); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); assertTrue(g.contains(rdf.createIRI(getBaseURL()), LDP.contains, rdf.createIRI(getResourceLocation())), "Check for an ldp:contains property"); } }
/** * Test that the binary appears in the parent container. */ @Test @DisplayName("Test that the binary appears in the parent container") default void testBinaryIsInContainer() { final RDF rdf = getInstance(); // Test the root container, verifying that the containment triple exists try (final Response res = target().request().get()) { assertAll("Check binary in container", checkRdfResponse(res, LDP.BasicContainer, null)); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); assertTrue(g.contains(rdf.createIRI(getBaseURL()), LDP.contains, rdf.createIRI(getResourceLocation())), "Check for an ldp:contains triple"); } }
/** * Test that the binary appears in the parent container. */ @Test @DisplayName("Test that the binary appears in the parent container") default void testBinaryIsInContainer() { final RDF rdf = getInstance(); // Test the root container, verifying that the containment triple exists try (final Response res = target().request().get()) { assertAll("Check binary in container", checkRdfResponse(res, LDP.BasicContainer, null)); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); assertTrue(g.contains(rdf.createIRI(getBaseURL()), LDP.contains, rdf.createIRI(getResourceLocation())), "Check for an ldp:contains triple"); } }
/** * Verify that the correct containment triples exist. */ @Test @DisplayName("Verify that the correct containment triples exist") default void testRdfContainment() { final RDF rdf = getInstance(); // Test the root container, verifying that the containment triple exists try (final Response res = target().request().get()) { assertAll("Check a container resource", checkRdfResponse(res, LDP.BasicContainer, TEXT_TURTLE_TYPE)); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); assertTrue(g.contains(rdf.createIRI(getBaseURL()), LDP.contains, rdf.createIRI(getResourceLocation())), "Check for an ldp:contains property"); } }
/** * Test fetching a basic container. */ @Test @DisplayName("Test fetching a basic container") default void testGetContainer() { final RDF rdf = getInstance(); try (final Response res = target(getContainerLocation()).request().get()) { assertAll("Check an LDP-BC response", checkRdfResponse(res, LDP.BasicContainer, TEXT_TURTLE_TYPE)); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); final IRI identifier = rdf.createIRI(getContainerLocation()); assertAll("Check the RDF graph", checkRdfGraph(g, identifier)); assertTrue(res.getEntityTag().isWeak(), "Verify that the ETag is weak"); } }
/** * Test fetching a basic container. */ @Test @DisplayName("Test fetching a basic container") default void testGetContainer() { final RDF rdf = getInstance(); try (final Response res = target(getContainerLocation()).request().get()) { assertAll("Check an LDP-BC response", checkRdfResponse(res, LDP.BasicContainer, TEXT_TURTLE_TYPE)); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); final IRI identifier = rdf.createIRI(getContainerLocation()); assertAll("Check the RDF graph", checkRdfGraph(g, identifier)); assertTrue(res.getEntityTag().isWeak(), "Verify that the ETag is weak"); } }
/** * Test with ldp:PreferMinimalContainer Prefer header. */ @Test @DisplayName("Test with ldp:PreferMinimalContainer Prefer header") default void testGetEmptyContainer() { final RDF rdf = getInstance(); try (final Response res = target(getContainerLocation()).request().header(PREFER, "return=representation; include=\"" + LDP.PreferMinimalContainer.getIRIString() + "\"").get()) { assertAll("Check a container response", checkRdfResponse(res, LDP.BasicContainer, TEXT_TURTLE_TYPE)); final IRI identifier = rdf.createIRI(getContainerLocation()); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); assertAll("Check the graph for triples", checkRdfGraph(g, identifier)); assertFalse(g.contains(identifier, LDP.contains, null), "Verify that no ldp:contains triples are present"); } }
/** * Test with ldp:PreferMinimalContainer Prefer header. */ @Test @DisplayName("Test with ldp:PreferMinimalContainer Prefer header") default void testGetEmptyContainer() { final RDF rdf = getInstance(); try (final Response res = target(getContainerLocation()).request().header(PREFER, "return=representation; include=\"" + LDP.PreferMinimalContainer.getIRIString() + "\"").get()) { assertAll("Check a container response", checkRdfResponse(res, LDP.BasicContainer, TEXT_TURTLE_TYPE)); final IRI identifier = rdf.createIRI(getContainerLocation()); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); assertAll("Check the graph for triples", checkRdfGraph(g, identifier)); assertFalse(g.contains(identifier, LDP.contains, null), "Verify that no ldp:contains triples are present"); } }
/** * Test fetching a binary description. */ @Test @DisplayName("Test fetching a binary description") default void testGetBinaryDescription() { final EntityTag etag = getETag(getResourceLocation()); // Fetch the description try (final Response res = target(getResourceLocation()).request().accept("text/turtle").get()) { assertAll("Check binary description", checkRdfResponse(res, LDP.RDFSource, TEXT_TURTLE_TYPE)); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); assertTrue(g.size() >= 0L, "Assert that the graph isn't empty"); assertTrue(res.getEntityTag().isWeak(), "Check for a weak ETag"); assertNotEquals(etag, res.getEntityTag(), "Check for different ETag values"); } }
/** * Test with ldp:PreferMinimalContainer Prefer header. */ @Test @DisplayName("Test with ldp:PreferMinimalContainer Prefer header") default void testGetEmptyMember() { final RDF rdf = getInstance(); try (final Response res = target(getMemberLocation()).request().header(PREFER, "return=representation; include=\"" + LDP.PreferMinimalContainer.getIRIString() + "\"").get()) { assertAll("Check the LDP-RS with Prefer", checkRdfResponse(res, LDP.RDFSource, TEXT_TURTLE_TYPE)); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); final IRI identifier = rdf.createIRI(getMemberLocation()); assertTrue(g.contains(identifier, SKOS.prefLabel, null), "Check for a skos:prefLabel triple"); assertFalse(g.contains(identifier, LDP.member, null), "Check for no ldp:member triples"); assertFalse(g.contains(identifier, DC.relation, null), "Check for no dc:relation triples"); } }
/** * Test with ldp:PreferMinimalContainer Prefer header. */ @Test @DisplayName("Test with ldp:PreferMinimalContainer Prefer header") default void testGetInverseEmptyMember() { final RDF rdf = getInstance(); try (final Response res = target(getMemberLocation()).request().header(PREFER, "return=representation; omit=\"" + LDP.PreferMinimalContainer.getIRIString() + "\"").get()) { assertAll("Check the LDP-RS with Prefer", checkRdfResponse(res, LDP.RDFSource, TEXT_TURTLE_TYPE)); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); final IRI identifier = rdf.createIRI(getMemberLocation()); assertFalse(g.contains(identifier, SKOS.prefLabel, null), "Check for no skos:prefLabel triples"); assertTrue(g.contains(identifier, LDP.member, null) || g.contains(identifier, DC.relation, null), "Check for either an ldp:member or dc:relation triple"); } }
/** * Test with ldp:PreferMinimalContainer Prefer header. */ @Test @DisplayName("Test with ldp:PreferMinimalContainer Prefer header") default void testGetInverseEmptyMember() { final RDF rdf = getInstance(); try (final Response res = target(getMemberLocation()).request().header(PREFER, "return=representation; omit=\"" + LDP.PreferMinimalContainer.getIRIString() + "\"").get()) { assertAll("Check a member resource with Prefer", checkRdfResponse(res, LDP.RDFSource, TEXT_TURTLE_TYPE)); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); final IRI identifier = rdf.createIRI(getMemberLocation()); assertFalse(g.contains(identifier, SKOS.prefLabel, null), "Check for no skos:prefLabel triple"); assertTrue(g.contains(identifier, LDP.member, null) || g.contains(identifier, DC.relation, null), "Check for either an ldp:member or dc:relation triple"); } }
/** * Test with ldp:PreferMinimalContainer Prefer header. */ @Test @DisplayName("Test with ldp:PreferMinimalContainer Prefer header") default void testGetInverseEmptyMember() { final RDF rdf = getInstance(); try (final Response res = target(getMemberLocation()).request().header(PREFER, "return=representation; omit=\"" + LDP.PreferMinimalContainer.getIRIString() + "\"").get()) { assertAll("Check the LDP-RS with Prefer", checkRdfResponse(res, LDP.RDFSource, TEXT_TURTLE_TYPE)); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); final IRI identifier = rdf.createIRI(getMemberLocation()); assertFalse(g.contains(identifier, SKOS.prefLabel, null), "Check for no skos:prefLabel triples"); assertTrue(g.contains(identifier, LDP.member, null) || g.contains(identifier, DC.relation, null), "Check for either an ldp:member or dc:relation triple"); } }
/** * Test with ldp:PreferMinimalContainer Prefer header. */ @Test @DisplayName("Test with ldp:PreferMinimalContainer Prefer header") default void testGetEmptyMember() { final RDF rdf = getInstance(); try (final Response res = target(getMemberLocation()).request().header(PREFER, "return=representation; include=\"" + LDP.PreferMinimalContainer.getIRIString() + "\"").get()) { assertAll("Check the LDP-RS with Prefer", checkRdfResponse(res, LDP.RDFSource, TEXT_TURTLE_TYPE)); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); final IRI identifier = rdf.createIRI(getMemberLocation()); assertTrue(g.contains(identifier, SKOS.prefLabel, null), "Check for a skos:prefLabel triple"); assertFalse(g.contains(identifier, LDP.member, null), "Check for no ldp:member triples"); assertFalse(g.contains(identifier, DC.relation, null), "Check for no dc:relation triples"); } }
/** * Test with ldp:PreferMinimalContainer Prefer header. */ @Test @DisplayName("Test with ldp:PreferMinimalContainer Prefer header") default void testGetEmptyMember() { final RDF rdf = getInstance(); try (final Response res = target(getMemberLocation()).request().header(PREFER, "return=representation; include=\"" + LDP.PreferMinimalContainer.getIRIString() + "\"").get()) { assertAll("Check a member resource with Prefer", checkRdfResponse(res, LDP.RDFSource, TEXT_TURTLE_TYPE)); final Graph g = readEntityAsGraph(res.getEntity(), getBaseURL(), TURTLE); final IRI identifier = rdf.createIRI(getMemberLocation()); assertTrue(g.contains(identifier, SKOS.prefLabel, null), "Check for a skos:prefLabel triple"); assertFalse(g.contains(identifier, LDP.member, null), "Check for no ldp:member triple"); assertFalse(g.contains(identifier, DC.relation, null), "Check for no dc:relation triple"); } }