Search in sources :

Example 66 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class ImpactProgagationRulesIT method testSimpleDownUpCase.

@Test
@DirtiesContext
public void testSimpleDownUpCase() throws Exception {
    // 1. Assert empty workspace
    resetFacts();
    verifyFacts();
    // 2. verify Impact on ComponentDownEvent
    resetFacts();
    resetEvents();
    // component to request dependencies for
    Component c = createComponent("ServiceElementComponent", "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)");
    Event downEvent = createVpnPwDownEvent(17, m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50");
    ComponentDownEvent cde = new ComponentDownEvent(c, downEvent);
    anticipateFacts(cde, new ComponentImpacted(c, cde), new DependenciesNeeded(c, cde), new ImpactEventSent(c, cde));
    anticipateEvent(createComponentImpactedEvent("ServiceElementComponent", "jnxVpnPw-vcid(50)", "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)", 17));
    // pretend to be a using rule that inserts the DependenciesNeeded fact
    insertFactAndFireRules(cde);
    verifyFacts();
    verifyEvents();
    // 3. Verify resolution and memory clean up on ComponentUpEvent
    resetFacts();
    resetEvents();
    anticipateEvent(createComponentResolvedEvent("ServiceElementComponent", "jnxVpnPw-vcid(50)", "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)", 17));
    Event upEvent = createVpnPwUpEvent(17, m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50");
    ComponentUpEvent cue = new ComponentUpEvent(c, upEvent);
    anticipateFacts(cue);
    insertFactAndFireRules(cue);
    verifyFacts();
    verifyEvents();
}
Also used : Event(org.opennms.netmgt.xml.event.Event) NCSComponent(org.opennms.netmgt.model.ncs.NCSComponent) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 67 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class EventMappingRulesIT method testMapPwUp.

@Test
@DirtiesContext
public void testMapPwUp() throws Exception {
    Event event = createVpnPwUpEvent(27, m_pe2NodeId, "10.1.1.1", "5", "ge-3/1/4.50");
    testEventMapping(event, ComponentUpEvent.class, "ServiceElementComponent", "NA-SvcElemComp", "9876,jnxVpnPw-vcid(50)");
}
Also used : Event(org.opennms.netmgt.xml.event.Event) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 68 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext 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 69 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext 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)

Example 70 with DirtiesContext

use of org.springframework.test.annotation.DirtiesContext in project opennms by OpenNMS.

the class EventMappingRulesIT method testMapMplsLspPathUp.

@Test
@DirtiesContext
public void testMapMplsLspPathUp() throws Exception {
    Event event = createMplsLspPathUpEvent(37, m_pe2NodeId, "10.1.1.1", "lspA-PE2-PE1");
    testEventMapping(event, ComponentUpEvent.class, "ServiceElementComponent", "NA-SvcElemComp", "9876,lspA-PE2-PE1");
}
Also used : Event(org.opennms.netmgt.xml.event.Event) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Aggregations

DirtiesContext (org.springframework.test.annotation.DirtiesContext)86 Test (org.junit.Test)83 Exchange (org.apache.camel.Exchange)21 Event (org.opennms.netmgt.xml.event.Event)19 Processor (org.apache.camel.Processor)11 DroolsCorrelationEngine (org.opennms.netmgt.correlation.drools.DroolsCorrelationEngine)10 IOException (java.io.IOException)9 NCSComponent (org.opennms.netmgt.model.ncs.NCSComponent)9 ProducerTemplate (org.apache.camel.ProducerTemplate)7 Ignore (org.junit.Ignore)7 SnmpValue (org.opennms.netmgt.snmp.SnmpValue)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 LinkedHashMap (java.util.LinkedHashMap)5 CommonBindyTest (org.apache.camel.dataformat.bindy.CommonBindyTest)5 FactHandle (org.kie.api.runtime.rule.FactHandle)5 SnmpValueFactory (org.opennms.netmgt.snmp.SnmpValueFactory)5 Message (org.apache.camel.Message)4 BigDecimal (java.math.BigDecimal)3 Registration (org.opennms.core.soa.Registration)3