use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class MonitoredServiceDaoIT method testLazy.
@Test
@Transactional
public void testLazy() {
final List<OnmsMonitoredService> allSvcs = m_monitoredServiceDao.findAll();
assertTrue(allSvcs.size() > 1);
final OnmsMonitoredService svc = allSvcs.iterator().next();
assertEquals(addr("192.168.1.1"), svc.getIpAddress());
assertEquals(1, svc.getIfIndex().intValue());
assertEquals(m_databasePopulator.getNode1().getId(), svc.getIpInterface().getNode().getId());
assertEquals("M", svc.getIpInterface().getIsManaged());
}
use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class IfServicesRestService method getServices.
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML })
public OnmsMonitoredServiceDetailList getServices(@Context final UriInfo uriInfo) {
final Criteria c = getCriteria(uriInfo.getQueryParameters());
final OnmsMonitoredServiceDetailList servicesList = new OnmsMonitoredServiceDetailList();
final List<OnmsMonitoredService> services = m_serviceDao.findMatching(c);
for (OnmsMonitoredService svc : services) {
servicesList.add(new OnmsMonitoredServiceDetail(svc));
}
c.setLimit(null);
c.setOffset(null);
c.setOrders(new ArrayList<Order>());
servicesList.setTotalCount(m_serviceDao.countMatching(c));
return servicesList;
}
use of org.opennms.netmgt.model.OnmsMonitoredService 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"));
}
use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class DaoWebOutageRepositoryIT method setUp.
@Before
public void setUp() {
m_dbPopulator.populateDatabase();
OnmsMonitoredService svc2 = m_dbPopulator.getMonitoredServiceDao().get(2, InetAddressUtils.addr("192.168.2.1"), "ICMP");
OnmsEvent event = m_dbPopulator.getEventDao().get(1);
OnmsOutage unresolved2 = new OnmsOutage(new Date(), event, svc2);
m_dbPopulator.getOutageDao().save(unresolved2);
m_dbPopulator.getOutageDao().flush();
}
use of org.opennms.netmgt.model.OnmsMonitoredService in project opennms by OpenNMS.
the class WebOutageRepositoryFilterIT method testRegainedServiceDateAfterFilter.
@Test
// Relies on records created in @Before so we need a fresh database
@JUnitTemporaryDatabase
public void testRegainedServiceDateAfterFilter() {
OnmsMonitoredService svc2 = m_dbPopulator.getMonitoredServiceDao().get(m_dbPopulator.getNode2().getId(), InetAddressUtils.addr("192.168.2.1"), "ICMP");
// This requires every test method to have a new database instance :/
OnmsEvent event = m_dbPopulator.getEventDao().get(1);
// Put a resolved outage into the database so that one will match the
// filter below
OnmsOutage resolvedToday = new OnmsOutage(new Date(), new Date(), event, event, svc2, null, null);
m_dbPopulator.getOutageDao().save(resolvedToday);
m_dbPopulator.getOutageDao().flush();
RegainedServiceDateAfterFilter filter = new RegainedServiceDateAfterFilter(yesterday());
OutageCriteria criteria = new OutageCriteria(filter);
Outage[] outages = m_daoOutageRepo.getMatchingOutages(criteria);
assertEquals(1, outages.length);
}
Aggregations