X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fstatistics%2Fservices%2Fcompatibility%2FAbstractCompatibleStatServiceTest.java;h=16d7f35aa1a9598d961013fbf99be192efe49219;hb=b4f4b4b702e2ccd8a7c62fd2a5c184c5b1cbe665;hp=d6dccf17037816a9bc6fbe6ac31442043455be0a;hpb=52f1d136aff5568e9d9607e6a61e4ec128c962aa;p=openflowplugin.git diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java index d6dccf1703..16d7f35aa1 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/AbstractCompatibleStatServiceTest.java @@ -8,6 +8,9 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; + import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.ListenableFuture; import java.math.BigInteger; @@ -17,13 +20,12 @@ import org.junit.Assert; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Captor; -import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.device.DeviceState; import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator; import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey; @@ -31,8 +33,8 @@ import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.Event import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext; import org.opendaylight.openflowplugin.impl.statistics.services.AbstractStatsServiceTest; import org.opendaylight.openflowplugin.impl.statistics.services.AggregateFlowsInTableService; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder; @@ -64,6 +66,8 @@ public class AbstractCompatibleStatServiceTest extends AbstractStatsServiceTest @Mock private DeviceState deviceState; @Mock + private DeviceInfo deviceInfo; + @Mock private MessageTranslator translator; @Mock private GetFeaturesOutput featuresOutput; @@ -83,28 +87,26 @@ public class AbstractCompatibleStatServiceTest extends AbstractStatsServiceTest //NOOP } }; - final Answer closeRequestFutureAnswer = new Answer() { - @Override - public Void answer(InvocationOnMock invocation) throws Throwable { - rqContext.setResult(rpcResult); - rqContext.close(); - return null; - } + final Answer closeRequestFutureAnswer = invocation -> { + rqContext.setResult(rpcResult); + rqContext.close(); + return null; }; - Mockito.when(featuresOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); + Mockito.lenient().when(featuresOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); Mockito.when(rqContextStack.createRequestContext()).thenReturn(rqContext); - Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState); - Mockito.when(deviceState.getNodeId()).thenReturn(NODE_ID); - Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); - Mockito.when(deviceState.getFeatures()).thenReturn(featuresOutput); - Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(); - Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(Matchers.any(EventIdentifier.class)); + Mockito.lenient().when(deviceContext.getDeviceState()).thenReturn(deviceState); + Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo); + Mockito.when(deviceInfo.getNodeId()).thenReturn(NODE_ID); + Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); + Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(null); + Mockito.lenient().doAnswer(closeRequestFutureAnswer).when(multiMsgCollector) + .endCollecting(any(EventIdentifier.class)); Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider) - .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class)); + .commitEntry(eq(42L), requestInput.capture(), any(FutureCallback.class)); - Mockito.when(translatorLibrary.lookupTranslator(Matchers.any(TranslatorKey.class))).thenReturn(translator); + Mockito.when(translatorLibrary.lookupTranslator(any(TranslatorKey.class))).thenReturn(translator); service = AggregateFlowsInTableService.createWithOook(rqContextStack, deviceContext, new AtomicLong(20L)); } @@ -140,7 +142,7 @@ public class AbstractCompatibleStatServiceTest extends AbstractStatsServiceTest .setFlowCount(new Counter32(12L)) .setPacketCount(new Counter64(BigInteger.valueOf(13L))) .build(); - Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceState), Matchers.any())) + Mockito.when(translator.translate(any(MultipartReply.class), eq(deviceInfo), any())) .thenReturn(aggregatedStats); @@ -148,10 +150,10 @@ public class AbstractCompatibleStatServiceTest extends AbstractStatsServiceTest service.handleAndNotify(input, notificationPublishService); Assert.assertTrue(resultFuture.isDone()); - final RpcResult rpcResult = resultFuture.get(); - Assert.assertTrue(rpcResult.isSuccessful()); + final RpcResult result = resultFuture.get(); + Assert.assertTrue(result.isSuccessful()); Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType()); - Mockito.verify(notificationPublishService, Mockito.timeout(500)).offerNotification(Matchers.any(AggregateFlowStatisticsUpdate.class)); + Mockito.verify(notificationPublishService, Mockito.timeout(500)) + .offerNotification(any(AggregateFlowStatisticsUpdate.class)); } - -} \ No newline at end of file +}