use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorPauseInputBuilder in project genius by opendaylight.
the class AlivenessMonitorTest method testMonitorPause.
@Test
public void testMonitorPause() throws InterruptedException, ExecutionException {
MonitorPauseInput input = new MonitorPauseInputBuilder().setMonitorId(2L).build();
Optional<MonitorProfile> optProfile = Optional.of(getTestMonitorProfile());
when(readTx.read(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitorProfile.class)))).thenReturn(Futures.immediateCheckedFuture(optProfile));
Optional<MonitoringInfo> optInfo = Optional.of(new MonitoringInfoBuilder().setId(2L).setProfileId(1L).build());
when(readTx.read(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitoringInfo.class)))).thenReturn(Futures.immediateCheckedFuture(optInfo));
Optional<MonitoringState> optState = Optional.of(new MonitoringStateBuilder().setStatus(MonitorStatus.Started).build());
when(readWriteTx.read(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitoringState.class)))).thenReturn(Futures.immediateCheckedFuture(optState));
Optional<MonitoridKeyEntry> optMap = Optional.of(new MonitoridKeyEntryBuilder().setMonitorId(2L).setMonitorKey("Test monitor Key").build());
when(readTx.read(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitoridKeyEntry.class)))).thenReturn(Futures.immediateCheckedFuture(optMap));
alivenessMonitor.monitorPause(input).get();
verify(readWriteTx).merge(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitoringState.class)), stateCaptor.capture());
assertEquals(MonitorStatus.Paused, stateCaptor.getValue().getStatus());
}
Aggregations