use of org.opennms.netmgt.bsm.persistence.api.functions.map.IdentityEntity in project opennms by OpenNMS.
the class BusinessServiceDaoIT method canCreateReadUpdateAndDeleteBusinessServices.
@Test
@Transactional
public void canCreateReadUpdateAndDeleteBusinessServices() {
final int ifServiceCount = m_monitoredServiceDao.countAll();
// Initially there should be no business services
assertEquals(0, m_businessServiceDao.countAll());
// Create a business service
BusinessServiceEntity bs = new BusinessServiceEntityBuilder().name("Web Servers").addAttribute("dc", "RDU").addReductionKey("TestReductionKeyA", new IdentityEntity()).addReductionKey("TestReductionKeyB", new IdentityEntity()).reduceFunction(m_highestSeverity).toEntity();
m_businessServiceDao.save(bs);
m_businessServiceDao.flush();
// Read a business service
assertEquals(bs, m_businessServiceDao.get(bs.getId()));
assertEquals(2, m_businessServiceDao.get(bs.getId()).getReductionKeyEdges().size());
// Update a business service
bs.setName("Application Servers");
bs.getAttributes().put("dc", "!RDU");
bs.getAttributes().put("cd", "/");
// Grab the first monitored service from node 1
OnmsMonitoredService ipService = m_databasePopulator.getNode1().getIpInterfaces().iterator().next().getMonitoredServices().iterator().next();
bs.addIpServiceEdge(ipService, m_ignore);
m_businessServiceDao.update(bs);
m_businessServiceDao.flush();
// Verify the update
assertEquals(bs, m_businessServiceDao.get(bs.getId()));
// Delete
m_businessServiceDao.delete(bs);
m_businessServiceDao.flush();
// There should be no business services after the delete
assertEquals(0, m_businessServiceDao.countAll());
// No if service should have been deleted
assertEquals(ifServiceCount, m_monitoredServiceDao.countAll());
}
use of org.opennms.netmgt.bsm.persistence.api.functions.map.IdentityEntity in project opennms by OpenNMS.
the class BusinessServiceChildEdgeIT method canCreateReadUpdateAndDeleteEdges.
@Test
public void canCreateReadUpdateAndDeleteEdges() {
// Create the Parent Business Service
BusinessServiceEntity parent = new BusinessServiceEntityBuilder().name("Parent Service").reduceFunction(new HighestSeverityEntity()).toEntity();
// Create the Child Business Service
BusinessServiceEntity child = new BusinessServiceEntityBuilder().name("Child Service").reduceFunction(new HighestSeverityEntity()).toEntity();
Long parentServiceId = m_businessServiceDao.save(parent);
Long childServiceId = m_businessServiceDao.save(child);
m_businessServiceDao.flush();
// Initially there should be no edges
assertEquals(0, m_businessServiceEdgeDao.countAll());
// Create an edge
BusinessServiceChildEdgeEntity edge = new BusinessServiceChildEdgeEntity();
edge.setMapFunction(new IdentityEntity());
edge.setBusinessService(parent);
edge.setChild(child);
m_businessServiceEdgeDao.save(edge);
m_businessServiceEdgeDao.flush();
// Read an edge
assertEquals(1, m_businessServiceEdgeDao.countAll());
assertEquals(edge, m_businessServiceEdgeDao.get(edge.getId()));
assertEquals(parentServiceId, edge.getBusinessService().getId());
assertEquals(childServiceId, edge.getChild().getId());
// Update an edge
edge.setWeight(2);
m_businessServiceEdgeDao.save(edge);
m_businessServiceEdgeDao.flush();
BusinessServiceEdgeEntity otherEdge = m_businessServiceEdgeDao.get(edge.getId());
assertEquals(edge, otherEdge);
assertEquals(1, m_businessServiceEdgeDao.countAll());
// Delete an edge
m_businessServiceEdgeDao.delete(edge);
assertEquals(0, m_businessServiceEdgeDao.countAll());
}
use of org.opennms.netmgt.bsm.persistence.api.functions.map.IdentityEntity in project opennms by OpenNMS.
the class IPServiceEdgeDaoIT method setUp.
@Before
public void setUp() {
BeanUtils.assertAutowiring(this);
m_databasePopulator.populateDatabase();
m_highestSeverity = new HighestSeverityEntity();
m_reductionFunctionDao.save(m_highestSeverity);
m_reductionFunctionDao.flush();
m_identity = new IdentityEntity();
m_mapFunctionDao.save(m_identity);
m_mapFunctionDao.flush();
}
use of org.opennms.netmgt.bsm.persistence.api.functions.map.IdentityEntity in project opennms by OpenNMS.
the class BusinessServiceEdgeDaoIT method setUp.
@Before
public void setUp() {
BeanUtils.assertAutowiring(this);
m_databasePopulator.populateDatabase();
m_highestSeverity = new HighestSeverityEntity();
m_reductionFunctionDao.save(m_highestSeverity);
m_reductionFunctionDao.flush();
m_identity = new IdentityEntity();
m_mapFunctionDao.save(m_identity);
m_mapFunctionDao.flush();
}
use of org.opennms.netmgt.bsm.persistence.api.functions.map.IdentityEntity in project opennms by OpenNMS.
the class FriendlyNameValidationTest method friendlyNameZero.
@Test
public void friendlyNameZero() {
IdentityEntity identityEntity = new IdentityEntity();
IPServiceEdgeEntity edge = new IPServiceEdgeEntity();
edge.setFriendlyName(FRIENDLYNAME_EMPTY);
edge.setMapFunction(identityEntity);
Set<ConstraintViolation<IPServiceEdgeEntity>> constraintViolations = validator.validate(edge);
Assert.assertEquals(0, constraintViolations.size());
}
Aggregations