Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EventsRestService: provide an ability to filter by asset record or service type, for example: /opennms/rest/events?serviceType.name=ICMP /opennms/rest/events?assetRecord.zip=27312 OnmsIpInterfaceResource: provide an ability to filter by service type, for example: /opennms/rest/nodes/10/ipinterfaces?serviceType.name=ICMP NotificationRestService: provide an ability to filter by node, IP interface, SNMP interface, events, or users notified, for example: /opennms/rest/notifications?node.foreignSource=Routers /opennms/rest/notifications?ipInterface.ipAddress=10.10.10.10 /opennms/rest/notifications?snmpInterface.ifDescr=eth0 /opennms/rest/notifications?event.severity=5 /opennms/rest/notifications?usersNotified.userId=agalue
- Loading branch information
Showing
5 changed files
with
134 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
opennms-webapp/src/test/java/org/opennms/web/rest/NotificationRestServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/******************************************************************************* | ||
* This file is part of OpenNMS(R). | ||
* | ||
* Copyright (C) 2012 The OpenNMS Group, Inc. | ||
* OpenNMS(R) is Copyright (C) 1999-2012 The OpenNMS Group, Inc. | ||
* | ||
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc. | ||
* | ||
* OpenNMS(R) is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, | ||
* or (at your option) any later version. | ||
* | ||
* OpenNMS(R) is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with OpenNMS(R). If not, see: | ||
* http://www.gnu.org/licenses/ | ||
* | ||
* For more information contact: | ||
* OpenNMS(R) Licensing <license@opennms.org> | ||
* http://www.opennms.org/ | ||
* http://www.opennms.com/ | ||
*******************************************************************************/ | ||
|
||
package org.opennms.web.rest; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.opennms.core.test.MockLogAppender; | ||
import org.opennms.core.test.OpenNMSJUnit4ClassRunner; | ||
import org.opennms.core.test.db.annotations.JUnitTemporaryDatabase; | ||
import org.opennms.core.test.rest.AbstractSpringJerseyRestTestCase; | ||
import org.opennms.netmgt.dao.DatabasePopulator; | ||
import org.opennms.test.JUnitConfigurationEnvironment; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.web.WebAppConfiguration; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.context.WebApplicationContext; | ||
import org.springframework.web.context.support.WebApplicationContextUtils; | ||
|
||
@RunWith(OpenNMSJUnit4ClassRunner.class) | ||
@WebAppConfiguration | ||
@ContextConfiguration(locations={ | ||
"classpath:/org/opennms/web/rest/applicationContext-test.xml", | ||
"classpath:/META-INF/opennms/applicationContext-commonConfigs.xml", | ||
"classpath:/META-INF/opennms/applicationContext-soa.xml", | ||
"classpath:/META-INF/opennms/applicationContext-dao.xml", | ||
"classpath*:/META-INF/opennms/component-service.xml", | ||
"classpath*:/META-INF/opennms/component-dao.xml", | ||
"classpath:/META-INF/opennms/applicationContext-reportingCore.xml", | ||
"classpath:/META-INF/opennms/applicationContext-databasePopulator.xml", | ||
"classpath:/org/opennms/web/svclayer/applicationContext-svclayer.xml", | ||
"classpath:/META-INF/opennms/applicationContext-mockEventProxy.xml", | ||
"classpath:/applicationContext-jersey-test.xml", | ||
"classpath:/META-INF/opennms/applicationContext-reporting.xml", | ||
"classpath:/META-INF/opennms/applicationContext-mock-usergroup.xml", | ||
"classpath:/META-INF/opennms/applicationContext-minimal-conf.xml", | ||
"file:src/main/webapp/WEB-INF/applicationContext-spring-security.xml", | ||
"file:src/main/webapp/WEB-INF/applicationContext-jersey.xml" | ||
}) | ||
@JUnitConfigurationEnvironment | ||
@JUnitTemporaryDatabase | ||
@Transactional | ||
public class NotificationRestServiceTest extends AbstractSpringJerseyRestTestCase { | ||
private DatabasePopulator m_databasePopulator; | ||
|
||
@Override | ||
protected void afterServletStart() { | ||
MockLogAppender.setupLogging(true, "DEBUG"); | ||
final WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); | ||
m_databasePopulator = context.getBean("databasePopulator", DatabasePopulator.class); | ||
m_databasePopulator.populateDatabase(); | ||
} | ||
|
||
@Test | ||
public void testNotifications() throws Exception { | ||
String xml = sendRequest(GET, "/notifications", 200); | ||
assertTrue(xml.contains("This is a test notification")); | ||
} | ||
} |