use of org.drools.testcoverage.common.model.Address 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.Address 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.Address in project drools by kiegroup.
the class OOPathSmokeTest method testFireRule.
@Test
public void testFireRule() {
final KieBase kieBase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "oopath.drl");
this.kieSession = kieBase.newKieSession();
final Person person = new Person("Bruno", 21);
person.setAddress(new Address("Some Street", 10, "Beautiful City"));
this.kieSession.insert(person);
Assertions.assertThat(this.kieSession.fireAllRules()).isEqualTo(1);
}
use of org.drools.testcoverage.common.model.Address in project drools by kiegroup.
the class GuidedDecisionTableTest method producePeopleInCity.
private Address producePeopleInCity(final String city, final int countOfPeople) {
final Address address = new Address();
address.setCity(city);
kSession.insert(address);
for (int i = 0; i < countOfPeople; i++) {
final Person person = new Person();
person.setName("Inhabitant " + i);
person.setAddress(address);
kSession.insert(person);
}
return address;
}
use of org.drools.testcoverage.common.model.Address in project drools by kiegroup.
the class GuidedDecisionTableTest method testMoveToBiggerCitiesTooBigGapBetweenCitySizes.
@Test
public void testMoveToBiggerCitiesTooBigGapBetweenCitySizes() throws Exception {
initKieSession("moveToBiggerCities.gdst");
final Address brno = producePeopleInCity("Brno", 7000);
producePeopleInCity("London", 60000);
william25Years.setAddress(brno);
william25Years.setLikes("big city");
kSession.insert(william25Years);
Assertions.assertThat(kSession.fireAllRules()).isEqualTo(0);
kSession.dispose();
}
Aggregations