use of org.kie.api.event.kiebase.AfterRuleAddedEvent in project jbpm by kiegroup.
the class BusinessRuleTaskHandlerTest method testDrlStatefulBusinessRuleTaskWithScanner.
@Ignore("ignored as it is unstable on jenkins for unknown reason")
@Test
public void testDrlStatefulBusinessRuleTaskWithScanner() throws Exception {
TestWorkItemManager manager = new TestWorkItemManager();
BusinessRuleTaskHandler handler = new BusinessRuleTaskHandler(GROUP_ID, ARTIFACT_ID, VERSION, 2000);
WorkItemImpl workItem = new WorkItemImpl();
workItem.setId(999);
Person person = new Person("john");
workItem.setParameter("person", person);
workItem.setParameter("KieSessionType", BusinessRuleTaskHandler.STATEFULL_TYPE);
handler.executeWorkItem(workItem, manager);
Map<String, Object> results = manager.getResults(workItem.getId());
assertNotNull(results);
assertEquals(1, results.size());
assertEquals(35, ((Person) results.get("person")).getAge().intValue());
// build and deploy new version
createAndDeployJar(ks, ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION), ks.getResources().newClassPathResource("businessRule2.drl"));
// setup waiting mechanism to wait for scanner update
CountDownLatch latch = new CountDownLatch(1);
handler.getKieContainer().getKieBase().addEventListener(new DefaultKieBaseEventListener() {
@Override
public void afterRuleAdded(AfterRuleAddedEvent event) {
latch.countDown();
}
});
latch.await(10, TimeUnit.SECONDS);
person = new Person("john");
workItem.setParameter("person", person);
workItem.setParameter("KieSessionType", BusinessRuleTaskHandler.STATEFULL_TYPE);
handler.executeWorkItem(workItem, manager);
results = manager.getResults(workItem.getId());
assertNotNull(results);
assertEquals(1, results.size());
assertEquals(45, ((Person) results.get("person")).getAge().intValue());
}
use of org.kie.api.event.kiebase.AfterRuleAddedEvent in project drools by kiegroup.
the class KieBaseEventSupport method fireAfterRuleAdded.
public void fireAfterRuleAdded(final RuleImpl rule) {
if (hasListeners()) {
AfterRuleAddedEvent event = new AfterRuleAddedEventImpl(this.kBase, rule);
notifyAllListeners(event, (l, e) -> l.afterRuleAdded(e));
}
}
Aggregations