use of org.opennms.netmgt.bsm.persistence.api.functions.map.IdentityEntity in project opennms by OpenNMS.
the class BusinessServiceSearchProviderIT method verifyQuery.
@Test
public void verifyQuery() {
BusinessServiceEntity bs1 = new BusinessServiceEntityBuilder().name("Test Service").reduceFunction(new HighestSeverityEntity()).addReductionKey("bs1.key1", new IdentityEntity(), 1).addReductionKey("bs1.key2", new IdentityEntity(), 1).toEntity();
BusinessServiceEntity bs2 = new BusinessServiceEntityBuilder().name("Real Service 2").reduceFunction(new HighestSeverityEntity()).addReductionKey("bs2.key1", new IdentityEntity(), 1).addReductionKey("bs2.key2", new IdentityEntity(), 1).toEntity();
businessServiceDao.save(bs1);
businessServiceDao.save(bs2);
businessServiceDao.flush();
// prepare mocks
TopologyServiceClient topologyServiceClientMock = EasyMock.createNiceMock(TopologyServiceClient.class);
EasyMock.expect(topologyServiceClientMock.getVertex(EasyMock.anyObject(BusinessServiceVertex.class))).andReturn(// always return a vertex, it just needs to be not null
new AbstractVertex("bsm", "0", "Dummy Vertex"));
GraphContainer graphContainerMock = EasyMock.createNiceMock(GraphContainer.class);
EasyMock.expect(graphContainerMock.getTopologyServiceClient()).andReturn(topologyServiceClientMock).anyTimes();
EasyMock.replay(graphContainerMock, topologyServiceClientMock);
// try searching
final BusinessServiceSearchProvider provider = new BusinessServiceSearchProvider();
provider.setBusinessServiceManager(businessServiceManager);
final SearchQuery query = new AbstractSearchQuery("Test") {
@Override
public boolean matches(String label) {
// always match, it does not matter
return true;
}
};
final List<SearchResult> result = provider.query(query, graphContainerMock);
Assert.assertEquals(1, result.size());
EasyMock.verify(graphContainerMock, topologyServiceClientMock);
}
use of org.opennms.netmgt.bsm.persistence.api.functions.map.IdentityEntity in project opennms by OpenNMS.
the class BsmdIT method createBusinessService.
private BusinessServiceEntity createBusinessService(String name) {
BusinessServiceEntity bs = new BusinessServiceEntity();
bs.setName(name);
bs.setReductionFunction(new HighestSeverityEntity());
bs.setAttribute("my-attr-key", "my-attr-value");
// Grab the first monitored service from node 1
OnmsMonitoredService ipService = m_databasePopulator.getNode1().getIpInterfaces().iterator().next().getMonitoredServices().iterator().next();
bs.addIpServiceEdge(ipService, new IdentityEntity());
// Persist
m_businessServiceDao.save(bs);
m_businessServiceDao.flush();
return bs;
}
use of org.opennms.netmgt.bsm.persistence.api.functions.map.IdentityEntity in project opennms by OpenNMS.
the class FriendlyNameValidationTest method friendlyNameTooLong.
@Test
public void friendlyNameTooLong() {
IdentityEntity identityEntity = new IdentityEntity();
IPServiceEdgeEntity edge = new IPServiceEdgeEntity();
edge.setFriendlyName(FRIENDLYNAME_TOO_LONG);
edge.setMapFunction(identityEntity);
validator.validate(edge);
Set<ConstraintViolation<IPServiceEdgeEntity>> constraintViolations = validator.validate(edge);
Assert.assertEquals(1, constraintViolations.size());
}
use of org.opennms.netmgt.bsm.persistence.api.functions.map.IdentityEntity in project opennms by OpenNMS.
the class FriendlyNameValidationTest method friendlyNameMaximum.
@Test
public void friendlyNameMaximum() {
IdentityEntity identityEntity = new IdentityEntity();
IPServiceEdgeEntity edge = new IPServiceEdgeEntity();
edge.setFriendlyName(FRIENDLYNAME_THIRTY_CHARS);
edge.setMapFunction(identityEntity);
validator.validate(edge);
Set<ConstraintViolation<IPServiceEdgeEntity>> constraintViolations = validator.validate(edge);
Assert.assertEquals(0, constraintViolations.size());
}
use of org.opennms.netmgt.bsm.persistence.api.functions.map.IdentityEntity in project opennms by OpenNMS.
the class BusinessServiceDaoIT method verifyDistinctObjectLoading.
@Test
@Transactional
public void verifyDistinctObjectLoading() {
BusinessServiceEntity entity = new BusinessServiceEntityBuilder().name("Parent Web Servers").addReductionKey("TestReductionKeyA", new IdentityEntity()).addReductionKey("TestReductionKeyB", new IdentityEntity()).addReductionKey("TestReductionKeyC", new IdentityEntity()).reduceFunction(m_highestSeverity).toEntity();
m_businessServiceDao.save(entity);
m_businessServiceDao.flush();
assertEquals(1, m_businessServiceDao.countAll());
assertEquals(3, m_edgeDao.countAll());
Criteria criteria = new CriteriaBuilder(BusinessServiceEntity.class).toCriteria();
// verify that root entity is merged
assertEquals(1, m_businessServiceDao.findMatching(criteria).size());
// verify that countMatching also works
assertEquals(1, m_businessServiceDao.countMatching(criteria));
}
Aggregations