use of org.kie.api.runtime.rule.FactHandle in project opennms by OpenNMS.
the class DependencyLoadingRulesIT method testSingleRequestToLoadDependenciesOfTypeAllAndWithdrawnTwice.
@Test
@DirtiesContext
public void testSingleRequestToLoadDependenciesOfTypeAllAndWithdrawnTwice() {
resetFacts();
// expect empty memory to start with
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();
// simulate other rules retracting the dep
retractFactAndFireRules(depsNeededHandle);
// nothing anticipated... everything cleaned up
verifyFacts();
resetFacts();
anticipateFacts(dependenciesNeeded, b, new DependsOn(a, b));
depsNeededHandle = insertFactAndFireRules(dependenciesNeeded);
verifyFacts();
// Clean up facts
resetFacts();
// Expecting empty list
anticipateFacts();
// simulate retracting the dep
retractFactAndFireRules(depsNeededHandle);
verifyFacts();
}
use of org.kie.api.runtime.rule.FactHandle in project opennms by OpenNMS.
the class DependencyLoadingRulesIT method testSingleRequestToLoadDependenciesOfTypeAllAndWithdrawn.
@Test
@DirtiesContext
public void testSingleRequestToLoadDependenciesOfTypeAllAndWithdrawn() {
resetFacts();
// expect empty memory to start with
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();
// simulate other rules retracting the dep
retractFactAndFireRules(depsNeededHandle);
// nothing anticipated... everything cleaned up
verifyFacts();
}
Aggregations