/** * Fetch a JSON-LD serialization with a custom profile. */ @Test @DisplayName("Fetch the JSON-LD serialization with a custom profile") default void testGetJsonLdAnnotationProfile() { assumeTrue(supportedJsonLdProfiles().contains("http://www.w3.org/ns/anno.jsonld"), "Support for the Web Annotation profile is not enabled."); final String location = createAnnotationResource(); try (final Response res = target(location).request() .accept("application/ld+json; profile=\"http://www.w3.org/ns/anno.jsonld\"").get()) { assertAll("Check for custom JSONLD", checkRdfResponse(res, LDP.RDFSource, APPLICATION_LD_JSON_TYPE)); final Map<String, Object> obj = readEntityAsJson(res.getEntity(), new TypeReference<Map<String, Object>>(){}); assertTrue(obj.containsKey("@context"), "Check for a @context property"); assertEquals("http://www.w3.org/ns/anno.jsonld", obj.get("@context"), "Check the @context value"); assertEquals(location, obj.get("id"), "Check the id value"); assertEquals("Annotation", obj.get("type"), "Check the type value"); assertEquals("http://example.org/post1", obj.get("body"), "Check the body value"); assertEquals("http://example.org/page1", obj.get("target"), "Check the target value"); } }
/** * Fetch a JSON-LD serialization with a custom profile. */ @Test @DisplayName("Fetch the JSON-LD serialization with a custom profile") default void testGetJsonLdAnnotationProfile() { assumeTrue(supportedJsonLdProfiles().contains("http://www.w3.org/ns/anno.jsonld"), "Support for the Web Annotation profile is not enabled."); final String location = createAnnotationResource(); try (final Response res = target(location).request() .accept("application/ld+json; profile=\"http://www.w3.org/ns/anno.jsonld\"").get()) { assertAll("Check for custom JSONLD", checkRdfResponse(res, LDP.RDFSource, APPLICATION_LD_JSON_TYPE)); final Map<String, Object> obj = readEntityAsJson(res.getEntity(), new TypeReference<Map<String, Object>>(){}); assertTrue(obj.containsKey("@context"), "Check for a @context property"); assertEquals("http://www.w3.org/ns/anno.jsonld", obj.get("@context"), "Check the @context value"); assertEquals(location, obj.get("id"), "Check the id value"); assertEquals("Annotation", obj.get("type"), "Check the type value"); assertEquals("http://example.org/post1", obj.get("body"), "Check the body value"); assertEquals("http://example.org/page1", obj.get("target"), "Check the target value"); } }