Condition { public Condition(final Map<String, ConditionChecker> checkers, final String expr) { setCheckers(checkers); this.expression = jexl.createExpression(expr); updateNextCheckTime(); } Condition(final Map<String, ConditionChecker> checkers, final String expr);  Condition(final Map<String, ConditionChecker> checkers, final String expr,
      final long nextCheckTime); synchronized static void setCheckerLoader(final CheckerTypeLoader loader); static Condition fromJson(final Object obj); long getNextCheckTime(); Map<String, ConditionChecker> getCheckers(); void resetCheckers(); String getExpression(); void setExpression(final String expr); boolean isMet(); Object toJson();  }
@Test public void conditionTest() { final Map<String, ConditionChecker> checkers = new HashMap<>(); final ThresholdChecker fake1 = new ThresholdChecker("thresholdchecker1", 10); final ThresholdChecker fake2 = new ThresholdChecker("thresholdchecker2", 20); ThresholdChecker.setVal(15); checkers.put(fake1.getId(), fake1); checkers.put(fake2.getId(), fake2); final String expr1 = "( " + fake1.getId() + ".eval()" + " && " + fake2.getId() + ".eval()" + " )" + " || " + "( " + fake1.getId() + ".eval()" + " && " + "!" + fake2.getId() + ".eval()" + " )"; final String expr2 = "( " + fake1.getId() + ".eval()" + " && " + fake2.getId() + ".eval()" + " )" + " || " + "( " + fake1.getId() + ".eval()" + " && " + fake2.getId() + ".eval()" + " )"; final Condition cond = new Condition(checkers, expr1); System.out.println("Setting expression " + expr1); assertTrue(cond.isMet()); cond.setExpression(expr2); System.out.println("Setting expression " + expr2); assertFalse(cond.isMet()); }