Search in sources :

Example 6 with MonitoringStateBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitoring.states.MonitoringStateBuilder in project genius by opendaylight.

the class AlivenessMonitorTest method testMonitorUnpause.

@Test
public void testMonitorUnpause() throws InterruptedException, ExecutionException {
    MonitorUnpauseInput input = new MonitorUnpauseInputBuilder().setMonitorId(2L).build();
    Optional<MonitoringState> optState = Optional.of(new MonitoringStateBuilder().setStatus(MonitorStatus.Paused).build());
    when(readWriteTx.read(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitoringState.class)))).thenReturn(Futures.immediateCheckedFuture(optState));
    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<MonitorProfile> optProfile = Optional.of(getTestMonitorProfile());
    when(readTx.read(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitorProfile.class)))).thenReturn(Futures.immediateCheckedFuture(optProfile));
    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));
    RpcResult<Void> result = alivenessMonitor.monitorUnpause(input).get();
    verify(readWriteTx).merge(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitoringState.class)), stateCaptor.capture());
    assertEquals(MonitorStatus.Started, stateCaptor.getValue().getStatus());
    assertTrue("Monitor unpause rpc result", result.isSuccessful());
}
Also used : MonitoringInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.configs.MonitoringInfo) MonitoringStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitoring.states.MonitoringStateBuilder) MonitorProfile(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profiles.MonitorProfile) MonitoringInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.configs.MonitoringInfoBuilder) MonitorUnpauseInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorUnpauseInputBuilder) MonitoringState(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitoring.states.MonitoringState) MonitoridKeyEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitorid.key.map.MonitoridKeyEntryBuilder) MonitorUnpauseInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorUnpauseInput) MonitoridKeyEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitorid.key.map.MonitoridKeyEntry) Test(org.junit.Test)

Example 7 with MonitoringStateBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitoring.states.MonitoringStateBuilder 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());
}
Also used : MonitoringInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.configs.MonitoringInfo) MonitoringStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitoring.states.MonitoringStateBuilder) MonitorProfile(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profiles.MonitorProfile) MonitoringInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.configs.MonitoringInfoBuilder) MonitorPauseInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorPauseInputBuilder) MonitoringState(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitoring.states.MonitoringState) MonitorPauseInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorPauseInput) MonitoridKeyEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitorid.key.map.MonitoridKeyEntryBuilder) MonitoridKeyEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitorid.key.map.MonitoridKeyEntry) Test(org.junit.Test)

Aggregations

MonitoringState (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitoring.states.MonitoringState)7 MonitoringStateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitoring.states.MonitoringStateBuilder)7 Optional (com.google.common.base.Optional)5 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)5 Semaphore (java.util.concurrent.Semaphore)4 MonitorProfile (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.profiles.MonitorProfile)4 FutureCallback (com.google.common.util.concurrent.FutureCallback)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 LivenessState (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.LivenessState)3 MonitoringInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.configs.MonitoringInfo)3 MonitoringInfoBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitor.configs.MonitoringInfoBuilder)3 MonitoridKeyEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitorid.key.map.MonitoridKeyEntry)3 MonitoridKeyEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.monitorid.key.map.MonitoridKeyEntryBuilder)3 Nonnull (javax.annotation.Nonnull)2 Test (org.junit.Test)2 MonitorPauseInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorPauseInput)2 MonitorUnpauseInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorUnpauseInput)2 Preconditions (com.google.common.base.Preconditions)1 Predicate (com.google.common.base.Predicate)1 Strings (com.google.common.base.Strings)1