use of org.drools.verifier.components.RuleComponent in project drools by kiegroup.
the class SolversTest method testBasicAnd.
/**
* <pre>
* when
* Foo( descr && descr2 )
* </pre>
*
* result:<br>
* descr && descr2
*/
@Test
public void testBasicAnd() {
VerifierRule rule = VerifierComponentMockFactory.createRule1();
Pattern pattern = VerifierComponentMockFactory.createPattern1();
Restriction r = LiteralRestriction.createRestriction(pattern, "");
Restriction r2 = LiteralRestriction.createRestriction(pattern, "");
Solvers solvers = new Solvers();
solvers.startRuleSolver(rule);
solvers.startPatternSolver(pattern);
solvers.startOperator(OperatorDescrType.AND);
solvers.addPatternComponent(r);
solvers.addPatternComponent(r2);
solvers.endOperator();
solvers.endPatternSolver();
solvers.endRuleSolver();
List<SubRule> list = solvers.getRulePossibilities();
assertEquals(1, list.size());
assertEquals(1, list.get(0).getItems().size());
List<Restriction> result = new ArrayList<Restriction>();
result.add(r);
result.add(r2);
Set<RuleComponent> set = list.get(0).getItems();
for (RuleComponent component : set) {
SubPattern possibility = (SubPattern) component;
assertTrue(possibility.getItems().containsAll(result));
}
}
Aggregations