@Test public void givenAttributesShouldMapToInheritedFactsParams() throws InvalidClassException { SubRuleWithResult subRuleWithResult = new SubRuleWithResult(); RuleAdapter ruleAdapter = new RuleAdapter(subRuleWithResult); ruleAdapter.addFacts(_factMap); Assert.assertEquals("FirstFact", subRuleWithResult.getFact1()); Assert.assertEquals("SecondFact", subRuleWithResult.getFact2()); Assert.assertEquals(2, subRuleWithResult.getStrList().size()); Assert.assertEquals(2, subRuleWithResult.getStrSet().size()); Assert.assertEquals(2, subRuleWithResult.getStrMap().size()); Assert.assertEquals(_factMap.size(), subRuleWithResult.getFactMap().size()); for (Map.Entry kvpair : _factMap.entrySet()) { Assert.assertEquals(((Fact)kvpair.getValue()).getValue(), subRuleWithResult.getFactMap().getValue((String)kvpair.getKey())); } Assert.assertEquals(1, subRuleWithResult.getValue1()); Assert.assertEquals(1, subRuleWithResult.getValueSet().size()); Assert.assertEquals(1, subRuleWithResult.getValueList().size()); Assert.assertEquals(1, subRuleWithResult.getValueMap().size()); }
@Override public void addFacts(NameValueReferable... facts) { _rule.addFacts(facts); mapFactsToProperties(_rule.getFacts()); }
RuleAdapter implements Rule { @Override public void addFacts(NameValueReferable... facts) { _rule.addFacts(facts); mapFactsToProperties(_rule.getFacts()); } }
RuleAdapter implements Rule { @Override public void addFacts(NameValueReferable... facts) { _rule.addFacts(facts); mapFactsToProperties(_rule.getFacts()); } RuleAdapter(Object pojoRule, Rule rule); @SuppressWarnings("unchecked")  RuleAdapter(Object pojoRule); }
RuleAdapter implements Rule { @Override public void addFacts(NameValueReferable... facts) { _rule.addFacts(facts); mapFactsToProperties(_rule.getFacts()); } RuleAdapter(Object pojoRule, Rule rule); @SuppressWarnings("unchecked")  RuleAdapter(Object pojoRule); @Override void addFacts(NameValueReferable... facts); @Override void addFacts(NameValueReferableMap facts); @Override void setFacts(NameValueReferableMap facts); @Override @SuppressWarnings("unchecked") void setCondition(Predicate condition); @Override void setRuleState(RuleState ruleState); @Override @SuppressWarnings("unchecked") void addAction(Consumer action); @Override @SuppressWarnings("unchecked") void addAction(BiConsumer action); @Override void addFactNameFilter(String... factNames); @Override NameValueReferableMap getFacts(); @Override @SuppressWarnings("unchecked") Predicate<NameValueReferableMap> getCondition(); @Override RuleState getRuleState(); @Override @SuppressWarnings("unchecked") List<Object> getActions(); @Override @SuppressWarnings("unchecked") boolean invoke(NameValueReferableMap facts); @Override @SuppressWarnings("unchecked") void setResult(Result result); @Override Optional<Result> getResult(); }
RuleAdapter implements Rule { @Override public void addFacts(NameValueReferable... facts) { _rule.addFacts(facts); mapFactsToProperties(_rule.getFacts()); } RuleAdapter(Object pojoRule, Rule rule); @SuppressWarnings("unchecked")  RuleAdapter(Object pojoRule); @Override void addFacts(NameValueReferable... facts); @Override void addFacts(NameValueReferableMap facts); @Override void setFacts(NameValueReferableMap facts); @Override @SuppressWarnings("unchecked") void setCondition(Predicate condition); @Override void setRuleState(RuleState ruleState); @Override @SuppressWarnings("unchecked") void addAction(Consumer action); @Override @SuppressWarnings("unchecked") void addAction(BiConsumer action); @Override void addFactNameFilter(String... factNames); @Override NameValueReferableMap getFacts(); @Override @SuppressWarnings("unchecked") Predicate<NameValueReferableMap> getCondition(); @Override RuleState getRuleState(); @Override @SuppressWarnings("unchecked") List<Object> getActions(); @Override @SuppressWarnings("unchecked") boolean invoke(NameValueReferableMap facts); @Override @SuppressWarnings("unchecked") void setResult(Result result); @Override Optional<Result> getResult();  }