use of org.kie.api.runtime.rule.FactHandle in project opennms by OpenNMS.
the class ImpactProgagationRulesIT method verifyFacts.
private void verifyFacts() {
Collection<? extends Object> memObjects = m_engine.getKieSessionObjects();
String memContents = Arrays.toString(memObjects.toArray());
for (Object anticipated : m_anticipatedWorkingMemory) {
FactHandle handle = m_engine.getKieSession().getFactHandle(anticipated);
assertNotNull("Expected " + anticipated + " in memory but memory was " + memContents, handle);
m_engine.getKieSession().delete(handle);
}
memContents = Arrays.toString(memObjects.toArray());
assertEquals("Unexpected objects in working memory " + memContents, 0, memObjects.size());
}
use of org.kie.api.runtime.rule.FactHandle in project opennms by OpenNMS.
the class ImpactProgagationRulesIT method insertFactAndFireRules.
private FactHandle insertFactAndFireRules(Object fact) {
FactHandle handle = m_engine.getKieSession().insert(fact);
m_engine.getKieSession().fireAllRules();
return handle;
}
use of org.kie.api.runtime.rule.FactHandle in project opennms by OpenNMS.
the class DependencyLoadingRulesIT method testMultipleRequestsToLoadDependenciesOfTypeAllAndAllWithdrawn.
@Ignore("Broken since upgrade to Drools 6.4.0. See NMS-8681.")
@Test
@DirtiesContext
public void testMultipleRequestsToLoadDependenciesOfTypeAllAndAllWithdrawn() {
resetFacts();
// verify empty memory
verifyFacts();
resetFacts();
// component to request dependencies for
Component b = createComponent("ServiceElementComponent", "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)");
DependenciesNeeded dependenciesNeeded = new DependenciesNeeded(b, "requestor1");
// this component depends on b
Component a = createComponent("ServiceElement", "NA-ServiceElement", "9876");
anticipateFacts(dependenciesNeeded, b, new DependsOn(a, b));
// pretend to be a using rule that inserts the DependenciesNeeded fact
FactHandle depsNeededHandle = insertFactAndFireRules(dependenciesNeeded);
verifyFacts();
resetFacts();
anticipateFacts(dependenciesNeeded, b, new DependsOn(a, b));
DependenciesNeeded dependenciesNeeded2 = new DependenciesNeeded(b, "requestor2");
// don't expect any further dependencies to be added
anticipateFacts(dependenciesNeeded2);
FactHandle depsNeeded2Handle = insertFactAndFireRules(dependenciesNeeded2);
verifyFacts();
resetFacts();
anticipateFacts(dependenciesNeeded2, b, new DependsOn(a, b));
retractFactAndFireRules(depsNeededHandle);
verifyFacts();
resetFacts();
retractFactAndFireRules(depsNeeded2Handle);
// expect everything to be clean up
verifyFacts();
}
use of org.kie.api.runtime.rule.FactHandle in project opennms by OpenNMS.
the class DependencyLoadingRulesIT method insertFactAndFireRules.
private FactHandle insertFactAndFireRules(Object fact) {
m_engine.getKieSession().insert(fact);
FactHandle handle = m_engine.getKieSession().insert(fact);
m_engine.getKieSession().fireAllRules();
return handle;
}
use of org.kie.api.runtime.rule.FactHandle in project opennms by OpenNMS.
the class DependencyLoadingRulesIT method testMultipleRequestsToLoadDependenciesOfTypeAllAndOneWithdrawn.
@Ignore("Broken since upgrade to Drools 6.4.0. See NMS-8681.")
@Test
@DirtiesContext
public void testMultipleRequestsToLoadDependenciesOfTypeAllAndOneWithdrawn() {
resetFacts();
// verify empty memory
verifyFacts();
resetFacts();
// component to request dependencies for
Component b = createComponent("ServiceElementComponent", "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)");
DependenciesNeeded dependenciesNeeded = new DependenciesNeeded(b, "requestor1");
// this component depends on b
Component a = createComponent("ServiceElement", "NA-ServiceElement", "9876");
anticipateFacts(dependenciesNeeded, b, new DependsOn(a, b));
// pretend to be a using rule that inserts the DependenciesNeeded fact
FactHandle depsNeededHandle = insertFactAndFireRules(dependenciesNeeded);
verifyFacts();
resetFacts();
anticipateFacts(dependenciesNeeded, b, new DependsOn(a, b));
DependenciesNeeded dependenciesNeeded2 = new DependenciesNeeded(b, "requestor2");
// don't expect any further dependencies to be added
anticipateFacts(dependenciesNeeded2);
insertFactAndFireRules(dependenciesNeeded2);
verifyFacts();
resetFacts();
anticipateFacts(dependenciesNeeded2, b, new DependsOn(a, b));
retractFactAndFireRules(depsNeededHandle);
verifyFacts();
}
Aggregations