use of org.opennms.netmgt.bsm.service.model.functions.map.Identity in project opennms by OpenNMS.
the class BusinessServiceManagerImplIT method testGetOperationalStatusForBusinessService.
@Test
public void testGetOperationalStatusForBusinessService() {
BusinessService bsService1 = createBusinessService("Dummy Business Service");
BusinessService bsService2 = createBusinessService("Another Dummy Business Service");
businessServiceStateMachine.setBusinessServices(Lists.newArrayList(bsService1, bsService2));
final IpService ipServiceWithId5 = getIpService(5);
final IpService ipServiceWithId6 = getIpService(6);
// no ip services attached
Assert.assertEquals(Status.NORMAL, businessServiceManager.getOperationalStatus(bsService1));
Assert.assertEquals(Status.NORMAL, businessServiceManager.getOperationalStatus(bsService2));
// ip services attached
businessServiceManager.addIpServiceEdge(bsService1, ipServiceWithId5, new Identity(), Edge.DEFAULT_WEIGHT);
businessServiceManager.addIpServiceEdge(bsService2, ipServiceWithId6, new Identity(), Edge.DEFAULT_WEIGHT);
bsService1.save();
bsService2.save();
businessServiceDao.flush();
Assert.assertFalse("Services are equal but should not", Objects.equals(bsService1, bsService2));
businessServiceStateMachine.setBusinessServices(Lists.newArrayList(bsService1, bsService2));
// should not have any effect
Assert.assertEquals(Status.NORMAL, businessServiceManager.getOperationalStatus(bsService1));
Assert.assertEquals(Status.NORMAL, businessServiceManager.getOperationalStatus(bsService2));
// attach NORMAL alarm to service 1
final IpServiceEdge ipServiceEdgeOnBsService1 = bsService1.getIpServiceEdges().iterator().next();
businessServiceStateMachine.handleNewOrUpdatedAlarm(createAlarmWrapper(monitoredServiceDao.get(5), OnmsSeverity.NORMAL));
Assert.assertEquals(Status.NORMAL, businessServiceManager.getOperationalStatus(ipServiceEdgeOnBsService1));
Assert.assertEquals(Status.NORMAL, businessServiceManager.getOperationalStatus(bsService1));
Assert.assertEquals(Status.NORMAL, businessServiceManager.getOperationalStatus(bsService2));
// attach INDETERMINATE alarm to service 1
businessServiceStateMachine.handleNewOrUpdatedAlarm(createAlarmWrapper(monitoredServiceDao.get(5), OnmsSeverity.INDETERMINATE));
Assert.assertEquals(Status.NORMAL, businessServiceManager.getOperationalStatus(ipServiceEdgeOnBsService1));
Assert.assertEquals(Status.NORMAL, businessServiceManager.getOperationalStatus(bsService1));
Assert.assertEquals(Status.NORMAL, businessServiceManager.getOperationalStatus(bsService2));
// attach WARNING alarm to service 1
businessServiceStateMachine.handleNewOrUpdatedAlarm(createAlarmWrapper(monitoredServiceDao.get(5), OnmsSeverity.WARNING));
Assert.assertEquals(Status.WARNING, businessServiceManager.getOperationalStatus(ipServiceEdgeOnBsService1));
Assert.assertEquals(Status.WARNING, businessServiceManager.getOperationalStatus(bsService1));
Assert.assertEquals(Status.NORMAL, businessServiceManager.getOperationalStatus(bsService2));
// attach CRITICAL alarm to service 1
businessServiceStateMachine.handleNewOrUpdatedAlarm(createAlarmWrapper(monitoredServiceDao.get(5), OnmsSeverity.CRITICAL));
Assert.assertEquals(Status.CRITICAL, businessServiceManager.getOperationalStatus(ipServiceEdgeOnBsService1));
Assert.assertEquals(Status.CRITICAL, businessServiceManager.getOperationalStatus(bsService1));
Assert.assertEquals(Status.NORMAL, businessServiceManager.getOperationalStatus(bsService2));
}
use of org.opennms.netmgt.bsm.service.model.functions.map.Identity in project opennms by OpenNMS.
the class BusinessServiceManagerImplIT method testChildMapping.
@Test
public void testChildMapping() {
BusinessService service_p_1 = createBusinessService("Business Service #p1");
BusinessService service_p_2 = createBusinessService("Business Service #p2");
BusinessService service_c_1 = createBusinessService("Business Service #c1");
BusinessService service_c_2 = createBusinessService("Business Service #c2");
businessServiceManager.addChildEdge(service_p_1, service_c_1, new Identity(), Edge.DEFAULT_WEIGHT);
businessServiceManager.addChildEdge(service_p_1, service_c_2, new Identity(), Edge.DEFAULT_WEIGHT);
businessServiceManager.addChildEdge(service_p_2, service_c_1, new Identity(), Edge.DEFAULT_WEIGHT);
businessServiceManager.addChildEdge(service_p_2, service_c_2, new Identity(), Edge.DEFAULT_WEIGHT);
Assert.assertEquals(ImmutableSet.of(service_p_1, service_p_2), service_c_1.getParentServices());
Assert.assertEquals(ImmutableSet.of(service_p_1, service_p_2), service_c_2.getParentServices());
}
use of org.opennms.netmgt.bsm.service.model.functions.map.Identity 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.Identity in project opennms by OpenNMS.
the class BusinessServiceManagerImplIT method testLoopDetection.
@Test
public void testLoopDetection() {
BusinessServiceEntity service1 = createDummyBusinessService("Business Service #1");
BusinessServiceEntity service2 = createDummyBusinessService("Business Service #2");
BusinessServiceEntity service3 = createDummyBusinessService("Business Service #3");
Long serviceId1 = businessServiceDao.save(service1);
Long serviceId2 = businessServiceDao.save(service2);
Long serviceId3 = businessServiceDao.save(service3);
BusinessService bs1 = getBusinessService(serviceId1);
BusinessService bs2 = getBusinessService(serviceId2);
BusinessService bs3 = getBusinessService(serviceId3);
Assert.assertEquals(ImmutableSet.of(businessServiceManager.getBusinessServiceById(serviceId2), businessServiceManager.getBusinessServiceById(serviceId3)), businessServiceManager.getFeasibleChildServices(businessServiceManager.getBusinessServiceById(serviceId1)));
Assert.assertEquals(ImmutableSet.of(businessServiceManager.getBusinessServiceById(serviceId1), businessServiceManager.getBusinessServiceById(serviceId3)), businessServiceManager.getFeasibleChildServices(businessServiceManager.getBusinessServiceById(serviceId2)));
Assert.assertEquals(ImmutableSet.of(businessServiceManager.getBusinessServiceById(serviceId1), businessServiceManager.getBusinessServiceById(serviceId2)), businessServiceManager.getFeasibleChildServices(businessServiceManager.getBusinessServiceById(serviceId3)));
businessServiceManager.addChildEdge(bs1, bs2, new Identity(), Edge.DEFAULT_WEIGHT);
bs1.save();
bs2.save();
Assert.assertEquals(ImmutableSet.of(businessServiceManager.getBusinessServiceById(serviceId2), businessServiceManager.getBusinessServiceById(serviceId3)), businessServiceManager.getFeasibleChildServices(businessServiceManager.getBusinessServiceById(serviceId1)));
Assert.assertEquals(ImmutableSet.of(businessServiceManager.getBusinessServiceById(serviceId3)), businessServiceManager.getFeasibleChildServices(businessServiceManager.getBusinessServiceById(serviceId2)));
Assert.assertEquals(ImmutableSet.of(businessServiceManager.getBusinessServiceById(serviceId1), businessServiceManager.getBusinessServiceById(serviceId2)), businessServiceManager.getFeasibleChildServices(businessServiceManager.getBusinessServiceById(serviceId3)));
businessServiceManager.addChildEdge(bs2, bs3, new Identity(), Edge.DEFAULT_WEIGHT);
bs2.save();
bs3.save();
Assert.assertEquals(ImmutableSet.of(businessServiceManager.getBusinessServiceById(serviceId2), businessServiceManager.getBusinessServiceById(serviceId3)), businessServiceManager.getFeasibleChildServices(businessServiceManager.getBusinessServiceById(serviceId1)));
Assert.assertEquals(ImmutableSet.of(businessServiceManager.getBusinessServiceById(serviceId3)), businessServiceManager.getFeasibleChildServices(businessServiceManager.getBusinessServiceById(serviceId2)));
Assert.assertEquals(ImmutableSet.of(), businessServiceManager.getFeasibleChildServices(businessServiceManager.getBusinessServiceById(serviceId3)));
}
use of org.opennms.netmgt.bsm.service.model.functions.map.Identity in project opennms by OpenNMS.
the class BusinessServiceManagerImplIT method testChildDeletionSingleLevel.
// 1 parent -> 2 children
@Test
public void testChildDeletionSingleLevel() {
BusinessService service_p = createBusinessService("Business Service #p");
BusinessService service_c_1 = createBusinessService("Business Service #c1");
BusinessService service_c_2 = createBusinessService("Business Service #c2");
businessServiceManager.addChildEdge(service_p, service_c_1, new Identity(), Edge.DEFAULT_WEIGHT);
businessServiceManager.addChildEdge(service_p, service_c_2, new Identity(), Edge.DEFAULT_WEIGHT);
service_p.save();
service_c_1.save();
service_c_2.save();
// ensure the edges are there before deleting
Assert.assertEquals(2, edgeDao.countAll());
service_c_1.delete();
Assert.assertEquals(ImmutableSet.of(service_c_2), service_p.getChildServices());
// verify that the edge is also gone
Assert.assertEquals(1, edgeDao.countAll());
}
Aggregations