@Before
 public void setUp() throws Exception {
   m_filterDao = new TestFilterDao();
   m_monitoredServiceDao = new TestMonitoredServiceDao();
   m_snmpConfigDao = new TestSnmpConfigDao();
   m_configResource = new AgentConfigurationResource();
   m_configResource.setCollectdConfigurationResource(
       new JaxbResourceConfiguration<CollectdConfiguration>(
           CollectdConfiguration.class,
           new ClassPathResource("/config-rest/collectd-configuration.xml")));
   m_configResource.setFilterDao(m_filterDao);
   m_configResource.setMonitoredServiceDao(m_monitoredServiceDao);
   m_configResource.setAgentConfigFactory(m_snmpConfigDao);
   m_configResource.afterPropertiesSet();
 }
  @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(null, "foo");
    node.setId(1);
    node.setForeignSource("foo");
    node.setForeignId("bar");
    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 GenericEntity<?>);
    @SuppressWarnings("unchecked")
    final List<AgentResponse> agentResponses =
        (List<AgentResponse>) ((GenericEntity<?>) entity).getEntity();
    System.err.println(agentResponses);
    assertEquals(1, agentResponses.size());
    assertEquals(oneNinetyTwo, agentResponses.get(0).getAddress());
    assertEquals(1161, agentResponses.get(0).getPort().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"));
  }
 @Test(expected = WebApplicationException.class)
 public void testMissingFilter() throws Exception {
   m_configResource.getAgentsJson("foo", "SNMP");
 }
 @Test(expected = IllegalArgumentException.class)
 public void testInvalidInputs() throws Exception {
   m_configResource.getAgentsJson(null, null);
 }