use of org.opennms.netmgt.bsm.service.model.functions.map.SetTo 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.SetTo 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.SetTo in project opennms by OpenNMS.
the class MapFunctionTest method verifySetTo.
@Test
public void verifySetTo() {
SetTo setTo = new SetTo();
setTo.setStatus(Status.WARNING);
for (Status eachStatus : Status.values()) {
Assert.assertEquals(Status.WARNING, setTo.map(eachStatus).get());
}
}
Aggregations