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());
}
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);
}
}
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());
}
Aggregations