use of org.opennms.netmgt.model.OnmsServiceType in project opennms by OpenNMS.
the class DatabasePopulator method getService.
private OnmsServiceType getService(final String serviceName) {
OnmsServiceType service = m_serviceTypeDao.findByName(serviceName);
if (service == null) {
service = new OnmsServiceType(serviceName);
m_serviceTypeDao.save(service);
m_serviceTypeDao.flush();
}
return service;
}
use of org.opennms.netmgt.model.OnmsServiceType in project opennms by OpenNMS.
the class ServiceTypeDaoIT method testLazyLoad.
@Test
@Transactional
public void testLazyLoad() {
OnmsServiceType t = new OnmsServiceType("ICMP");
m_serviceTypeDao.save(t);
OnmsServiceType type = m_serviceTypeDao.get(1);
assertEquals("ICMP", type.getName());
}
use of org.opennms.netmgt.model.OnmsServiceType in project opennms by OpenNMS.
the class AgentConfigurationResourceTest method testSimpleFilter.
@Test
public void testSimpleFilter() throws Exception {
final InetAddress oneNinetyTwo = addr("192.168.0.1");
final List<InetAddress> addresses = Arrays.asList(oneNinetyTwo);
m_filterDao.setActiveIPAddressList(addresses);
final OnmsNode node = new OnmsNode();
node.setId(1);
node.setForeignSource("foo");
node.setForeignId("bar");
node.setLabel("foo");
node.setSysObjectId(".1.2.3.4.5");
final OnmsIpInterface iface = new OnmsIpInterface(oneNinetyTwo, node);
final OnmsServiceType serviceType = new OnmsServiceType("SNMP");
final OnmsMonitoredService service = new OnmsMonitoredService(iface, serviceType);
m_monitoredServiceDao.setMatching(Arrays.asList(service));
final Response response = m_configResource.getAgentsJson("example1", "SNMP");
assertEquals(200, response.getStatus());
final Object entity = response.getEntity();
assertNotNull(entity);
assertTrue(entity instanceof List<?>);
@SuppressWarnings("unchecked") final List<AgentResponse> agentResponses = (List<AgentResponse>) entity;
System.err.println(agentResponses);
assertEquals(1, agentResponses.size());
assertTrue(agentResponses.get(0).getAddress().isPresent());
assertEquals(oneNinetyTwo, agentResponses.get(0).getAddress().get());
assertTrue(agentResponses.get(0).getPort().isPresent());
assertEquals(1161, agentResponses.get(0).getPort().get().intValue());
assertEquals(".1.2.3.4.5", agentResponses.get(0).getParameters().get("sysObjectId"));
assertEquals("1", agentResponses.get(0).getParameters().get("nodeId"));
assertEquals("foo", agentResponses.get(0).getParameters().get("foreignSource"));
assertEquals("bar", agentResponses.get(0).getParameters().get("foreignId"));
}
Aggregations