use of org.springframework.transaction.annotation.Transactional in project opennms by OpenNMS.
the class DefaultSurveillanceServiceIntegrationIT method testCreateSurveillanceServiceTableUsingViewName.
@Test
@Transactional
public void testCreateSurveillanceServiceTableUsingViewName() {
String viewName = "default";
SimpleWebTable table = m_surveillanceService.createSurveillanceTable(viewName, new ProgressMonitor() {
@Override
public void beginNextPhase(String string) {
System.err.println("PHASE: " + string);
}
@Override
public void setPhaseCount(int i) {
}
});
assertEquals("default", table.getTitle());
}
use of org.springframework.transaction.annotation.Transactional in project opennms by OpenNMS.
the class AlarmRestServiceIT method testAlarmUpdates.
@Test
@Transactional
@JUnitTemporaryDatabase
public void testAlarmUpdates() throws Exception {
createAlarm(OnmsSeverity.MAJOR);
OnmsAlarm alarm = getLastAlarm();
alarm.setAlarmAckTime(null);
alarm.setAlarmAckUser(null);
getAlarmDao().saveOrUpdate(alarm);
final Integer alarmId = alarm.getId();
sendPut("/alarms", "ack=true&alarmId=" + alarmId, 204);
String xml = sendRequest(GET, "/alarms/" + alarmId, 200);
assertTrue(xml.contains("ackUser>admin<"));
sendPut("/alarms/" + alarmId, "clear=true", 204);
xml = sendRequest(GET, "/alarms/" + alarmId, 200);
assertTrue(xml.contains("severity=\"CLEARED\""));
sendPut("/alarms/" + alarmId, "escalate=true", 204);
xml = sendRequest(GET, "/alarms/" + alarmId, 200);
assertTrue(xml.contains("severity=\"NORMAL\""));
sendPut("/alarms/" + alarmId, "ticketId=12345", 204);
xml = sendRequest(GET, "/alarms/" + alarmId, 200);
assertTrue(xml.contains("<troubleTicket>12345</troubleTicket>"));
sendPut("/alarms/" + alarmId, "ticketState=UPDATE_PENDING", 204);
xml = sendRequest(GET, "/alarms/" + alarmId, 200);
sendPut("/alarms/" + alarmId, "ticketState=UPDATE_PENDING", 204);
alarm = getLastAlarm();
alarm.setSeverity(OnmsSeverity.MAJOR);
alarm.setAlarmAckTime(null);
alarm.setAlarmAckUser(null);
getAlarmDao().saveOrUpdate(alarm);
// Log in as a normal REST user and attempt to resolve an alarm as a different user.
// This should fail with a 403 forbidden.
setUser("foo", new String[] { "ROLE_REST" });
sendPut("/alarms/" + alarmId, "ack=true&ackUser=bar", 403);
}
use of org.springframework.transaction.annotation.Transactional 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.springframework.transaction.annotation.Transactional in project opennms by OpenNMS.
the class AlarmRepositoryFilterIT method testBeforeFirstEventTimeFilter.
@Test
@Transactional
@JUnitTemporaryDatabase
public void testBeforeFirstEventTimeFilter() {
OnmsAlarm[] alarms = m_daoAlarmRepo.getMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new BeforeFirstEventTimeFilter(new Date()))));
assertEquals(1, alarms.length);
alarms = m_daoAlarmRepo.getMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new BeforeLastEventTimeFilter(new Date()))));
assertEquals(1, alarms.length);
}
use of org.springframework.transaction.annotation.Transactional in project opennms by OpenNMS.
the class AlarmRepositoryIT method testSortAndSearchBySameProperty.
@Test
@Transactional
@JUnitTemporaryDatabase
public void testSortAndSearchBySameProperty() {
Filter[] filters = new Filter[] { new NodeNameLikeFilter("node") };
AlarmCriteria sorted = new AlarmCriteria(filters, SortStyle.NODE, AcknowledgeType.UNACKNOWLEDGED, 100, 0);
OnmsAlarm[] alarms = m_alarmRepo.getMatchingAlarms(AlarmUtil.getOnmsCriteria(sorted));
assertTrue("Failed to sort with style " + SortStyle.NODE, alarms.length > 0);
}
Aggregations