use of org.opennms.netmgt.model.DemandPoll in project opennms by OpenNMS.
the class DefaultDemandPollService method pollMonitoredService.
@Override
public DemandPoll pollMonitoredService(final int nodeId, final InetAddress ipAddr, final int ifIndex, final int serviceId) {
final DemandPoll demandPoll = new DemandPoll();
demandPoll.setRequestTime(new Date());
m_demandPollDao.save(demandPoll);
final OnmsMonitoredService monSvc = m_monitoredServiceDao.get(nodeId, ipAddr, ifIndex, serviceId);
if (monSvc == null) {
throw new RuntimeException("Service doesn't exist: " + monSvc);
}
m_pollerService.poll(monSvc, demandPoll.getId());
return demandPoll;
}
use of org.opennms.netmgt.model.DemandPoll in project opennms by OpenNMS.
the class DemandPollServiceTest method testPollMonitoredService.
public void testPollMonitoredService() throws EventProxyException {
final int expectedResultId = m_pollStore.getExpectedId();
// anticipate a call to the dao save with a pollResult
m_demandPollDao.save(isA(DemandPoll.class));
expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
DemandPoll poll = (DemandPoll) getCurrentArguments()[0];
m_pollStore.save(poll);
return null;
}
});
OnmsServiceType svcType = new OnmsServiceType();
svcType.setId(3);
svcType.setName("HTTP");
OnmsNode node = new OnmsNode();
node.setId(1);
OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(node, 1);
OnmsIpInterface iface = new OnmsIpInterface("192.168.1.1", node);
iface.setSnmpInterface(snmpIface);
OnmsMonitoredService monSvc = new OnmsMonitoredService(iface, svcType);
expect(m_monitoredServiceDao.get(1, addr("192.168.1.1"), 1, 3)).andReturn(monSvc);
m_pollerService.poll(monSvc, expectedResultId);
replay(m_demandPollDao);
replay(m_monitoredServiceDao);
replay(m_pollerService);
DemandPoll result = m_demandPollService.pollMonitoredService(1, addr("192.168.1.1"), 1, 3);
verify(m_demandPollDao);
verify(m_monitoredServiceDao);
verify(m_pollerService);
assertNotNull("Null is an invalid response from pollMonitoredService", result);
assertEquals("Expected Id to be set by dao", expectedResultId, result.getId().intValue());
}
use of org.opennms.netmgt.model.DemandPoll in project opennms by OpenNMS.
the class DefaultPollServiceIntegrationIT method testPollMonitoredService.
/**
* this is a feature that has not been written yet
*/
@Test
@Ignore
public void testPollMonitoredService() {
final PollerService api = createMock(PollerService.class);
((DefaultDemandPollService) m_demandPollService).setPollerAPI(api);
final DemandPoll poll = m_demandPollService.pollMonitoredService(1, addr("192.168.2.100"), 1, 1);
assertNotNull("DemandPoll should not be null", poll);
assertTrue("Polled service addr doesn't match...", poll.getId() >= 1);
}
use of org.opennms.netmgt.model.DemandPoll in project opennms by OpenNMS.
the class DemandPollServiceTest method testGetUpdatedResults.
public void testGetUpdatedResults() {
final int resultId = 3;
DemandPoll expectedResult = new DemandPoll();
expect(m_demandPollDao.get(resultId)).andReturn(expectedResult);
replay(m_demandPollDao);
DemandPoll result = m_demandPollService.getUpdatedResults(resultId);
verify(m_demandPollDao);
assertEquals(expectedResult, result);
}
Aggregations