From 3cf248087588acd84f50c5694e193c1600c57770 Mon Sep 17 00:00:00 2001 From: Timon Borter Date: Tue, 5 Sep 2023 18:10:25 +0200 Subject: [PATCH] feat: static access to extractor builders --- .../validation/json/JsonPathVariableExtractor.java | 4 ++++ .../validation/xml/XpathPayloadVariableExtractor.java | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathVariableExtractor.java b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathVariableExtractor.java index 51ce7cb873..dacede2998 100644 --- a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathVariableExtractor.java +++ b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathVariableExtractor.java @@ -112,6 +112,10 @@ public void extractVariables(Message message, TestContext context) { public static final class Builder implements VariableExtractor.Builder, MessageProcessorAdapter, ValidationContextAdapter { private final Map expressions = new LinkedHashMap<>(); + public static Builder fromJsonPath() { + return new Builder(); + } + @Override public Builder expressions(Map expressions) { this.expressions.putAll(expressions); diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathPayloadVariableExtractor.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathPayloadVariableExtractor.java index 92d47c4053..659bdd265d 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathPayloadVariableExtractor.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathPayloadVariableExtractor.java @@ -51,6 +51,8 @@ * @author Christoph Deppisch */ public class XpathPayloadVariableExtractor implements VariableExtractor { + /** Logger */ + private static final Logger LOG = LoggerFactory.getLogger(XpathPayloadVariableExtractor.class); /** Map defines xpath expressions and target variable names */ private final Map xPathExpressions; @@ -58,9 +60,6 @@ public class XpathPayloadVariableExtractor implements VariableExtractor { /** Namespace definitions used in xpath expressions */ private final Map namespaces; - /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(XpathPayloadVariableExtractor.class); - public XpathPayloadVariableExtractor() { this(new Builder()); } @@ -143,6 +142,10 @@ public static final class Builder implements VariableExtractor.Builder expressions = new HashMap<>(); private final Map namespaces = new HashMap<>(); + public static Builder fromXpath() { + return new Builder(); + } + /** * Adds explicit namespace declaration for later path validation expressions. *