import com.google.common.collect.Lists;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.lispflowmapping.lisp.serializer.MapNotifySerializer;
import org.opendaylight.lispflowmapping.lisp.serializer.MapRegisterSerializer;
import org.opendaylight.lispflowmapping.lisp.serializer.MapReplySerializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MessageType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotify;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container
- .MappingRecordBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list
- .MappingRecordItemBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregistermessage.MapRegister;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapregistermessage.MapRegisterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequestBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.GetStatsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.GetStatsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ResetStatsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ResetStatsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapNotifyInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRegisterInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapReplyInput;
/**
* Tests {@link LispSouthboundRPC#sendMapNotify} method.
- *
- * @throws ExecutionException
- * @throws InterruptedException
*/
@Test
public void sendMapNotifyTest_inputNotNull() throws ExecutionException, InterruptedException {
/**
* Tests {@link LispSouthboundRPC#sendMapNotify} method with null input.
- *
- * @throws ExecutionException
- * @throws InterruptedException
*/
@Test
public void sendMapNotifyTest_nullInput() throws ExecutionException, InterruptedException {
/**
* Tests {@link LispSouthboundRPC#sendMapReply} method.
- *
- * @throws ExecutionException
- * @throws InterruptedException
*/
@Test
public void sendMapReplyTest_inputNotNull() throws ExecutionException, InterruptedException {
/**
* Tests {@link LispSouthboundRPC#sendMapReply} method with null input.
- *
- * @throws ExecutionException
- * @throws InterruptedException
*/
@Test
public void sendMapReplyTest_nullInput() throws ExecutionException, InterruptedException {
/**
* Tests {@link LispSouthboundRPC#sendMapRequest} method.
- *
- * @throws ExecutionException
- * @throws InterruptedException
*/
@Test
public void sendMapRequestTest_inputNotNull() throws ExecutionException, InterruptedException {
/**
* Tests {@link LispSouthboundRPC#sendMapRequest} method with null input.
- *
- * @throws ExecutionException
- * @throws InterruptedException
*/
@Test
public void sendMapRequestTest_nullInput() throws ExecutionException, InterruptedException {
/**
* Tests {@link LispSouthboundRPC#sendMapRegister} method.
- *
- * @throws ExecutionException
- * @throws InterruptedException
*/
@Test
public void sendMapRegisterTest_inputNotNull() throws ExecutionException, InterruptedException {
/**
* Tests {@link LispSouthboundRPC#sendMapRegister} method with null input.
- *
- * @throws ExecutionException
- * @throws InterruptedException
*/
@Test
public void sendMapRegisterTest_nullInput() throws ExecutionException, InterruptedException {
/**
* Tests {@link LispSouthboundRPC#getStats} method.
- *
- * @throws ExecutionException
- * @throws InterruptedException
*/
@Test
public void getStatsTest() throws ExecutionException, InterruptedException {
- final LispSouthboundStats stats = new LispSouthboundStats();
+ final ConcurrentLispSouthboundStats stats = new ConcurrentLispSouthboundStats();
incrementAll(stats);
Mockito.when(lispSouthboundPlugin.getStats()).thenReturn(stats);
// result
- final ControlMessageStats resultStats = lispSouthboundRPC.getStats().get().getResult().getControlMessageStats();
+ final ControlMessageStats resultStats = lispSouthboundRPC.getStats(
+ Mockito.mock(GetStatsInput.class)).get().getResult().getControlMessageStats();
assertEquals(stats.getRx()[0], (long) resultStats.getControlMessage().get(0).getRxCount());
assertEquals(stats.getRx()[1], (long) resultStats.getControlMessage().get(1).getRxCount());
/**
* Tests {@link LispSouthboundRPC#getStats} method with null stats.
- *
- * @throws ExecutionException
- * @throws InterruptedException
*/
@Test
public void getStatsTest_withNullStats() throws ExecutionException, InterruptedException {
Mockito.when(lispSouthboundPlugin.getStats()).thenReturn(null);
- final Future<RpcResult<GetStatsOutput>> resultFuture = lispSouthboundRPC.getStats();
+ final Future<RpcResult<GetStatsOutput>> resultFuture = lispSouthboundRPC.getStats(
+ Mockito.mock(GetStatsInput.class));
final RpcResult<GetStatsOutput> rpcResult = resultFuture.get();
assertEquals(RPC_RESULT_ERROR.isSuccessful(), rpcResult.isSuccessful());
/**
* Tests {@link LispSouthboundRPC#resetStats} method.
- *
- * @throws ExecutionException
- * @throws InterruptedException
*/
@Test
public void resetStatsTest() throws ExecutionException, InterruptedException {
- final LispSouthboundStats stats = new LispSouthboundStats();
+ final ConcurrentLispSouthboundStats stats = new ConcurrentLispSouthboundStats();
incrementAll(stats);
Mockito.when(lispSouthboundPlugin.getStats()).thenReturn(stats);
- assertEquals(RPC_RESULT_SUCCESS.isSuccessful(), lispSouthboundRPC.resetStats().get().isSuccessful());
+ assertEquals(RPC_RESULT_SUCCESS.isSuccessful(), lispSouthboundRPC.resetStats(
+ Mockito.mock(ResetStatsInput.class)).get().isSuccessful());
for (long rx : stats.getRx()) {
assertEquals(0, rx);
/**
* Tests {@link LispSouthboundRPC#resetStats} method with null stats.
- *
- * @throws ExecutionException
- * @throws InterruptedException
*/
@Test
public void resetStatsTest_withNullStats() throws ExecutionException, InterruptedException {
Mockito.when(lispSouthboundPlugin.getStats()).thenReturn(null);
- final Future<RpcResult<Void>> resultFuture = lispSouthboundRPC.resetStats();
- final RpcResult<Void> rpcResult = resultFuture.get();
+ final Future<RpcResult<ResetStatsOutput>> resultFuture = lispSouthboundRPC.resetStats(
+ Mockito.mock(ResetStatsInput.class));
+ final RpcResult<ResetStatsOutput> rpcResult = resultFuture.get();
assertEquals(RPC_RESULT_ERROR.isSuccessful(), rpcResult.isSuccessful());
assertEquals(expectedMsg, rpcResult.getErrors().iterator().next().getMessage());
.setMappingRecordItem(Lists.newArrayList(getDefaultMappingRecordItem()));
}
- private static void incrementAll(LispSouthboundStats stats) {
+ private static void incrementAll(ConcurrentLispSouthboundStats stats) {
for (MessageType type : MessageType.values()) {
stats.incrementRx(type.getIntValue());
}