X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fstatistics%2Fservices%2FGetFlowTablesStatisticsImplTest.java;fp=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fstatistics%2Fservices%2FOpendaylightFlowTableStatisticsServiceImplTest.java;h=9cbb4b6471b1ee9a09a4af72607be7c52e03c85a;hb=3ee047a21cbd0754dabaab6d01708d5c20be80fd;hp=0c33acdf4bfb17f357fb91531a72d84417783640;hpb=73776c548ab153dee35ca4165ca0ef2413969704;p=openflowplugin.git diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/GetFlowTablesStatisticsImplTest.java similarity index 60% rename from openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImplTest.java rename to openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/GetFlowTablesStatisticsImplTest.java index 0c33acdf4b..9cbb4b6471 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowTableStatisticsServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/GetFlowTablesStatisticsImplTest.java @@ -7,68 +7,67 @@ */ package org.opendaylight.openflowplugin.impl.statistics.services; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.verify; import com.google.common.util.concurrent.FutureCallback; -import java.util.Collections; -import java.util.concurrent.Future; +import java.util.List; import java.util.concurrent.atomic.AtomicLong; -import org.junit.Assert; import org.junit.Test; import org.mockito.ArgumentCaptor; -import org.mockito.ArgumentMatchers; import org.mockito.Captor; -import org.mockito.Mockito; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTableBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCase; -import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint64; import org.opendaylight.yangtools.yang.common.Uint8; /** - * Test for {@link OpendaylightFlowTableStatisticsServiceImpl}. + * Test for {@link GetFlowTablesStatisticsImpl}. */ -public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractSingleStatsServiceTest { +@Deprecated +public class GetFlowTablesStatisticsImplTest extends AbstractSingleStatsServiceTest { private static final Uint8 TABLE_ID = Uint8.valueOf(123); @Captor private ArgumentCaptor requestInput; - private OpendaylightFlowTableStatisticsServiceImpl flowTableStatisticsService; + private GetFlowTablesStatisticsImpl getFlowTablesStatistics; @Override public void setUp() { - flowTableStatisticsService = new OpendaylightFlowTableStatisticsServiceImpl(rqContextStack, deviceContext, - new AtomicLong(), notificationPublishService); + getFlowTablesStatistics = new GetFlowTablesStatisticsImpl(rqContextStack, deviceContext, new AtomicLong(), + notificationPublishService); } @Test public void testGetFlowTablesStatistics() throws Exception { - Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider) + doAnswer(answerVoidToCallback).when(outboundQueueProvider) .commitEntry(eq(Uint32.valueOf(42)), requestInput.capture(), any(FutureCallback.class)); - GetFlowTablesStatisticsInputBuilder input = new GetFlowTablesStatisticsInputBuilder() + var input = new GetFlowTablesStatisticsInputBuilder() .setNode(createNodeRef("unitProt:123")); - rpcResult = RpcResultBuilder.success(Collections.singletonList( + rpcResult = RpcResultBuilder.success(List.of( new MultipartReplyMessageBuilder() .setVersion(EncodeConstants.OF_VERSION_1_3) .setMultipartReplyBody(new MultipartReplyTableCaseBuilder() .setMultipartReplyTable(new MultipartReplyTableBuilder() - .setTableStats(Collections.singletonList(new TableStatsBuilder() + .setTableStats(List.of(new TableStatsBuilder() .setActiveCount(Uint32.valueOf(31)) .setLookupCount(Uint64.valueOf(32)) .setMatchedCount(Uint64.valueOf(33)) @@ -83,29 +82,27 @@ public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractSing .build() )).build(); - final Future> resultFuture - = flowTableStatisticsService.getFlowTablesStatistics(input.build()); + final var resultFuture = getFlowTablesStatistics.invoke(input.build()); - Assert.assertTrue(resultFuture.isDone()); - final RpcResult rpcResult = resultFuture.get(); - Assert.assertTrue(rpcResult.isSuccessful()); - Assert.assertEquals(MultipartType.OFPMPTABLE, requestInput.getValue().getType()); + assertTrue(resultFuture.isDone()); + final var rpcResult = resultFuture.get(); + assertTrue(rpcResult.isSuccessful()); + assertEquals(MultipartType.OFPMPTABLE, requestInput.getValue().getType()); - Mockito.verify(notificationPublishService).offerNotification(ArgumentMatchers.any()); + verify(notificationPublishService).offerNotification(any()); } @Test public void testBuildRequest() { - Xid xid = new Xid(Uint32.valueOf(42L)); - GetFlowTablesStatisticsInputBuilder input = new GetFlowTablesStatisticsInputBuilder() + final var xid = new Xid(Uint32.valueOf(42L)); + final var input = new GetFlowTablesStatisticsInputBuilder() .setNode(createNodeRef("unitProt:123")); - final OfHeader request = flowTableStatisticsService.buildRequest(xid, input.build()); - Assert.assertTrue(request instanceof MultipartRequestInput); - final MultipartRequestInput mpRequest = (MultipartRequestInput) request; - Assert.assertEquals(MultipartType.OFPMPTABLE, mpRequest.getType()); - Assert.assertTrue(mpRequest.getMultipartRequestBody() instanceof MultipartRequestTableCase); - final MultipartRequestTableCase mpRequestBody = - (MultipartRequestTableCase) mpRequest.getMultipartRequestBody(); - Assert.assertNotNull(mpRequestBody.getMultipartRequestTable().getEmpty()); + final var request = getFlowTablesStatistics.buildRequest(xid, input.build()); + assertTrue(request instanceof MultipartRequestInput); + final var mpRequest = (MultipartRequestInput) request; + assertEquals(MultipartType.OFPMPTABLE, mpRequest.getType()); + assertTrue(mpRequest.getMultipartRequestBody() instanceof MultipartRequestTableCase); + final var mpRequestBody = (MultipartRequestTableCase) mpRequest.getMultipartRequestBody(); + assertNotNull(mpRequestBody.getMultipartRequestTable().getEmpty()); } }