Search in sources :

Example 41 with BusinessService

use of org.opennms.netmgt.bsm.service.model.BusinessService in project opennms by OpenNMS.

the class BusinessServiceCriteriaTest method createDummyBusinessService.

private BusinessService createDummyBusinessService(final long id, final String name, String attributeKey, String attributeValue, final Status status) {
    BusinessServiceEntity businessServiceEntity = new BusinessServiceEntity();
    businessServiceEntity.setId(id);
    businessServiceEntity.setAttribute(attributeKey, attributeValue);
    businessServiceEntity.setName(name);
    BusinessService businessService = new BusinessServiceImpl(businessServiceManager, businessServiceEntity) {

        @Override
        public Status getOperationalStatus() {
            return status;
        }
    };
    return businessService;
}
Also used : BusinessService(org.opennms.netmgt.bsm.service.model.BusinessService) BusinessServiceEntity(org.opennms.netmgt.bsm.persistence.api.BusinessServiceEntity)

Example 42 with BusinessService

use of org.opennms.netmgt.bsm.service.model.BusinessService 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

BusinessService (org.opennms.netmgt.bsm.service.model.BusinessService)42 Test (org.junit.Test)13 Collectors (java.util.stream.Collectors)10 IpServiceEdge (org.opennms.netmgt.bsm.service.model.edge.IpServiceEdge)10 List (java.util.List)9 BusinessServiceManager (org.opennms.netmgt.bsm.service.BusinessServiceManager)9 Status (org.opennms.netmgt.bsm.service.model.Status)9 Path (javax.ws.rs.Path)8 IpService (org.opennms.netmgt.bsm.service.model.IpService)8 Edge (org.opennms.netmgt.bsm.service.model.edge.Edge)8 Identity (org.opennms.netmgt.bsm.service.model.functions.map.Identity)8 BusinessServiceGraph (org.opennms.netmgt.bsm.service.model.graph.BusinessServiceGraph)8 Map (java.util.Map)7 BusinessServiceStateMachine (org.opennms.netmgt.bsm.service.BusinessServiceStateMachine)7 ChildEdge (org.opennms.netmgt.bsm.service.model.edge.ChildEdge)7 ReductionKeyEdge (org.opennms.netmgt.bsm.service.model.edge.ReductionKeyEdge)7 Objects (java.util.Objects)6 BusinessServiceEntity (org.opennms.netmgt.bsm.persistence.api.BusinessServiceEntity)6 NoSuchElementException (java.util.NoSuchElementException)5 Criteria (org.opennms.core.criteria.Criteria)5