use of org.opennms.netmgt.bsm.service.model.functions.map.Increase in project opennms by OpenNMS.
the class BusinessServiceRequestDTOMarshalTest method data.
@Parameterized.Parameters
public static Collection<Object[]> data() throws IOException {
final SetTo setTo = new SetTo();
setTo.setStatus(Status.CRITICAL);
final MapFunctionDTO increaseDto = createMapFunctionDTO(new Increase());
final MapFunctionDTO setToDto = createMapFunctionDTO(setTo);
final BusinessServiceRequestDTO requestDTO = new BusinessServiceRequestDTO();
requestDTO.setReduceFunction(createReduceFunctionDTO(new HighestSeverity()));
requestDTO.setName("Web Servers");
requestDTO.addAttribute("dc", "RDU");
requestDTO.addAttribute("some-key", "some-value");
requestDTO.addChildService(2L, increaseDto, 5);
requestDTO.addChildService(3L, setToDto, 5);
requestDTO.addReductionKey("myReductionKeyA", increaseDto, 7, "reduction-key-a-friendly-name");
requestDTO.addReductionKey("myReductionKeyB", increaseDto, 7, "reduction-key-b-friendly-name");
requestDTO.addIpService(1, increaseDto, 9, "ip-service-friendly-name");
return Arrays.asList(new Object[][] { { BusinessServiceRequestDTO.class, requestDTO, "{" + " \"name\" : \"Web Servers\"," + " \"attributes\" : {" + " \"attribute\" : [ {" + " \"key\" : \"dc\"," + " \"value\" : \"RDU\"" + " }, {" + " \"key\" : \"some-key\"," + " \"value\" : \"some-value\"" + " } ]" + " }," + " \"reduce-function\" : {" + " \"type\" : \"HighestSeverity\"," + " \"properties\" : { }" + " }," + " \"child-edges\" : [" + " {" + " \"map-function\" : {" + " \"type\" : \"Increase\"," + " \"properties\" : { }" + " }," + " \"weight\" : 5," + " \"child-id\" : 2" + " }," + " {" + " \"map-function\" : {" + " \"type\" : \"SetTo\"," + " \"properties\" : {" + " \"status\" : \"Critical\"" + " }" + " }," + " \"weight\" : 5," + " \"child-id\" : 3" + " }," + " ]," + " \"ip-service-edges\" : [" + " {" + " \"map-function\" : {" + " \"type\" : \"Increase\"," + " \"properties\" : { }" + " }," + " \"weight\" : 9," + " \"ip-service-id\" : 1," + " \"friendly-name\" : \"ip-service-friendly-name\"" + " }," + " ]," + " \"reduction-key-edges\" : [" + " {" + " \"map-function\" : {" + " \"type\" : \"Increase\"," + " \"properties\" : { }" + " }," + " \"weight\" : 7," + " \"reduction-key\" : \"myReductionKeyA\"," + " \"friendly-name\" : \"reduction-key-a-friendly-name\"" + " }," + " {" + " \"map-function\" : {" + " \"type\" : \"Increase\"," + " \"properties\" : { }" + " }," + " \"weight\" : 7," + " \"reduction-key\" : \"myReductionKeyB\"," + " \"friendly-name\" : \"reduction-key-b-friendly-name\"" + " }," + " ]," + "}", "<business-service>\n" + " <name>Web Servers</name>\n" + " <attributes>\n" + " <attribute>\n" + " <key>dc</key>\n" + " <value>RDU</value>\n" + " </attribute>\n" + " <attribute>\n" + " <key>some-key</key>\n" + " <value>some-value</value>\n" + " </attribute>\n" + " </attributes>\n" + " <ip-service-edges>\n" + " <ip-service-edge>\n" + " <map-function>\n" + " <type>Increase</type>\n" + " </map-function>\n" + " <weight>9</weight>\n" + " <friendly-name>ip-service-friendly-name</friendly-name>\n" + " <ip-service-id>1</ip-service-id>\n" + " </ip-service-edge>\n" + " </ip-service-edges>\n" + " <child-edges>\n" + " <child-edge>\n" + " <map-function>\n" + " <type>Increase</type>\n" + " </map-function>\n" + " <weight>5</weight>\n" + " <child-id>2</child-id>\n" + " </child-edge>\n" + " <child-edge>\n" + " <map-function>\n" + " <type>SetTo</type>\n" + " <properties>\n" + " <entry>\n" + " <key>status</key>\n" + " <value>Critical</value>\n" + " </entry>\n" + " </properties>\n" + " </map-function>\n" + " <weight>5</weight>\n" + " <child-id>3</child-id>\n" + " </child-edge>\n" + " </child-edges>\n" + " <reduction-key-edges>\n" + " <reduction-key-edge>\n" + " <map-function>\n" + " <type>Increase</type>\n" + " </map-function>\n" + " <weight>7</weight>\n" + " <friendly-name>reduction-key-a-friendly-name</friendly-name>\n" + " <reduction-key>myReductionKeyA</reduction-key>\n" + " </reduction-key-edge>\n" + " <reduction-key-edge>\n" + " <map-function>\n" + " <type>Increase</type>\n" + " </map-function>\n" + " <weight>7</weight>\n" + " <friendly-name>reduction-key-b-friendly-name</friendly-name>\n" + " <reduction-key>myReductionKeyB</reduction-key>\n" + " </reduction-key-edge>\n" + " </reduction-key-edges>\n" + " <reduce-function>\n" + " <type>HighestSeverity</type>\n" + " </reduce-function>\n" + "</business-service>" } });
}
use of org.opennms.netmgt.bsm.service.model.functions.map.Increase 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.Increase in project opennms by OpenNMS.
the class MapFunctionTest method verifyIncrease.
@Test
public void verifyIncrease() {
Increase increase = new Increase();
Assert.assertEquals(Status.WARNING, increase.map(Status.NORMAL).get());
Assert.assertEquals(Status.MINOR, increase.map(Status.WARNING).get());
Assert.assertEquals(Status.MAJOR, increase.map(Status.MINOR).get());
Assert.assertEquals(Status.CRITICAL, increase.map(Status.MAJOR).get());
Assert.assertEquals(Status.CRITICAL, increase.map(Status.CRITICAL).get());
}
use of org.opennms.netmgt.bsm.service.model.functions.map.Increase 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