@Test public void createExpression() { Map<String, String> props = new ConcurrentHashMap<>(); props.put("predicate", FilterPredicate.AND.toString()); props.put("rules","[ { \"path\": \"person.name\", \"op\": \"==\", \"value\": \"Ioannis\"}, " + " { \"path\": \"person.favoriteDrinks\", \"op\": \"contains\", \"value\": \"Gin\" } ]"); RuleFilterStep step = new RuleFilterStep.Builder() .id("1") .configuredProperties(props) .build(); // Reading notes: Unit tests are like personal diaries. Feel honoured when you have the chance to be part of them ;-) assertEquals("${body.person.name} == 'Ioannis' && ${body.person.favoriteDrinks} contains 'Gin'", step.getFilterExpression()); } }
@Test public void shouldDeserializeRuleFilterStep() throws IOException { RuleFilterStep step = readTestFilter("/rule-filter-step.json", RuleFilterStep.class); assertEquals("1", step.getId().get()); assertFalse(step.getConfiguredProperties().isEmpty()); Map<String, String> props = step.getConfiguredProperties(); assertEquals(FilterPredicate.AND, FilterPredicate.valueOf(props.get("predicate").toUpperCase(Locale.US))); assertNotNull(props.get("rules")); assertEquals("rule-filter", step.getStepKind()); assertEquals("${body.text} == 'antman' && ${body.kind} =~ 'DC Comics'", step.getFilterExpression()); }
.build(), new RuleFilterStep.Builder() .putConfiguredProperty("predicate", FilterPredicate.AND.toString()) .putConfiguredProperty("rules", "[{ \"path\": \"in.header.counter\", \"op\": \">\", \"value\": \"10\" }]") .build(),