Search in sources :

Example 1 with LocationMonitorIdCommand

use of org.opennms.web.svclayer.model.LocationMonitorIdCommand in project opennms by OpenNMS.

the class DefaultDistributedPollerServiceTest method testDeleteLocationMonitorNullCommand.

public void testDeleteLocationMonitorNullCommand() {
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalStateException("command argument cannot be null"));
    LocationMonitorIdCommand command = new LocationMonitorIdCommand();
    BindException errors = new BindException(command, "command");
    replayMocks();
    try {
        m_distributedPollerService.deleteLocationMonitor(null, errors);
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
    verifyMocks();
}
Also used : LocationMonitorIdCommand(org.opennms.web.svclayer.model.LocationMonitorIdCommand) BindException(org.springframework.validation.BindException) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 2 with LocationMonitorIdCommand

use of org.opennms.web.svclayer.model.LocationMonitorIdCommand in project opennms by OpenNMS.

the class DefaultDistributedPollerServiceTest method testResumeLocationMonitorBindingErrors.

public void testResumeLocationMonitorBindingErrors() {
    LocationMonitorIdCommand command = new LocationMonitorIdCommand();
    BindException errors = new BindException(command, "command");
    errors.addError(new ObjectError("foo", null, null, "foo"));
    assertEquals("error count before pause", 1, errors.getErrorCount());
    replayMocks();
    m_distributedPollerService.resumeLocationMonitor(command, errors);
    verifyMocks();
    assertEquals("error count after pause", 1, errors.getErrorCount());
}
Also used : LocationMonitorIdCommand(org.opennms.web.svclayer.model.LocationMonitorIdCommand) ObjectError(org.springframework.validation.ObjectError) BindException(org.springframework.validation.BindException)

Example 3 with LocationMonitorIdCommand

use of org.opennms.web.svclayer.model.LocationMonitorIdCommand in project opennms by OpenNMS.

the class DefaultDistributedPollerServiceTest method testResumeLocationMonitorSuccess.

public void testResumeLocationMonitorSuccess() {
    OnmsLocationMonitor locationMonitor = new OnmsLocationMonitor();
    locationMonitor.setId(LOCATION_MONITOR_ID);
    locationMonitor.setStatus(MonitorStatus.PAUSED);
    expect(m_locationMonitorDao.load(locationMonitor.getId())).andReturn(locationMonitor);
    m_locationMonitorDao.update(locationMonitor);
    LocationMonitorIdCommand command = new LocationMonitorIdCommand();
    command.setMonitorId(LOCATION_MONITOR_ID);
    BindException errors = new BindException(command, "command");
    replayMocks();
    m_distributedPollerService.resumeLocationMonitor(command, errors);
    verifyMocks();
    assertEquals("error count", 0, errors.getErrorCount());
    assertEquals("new monitor status", MonitorStatus.STARTED, locationMonitor.getStatus());
}
Also used : LocationMonitorIdCommand(org.opennms.web.svclayer.model.LocationMonitorIdCommand) BindException(org.springframework.validation.BindException) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor)

Example 4 with LocationMonitorIdCommand

use of org.opennms.web.svclayer.model.LocationMonitorIdCommand in project opennms by OpenNMS.

the class DefaultDistributedPollerServiceTest method testPauseLocationMonitorNullBindException.

public void testPauseLocationMonitorNullBindException() {
    ThrowableAnticipator ta = new ThrowableAnticipator();
    ta.anticipate(new IllegalStateException("errors argument cannot be null"));
    LocationMonitorIdCommand command = new LocationMonitorIdCommand();
    replayMocks();
    try {
        m_distributedPollerService.pauseLocationMonitor(command, null);
    } catch (Throwable t) {
        ta.throwableReceived(t);
    }
    ta.verifyAnticipated();
    verifyMocks();
}
Also used : LocationMonitorIdCommand(org.opennms.web.svclayer.model.LocationMonitorIdCommand) ThrowableAnticipator(org.opennms.test.ThrowableAnticipator)

Example 5 with LocationMonitorIdCommand

use of org.opennms.web.svclayer.model.LocationMonitorIdCommand in project opennms by OpenNMS.

the class DefaultDistributedPollerServiceTest method testDeleteLocationMonitorBindingErrors.

public void testDeleteLocationMonitorBindingErrors() {
    LocationMonitorIdCommand command = new LocationMonitorIdCommand();
    BindException errors = new BindException(command, "command");
    errors.addError(new ObjectError("foo", null, null, "foo"));
    assertEquals("error count before pause", 1, errors.getErrorCount());
    replayMocks();
    m_distributedPollerService.deleteLocationMonitor(command, errors);
    verifyMocks();
    assertEquals("error count after pause", 1, errors.getErrorCount());
}
Also used : LocationMonitorIdCommand(org.opennms.web.svclayer.model.LocationMonitorIdCommand) ObjectError(org.springframework.validation.ObjectError) BindException(org.springframework.validation.BindException)

Aggregations

LocationMonitorIdCommand (org.opennms.web.svclayer.model.LocationMonitorIdCommand)15 BindException (org.springframework.validation.BindException)11 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)6 ThrowableAnticipator (org.opennms.test.ThrowableAnticipator)6 ObjectError (org.springframework.validation.ObjectError)5 DataAccessException (org.springframework.dao.DataAccessException)1 ObjectRetrievalFailureException (org.springframework.orm.ObjectRetrievalFailureException)1