use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileCreateInputBuilder in project genius by opendaylight.
the class AlivenessMonitorTest method testMonitorProfileCreate.
@Test
public void testMonitorProfileCreate() throws InterruptedException, ExecutionException {
MonitorProfileCreateInput input = new MonitorProfileCreateInputBuilder().setProfile(new ProfileBuilder().setFailureThreshold(10L).setMonitorInterval(10000L).setMonitorWindow(10L).setProtocolType(EtherTypes.Arp).build()).build();
doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(readWriteTx).read(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitorProfile.class)));
doReturn(Futures.immediateCheckedFuture(null)).when(readWriteTx).submit();
RpcResult<MonitorProfileCreateOutput> output = alivenessMonitor.monitorProfileCreate(input).get();
assertTrue("Monitor Profile Create result", output.isSuccessful());
assertNotNull("Monitor Profile Output", output.getResult().getProfileId());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileCreateInputBuilder in project genius by opendaylight.
the class AlivenessMonitorTest method createProfile.
@SuppressWarnings("unchecked")
private long createProfile() throws InterruptedException, ExecutionException {
MonitorProfileCreateInput input = new MonitorProfileCreateInputBuilder().setProfile(new ProfileBuilder().setFailureThreshold(10L).setMonitorInterval(10000L).setMonitorWindow(10L).setProtocolType(EtherTypes.Arp).build()).build();
doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(readWriteTx).read(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class));
doReturn(Futures.immediateCheckedFuture(null)).when(readWriteTx).submit();
RpcResult<MonitorProfileCreateOutput> output = alivenessMonitor.monitorProfileCreate(input).get();
return output.getResult().getProfileId();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.MonitorProfileCreateInputBuilder in project genius by opendaylight.
the class AlivenessMonitorTest method testMonitorProfileCreateAlreadyExist.
@Test
public void testMonitorProfileCreateAlreadyExist() throws InterruptedException, ExecutionException {
MonitorProfileCreateInput input = new MonitorProfileCreateInputBuilder().setProfile(new ProfileBuilder().setFailureThreshold(10L).setMonitorInterval(10000L).setMonitorWindow(10L).setProtocolType(EtherTypes.Arp).build()).build();
@SuppressWarnings("unchecked") Optional<MonitorProfile> optionalProfile = mock(Optional.class);
CheckedFuture<Optional<MonitorProfile>, ReadFailedException> proFuture = Futures.immediateCheckedFuture(optionalProfile);
doReturn(true).when(optionalProfile).isPresent();
doReturn(proFuture).when(readWriteTx).read(eq(LogicalDatastoreType.OPERATIONAL), argThat(isType(MonitorProfile.class)));
RpcResult<MonitorProfileCreateOutput> output = alivenessMonitor.monitorProfileCreate(input).get();
assertTrue("Monitor Profile Create result", output.isSuccessful());
assertThat(output.getErrors(), CoreMatchers.hasItem(hasErrorType(ErrorType.PROTOCOL)));
}
Aggregations