diff --git a/pom.xml b/pom.xml
index 4f1fcce1..e5b577a5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
JsonLdOptions#getUriValidation
+ * @return true if full validation is enabled
*/
+ @Deprecated
public boolean isUriValidation() {
+ return uriValidation == UriValidationPolicy.Full;
+ }
+
+ public UriValidationPolicy getUriValidation() {
return uriValidation;
}
@@ -505,10 +512,16 @@ public boolean isUriValidation() {
* Enabled by default.
*
*
+ * @deprecated use JsonLdOptions#setUriValidation(com.apicatalog.jsonld.uri.UriValidationPolicy)
* @param enabled set true
to enable validation
*/
+ @Deprecated
public void setUriValidation(boolean enabled) {
- this.uriValidation = enabled;
+ this.uriValidation = UriValidationPolicy.of(enabled);
+ }
+
+ public void setUriValidation(UriValidationPolicy uriValidation) {
+ this.uriValidation = uriValidation;
}
/**
diff --git a/src/main/java/com/apicatalog/jsonld/context/ActiveContext.java b/src/main/java/com/apicatalog/jsonld/context/ActiveContext.java
index d17018de..c15263b4 100644
--- a/src/main/java/com/apicatalog/jsonld/context/ActiveContext.java
+++ b/src/main/java/com/apicatalog/jsonld/context/ActiveContext.java
@@ -160,7 +160,7 @@ public ActiveContextBuilder newContext() {
}
public UriExpansion uriExpansion() {
- return UriExpansion.with(this).uriValidation(runtime.isUriValidation());
+ return UriExpansion.with(this).uriValidation(runtime.getUriValidation());
}
public ValueExpansion valueExpansion() {
diff --git a/src/main/java/com/apicatalog/jsonld/context/TermDefinitionBuilder.java b/src/main/java/com/apicatalog/jsonld/context/TermDefinitionBuilder.java
index c75581cb..1f709366 100644
--- a/src/main/java/com/apicatalog/jsonld/context/TermDefinitionBuilder.java
+++ b/src/main/java/com/apicatalog/jsonld/context/TermDefinitionBuilder.java
@@ -35,6 +35,7 @@
import com.apicatalog.jsonld.lang.LanguageTag;
import com.apicatalog.jsonld.uri.UriUtils;
+import com.apicatalog.jsonld.uri.UriValidationPolicy;
import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
import jakarta.json.JsonString;
@@ -270,7 +271,7 @@ public void create(final String term) throws JsonLdError {
&& activeContext.runtime().isV10())
// 12.4.
|| (Keywords.noneMatch(expandedTypeString, Keywords.ID, Keywords.JSON, Keywords.NONE, Keywords.VOCAB)
- && UriUtils.isNotAbsoluteUri(expandedTypeString, true))) {
+ && UriUtils.isNotAbsoluteUri(expandedTypeString, UriValidationPolicy.Full))) {
throw new JsonLdError(JsonLdErrorCode.INVALID_TYPE_MAPPING);
}
diff --git a/src/main/java/com/apicatalog/jsonld/deseralization/JsonLdToRdf.java b/src/main/java/com/apicatalog/jsonld/deseralization/JsonLdToRdf.java
index f2153755..bbb1102b 100644
--- a/src/main/java/com/apicatalog/jsonld/deseralization/JsonLdToRdf.java
+++ b/src/main/java/com/apicatalog/jsonld/deseralization/JsonLdToRdf.java
@@ -29,6 +29,7 @@
import com.apicatalog.jsonld.lang.Keywords;
import com.apicatalog.jsonld.lang.Utils;
import com.apicatalog.jsonld.uri.UriUtils;
+import com.apicatalog.jsonld.uri.UriValidationPolicy;
import com.apicatalog.rdf.Rdf;
import com.apicatalog.rdf.RdfDataset;
import com.apicatalog.rdf.RdfResource;
@@ -50,7 +51,7 @@ public final class JsonLdToRdf {
// optional
private boolean produceGeneralizedRdf;
private RdfDirection rdfDirection;
- private boolean uriValidation;
+ private UriValidationPolicy uriValidation;
private JsonLdToRdf(NodeMap nodeMap, RdfDataset dataset) {
this.nodeMap = nodeMap;
@@ -202,7 +203,15 @@ public RdfDataset build() throws JsonLdError {
return dataset;
}
+ /**
+ * @deprecated use JsonLdToRdf#uriValidation(com.apicatalog.jsonld.uri.UriValidationPolicy)
+ */
+ @Deprecated
public JsonLdToRdf uriValidation(boolean uriValidation) {
+ return uriValidation(UriValidationPolicy.of(uriValidation));
+ }
+
+ public JsonLdToRdf uriValidation(UriValidationPolicy uriValidation) {
this.uriValidation = uriValidation;
return this;
}
diff --git a/src/main/java/com/apicatalog/jsonld/deseralization/ListToRdf.java b/src/main/java/com/apicatalog/jsonld/deseralization/ListToRdf.java
index fffcb201..98930b47 100644
--- a/src/main/java/com/apicatalog/jsonld/deseralization/ListToRdf.java
+++ b/src/main/java/com/apicatalog/jsonld/deseralization/ListToRdf.java
@@ -24,6 +24,7 @@
import com.apicatalog.jsonld.JsonLdOptions.RdfDirection;
import com.apicatalog.jsonld.flattening.NodeMap;
import com.apicatalog.jsonld.json.JsonUtils;
+import com.apicatalog.jsonld.uri.UriValidationPolicy;
import com.apicatalog.rdf.Rdf;
import com.apicatalog.rdf.RdfTriple;
import com.apicatalog.rdf.RdfValue;
@@ -46,7 +47,7 @@ final class ListToRdf {
// optional
private RdfDirection rdfDirection;
- private boolean uriValidation;
+ private UriValidationPolicy uriValidation;
private ListToRdf(final JsonArray list, final ListListToRdf#uriValidation(com.apicatalog.jsonld.uri.UriValidationPolicy)
+ */
+ @Deprecated
public ListToRdf uriValidation(boolean uriValidation) {
+ return uriValidation(UriValidationPolicy.of(uriValidation));
+ }
+
+ public ListToRdf uriValidation(UriValidationPolicy uriValidation) {
this.uriValidation = uriValidation;
return this;
}
diff --git a/src/main/java/com/apicatalog/jsonld/deseralization/ObjectToRdf.java b/src/main/java/com/apicatalog/jsonld/deseralization/ObjectToRdf.java
index 9964c9e4..75007bf6 100644
--- a/src/main/java/com/apicatalog/jsonld/deseralization/ObjectToRdf.java
+++ b/src/main/java/com/apicatalog/jsonld/deseralization/ObjectToRdf.java
@@ -37,6 +37,7 @@
import com.apicatalog.jsonld.lang.NodeObject;
import com.apicatalog.jsonld.lang.ValueObject;
import com.apicatalog.jsonld.uri.UriUtils;
+import com.apicatalog.jsonld.uri.UriValidationPolicy;
import com.apicatalog.rdf.Rdf;
import com.apicatalog.rdf.RdfLiteral;
import com.apicatalog.rdf.RdfResource;
@@ -71,7 +72,7 @@ final class ObjectToRdf {
// optional
private RdfDirection rdfDirection;
- private boolean uriValidation;
+ private UriValidationPolicy uriValidation;
private ObjectToRdf(JsonObject item, ListObject#uriValidation(com.apicatalog.jsonld.uri.UriValidationPolicy)
+ */
+ @Deprecated
public ObjectToRdf uriValidation(boolean uriValidation) {
+ return uriValidation(UriValidationPolicy.of(uriValidation));
+ }
+
+ public ObjectToRdf uriValidation(UriValidationPolicy uriValidation) {
this.uriValidation = uriValidation;
return this;
}
diff --git a/src/main/java/com/apicatalog/jsonld/expansion/UriExpansion.java b/src/main/java/com/apicatalog/jsonld/expansion/UriExpansion.java
index 3a6397bf..b844d4ab 100644
--- a/src/main/java/com/apicatalog/jsonld/expansion/UriExpansion.java
+++ b/src/main/java/com/apicatalog/jsonld/expansion/UriExpansion.java
@@ -30,6 +30,7 @@
import com.apicatalog.jsonld.uri.UriResolver;
import com.apicatalog.jsonld.uri.UriUtils;
+import com.apicatalog.jsonld.uri.UriValidationPolicy;
import jakarta.json.JsonObject;
import jakarta.json.JsonString;
import jakarta.json.JsonValue;
@@ -51,7 +52,7 @@ public final class UriExpansion {
// optional
private boolean documentRelative;
private boolean vocab;
- private boolean uriValidation;
+ private UriValidationPolicy uriValidation;
private JsonObject localContext;
private MapUriExpansion#uriValidation(com.apicatalog.jsonld.uri.UriValidationPolicy)
+ */
+ @Deprecated
public UriExpansion uriValidation(boolean uriValidation) {
+ return uriValidation(UriValidationPolicy.of(uriValidation));
+ }
+
+ public UriExpansion uriValidation(UriValidationPolicy uriValidation) {
this.uriValidation = uriValidation;
return this;
}
diff --git a/src/main/java/com/apicatalog/jsonld/framing/Frame.java b/src/main/java/com/apicatalog/jsonld/framing/Frame.java
index 79c76c25..a7cdc710 100644
--- a/src/main/java/com/apicatalog/jsonld/framing/Frame.java
+++ b/src/main/java/com/apicatalog/jsonld/framing/Frame.java
@@ -31,6 +31,7 @@
import com.apicatalog.jsonld.lang.ValueObject;
import com.apicatalog.jsonld.uri.UriUtils;
+import com.apicatalog.jsonld.uri.UriValidationPolicy;
import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
import jakarta.json.JsonString;
@@ -172,9 +173,9 @@ private static final boolean validateFrameId(JsonObject frame) {
|| idArray
.stream()
.noneMatch(item -> JsonUtils.isNotString(item)
- || UriUtils.isNotAbsoluteUri(((JsonString)item).getString(), true)));
+ || UriUtils.isNotAbsoluteUri(((JsonString)item).getString(), UriValidationPolicy.Full)));
}
- return JsonUtils.isString(id) && UriUtils.isAbsoluteUri(((JsonString)id).getString(), true);
+ return JsonUtils.isString(id) && UriUtils.isAbsoluteUri(((JsonString)id).getString(), UriValidationPolicy.Full);
}
private static final boolean validateFrameType(JsonObject frame) {
@@ -193,12 +194,12 @@ private static final boolean validateFrameType(JsonObject frame) {
|| typeArray
.stream()
.noneMatch(item -> JsonUtils.isNotString(item)
- || UriUtils.isNotAbsoluteUri(((JsonString)item).getString(), true)));
+ || UriUtils.isNotAbsoluteUri(((JsonString)item).getString(), UriValidationPolicy.Full)));
}
return JsonUtils.isEmptyArray(type)
|| JsonUtils.isEmptyObject(type)
- || JsonUtils.isString(type) && UriUtils.isAbsoluteUri(((JsonString)type).getString(), true);
+ || JsonUtils.isString(type) && UriUtils.isAbsoluteUri(((JsonString)type).getString(), UriValidationPolicy.Full);
}
public SetProcessingRuntime#getUriValidation()
+ */
+ @Deprecated
public boolean isUriValidation() {
return options.isUriValidation();
}
+ public UriValidationPolicy getUriValidation() {
+ return options.getUriValidation();
+ }
+
public boolean isV10() {
return options.getProcessingMode() != null && options.getProcessingMode().equals(JsonLdVersion.V1_0);
}
diff --git a/src/main/java/com/apicatalog/jsonld/processor/ToRdfProcessor.java b/src/main/java/com/apicatalog/jsonld/processor/ToRdfProcessor.java
index 55496dc9..863b9d8a 100644
--- a/src/main/java/com/apicatalog/jsonld/processor/ToRdfProcessor.java
+++ b/src/main/java/com/apicatalog/jsonld/processor/ToRdfProcessor.java
@@ -75,7 +75,7 @@ public static final RdfDataset toRdf(Document input, final JsonLdOptions options
)
.produceGeneralizedRdf(options.isProduceGeneralizedRdf())
.rdfDirection(options.getRdfDirection())
- .uriValidation(options.isUriValidation())
+ .uriValidation(options.getUriValidation())
.build();
}
}
diff --git a/src/main/java/com/apicatalog/jsonld/serialization/RdfToJsonld.java b/src/main/java/com/apicatalog/jsonld/serialization/RdfToJsonld.java
index 18327cff..d4f79ee0 100644
--- a/src/main/java/com/apicatalog/jsonld/serialization/RdfToJsonld.java
+++ b/src/main/java/com/apicatalog/jsonld/serialization/RdfToJsonld.java
@@ -34,6 +34,7 @@
import com.apicatalog.jsonld.lang.LanguageTag;
import com.apicatalog.jsonld.lang.Utils;
import com.apicatalog.jsonld.uri.UriUtils;
+import com.apicatalog.jsonld.uri.UriValidationPolicy;
import com.apicatalog.rdf.RdfDataset;
import com.apicatalog.rdf.RdfGraph;
import com.apicatalog.rdf.RdfResource;
@@ -57,7 +58,7 @@ public final class RdfToJsonld {
private RdfDirection rdfDirection;
private boolean useNativeTypes;
private boolean useRdfType;
- private boolean uriValidation;
+ private UriValidationPolicy uriValidation;
private JsonLdVersion processingMode;
@@ -434,7 +435,15 @@ protected static class Reference {
private JsonObject value;
}
+ /**
+ * @deprecated use RdfToJsonld#uriValidation(com.apicatalog.jsonld.uri.UriValidationPolicy)
+ */
+ @Deprecated
public RdfToJsonld uriValidation(boolean uriValidation) {
+ return uriValidation(UriValidationPolicy.of(uriValidation));
+ }
+
+ public RdfToJsonld uriValidation(UriValidationPolicy uriValidation) {
this.uriValidation = uriValidation;
return this;
}
diff --git a/src/main/java/com/apicatalog/jsonld/uri/UriUtils.java b/src/main/java/com/apicatalog/jsonld/uri/UriUtils.java
index 851a3701..a15e02f1 100644
--- a/src/main/java/com/apicatalog/jsonld/uri/UriUtils.java
+++ b/src/main/java/com/apicatalog/jsonld/uri/UriUtils.java
@@ -94,15 +94,28 @@ public static final boolean isNotURI(final String uri) {
*/
@Deprecated
public static final boolean isNotAbsoluteUri(final String uri) {
- return isNotAbsoluteUri(uri, true);
+ return isNotAbsoluteUri(uri, UriValidationPolicy.of(true));
}
+ /**
+ * Deprecated in favor of {@link UriUtils#isNotAbsoluteUri(String, UriValidationPolicy)}
+ *
+ * @deprecated since 1.3.0
+ *
+ * @param uri to check
+ * @return true
if the given URI is absolute
+ */
+ @Deprecated
public static final boolean isNotAbsoluteUri(final String uri, final boolean validate) {
- return !isAbsoluteUri(uri, validate);
+ return !isAbsoluteUri(uri, UriValidationPolicy.of(validate));
+ }
+
+ public static final boolean isNotAbsoluteUri(final String uri, UriValidationPolicy policy) {
+ return !isAbsoluteUri(uri, policy);
}
/**
- * Deprecated in favor of {@link UriUtils#isAbsoluteUri(String, boolean)}
+ * Deprecated in favor of {@link UriUtils#isAbsoluteUri(String, UriValidationPolicy)}
*
* @deprecated since 1.3.0
*
@@ -111,28 +124,44 @@ public static final boolean isNotAbsoluteUri(final String uri, final boolean val
*/
@Deprecated
public static final boolean isAbsoluteUri(final String uri) {
- return isAbsoluteUri(uri, true);
+ return isAbsoluteUri(uri, UriValidationPolicy.Full);
}
- public static final boolean isAbsoluteUri(final String uri, final boolean validate) {
-
- // if URI validation is disabled
- if (!validate) {
- // then validate just a scheme
- return startsWithScheme(uri);
- }
+ /**
+ * Deprecated in favor of {@link UriUtils#isAbsoluteUri(String, UriValidationPolicy)}
+ *
+ * @deprecated since 1.4.2
+ *
+ * @param uri to check
+ * @return true
if the given URI is absolute
+ */
+ @Deprecated
+ public static final boolean isAbsoluteUri(final String uri, boolean validate) {
+ return isAbsoluteUri(uri, UriValidationPolicy.of(validate));
+ }
- if (uri == null
- || uri.length() < 3 // minimal form s(1):ssp(1)
+ public static final boolean isAbsoluteUri(final String uri, final UriValidationPolicy policy) {
+ switch (policy) {
+ case None:
+ return true;
+ case SchemeOnly:
+ return startsWithScheme(uri);
+ case Full:
+ if (uri == null
+ || uri.length() < 3 // minimal form s(1):ssp(1)
) {
- return false;
+ return false;
+ } else{
+ try {
+ return URI.create(uri).isAbsolute();
+ } catch (IllegalArgumentException e) {
+ return false;
+ }
+ }
+ default:
+ return false;
}
- try {
- return URI.create(uri).isAbsolute();
- } catch (IllegalArgumentException e) {
- return false;
- }
}
private static final boolean startsWithScheme(final String uri) {
diff --git a/src/main/java/com/apicatalog/jsonld/uri/UriValidationPolicy.java b/src/main/java/com/apicatalog/jsonld/uri/UriValidationPolicy.java
new file mode 100644
index 00000000..abb64f37
--- /dev/null
+++ b/src/main/java/com/apicatalog/jsonld/uri/UriValidationPolicy.java
@@ -0,0 +1,26 @@
+package com.apicatalog.jsonld.uri;
+
+public enum UriValidationPolicy {
+
+ /**
+ * No validation is performed
+ */
+ None,
+
+ /**
+ * The validation only targets the scheme
+ */
+ SchemeOnly,
+
+ /**
+ * The validation is be fully performed
+ */
+ Full ;
+
+ /**
+ * Method allowing to convert the legacy boolean to the matching policy
+ */
+ public static UriValidationPolicy of(boolean value) {
+ return value ? Full : SchemeOnly ;
+ }
+}
diff --git a/src/main/java/com/apicatalog/rdf/Rdf.java b/src/main/java/com/apicatalog/rdf/Rdf.java
index 24fbb65d..ce107913 100644
--- a/src/main/java/com/apicatalog/rdf/Rdf.java
+++ b/src/main/java/com/apicatalog/rdf/Rdf.java
@@ -27,6 +27,7 @@
import com.apicatalog.jsonld.http.media.MediaType;
import com.apicatalog.jsonld.lang.BlankNode;
import com.apicatalog.jsonld.uri.UriUtils;
+import com.apicatalog.jsonld.uri.UriValidationPolicy;
import com.apicatalog.rdf.io.RdfReader;
import com.apicatalog.rdf.io.RdfWriter;
import com.apicatalog.rdf.io.error.UnsupportedContentException;
@@ -133,7 +134,7 @@ public static RdfValue createValue(String value) {
return RdfProvider.provider().createBlankNode(value);
}
- if (UriUtils.isAbsoluteUri(value, true)) {
+ if (UriUtils.isAbsoluteUri(value, UriValidationPolicy.Full)) {
return RdfProvider.provider().createIRI(value);
}
@@ -184,7 +185,7 @@ public static RdfResource createResource(String resource) {
return RdfProvider.provider().createBlankNode(resource);
}
- if (UriUtils.isAbsoluteUri(resource, true)) {
+ if (UriUtils.isAbsoluteUri(resource, UriValidationPolicy.Full)) {
return RdfProvider.provider().createIRI(resource);
}
diff --git a/src/main/java/com/apicatalog/rdf/io/nquad/NQuadsReader.java b/src/main/java/com/apicatalog/rdf/io/nquad/NQuadsReader.java
index ab69d73d..8f1498eb 100644
--- a/src/main/java/com/apicatalog/rdf/io/nquad/NQuadsReader.java
+++ b/src/main/java/com/apicatalog/rdf/io/nquad/NQuadsReader.java
@@ -19,6 +19,7 @@
import java.util.Arrays;
import com.apicatalog.jsonld.uri.UriUtils;
+import com.apicatalog.jsonld.uri.UriValidationPolicy;
import com.apicatalog.rdf.Rdf;
import com.apicatalog.rdf.RdfDataset;
import com.apicatalog.rdf.RdfLiteral;
@@ -242,7 +243,7 @@ private void skipWhitespace(int min) throws RdfReaderException {
}
private static final void assertAbsoluteIri(final String iri, final String what) throws RdfReaderException {
- if (UriUtils.isNotAbsoluteUri(iri, true)) {
+ if (UriUtils.isNotAbsoluteUri(iri, UriValidationPolicy.Full)) {
throw new RdfReaderException(what + " must be an absolute IRI [" + iri + "]. ");
}
}
diff --git a/src/test/java/com/apicatalog/jsonld/api/ToRdfApiTest.java b/src/test/java/com/apicatalog/jsonld/api/ToRdfApiTest.java
index a5a4dcd2..3acbee88 100644
--- a/src/test/java/com/apicatalog/jsonld/api/ToRdfApiTest.java
+++ b/src/test/java/com/apicatalog/jsonld/api/ToRdfApiTest.java
@@ -15,22 +15,26 @@
*/
package com.apicatalog.jsonld.api;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStreamReader;
-import java.net.URI;
-
-import org.junit.jupiter.api.Test;
-
import com.apicatalog.jsonld.JsonLd;
import com.apicatalog.jsonld.JsonLdError;
+import com.apicatalog.jsonld.JsonLdOptions;
+import com.apicatalog.jsonld.document.Document;
import com.apicatalog.jsonld.document.JsonDocument;
import com.apicatalog.jsonld.http.media.MediaType;
+import com.apicatalog.jsonld.uri.UriValidationPolicy;
import com.apicatalog.rdf.RdfDataset;
-
+import com.apicatalog.rdf.RdfNQuad;
import jakarta.json.JsonValue;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.util.function.Predicate;
+
+import static org.junit.jupiter.api.Assertions.*;
class ToRdfApiTest {
@@ -112,4 +116,80 @@ void test11() throws JsonLdError {
assertNotNull(result);
assertEquals(0, result.size());
}
+
+ private final String invalidUri = " http://example.com/invalid";
+ private final String expandedInvalidSubject = "/com/apicatalog/jsonld/test/issue383-expanded-subject.json";
+
+ @Test
+ void test12() throws JsonLdError, IOException {
+ RdfDataset result = readRdfDataset(expandedInvalidSubject, UriValidationPolicy.None);
+
+ boolean includeInvalidSubject = anyInDataset(result, rdfNQuad -> rdfNQuad.getSubject().getValue().equals(invalidUri));
+
+ assertTrue(includeInvalidSubject, "The resulting dataset without uri validation should include :" + invalidUri);
+ }
+
+ @Test
+ void test13() throws JsonLdError, IOException {
+ RdfDataset result = readRdfDataset(expandedInvalidSubject, UriValidationPolicy.Full);
+
+ boolean includeInvalidSubject = anyInDataset(result, rdfNQuad -> rdfNQuad.getSubject().getValue().equals(invalidUri));
+
+ assertFalse(includeInvalidSubject, "The resulting dataset with uri validation should NOT include :" + invalidUri);
+ }
+
+ private final String expandedInvalidPredicate = "/com/apicatalog/jsonld/test/issue383-expanded-predicate.json";
+
+ @Test
+ void test14() throws JsonLdError, IOException {
+ RdfDataset result = readRdfDataset(expandedInvalidPredicate, UriValidationPolicy.None);
+
+ boolean includeInvalidPredicate = anyInDataset(result, rdfNQuad -> rdfNQuad.getPredicate().getValue().equals(invalidUri));
+
+ assertTrue(includeInvalidPredicate, "The resulting dataset without uri validation should include :" + invalidUri);
+ }
+
+ @Test
+ void test15() throws JsonLdError, IOException {
+ RdfDataset result = readRdfDataset(expandedInvalidPredicate, UriValidationPolicy.Full);
+
+ boolean includeInvalidPredicate = anyInDataset(result, rdfNQuad -> rdfNQuad.getPredicate().getValue().equals(invalidUri));
+
+ assertFalse(includeInvalidPredicate, "The resulting dataset with uri validation should NOT include :" + invalidUri);
+ }
+
+ private final String expandedInvalidObject = "/com/apicatalog/jsonld/test/issue383-expanded-object.json";
+
+ @Test
+ void test16() throws JsonLdError, IOException {
+ RdfDataset result = readRdfDataset(expandedInvalidObject, UriValidationPolicy.None);
+
+ boolean includeInvalidObject = anyInDataset(result, rdfNQuad -> rdfNQuad.getObject().getValue().equals(invalidUri));
+
+ assertTrue(includeInvalidObject, "The resulting dataset without uri validation should include :" + invalidUri);
+ }
+
+ @Test
+ void test17() throws JsonLdError, IOException {
+ RdfDataset result = readRdfDataset(expandedInvalidObject, UriValidationPolicy.Full);
+
+ boolean includeInvalidObject = anyInDataset(result, rdfNQuad -> rdfNQuad.getObject().getValue().equals(invalidUri));
+
+ assertFalse(includeInvalidObject, "The resulting dataset with uri validation should NOT include :" + invalidUri);
+ }
+
+ private boolean anyInDataset(final RdfDataset dataset, Predicate