Search in sources :

Example 11 with FactHandle

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();
}
Also used : FactHandle(org.kie.api.runtime.rule.FactHandle) NCSComponent(org.opennms.netmgt.model.ncs.NCSComponent) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 12 with FactHandle

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();
}
Also used : FactHandle(org.kie.api.runtime.rule.FactHandle) NCSComponent(org.opennms.netmgt.model.ncs.NCSComponent) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Aggregations

FactHandle (org.kie.api.runtime.rule.FactHandle)12 Test (org.junit.Test)5 NCSComponent (org.opennms.netmgt.model.ncs.NCSComponent)5 DirtiesContext (org.springframework.test.annotation.DirtiesContext)5 Ignore (org.junit.Ignore)2 Event (org.opennms.netmgt.xml.event.Event)1