use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class AlarmRestServiceIT method testAlarmClearAsRest.
@Test
@JUnitTemporaryDatabase
public void testAlarmClearAsRest() throws Exception {
setUser("ranger", new String[] { "ROLE_REST" });
final OnmsAlarm alarm = createAlarm(OnmsSeverity.MAJOR);
sendRequest(PUT, "/alarms/" + alarm.getId(), parseParamData("clear=true"), 204);
final String xml = sendRequest(GET, "/alarms/" + alarm.getId(), 200);
final OnmsAlarm fromRest = JaxbUtils.unmarshal(OnmsAlarm.class, xml);
assertEquals(fromRest.getSeverity(), OnmsSeverity.CLEARED);
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class AlarmRestServiceIT method testAlarmClearAsMobile.
@Test
@JUnitTemporaryDatabase
public void testAlarmClearAsMobile() throws Exception {
setUser("ranger", new String[] { "ROLE_MOBILE" });
final OnmsAlarm alarm = createAlarm(OnmsSeverity.MAJOR);
sendRequest(PUT, "/alarms/" + alarm.getId(), parseParamData("clear=true"), 204);
final String xml = sendRequest(GET, "/alarms/" + alarm.getId(), 200);
final OnmsAlarm fromRest = JaxbUtils.unmarshal(OnmsAlarm.class, xml);
assertEquals(fromRest.getSeverity(), OnmsSeverity.CLEARED);
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class AlarmRepositoryIT method testEscalateAlarms.
@Test
@JUnitTemporaryDatabase
public void testEscalateAlarms() {
int[] alarmIds = { 1 };
m_alarmRepo.escalateAlarms(alarmIds, "TestUser", new Date());
OnmsAlarm[] alarms = m_alarmRepo.getMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AlarmIdFilter(1))));
assertNotNull(alarms);
assertEquals(OnmsSeverity.WARNING.getId(), alarms[0].getSeverity().getId());
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class AlarmRepositoryIT method testCountMatchingBySeverity.
@Test
@Transactional
@JUnitTemporaryDatabase
public void testCountMatchingBySeverity() {
int[] matchingAlarmCount = m_alarmRepo.countMatchingAlarmsBySeverity(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new SeverityFilter(OnmsSeverity.NORMAL))));
assertEquals(8, matchingAlarmCount.length);
}
use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.
the class AlarmRepositoryIT method testAcknowledgeUnacknowledge.
@Test
@JUnitTemporaryDatabase
public void testAcknowledgeUnacknowledge() {
String user = "TestUser";
m_alarmRepo.acknowledgeMatchingAlarms(user, new Date(), AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AlarmIdFilter(1))));
int matchingAlarmCount = m_alarmRepo.countMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AcknowledgedByFilter(user))));
assertEquals(1, matchingAlarmCount);
m_alarmRepo.unacknowledgeMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AlarmIdFilter(1))), user);
matchingAlarmCount = m_alarmRepo.countMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AcknowledgedByFilter(user))));
assertEquals(0, matchingAlarmCount);
}
Aggregations