changeset 917:4cd8f1649ef7

st128
author Devel 1
date Wed, 25 Apr 2018 14:23:52 +0200
parents b3e412d37d75
children 1d9f14d387f6
files stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilterMessagePredicateNodeDefinition.java stress-tester/src/main/java/com/passus/st/filter/Transformers.java
diffstat 2 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilterMessagePredicateNodeDefinition.java	Wed Apr 25 11:55:25 2018 +0200
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilterMessagePredicateNodeDefinition.java	Wed Apr 25 14:23:52 2018 +0200
@@ -12,6 +12,7 @@
 import com.passus.config.validation.Errors;
 import static com.passus.config.validation.ValidationDefaultMessages.GENERAL_CONVERSION_ERROR;
 import com.passus.filter.config.PredicateNodeTransformer;
+import com.passus.lookup.filter.LookupKeyExistsLeftOperatorTransformer;
 import com.passus.st.filter.Transformers;
 import java.util.Set;
 import java.util.function.Predicate;
@@ -34,7 +35,11 @@
     @Override
     protected void doValidate(CNode node, Errors errors, ConfigurationContext context) {
         try {
+            // TODO: refactor
+            LookupKeyExistsLeftOperatorTransformer lookupKeyExistsTransformer = Transformers.lookupKeyExistsTransformer(context);
+            TRANSFORMER.addLeftOperatorTransformer(lookupKeyExistsTransformer);
             TRANSFORMER.transform(node);
+            TRANSFORMER.removeLeftOperatorTransformer(lookupKeyExistsTransformer);
         } catch (NodeConversionException ex) {
             errors.reject(node, ex.getMessage());
         } catch (ConversionException ex) {
@@ -45,10 +50,14 @@
     @Override
     protected CNode doTransform(CNode node, Errors errors, ConfigurationContext context, boolean reverse) {
         if (reverse) {
-            
+
         } else {
             try {
+                // TODO: refactor
+                LookupKeyExistsLeftOperatorTransformer lookupKeyExistsTransformer = Transformers.lookupKeyExistsTransformer(context);
+                TRANSFORMER.addLeftOperatorTransformer(lookupKeyExistsTransformer);
                 Predicate predicate = TRANSFORMER.transform(node);
+                TRANSFORMER.removeLeftOperatorTransformer(lookupKeyExistsTransformer);
                 return new CValueNode(new HttpMessagePredicate(predicate));
             } catch (NodeConversionException ex) {
                 errors.reject(node, ex.getMessage());
--- a/stress-tester/src/main/java/com/passus/st/filter/Transformers.java	Wed Apr 25 11:55:25 2018 +0200
+++ b/stress-tester/src/main/java/com/passus/st/filter/Transformers.java	Wed Apr 25 14:23:52 2018 +0200
@@ -8,6 +8,7 @@
 import com.passus.filter.config.ValueExtractorResolver;
 import com.passus.lookup.Lookup;
 import com.passus.lookup.filter.LookupHelper;
+import com.passus.lookup.filter.LookupKeyExistsLeftOperatorTransformer;
 import com.passus.lookup.filter.LookupValueExtractorTransformer;
 import com.passus.st.utils.ConfigurationContextConsts;
 import com.passus.st.vars.VarsExtractorResolver;
@@ -47,4 +48,9 @@
         return new LookupValueExtractorTransformer(lookups, LOOKUP_HELPER);
     }
 
+    public static LookupKeyExistsLeftOperatorTransformer lookupKeyExistsTransformer(ConfigurationContext context) {
+        List<Lookup> lookups = context.get(ConfigurationContextConsts.LOOKUPS, Collections.EMPTY_LIST);
+        return new LookupKeyExistsLeftOperatorTransformer(lookups, LOOKUP_HELPER);
+    }
+
 }