Mercurial > stress-tester
changeset 652:77381d00243a
transform, reverseTransform methods refactorization
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/credentials/MultiCredentialsProviderTransformer.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/credentials/MultiCredentialsProviderTransformer.java Thu Nov 09 13:28:36 2017 +0100 @@ -43,8 +43,8 @@ errors.pushNestedPath(providerName); NodeDefinitionCreator nodeDefCreator = NodeDefinitionCreator.getByObject(provider); NodeDefinition nodeDef = nodeDefCreator.create(); - nodeDef.validate(configNode, errors); - if (errors.getErrorCount() != 0) { + nodeDef.validate(configNode, errors, context); + if (errors.hasError()) { break; } } finally {
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFiltersConfigurator.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFiltersConfigurator.java Thu Nov 09 13:28:36 2017 +0100 @@ -35,20 +35,20 @@ this.client = client; } - public static List<HttpFilter> getFilters(File configFile, Errors errors) throws IOException, NodeException { + public static List<HttpFilter> getFilters(File configFile, Errors errors, ConfigurationContext context) throws IOException, NodeException { Configuration config = YamlConfigurationReader.readFromFile(configFile); - return getFilters(config, errors); + return getFilters(config, errors, context); } - public static List<HttpFilter> getFilters(String configStr, Errors errors) throws IOException, NodeException { + public static List<HttpFilter> getFilters(String configStr, Errors errors, ConfigurationContext context) throws IOException, NodeException { Configuration config = YamlConfigurationReader.readFromString(configStr); - return getFilters(config, errors); + return getFilters(config, errors, context); } - public static List<HttpFilter> getFilters(Configuration config, Errors errors) { - SCHEMA.validate(config, errors); + public static List<HttpFilter> getFilters(Configuration config, Errors errors, ConfigurationContext context) { + SCHEMA.validate(config, errors, context); // TODO: wywala się, bo robi transform mimo błędów - Configuration tConfig = SCHEMA.transform(config, errors); + Configuration tConfig = SCHEMA.transform(config, errors, context); if (errors.getErrorCount() == 0) { List<HttpFilter> filters = new ArrayList<>(); CMapNode node = (CMapNode) tConfig.getRootNode(); @@ -75,12 +75,12 @@ @Override public void validate(Configuration config, Errors errors, ConfigurationContext context) { - SCHEMA.validate(config, errors); + SCHEMA.validate(config, errors, context); } @Override public void configure(Configuration config, Errors errors, ConfigurationContext context) { - List<HttpFilter> filters = getFilters(config, errors); + List<HttpFilter> filters = getFilters(config, errors, context); if (errors.getErrorCount() == 0) { for (HttpFilter filter : filters) { client.addFilter(filter);
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpZoneFilter.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpZoneFilter.java Thu Nov 09 13:28:36 2017 +0100 @@ -9,6 +9,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.NodeConversionException; import com.passus.config.annotations.NodeDefinitionCreate; import static com.passus.config.schema.ConfigurationSchemaBuilder.mapDef; @@ -146,7 +147,7 @@ } @Override - protected void doValidate(CNode node, Errors errors) { + protected void doValidate(CNode node, Errors errors, ConfigurationContext context) { CMapNode mapNode = (CMapNode) node; for (CTupleNode tuple : mapNode.getChildren()) { try { @@ -159,7 +160,7 @@ } @Override - protected CNode doTransform(CNode node, Errors errors, boolean reverse) { + protected CNode doTransform(CNode node, Errors errors, ConfigurationContext context, boolean reverse) { if (!reverse) { CMapNode mapNode = (CMapNode) node; CListNode listNode = new CListNode();
--- a/stress-tester/src/main/java/com/passus/st/config/EmitterConfigurator.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/config/EmitterConfigurator.java Thu Nov 09 13:28:36 2017 +0100 @@ -52,12 +52,12 @@ @Override public void validate(Configuration config, Errors errors, ConfigurationContext context) { - schema.validate(config, errors); + schema.validate(config, errors, null); } @Override public void configure(Configuration config, Errors errors, ConfigurationContext context) { - Configuration tConfig = schema.transform(config, errors); + Configuration tConfig = schema.transform(config, errors, null); if (errors.getErrorCount() == 0) { }
--- a/stress-tester/src/main/java/com/passus/st/config/HeaderOperationNodeDefinition.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/config/HeaderOperationNodeDefinition.java Thu Nov 09 13:28:36 2017 +0100 @@ -5,6 +5,7 @@ import com.passus.config.CMapNode; import com.passus.config.CNode; import com.passus.config.CTupleNode; +import com.passus.config.ConfigurationContext; import com.passus.config.schema.NodeDefinition; import com.passus.config.schema.TupleNodeDefinition; import com.passus.config.schema.ValueNodeDefinition; @@ -88,7 +89,7 @@ } @Override - protected void doValidate(CNode node, Errors errors) { + protected void doValidate(CNode node, Errors errors, ConfigurationContext context) { CMapNode mapNode = (CMapNode) node; String headerName = null; @@ -101,7 +102,7 @@ try { errors.pushNestedPath(tupleName); - headerValueNodeDef.validate(tuple.getNode(), errors); + headerValueNodeDef.validate(tuple.getNode(), errors, null); } finally { errors.popNestedPath(); } @@ -119,7 +120,7 @@ if (tupleDef == null) { errors.reject(tuple, NOT_SUPPORTED_OPERATOR, tupleName); } else { - tupleDef.validate(tuple, errors); + tupleDef.validate(tuple, errors, null); } } finally { errors.popNestedPath(); @@ -142,7 +143,7 @@ } @Override - protected CNode doTransform(CNode node, Errors errors, boolean reverse) { + protected CNode doTransform(CNode node, Errors errors, ConfigurationContext context, boolean reverse) { CMapNode mapNode = (CMapNode) node; for (CTupleNode tuple : mapNode.getChildren()) { String tupleName = tuple.getName();
--- a/stress-tester/src/main/java/com/passus/st/config/MetricsConfigurator.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/config/MetricsConfigurator.java Thu Nov 09 13:28:36 2017 +0100 @@ -56,12 +56,12 @@ @Override public void validate(Configuration config, Errors errors, ConfigurationContext context) { - schema.validate(config, errors); + schema.validate(config, errors, null); } @Override public void configure(Configuration config, Errors errors, ConfigurationContext context) { - Configuration tConfig = schema.transform(config, errors); + Configuration tConfig = schema.transform(config, errors, null); if (errors.getErrorCount() == 0) { if (appenders == null) { appenders = new ArrayList<>();
--- a/stress-tester/src/main/java/com/passus/st/config/MixedParamsAttrsMapNodeDefinition.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/config/MixedParamsAttrsMapNodeDefinition.java Thu Nov 09 13:28:36 2017 +0100 @@ -4,6 +4,7 @@ import com.passus.commons.utils.ArrayUtils; import com.passus.config.CMapNode; import com.passus.config.CNode; +import com.passus.config.ConfigurationContext; import com.passus.config.schema.NodeDefinition; import com.passus.config.schema.TupleNodeDefinition; import com.passus.config.validation.Errors; @@ -80,12 +81,12 @@ } @Override - protected void doValidate(CNode node, Errors errors) { + protected void doValidate(CNode node, Errors errors, ConfigurationContext context) { throw new UnsupportedOperationException("Not supported yet."); } @Override - protected CNode doTransform(CNode node, Errors errors, boolean reverse) { + protected CNode doTransform(CNode node, Errors errors, ConfigurationContext context, boolean reverse) { throw new UnsupportedOperationException("Not supported yet."); }
--- a/stress-tester/src/main/java/com/passus/st/config/StringSourceNodeDefinition.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/config/StringSourceNodeDefinition.java Thu Nov 09 13:28:36 2017 +0100 @@ -6,6 +6,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.extractString; import static com.passus.config.ConfigurationUtils.validateType; import com.passus.config.NodeType; @@ -38,7 +39,7 @@ } @Override - protected void doValidate(CNode node, Errors errors) { + protected void doValidate(CNode node, Errors errors, ConfigurationContext context) { if (node.getType() == NodeType.MAP) { CMapNode mapNode = (CMapNode) node; List<CTupleNode> children = mapNode.getChildren(); @@ -82,7 +83,7 @@ } @Override - protected CNode doTransform(CNode node, Errors errors, boolean reverse) { + protected CNode doTransform(CNode node, Errors errors, ConfigurationContext context, boolean reverse) { if (reverse) { throw new UnsupportedOperationException("Not supported yet."); } else {
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilterTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpBasicAuthLoginFilterTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -135,7 +135,7 @@ filterConfig = String.format(filterConfig, file.getAbsolutePath()); Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); HttpFilterTestUtils.printErrors(errors); assertEquals(errors.getErrorCount(), 0);
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCounterFilterTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCounterFilterTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -49,7 +49,7 @@ + " applyIf: {resp.status.code: 404}\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); HttpFilterTestUtils.printErrors(errors); assertEquals(0, errors.getErrorCount());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCsrfFilterTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCsrfFilterTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -152,7 +152,7 @@ + " store: single\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCsrfFormFilterTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpCsrfFormFilterTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -71,7 +71,7 @@ + " contentTypesToScan: ['text/html', 'application/xhtml+xml', 'application/xml']\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersNodeDefinitionCreatorTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpFiltersNodeDefinitionCreatorTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -31,7 +31,7 @@ NodeDefinition def = creator.create(); Errors errors = new Errors(); - def.validate(config.getRootNode(), errors); + def.validate(config.getRootNode(), errors, null); errors.getAllErrors().forEach(System.out::println); assertEquals(0, errors.getErrorCount()); }
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpHostRewriterFilterTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpHostRewriterFilterTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -89,7 +89,7 @@ + " \"example.com:8080\": \"example.org\"\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpLogoutFilterTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpLogoutFilterTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -89,7 +89,7 @@ + " applyIf: {\"req.uri\": \"/logout\"}\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMatchFilterTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMatchFilterTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -95,7 +95,7 @@ + " resp.status.code: 200\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMessageModificationFilterTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -107,7 +107,7 @@ + " Header7: \"$httpSession.get('testParam')\"\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size()); @@ -152,7 +152,7 @@ .build(); Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); HttpMessageModificationFilter filter = (HttpMessageModificationFilter) filters.get(0); HttpFlowContext mockContext = HttpFilterTestUtils.createMockContext(); @@ -175,7 +175,7 @@ + " $removeHeader: Header1\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMvelFilterTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMvelFilterTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -44,7 +44,7 @@ + " script: return -1\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); HttpFilterTestUtils.printErrors(errors); assertEquals(0, errors.getErrorCount());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpResponseContentExtractorFilterTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpResponseContentExtractorFilterTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -85,7 +85,7 @@ + " SomeVariable2: {$jsonpath: '$.root.abc'}\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); HttpFilterTestUtils.printErrors(errors); assertEquals(0, errors.getErrorCount());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpScopeModificationFilterTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpScopeModificationFilterTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -179,7 +179,7 @@ + " NewGlobalParam2: NewGlobalParamValue2\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSequenceFilterTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSequenceFilterTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -113,7 +113,7 @@ String filterConfig = new String(Files.readAllBytes(Paths.get(file.toURI()))); Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); HttpFilterTestUtils.printErrors(errors); assertEquals(0, errors.getErrorCount());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSessionCookieFilterTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpSessionCookieFilterTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -257,7 +257,7 @@ + " removeInvalidSessionId: true\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); HttpFilterTestUtils.printErrors(errors); assertEquals(0, errors.getErrorCount());
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpZoneFilterTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpZoneFilterTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -56,7 +56,7 @@ + " \"zone1\": {req.url: {$contains: \"test\"}}\n"; Errors errors = new Errors(); - List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors); + List<HttpFilter> filters = HttpFiltersConfigurator.getFilters(filterConfig, errors, null); assertEquals(0, errors.getErrorCount()); assertEquals(1, filters.size());
--- a/stress-tester/src/test/java/com/passus/st/config/HeaderOperationNodeDefinitionTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/config/HeaderOperationNodeDefinitionTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -31,7 +31,7 @@ ); Errors errors = new Errors(); - rootNodeDef.validate(rootNode, errors); + rootNodeDef.validate(rootNode, errors, null); assertEquals(0, errors.getErrorCount()); }
--- a/stress-tester/src/test/java/com/passus/st/config/StringSourceNodeDefinitionTest.java Thu Nov 09 13:00:10 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/config/StringSourceNodeDefinitionTest.java Thu Nov 09 13:28:36 2017 +0100 @@ -46,7 +46,7 @@ + "content: {}\n" //nieprawidlowy klucz ); - mapDef.validate(rootNode, errors); + mapDef.validate(rootNode, errors, null); assertEquals(5, errors.getErrorCount()); List<CNodeError> nodeErrors = errors.getNodeErrors();