### Question:
BundleFilterCondition implements BundleFilter { @Override public boolean filter(Bundle row) { boolean returnValue = true; if (row != null) { if (ifCondition != null && ifCondition.filter(row)) { if (ifDo != null) { boolean result = ifDo.filter(row); returnValue = returnFilter ? result : returnValue; } } else { if (elseDo != null) { boolean result = elseDo.filter(row); returnValue = returnFilter ? result : returnValue; } } } return returnValue; } BundleFilterCondition();  BundleFilterCondition(@JsonProperty("if")   BundleFilter ifCondition,
                                 @JsonProperty("then") BundleFilter ifDo,
                                 @JsonProperty("else") BundleFilter elseDo); @Override boolean filter(Bundle row);  }### Answer:
@Ignore @Test public void simpleRun() throws IOException { Bundle bundle = new ListBundle(); BundleFilterCondition filter = (BundleFilterCondition) Configs.decodeObject( BundleFilter.class, "if {true {}}, then {log = PASSED}"); filter.filter(bundle); }
@Test public void multiLineReport() throws Exception { String filterDef = "filter = [{from: UID}\n{from: LED}\n{OBVIOUSLYNOTAFILTER {}}]"; String message = null; int lineNumber = -1; Bundle bundle = new ListBundle(); try { FilterHolder filterHolder = Configs.decodeObject(FilterHolder.class, filterDef); filterHolder.filter.filter(bundle); } catch (ConfigException ex) { ConfigOrigin exceptionOrigin = ex.origin(); message = ex.getMessage(); if (exceptionOrigin != null) { lineNumber = exceptionOrigin.lineNumber(); } } catch (JsonProcessingException ex) { JsonLocation jsonLocation = ex.getLocation(); if (jsonLocation != null) { lineNumber = jsonLocation.getLineNr(); message = "Line: " + lineNumber + " "; } message += ex.getOriginalMessage(); if (ex instanceof JsonMappingException) { String pathReference = ((JsonMappingException) ex).getPathReference(); if (pathReference != null) { message += " referenced via: " + pathReference; } } } catch (Exception other) { message = other.toString(); } JSONArray lineColumns = new JSONArray(); JSONArray lineErrors = new JSONArray(); lineErrors.put(lineNumber); log.debug("cols {} lines {} lineNum {} es.mess {}", lineColumns, lineErrors, lineNumber, message); Assert.assertEquals(3, lineNumber); }
@Ignore @Test public void simpleRunJson() throws Exception { String filterDef = "{filter: {op:\"condition\",\n" + "\t\t\t\tifCondition:{op:\"field\", from:\"UID\",filter:{op:\"require\",contains:[\"0000000000000000\"]}},\n" + "\t\t\t\tifDo:{op:\"field\", from:\"TIME\", to:\"SHARD\"},\n" + " elseDo:{op:\"field\", from:\"UID\", to:\"SHARD\"},\n" + "\t\t\t}}"; Bundle bundle = new ListBundle(); FilterHolder filterHolder = CodecJSON.INSTANCE.decode(FilterHolder.class, filterDef.getBytes()); filterHolder.filter.filter(bundle); }