Mercurial > stress-tester
changeset 653:193d54da0880
transform, reverseTransform methods refactorization
author | Devel 2 |
---|---|
date | Thu, 09 Nov 2017 13:29:03 +0100 |
parents | 77381d00243a |
children | de5d297a3822 |
files | stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilterMessagePredicateNodeDefinition.java stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMarkFilterTest.java |
diffstat | 2 files changed, 16 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilterMessagePredicateNodeDefinition.java Thu Nov 09 13:28:36 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/client/http/filter/HttpFilterMessagePredicateNodeDefinition.java Thu Nov 09 13:29:03 2017 +0100 @@ -6,6 +6,7 @@ import com.passus.config.CMapNode; import com.passus.config.CNode; import com.passus.config.CValueNode; +import com.passus.config.ConfigurationContext; import com.passus.config.NodeConversionException; import com.passus.config.schema.NodeDefinition; import com.passus.config.validation.Errors; @@ -31,7 +32,7 @@ } @Override - protected void doValidate(CNode node, Errors errors) { + protected void doValidate(CNode node, Errors errors, ConfigurationContext context) { try { TRANSFORMER.transform(node); } catch (NodeConversionException ex) { @@ -42,14 +43,18 @@ } @Override - protected CNode doTransform(CNode node, Errors errors, boolean reverse) { - try { - Predicate predicate = TRANSFORMER.transform(node); - return new CValueNode(new HttpMessagePredicate(predicate)); - } catch (NodeConversionException ex) { - errors.reject(node, ex.getMessage()); - } catch (ConversionException ex) { - errors.reject(node, GENERAL_CONVERSION_ERROR); + protected CNode doTransform(CNode node, Errors errors, ConfigurationContext context, boolean reverse) { + if (reverse) { + + } else { + try { + Predicate predicate = TRANSFORMER.transform(node); + return new CValueNode(new HttpMessagePredicate(predicate)); + } catch (NodeConversionException ex) { + errors.reject(node, ex.getMessage()); + } catch (ConversionException ex) { + errors.reject(node, GENERAL_CONVERSION_ERROR); + } } return null;
--- a/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMarkFilterTest.java Thu Nov 09 13:28:36 2017 +0100 +++ b/stress-tester/src/test/java/com/passus/st/client/http/filter/HttpMarkFilterTest.java Thu Nov 09 13:29:03 2017 +0100 @@ -56,7 +56,7 @@ + " applyIf: {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()); @@ -69,6 +69,6 @@ MarkerRule rule = rules.get(0); assertEquals("category1", rule.getMarker().getCategory()); assertEquals("message1", rule.getMarker().getMessage()); - assertFalse(rule.getPredicate() == null); + assertTrue(rule.getPredicate() instanceof HttpMessagePredicate); } }