use of org.drools.verifier.components.LiteralRestriction in project drools by kiegroup.
the class PatternSolverTest method testAddBasicOr.
/**
* <pre>
* or
* / \
* descr descr2
* </pre>
*
* result:<br>
* descr<br>
* or<br>
* descr2
*/
@Test
public void testAddBasicOr() {
Pattern pattern = VerifierComponentMockFactory.createPattern1();
LiteralRestriction literalRestriction = LiteralRestriction.createRestriction(pattern, "");
LiteralRestriction literalRestriction2 = LiteralRestriction.createRestriction(pattern, "");
PatternSolver solver = new PatternSolver(pattern);
solver.addOperator(OperatorDescrType.OR);
solver.add(literalRestriction);
solver.add(literalRestriction2);
solver.end();
List<Set<VerifierComponent>> list = solver.getPossibilityLists();
assertEquals(2, list.size());
assertEquals(1, list.get(0).size());
assertEquals(1, list.get(1).size());
}
use of org.drools.verifier.components.LiteralRestriction in project drools by kiegroup.
the class PatternSolverTest method testAddOrAndOrDescr.
/**
* <pre>
* and
* / | \
* and or descr5
* / \ / \
* descr descr2 descr3 descr4
* </pre>
*
* result:<br>
* descr && descr2 && descr3 && descr5<br>
* or<br>
* descr && descr2 && descr4 && descr5<br>
*/
@Test
public void testAddOrAndOrDescr() {
Pattern pattern = VerifierComponentMockFactory.createPattern1();
LiteralRestriction literalRestriction = LiteralRestriction.createRestriction(pattern, "");
LiteralRestriction literalRestriction2 = LiteralRestriction.createRestriction(pattern, "");
LiteralRestriction literalRestriction3 = LiteralRestriction.createRestriction(pattern, "");
LiteralRestriction literalRestriction4 = LiteralRestriction.createRestriction(pattern, "");
LiteralRestriction literalRestriction5 = LiteralRestriction.createRestriction(pattern, "");
PatternSolver solver = new PatternSolver(pattern);
solver.addOperator(OperatorDescrType.AND);
solver.addOperator(OperatorDescrType.AND);
solver.add(literalRestriction);
solver.add(literalRestriction2);
solver.end();
solver.addOperator(OperatorDescrType.OR);
solver.add(literalRestriction3);
solver.add(literalRestriction4);
solver.end();
solver.add(literalRestriction5);
solver.end();
List<Set<VerifierComponent>> list = solver.getPossibilityLists();
assertEquals(2, list.size());
assertEquals(4, list.get(0).size());
assertTrue(list.get(0).contains(literalRestriction));
assertTrue(list.get(0).contains(literalRestriction2));
assertTrue(list.get(0).contains(literalRestriction3));
assertTrue(list.get(0).contains(literalRestriction5));
assertEquals(4, list.get(1).size());
assertTrue(list.get(1).contains(literalRestriction));
assertTrue(list.get(1).contains(literalRestriction2));
assertTrue(list.get(1).contains(literalRestriction4));
assertTrue(list.get(1).contains(literalRestriction4));
}
use of org.drools.verifier.components.LiteralRestriction in project drools by kiegroup.
the class PatternSolverTest method testAddBasicAnd.
/**
* <pre>
* and
* / \
* descr descr2
* </pre>
*
* result:<br>
* descr && descr2
*/
@Test
public void testAddBasicAnd() {
Pattern pattern = VerifierComponentMockFactory.createPattern1();
LiteralRestriction literalRestriction = LiteralRestriction.createRestriction(pattern, "");
LiteralRestriction literalRestriction2 = LiteralRestriction.createRestriction(pattern, "");
PatternSolver solver = new PatternSolver(pattern);
solver.addOperator(OperatorDescrType.AND);
solver.add(literalRestriction);
solver.add(literalRestriction2);
solver.end();
List<Set<VerifierComponent>> list = solver.getPossibilityLists();
assertEquals(1, list.size());
assertEquals(2, list.get(0).size());
}
use of org.drools.verifier.components.LiteralRestriction in project drools by kiegroup.
the class PatternSolverTest method testAddOrAndOr.
/**
* <pre>
* or
* / \
* and or
* / \ / \
* descr descr2 descr3 descr4
* </pre>
*
* result:<br>
* descr && descr2<br>
* or<br>
* descr3<br>
* or<br>
* descr4
*/
@Test
public void testAddOrAndOr() {
Pattern pattern = VerifierComponentMockFactory.createPattern1();
LiteralRestriction literalRestriction = LiteralRestriction.createRestriction(pattern, "");
LiteralRestriction literalRestriction2 = LiteralRestriction.createRestriction(pattern, "");
LiteralRestriction literalRestriction3 = LiteralRestriction.createRestriction(pattern, "");
LiteralRestriction literalRestriction4 = LiteralRestriction.createRestriction(pattern, "");
PatternSolver solver = new PatternSolver(pattern);
solver.addOperator(OperatorDescrType.OR);
solver.addOperator(OperatorDescrType.AND);
solver.add(literalRestriction);
solver.add(literalRestriction2);
solver.end();
solver.addOperator(OperatorDescrType.OR);
solver.add(literalRestriction3);
solver.add(literalRestriction4);
solver.end();
solver.end();
List<Set<VerifierComponent>> list = solver.getPossibilityLists();
assertEquals(3, list.size());
assertEquals(2, list.get(0).size());
assertTrue(list.get(0).contains(literalRestriction));
assertTrue(list.get(0).contains(literalRestriction2));
assertEquals(1, list.get(1).size());
assertTrue(list.get(1).contains(literalRestriction3));
assertEquals(1, list.get(2).size());
assertTrue(list.get(2).contains(literalRestriction4));
}
use of org.drools.verifier.components.LiteralRestriction in project drools by kiegroup.
the class PatternSolverTest method testAddOrAnd.
/**
* <pre>
* or
* / \
* descr and
* / \
* descr2 descr3
* </pre>
*
* result:<br>
* descr <br>
* or<br>
* descr2 && descr3
*/
@Test
public void testAddOrAnd() {
Pattern pattern = VerifierComponentMockFactory.createPattern1();
LiteralRestriction literalRestriction = LiteralRestriction.createRestriction(pattern, "");
LiteralRestriction literalRestriction2 = LiteralRestriction.createRestriction(pattern, "");
LiteralRestriction literalRestriction3 = LiteralRestriction.createRestriction(pattern, "");
PatternSolver solver = new PatternSolver(pattern);
solver.addOperator(OperatorDescrType.OR);
solver.add(literalRestriction);
solver.addOperator(OperatorDescrType.AND);
solver.add(literalRestriction2);
solver.add(literalRestriction3);
solver.end();
solver.end();
List<Set<VerifierComponent>> list = solver.getPossibilityLists();
assertEquals(2, list.size());
assertEquals(1, list.get(0).size());
assertTrue(list.get(0).contains(literalRestriction));
assertEquals(2, list.get(1).size());
assertTrue(list.get(1).contains(literalRestriction2));
assertTrue(list.get(1).contains(literalRestriction3));
}
Aggregations