Search in sources :

Example 1 with Decrease

use of org.opennms.netmgt.bsm.service.model.functions.map.Decrease in project opennms by OpenNMS.

the class MapFunctionTest method verifyDecrease.

@Test
public void verifyDecrease() {
    Decrease decrease = new Decrease();
    Assert.assertEquals(Status.MAJOR, decrease.map(Status.CRITICAL).get());
    Assert.assertEquals(Status.MINOR, decrease.map(Status.MAJOR).get());
    Assert.assertEquals(Status.WARNING, decrease.map(Status.MINOR).get());
    Assert.assertEquals(Status.NORMAL, decrease.map(Status.WARNING).get());
    Assert.assertEquals(Status.INDETERMINATE, decrease.map(Status.INDETERMINATE).get());
}
Also used : Decrease(org.opennms.netmgt.bsm.service.model.functions.map.Decrease) Test(org.junit.Test)

Example 2 with Decrease

use of org.opennms.netmgt.bsm.service.model.functions.map.Decrease in project opennms by OpenNMS.

the class BusinessServiceEdgeEditWindow method getMapFunction.

@SuppressWarnings("unchecked")
private MapFunction getMapFunction() {
    try {
        final MapFunction mapFunction = ((Class<? extends MapFunction>) m_mapFunctionSelect.getValue()).newInstance();
        mapFunction.accept(new MapFunctionVisitor<Void>() {

            @Override
            public Void visit(Decrease decrease) {
                return null;
            }

            @Override
            public Void visit(Identity identity) {
                return null;
            }

            @Override
            public Void visit(Ignore ignore) {
                return null;
            }

            @Override
            public Void visit(Increase increase) {
                return null;
            }

            @Override
            public Void visit(SetTo setTo) {
                setTo.setStatus((Status) m_mapFunctionSeveritySelect.getValue());
                return null;
            }
        });
        return mapFunction;
    } catch (final InstantiationException | IllegalAccessException e) {
        throw Throwables.propagate(e);
    }
}
Also used : Status(org.opennms.netmgt.bsm.service.model.Status) Ignore(org.opennms.netmgt.bsm.service.model.functions.map.Ignore) Increase(org.opennms.netmgt.bsm.service.model.functions.map.Increase) MapFunction(org.opennms.netmgt.bsm.service.model.functions.map.MapFunction) Decrease(org.opennms.netmgt.bsm.service.model.functions.map.Decrease) Identity(org.opennms.netmgt.bsm.service.model.functions.map.Identity) SetTo(org.opennms.netmgt.bsm.service.model.functions.map.SetTo)

Example 3 with Decrease

use of org.opennms.netmgt.bsm.service.model.functions.map.Decrease in project opennms by OpenNMS.

the class BusinessServiceManagerImplIT method ensureNoDanglingMapFunctions.

@Test
public void ensureNoDanglingMapFunctions() {
    // Create a business service with an edge
    final BusinessService bs = this.createBusinessService("bs1");
    bs.addReductionKeyEdge("my-reduction-key", new Increase(), Edge.DEFAULT_WEIGHT, "My Reduction Key");
    bs.save();
    // Ensure there is an associated mapping function
    assertEquals(1, mapFunctionDao.countAll());
    Iterables.getOnlyElement(bs.getReductionKeyEdges()).setMapFunction(new Decrease());
    bs.save();
    // Ensure there is still only one associated mapping function
    assertEquals(1, mapFunctionDao.countAll());
    // Delete an edge
    bs.delete();
    // Ensure there are no mapping functions left
    assertEquals(0, mapFunctionDao.countAll());
}
Also used : BsmTestUtils.createDummyBusinessService(org.opennms.netmgt.bsm.test.BsmTestUtils.createDummyBusinessService) BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) Decrease(org.opennms.netmgt.bsm.service.model.functions.map.Decrease) Increase(org.opennms.netmgt.bsm.service.model.functions.map.Increase) Test(org.junit.Test)

Aggregations

Decrease (org.opennms.netmgt.bsm.service.model.functions.map.Decrease)3 Test (org.junit.Test)2 Increase (org.opennms.netmgt.bsm.service.model.functions.map.Increase)2 BusinessService (org.opennms.netmgt.bsm.service.model.BusinessService)1 Status (org.opennms.netmgt.bsm.service.model.Status)1 Identity (org.opennms.netmgt.bsm.service.model.functions.map.Identity)1 Ignore (org.opennms.netmgt.bsm.service.model.functions.map.Ignore)1 MapFunction (org.opennms.netmgt.bsm.service.model.functions.map.MapFunction)1 SetTo (org.opennms.netmgt.bsm.service.model.functions.map.SetTo)1 BsmTestUtils.createDummyBusinessService (org.opennms.netmgt.bsm.test.BsmTestUtils.createDummyBusinessService)1