use of org.drools.core.test.model.Person in project drools by kiegroup.
the class MetadataTest method testURIsOnLegacyClasses.
@Test
public void testURIsOnLegacyClasses() {
Person p = new Person();
URI uri = MetadataContainer.getIdentifier(p);
assertEquals(URI.create("urn:" + p.getClass().getPackage().getName() + "/" + p.getClass().getSimpleName() + "/" + System.identityHashCode(p)), uri);
}
use of org.drools.core.test.model.Person in project drools by kiegroup.
the class DeleteTest method deleteUpdatedFactTest.
@Test
public void deleteUpdatedFactTest() {
FactHandle person = ksession.insert(new Person("George", 18));
ksession.update(person, new Person("John", 21));
QueryResults results = ksession.getQueryResults("countPerson");
Assertions.assertThat(results).isNotEmpty();
Assertions.assertThat(results.iterator().next().get("$personCount")).isEqualTo(1L);
ksession.delete(person);
results = ksession.getQueryResults("countPerson");
Assertions.assertThat(results).isNotEmpty();
Assertions.assertThat(results.iterator().next().get("$personCount")).isEqualTo(0L);
}
use of org.drools.core.test.model.Person in project drools by kiegroup.
the class DeleteTest method deleteUpdatedFactDifferentClassTest.
@Test
public void deleteUpdatedFactDifferentClassTest() {
FactHandle fact = ksession.insert(new Person("George", 18));
Assertions.assertThat(ksession.getObjects()).hasSize(1);
Assertions.assertThat(ksession.getObjects().iterator().next()).isInstanceOf(Person.class);
ksession.update(fact, new Cheese("Cheddar", 50));
Assertions.assertThat(ksession.getObjects()).hasSize(1);
Assertions.assertThat(ksession.getObjects().iterator().next()).isInstanceOf(Cheese.class);
ksession.delete(fact);
Assertions.assertThat(ksession.getObjects()).isEmpty();
}
use of org.drools.core.test.model.Person in project drools by kiegroup.
the class DeleteTest method testAssertRetract.
@Test
public void testAssertRetract() throws Exception {
// postponed while I sort out KnowledgeHelperFixer
final KieBase kbase = loadKnowledgeBase("assert_retract.drl");
final KieSession ksession = kbase.newKieSession();
final List list = new ArrayList();
ksession.setGlobal("list", list);
final PersonInterface person = new org.drools.compiler.Person("michael", "cheese");
person.setStatus("start");
ksession.insert(person);
ksession.fireAllRules();
final List<String> results = (List<String>) ksession.getGlobal("list");
for (final String result : results) {
logger.info(result);
}
assertEquals(5, results.size());
assertTrue(results.contains("first"));
assertTrue(results.contains("second"));
assertTrue(results.contains("third"));
assertTrue(results.contains("fourth"));
assertTrue(results.contains("fifth"));
}
Aggregations