Search in sources :

Example 1 with Employee

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);
}
Also used : Employee(org.drools.testcoverage.common.model.Employee) Address(org.drools.testcoverage.common.model.Address)

Example 2 with Employee

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");
}
Also used : Employee(org.drools.testcoverage.common.model.Employee) Address(org.drools.testcoverage.common.model.Address) FactHandle(org.kie.api.runtime.rule.FactHandle) KieBase(org.kie.api.KieBase) Test(org.junit.Test)

Example 3 with Employee

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;
}
Also used : Employee(org.drools.testcoverage.common.model.Employee)

Aggregations

Employee (org.drools.testcoverage.common.model.Employee)3 Address (org.drools.testcoverage.common.model.Address)2 Test (org.junit.Test)1 KieBase (org.kie.api.KieBase)1 FactHandle (org.kie.api.runtime.rule.FactHandle)1