From 12e7221e8c8b6fc0cce74c85ff30212ee1ce445c Mon Sep 17 00:00:00 2001 From: Xavi Aracil Date: Thu, 21 Mar 2024 17:23:59 +0100 Subject: [PATCH] Raise a warning when the context is not the latest one --- .../oneedtech/inspect/vc/probe/ContextPropertyProbe.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ContextPropertyProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ContextPropertyProbe.java index 865daca..b41e31d 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ContextPropertyProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/ContextPropertyProbe.java @@ -2,6 +2,7 @@ package org.oneedtech.inspect.vc.probe; import static org.oneedtech.inspect.util.code.Defensives.checkNotNull; +import java.util.ArrayList; import java.util.List; import org.oneedtech.inspect.core.probe.RunContext; @@ -35,12 +36,20 @@ public class ContextPropertyProbe extends StringValuePropertyProbe { checkNotNull(contextUris); int pos = 0; + List warnings = new ArrayList<>(); for (String uri : contextUris) { if ((nodeValues.size() < pos + 1) || !contains(uri, nodeValues.get(pos))) { return error("missing required @context uri " + uri + " at position " + (pos + 1), ctx); } + if (!nodeValues.get(pos).equals(uri)) { + warnings.add(warning("expected @context uri " + uri + " at position " + (pos + 1) + ", gotten " + nodeValues.get(pos).toString() + " instead", ctx)); + } + pos++; } + if (!warnings.isEmpty()) { + return new ReportItems(warnings); + } } return success(ctx);