use of org.opennms.netmgt.bsm.persistence.api.functions.reduce.HighestSeverityEntity 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.reduce.HighestSeverityEntity 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.reduce.HighestSeverityEntity in project opennms by OpenNMS.
the class AbstractBusinessServiceRestServiceIT method canCreateBusinessService.
@Test
public void canCreateBusinessService() throws Exception {
final BusinessServiceEntity bs = new BusinessServiceEntityBuilder().name("some-service").addAttribute("some-key", "some-value").reduceFunction(new HighestSeverityEntity()).addReductionKey("reductionKey-1", new IdentityEntity()).addReductionKey("reductionKey-2", new IdentityEntity()).addReductionKey("reductionKey-3", new IdentityEntity()).toEntity();
sendData(POST, getMediaType(), "/business-services", marshal(toRequestDto(bs)), 201);
Assert.assertEquals(1, m_businessServiceDao.countAll());
for (BusinessServiceEntity eachEntity : m_businessServiceDao.findAll()) {
BusinessServiceResponseDTO responseDTO = verifyResponse(eachEntity);
Assert.assertEquals(3, responseDTO.getReductionKeys().size());
}
}
use of org.opennms.netmgt.bsm.persistence.api.functions.reduce.HighestSeverityEntity in project opennms by OpenNMS.
the class AbstractBusinessServiceRestServiceIT method canAddIpServiceEdge.
@Test
public void canAddIpServiceEdge() throws Exception {
// Create a business service without any edges
BusinessServiceEntity service = new BusinessServiceEntityBuilder().name("Dummy Service").reduceFunction(new HighestSeverityEntity()).toEntity();
final Long serviceId = m_businessServiceDao.save(service);
m_businessServiceDao.flush();
// The Request to send to create an edge
IpServiceEdgeRequestDTO edgeRequestDTO = new IpServiceEdgeRequestDTO();
edgeRequestDTO.setMapFunction(new FunctionsManager().getMapFunctionDTO(new Identity()));
// verify adding of not existing ip service is not possible
edgeRequestDTO.setIpServiceId(-1);
sendData(POST, getMediaType(), buildIpServiceEdgeUrl(serviceId), marshal(edgeRequestDTO), 404);
// verify adding of existing ip service is possible
edgeRequestDTO.setIpServiceId(10);
sendData(POST, getMediaType(), buildIpServiceEdgeUrl(serviceId), marshal(edgeRequestDTO), 200);
Assert.assertEquals(1, m_businessServiceDao.get(serviceId).getIpServiceEdges().size());
// verify adding twice possible, but not modified
sendData(POST, getMediaType(), buildIpServiceEdgeUrl(serviceId), marshal(edgeRequestDTO), 304);
Assert.assertEquals(1, m_businessServiceDao.get(serviceId).getIpServiceEdges().size());
// verify adding of existing ip service is possible
edgeRequestDTO.setIpServiceId(17);
sendData(POST, getMediaType(), buildIpServiceEdgeUrl(serviceId), marshal(edgeRequestDTO), 200);
Assert.assertEquals(2, m_businessServiceDao.get(serviceId).getIpServiceEdges().size());
}
use of org.opennms.netmgt.bsm.persistence.api.functions.reduce.HighestSeverityEntity in project opennms by OpenNMS.
the class AbstractBusinessServiceRestServiceIT method canAddReductionKeyEdge.
@Test
public void canAddReductionKeyEdge() throws Exception {
// Create a business service without any edges
BusinessServiceEntity service = new BusinessServiceEntityBuilder().name("Dummy Service").reduceFunction(new HighestSeverityEntity()).toEntity();
final Long serviceId = m_businessServiceDao.save(service);
m_businessServiceDao.flush();
// The Request to send to create an edge
ReductionKeyEdgeRequestDTO edgeRequestDTO = new ReductionKeyEdgeRequestDTO();
edgeRequestDTO.setMapFunction(new FunctionsManager().getMapFunctionDTO(new Identity()));
// verify adding of existing ip service is possible
edgeRequestDTO.setReductionKey("1st reduction key");
sendData(POST, getMediaType(), buildReductionKeyEdgeUrl(serviceId), marshal(edgeRequestDTO), 200);
Assert.assertEquals(1, m_businessServiceDao.get(serviceId).getReductionKeyEdges().size());
// verify adding twice possible, but not modified
sendData(POST, getMediaType(), buildReductionKeyEdgeUrl(serviceId), marshal(edgeRequestDTO), 304);
Assert.assertEquals(1, m_businessServiceDao.get(serviceId).getReductionKeyEdges().size());
// verify adding of existing ip service is possible
edgeRequestDTO.setReductionKey("2nd reduction key");
sendData(POST, getMediaType(), buildReductionKeyEdgeUrl(serviceId), marshal(edgeRequestDTO), 200);
Assert.assertEquals(2, m_businessServiceDao.get(serviceId).getReductionKeyEdges().size());
}
Aggregations