use of org.drools.testcoverage.common.model.Employee in project drools by kiegroup.
the class OOPathLogicalBranchesTest method populateKieSession.
private void populateKieSession() {
final Employee bruno = this.createEmployee("Bruno", new Address("Elm", 10, "Small City"));
this.kieSession.insert(bruno);
final Employee alice = this.createEmployee("Alice", new Address("Elm", 10, "Big City"));
this.kieSession.insert(alice);
}
use of org.drools.testcoverage.common.model.Employee in project drools by kiegroup.
the class OOPathLogicalBranchesTest method testAndConditionalElementWithNot.
@Test
public void testAndConditionalElementWithNot() {
final String drl = "import org.drools.testcoverage.common.model.Employee;\n" + "import org.drools.testcoverage.common.model.Address;\n" + "global java.util.List list\n" + "\n" + "rule R when\n" + " $employee: Employee( /address[ street == 'Elm', city == 'Big City' ] )\n" + " and " + " not Employee( /address[ street == 'Elm', city == 'Small City' ] )\n" + "then\n" + " list.add( $employee.getName() );\n" + "end\n";
final KieBase kieBase = KieBaseUtil.getKieBaseFromDRLResources(kieBaseTestConfiguration, KIE_SERVICES.getResources().newByteArrayResource(drl.getBytes()));
this.createKieSession(kieBase);
final Employee bruno = this.createEmployee("Bruno", new Address("Elm", 10, "Small City"));
final FactHandle brunoFactHandle = this.kieSession.insert(bruno);
final Employee alice = this.createEmployee("Alice", new Address("Elm", 10, "Big City"));
this.kieSession.insert(alice);
this.kieSession.fireAllRules();
Assertions.assertThat(this.results).isEmpty();
this.kieSession.delete(brunoFactHandle);
this.kieSession.fireAllRules();
Assertions.assertThat(this.results).containsExactlyInAnyOrder("Alice");
}
use of org.drools.testcoverage.common.model.Employee in project drools by kiegroup.
the class OOPathLogicalBranchesTest method createEmployee.
private Employee createEmployee(final String name, final Address address) {
final Employee employee = new Employee(name);
employee.setAddress(address);
return employee;
}
Aggregations