changeset 647:a60392f31cf0

transform, reverseTransform methods refactorization
author Devel 2
date Thu, 09 Nov 2017 11:40:26 +0100
parents cbf6caefb2f6
children 4434d61d41b4
files stress-tester/src/main/java/com/passus/st/Main.java stress-tester/src/main/java/com/passus/st/Main2.java stress-tester/src/main/java/com/passus/st/client/credentials/MultiCredentialsProviderTransformer.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCsrfFilterExtractorTransformer.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCsrfFilterInjectorTransformer.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFiltersConfigurator.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformer.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpResponseContentExtractorFilterTransformer.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpScopeModificationFilterTransformer.java stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSequenceFilter.java stress-tester/src/main/java/com/passus/st/config/EmitterConfigurator.java stress-tester/src/main/java/com/passus/st/config/EventSourceConfigurator.java stress-tester/src/main/java/com/passus/st/config/HeaderOperationNodeDefinition.java stress-tester/src/main/java/com/passus/st/config/MetricsConfigurator.java stress-tester/src/test/java/com/passus/st/client/credentials/MultiCredentialsProviderTransformerTest.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersConfiguratorTest.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersNodeDefinitionCreatorTest.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformerTest.java stress-tester/src/test/java/com/passus/st/config/MetricsConfiguratorTest.java stress-tester/src/test/java/com/passus/st/config/StringSourceNodeDefinitionTest.java
diffstat 20 files changed, 46 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/Main.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/Main.java	Thu Nov 09 11:40:26 2017 +0100
@@ -31,7 +31,6 @@
 import com.passus.st.reporter.server.AvroRpcReporterClient;
 import com.passus.st.reporter.trx.SocketReporterClient;
 import com.passus.st.source.PcapSessionEventSource;
-import static com.passus.st.utils.CliUtils.option;
 import com.passus.st.utils.PeriodFormatter;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -54,8 +53,6 @@
 import org.apache.commons.cli.ParseException;
 import org.apache.commons.io.IOUtils;
 import static com.passus.st.utils.CliUtils.option;
-import static com.passus.st.utils.CliUtils.option;
-import static com.passus.st.utils.CliUtils.option;
 
 /**
  *
@@ -341,7 +338,7 @@
                 Configuration config = YamlConfigurationReader.readFromFile(filtersFile);
                 HttpFiltersConfigurator configurator = new HttpFiltersConfigurator(client);
                 Errors errors = new Errors();
-                configurator.configure(config, errors);
+                configurator.configure(config, errors, null);
                 if (errors.getErrorCount() != 0) {
                     System.out.println("Error in file '" + filtersFile.getAbsolutePath() + "'.");
                     for (ObjectError error : errors.getAllErrors()) {
--- a/stress-tester/src/main/java/com/passus/st/Main2.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/Main2.java	Thu Nov 09 11:40:26 2017 +0100
@@ -339,7 +339,7 @@
                 Configuration config = YamlConfigurationReader.readFromFile(filtersFile);
                 HttpFiltersConfigurator configurator = new HttpFiltersConfigurator(client);
                 Errors errors = new Errors();
-                configurator.configure(config, errors);
+                configurator.configure(config, errors, null);
                 if (errors.getErrorCount() != 0) {
                     System.out.println("Error in file '" + filtersFile.getAbsolutePath() + "'.");
                     for (ObjectError error : errors.getAllErrors()) {
--- a/stress-tester/src/main/java/com/passus/st/client/credentials/MultiCredentialsProviderTransformer.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/credentials/MultiCredentialsProviderTransformer.java	Thu Nov 09 11:40:26 2017 +0100
@@ -5,6 +5,7 @@
 import com.passus.config.CNode;
 import com.passus.config.CTupleNode;
 import com.passus.config.CValueNode;
+import com.passus.config.ConfigurationContext;
 import com.passus.config.ConfigurationImpl;
 import com.passus.config.NodeType;
 import com.passus.config.schema.NodeDefinition;
@@ -24,7 +25,7 @@
     private final CredentialsProviderFactory factory = CredentialsProviderFactory.getInstance();
 
     @Override
-    public CValueNode transform(CNode node, Errors errors) {
+    public CValueNode transform(CNode node, Errors errors, ConfigurationContext context) {
         if (validateType(node, NodeType.MAP, errors)) {
             CMapNode mapNode = (CMapNode) node;
             List<CTupleNode> children = mapNode.getChildren();
@@ -61,7 +62,7 @@
     }
 
     @Override
-    public CValueNode reverseTransform(CNode node, Errors errors) {
+    public CValueNode reverseTransform(CNode node, Errors errors, ConfigurationContext context) {
         throw new UnsupportedOperationException("Not supported yet.");
     }
 
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCsrfFilterExtractorTransformer.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCsrfFilterExtractorTransformer.java	Thu Nov 09 11:40:26 2017 +0100
@@ -4,6 +4,7 @@
 import com.passus.config.CNode;
 import com.passus.config.CTupleNode;
 import com.passus.config.CValueNode;
+import com.passus.config.ConfigurationContext;
 import com.passus.config.NodeType;
 import com.passus.config.schema.NodeTransformer;
 import com.passus.config.validation.Errors;
@@ -37,7 +38,7 @@
     }
 
     @Override
-    public CValueNode transform(CNode node, Errors errors) {
+    public CValueNode transform(CNode node, Errors errors, ConfigurationContext context) {
         CMapNode mapNode = (CMapNode) node;
 
         List<CTupleNode> tuples = mapNode.getChildren();
@@ -76,7 +77,7 @@
     }
 
     @Override
-    public CValueNode reverseTransform(CNode node, Errors errors) {
+    public CValueNode reverseTransform(CNode node, Errors errors, ConfigurationContext context) {
         throw new UnsupportedOperationException("Not supported yet.");
     }
 
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCsrfFilterInjectorTransformer.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpCsrfFilterInjectorTransformer.java	Thu Nov 09 11:40:26 2017 +0100
@@ -4,6 +4,7 @@
 import com.passus.config.CNode;
 import com.passus.config.CTupleNode;
 import com.passus.config.CValueNode;
+import com.passus.config.ConfigurationContext;
 import com.passus.config.NodeType;
 import com.passus.config.schema.NodeTransformer;
 import com.passus.config.validation.Errors;
@@ -37,7 +38,7 @@
     }
 
     @Override
-    public CValueNode transform(CNode node, Errors errors) {
+    public CValueNode transform(CNode node, Errors errors, ConfigurationContext context) {
         CMapNode mapNode = (CMapNode) node;
 
         List<CTupleNode> tuples = mapNode.getChildren();
@@ -76,7 +77,7 @@
     }
 
     @Override
-    public CValueNode reverseTransform(CNode node, Errors errors) {
+    public CValueNode reverseTransform(CNode node, Errors errors, ConfigurationContext context) {
         throw new UnsupportedOperationException("Not supported yet.");
     }
 
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFiltersConfigurator.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFiltersConfigurator.java	Thu Nov 09 11:40:26 2017 +0100
@@ -5,6 +5,7 @@
 import com.passus.config.CMapNode;
 import com.passus.config.CNode;
 import com.passus.config.Configuration;
+import com.passus.config.ConfigurationContext;
 import com.passus.config.ConfigurationImpl;
 import com.passus.config.Configurator;
 import com.passus.config.schema.ConfigurationSchema;
@@ -73,12 +74,12 @@
     }
 
     @Override
-    public void validate(Configuration config, Errors errors) {
+    public void validate(Configuration config, Errors errors, ConfigurationContext context) {
         SCHEMA.validate(config, errors);
     }
 
     @Override
-    public void configure(Configuration config, Errors errors) {
+    public void configure(Configuration config, Errors errors, ConfigurationContext context) {
         List<HttpFilter> filters = getFilters(config, errors);
         if (errors.getErrorCount() == 0) {
             for (HttpFilter filter : filters) {
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformer.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformer.java	Thu Nov 09 11:40:26 2017 +0100
@@ -5,6 +5,7 @@
 import com.passus.config.CNode;
 import com.passus.config.CTupleNode;
 import com.passus.config.CValueNode;
+import com.passus.config.ConfigurationContext;
 import com.passus.config.NodeType;
 import com.passus.config.schema.NodeTransformer;
 import com.passus.config.validation.Errors;
@@ -110,7 +111,7 @@
     }
 
     @Override
-    public CValueNode transform(CNode node, Errors errors) {
+    public CValueNode transform(CNode node, Errors errors, ConfigurationContext context) {
         CMapNode mapNode = (CMapNode) node;
 
         List<CTupleNode> tuples = mapNode.getChildren();
@@ -179,7 +180,7 @@
     }
 
     @Override
-    public CNode reverseTransform(CNode node, Errors errors) {
+    public CNode reverseTransform(CNode node, Errors errors, ConfigurationContext context) {
         throw new UnsupportedOperationException("Not supported yet.");
     }
 
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpResponseContentExtractorFilterTransformer.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpResponseContentExtractorFilterTransformer.java	Thu Nov 09 11:40:26 2017 +0100
@@ -4,6 +4,7 @@
 import com.passus.config.CNode;
 import com.passus.config.CTupleNode;
 import com.passus.config.CValueNode;
+import com.passus.config.ConfigurationContext;
 import static com.passus.config.ConfigurationUtils.extractBoolean;
 import com.passus.config.NodeType;
 import com.passus.config.schema.NodeTransformer;
@@ -91,7 +92,7 @@
     }
 
     @Override
-    public CValueNode transform(CNode node, Errors errors) {
+    public CValueNode transform(CNode node, Errors errors, ConfigurationContext context) {
         CMapNode mapNode = (CMapNode) node;
 
         List<CTupleNode> tuples = mapNode.getChildren();
@@ -138,7 +139,7 @@
     }
 
     @Override
-    public CValueNode reverseTransform(CNode node, Errors errors) {
+    public CValueNode reverseTransform(CNode node, Errors errors, ConfigurationContext context) {
         throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
     }
 
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpScopeModificationFilterTransformer.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpScopeModificationFilterTransformer.java	Thu Nov 09 11:40:26 2017 +0100
@@ -4,6 +4,7 @@
 import com.passus.config.CNode;
 import com.passus.config.CTupleNode;
 import com.passus.config.CValueNode;
+import com.passus.config.ConfigurationContext;
 import com.passus.config.ConfigurationUtils;
 import static com.passus.config.ConfigurationUtils.extractBoolean;
 import com.passus.config.NodeType;
@@ -96,7 +97,7 @@
     }
 
     @Override
-    public CValueNode transform(CNode node, Errors errors) {
+    public CValueNode transform(CNode node, Errors errors, ConfigurationContext context) {
         CMapNode mapNode = (CMapNode) node;
 
         List<CTupleNode> tuples = mapNode.getChildren();
@@ -159,7 +160,7 @@
     }
 
     @Override
-    public CValueNode reverseTransform(CNode node, Errors errors) {
+    public CValueNode reverseTransform(CNode node, Errors errors, ConfigurationContext context) {
         throw new UnsupportedOperationException("Not supported yet.");
     }
 
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSequenceFilter.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpSequenceFilter.java	Thu Nov 09 11:40:26 2017 +0100
@@ -8,6 +8,7 @@
 import com.passus.config.CTupleNode;
 import com.passus.config.CValueNode;
 import com.passus.config.Configuration;
+import com.passus.config.ConfigurationContext;
 import com.passus.config.annotations.NodeDefinitionCreate;
 import static com.passus.config.schema.ConfigurationSchemaBuilder.mapDef;
 import static com.passus.config.schema.ConfigurationSchemaBuilder.tupleDef;
@@ -413,7 +414,7 @@
         private static final PredicateNodeTransformer TRANSFORMER = Transformers.PREDICATE;
 
         @Override
-        public CNode transform(CNode node, Errors errors) {
+        public CNode transform(CNode node, Errors errors, ConfigurationContext context) {
             try {
                 CMapNode mapNode = (CMapNode) node;
                 List<CTupleNode> tupleNodes = mapNode.getChildren();
@@ -453,7 +454,7 @@
         }
 
         @Override
-        public CNode reverseTransform(CNode node, Errors errors) {
+        public CNode reverseTransform(CNode node, Errors errors, ConfigurationContext context) {
             throw new UnsupportedOperationException("Not supported yet.");
         }
 
@@ -462,7 +463,7 @@
     private static class ValuesNodeTransformer implements NodeTransformer<CNode> {
 
         @Override
-        public CNode transform(CNode node, Errors errors) {
+        public CNode transform(CNode node, Errors errors, ConfigurationContext context) {
             Map<String, ValueExtractor> result = new HashMap<>();
 
             CMapNode mapNode = (CMapNode) node;
@@ -485,7 +486,7 @@
         }
 
         @Override
-        public CNode reverseTransform(CNode node, Errors errors) {
+        public CNode reverseTransform(CNode node, Errors errors, ConfigurationContext context) {
             throw new UnsupportedOperationException("Not supported yet.");
         }
 
--- a/stress-tester/src/main/java/com/passus/st/config/EmitterConfigurator.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/config/EmitterConfigurator.java	Thu Nov 09 11:40:26 2017 +0100
@@ -1,6 +1,7 @@
 package com.passus.st.config;
 
 import com.passus.config.Configuration;
+import com.passus.config.ConfigurationContext;
 import com.passus.config.DomainConfigurator;
 import com.passus.config.schema.ConfigurationSchema;
 import static com.passus.config.schema.ConfigurationSchemaBuilder.*;
@@ -50,12 +51,12 @@
     }
 
     @Override
-    public void validate(Configuration config, Errors errors) {
+    public void validate(Configuration config, Errors errors, ConfigurationContext context) {
         schema.validate(config, errors);
     }
 
     @Override
-    public void configure(Configuration config, Errors errors) {
+    public void configure(Configuration config, Errors errors, ConfigurationContext context) {
         Configuration tConfig = schema.transform(config, errors);
         if (errors.getErrorCount() == 0) {
 
--- a/stress-tester/src/main/java/com/passus/st/config/EventSourceConfigurator.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/config/EventSourceConfigurator.java	Thu Nov 09 11:40:26 2017 +0100
@@ -1,6 +1,7 @@
 package com.passus.st.config;
 
 import com.passus.config.Configuration;
+import com.passus.config.ConfigurationContext;
 import com.passus.config.DomainConfigurator;
 import static com.passus.config.schema.ConfigurationSchemaBuilder.*;
 import com.passus.config.schema.MapNodeDefinition;
@@ -45,12 +46,12 @@
     }
 
     @Override
-    public void validate(Configuration config, Errors errors) {
+    public void validate(Configuration config, Errors errors, ConfigurationContext context) {
 
     }
 
     @Override
-    public void configure(Configuration config, Errors errors) {
+    public void configure(Configuration config, Errors errors, ConfigurationContext context) {
 
     }
 
--- a/stress-tester/src/main/java/com/passus/st/config/HeaderOperationNodeDefinition.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/config/HeaderOperationNodeDefinition.java	Thu Nov 09 11:40:26 2017 +0100
@@ -157,9 +157,9 @@
                 try {
                     errors.pushNestedPath(tupleName);
                     if (reverse) {
-                        def.reverseTransform(tuple, errors);
+                        def.reverseTransform(tuple, errors, null);
                     } else {
-                        def.transform(tuple, errors);
+                        def.transform(tuple, errors, null);
                     }
                 } finally {
                     errors.popNestedPath();
--- a/stress-tester/src/main/java/com/passus/st/config/MetricsConfigurator.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/config/MetricsConfigurator.java	Thu Nov 09 11:40:26 2017 +0100
@@ -2,6 +2,7 @@
 
 import com.passus.commons.annotations.Plugin;
 import com.passus.config.Configuration;
+import com.passus.config.ConfigurationContext;
 import com.passus.config.DomainConfigurator;
 import com.passus.config.schema.ConfigurationSchema;
 import static com.passus.config.schema.ConfigurationSchemaBuilder.dynaKeyValueVaryListDef;
@@ -54,12 +55,12 @@
     }
 
     @Override
-    public void validate(Configuration config, Errors errors) {
+    public void validate(Configuration config, Errors errors, ConfigurationContext context) {
         schema.validate(config, errors);
     }
 
     @Override
-    public void configure(Configuration config, Errors errors) {
+    public void configure(Configuration config, Errors errors, ConfigurationContext context) {
         Configuration tConfig = schema.transform(config, errors);
         if (errors.getErrorCount() == 0) {
             if (appenders == null) {
--- a/stress-tester/src/test/java/com/passus/st/client/credentials/MultiCredentialsProviderTransformerTest.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/test/java/com/passus/st/client/credentials/MultiCredentialsProviderTransformerTest.java	Thu Nov 09 11:40:26 2017 +0100
@@ -97,7 +97,7 @@
         CNode node = providerNode.getNode();
 
         MultiCredentialsProviderTransformer transformer = new MultiCredentialsProviderTransformer();
-        CValueNode valueNode = transformer.transform(node);
+        CValueNode valueNode = transformer.transform(node, null);
         return (MultiCredentialsProvider) valueNode.getValue();
     }
 
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersConfiguratorTest.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersConfiguratorTest.java	Thu Nov 09 11:40:26 2017 +0100
@@ -30,7 +30,7 @@
 
         HttpFiltersConfigurator configurator = new HttpFiltersConfigurator(client);
         Errors errors = new Errors();
-        configurator.configure(config, errors);
+        configurator.configure(config, errors, null);
         assertEquals(0, errors.getErrorCount());
         
         verify(client, times(3)).addFilter(captor.capture());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersNodeDefinitionCreatorTest.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersNodeDefinitionCreatorTest.java	Thu Nov 09 11:40:26 2017 +0100
@@ -46,7 +46,7 @@
 
         Errors errors = new Errors();
         CNode filtersNode = ((CTupleNode) config.getRootNode().getFirstChild()).getNode();
-        CListNode listNode = (CListNode) def.transform(filtersNode, errors);
+        CListNode listNode = (CListNode) def.transform(filtersNode, errors, null);
 
         errors.getAllErrors().forEach(System.out::println);
         assertEquals(0, errors.getErrorCount());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformerTest.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTransformerTest.java	Thu Nov 09 11:40:26 2017 +0100
@@ -49,7 +49,7 @@
         CTupleNode node = read(config);
 
         Errors errors = new Errors();
-        CValueNode value = transformer.transform(node.getNode(), errors);
+        CValueNode value = transformer.transform(node.getNode(), errors, null);
         List<Operation> operations = (List) value.getValue();
 
         assertEquals(0, errors.getErrorCount());
--- a/stress-tester/src/test/java/com/passus/st/config/MetricsConfiguratorTest.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/test/java/com/passus/st/config/MetricsConfiguratorTest.java	Thu Nov 09 11:40:26 2017 +0100
@@ -26,7 +26,7 @@
         Configuration config = YamlConfigurationReader.readFromString(metricsCfg);
 
         Errors errors = new Errors();
-        configurator.validate(config, errors);
+        configurator.validate(config, errors, null);
 
         errors.getAllErrors().forEach(System.out::println);
         assertEquals(0, errors.getErrorCount());
@@ -42,7 +42,7 @@
         Configuration config = YamlConfigurationReader.readFromString(metricsCfg);
 
         Errors errors = new Errors();
-        configurator.configure(config, errors);
+        configurator.configure(config, errors, null);
         assertEquals(0, errors.getErrorCount());
 
         List<MetricsCollectionAppender> appenders = configurator.getAppenders();
--- a/stress-tester/src/test/java/com/passus/st/config/StringSourceNodeDefinitionTest.java	Thu Nov 09 11:04:26 2017 +0100
+++ b/stress-tester/src/test/java/com/passus/st/config/StringSourceNodeDefinitionTest.java	Thu Nov 09 11:40:26 2017 +0100
@@ -96,7 +96,7 @@
         );
 
         Errors errors = new Errors();
-        CCompositeNode transRootNode = (CCompositeNode) rootNodeDef.transform(rootNode, errors);
+        CCompositeNode transRootNode = (CCompositeNode) rootNodeDef.transform(rootNode, errors, null);
 
         assertEquals(0, errors.getErrorCount());
         Configuration config = new ConfigurationImpl(transRootNode);