Pass node to reportForNonExistentProperty

This commit is contained in:
Xavi Aracil 2022-11-28 15:03:21 +01:00
parent 4267423273
commit 2f11941ebd
2 changed files with 5 additions and 6 deletions

View File

@ -8,6 +8,8 @@ import org.oneedtech.inspect.core.probe.RunContext;
import org.oneedtech.inspect.core.report.ReportItems; import org.oneedtech.inspect.core.report.ReportItems;
import org.oneedtech.inspect.vc.Credential.CredentialEnum; import org.oneedtech.inspect.vc.Credential.CredentialEnum;
import com.fasterxml.jackson.databind.JsonNode;
/** /**
* A Probe that verifies a credential's context property. * A Probe that verifies a credential's context property.
* *
@ -23,7 +25,7 @@ public class ContextPropertyProbe extends StringValuePropertyProbe {
} }
@Override @Override
protected ReportItems reportForNonExistentProperty(RunContext ctx) { protected ReportItems reportForNonExistentProperty(JsonNode node, RunContext ctx) {
return notRun("No @context property", ctx); return notRun("No @context property", ctx);
} }

View File

@ -1,12 +1,10 @@
package org.oneedtech.inspect.vc.probe; package org.oneedtech.inspect.vc.probe;
import java.util.List;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import org.oneedtech.inspect.core.probe.Probe; import org.oneedtech.inspect.core.probe.Probe;
import org.oneedtech.inspect.core.probe.RunContext; import org.oneedtech.inspect.core.probe.RunContext;
import org.oneedtech.inspect.core.report.ReportItems; import org.oneedtech.inspect.core.report.ReportItems;
import org.oneedtech.inspect.vc.util.JsonNodeUtil;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
@ -28,14 +26,13 @@ public class PropertyProbe extends Probe<JsonNode> {
public ReportItems run(JsonNode root, RunContext ctx) throws Exception { public ReportItems run(JsonNode root, RunContext ctx) throws Exception {
JsonNode propertyNode = root.get(propertyName); JsonNode propertyNode = root.get(propertyName);
if (propertyNode == null) { if (propertyNode == null) {
return reportForNonExistentProperty(ctx); return reportForNonExistentProperty(root, ctx);
} }
List<String> values = JsonNodeUtil.asStringList(propertyNode);
return validations.apply(propertyNode, ctx); return validations.apply(propertyNode, ctx);
} }
protected ReportItems reportForNonExistentProperty(RunContext ctx) { protected ReportItems reportForNonExistentProperty(JsonNode node, RunContext ctx) {
return fatal("No " + propertyName + " property", ctx); return fatal("No " + propertyName + " property", ctx);
} }