Search in sources :

Example 36 with OnmsServiceType

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;
}
Also used : OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType)

Example 37 with OnmsServiceType

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());
}
Also used : OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 38 with OnmsServiceType

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"));
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) AgentResponse(org.opennms.netmgt.config.agents.AgentResponse) Response(javax.ws.rs.core.Response) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType) List(java.util.List) InetAddress(java.net.InetAddress) AgentResponse(org.opennms.netmgt.config.agents.AgentResponse) Test(org.junit.Test)

Aggregations

OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)38 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)19 OnmsNode (org.opennms.netmgt.model.OnmsNode)19 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)17 Date (java.util.Date)8 Test (org.junit.Test)8 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)6 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)6 OnmsCategory (org.opennms.netmgt.model.OnmsCategory)4 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)4 OnmsOutage (org.opennms.netmgt.model.OnmsOutage)4 OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)4 Transactional (org.springframework.transaction.annotation.Transactional)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 Before (org.junit.Before)3 MockEventIpcManager (org.opennms.netmgt.dao.mock.MockEventIpcManager)3 MockPersisterFactory (org.opennms.netmgt.mock.MockPersisterFactory)3 ServiceSelector (org.opennms.netmgt.model.ServiceSelector)3 Properties (java.util.Properties)2