X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fstatistics%2Fservices%2FOpendaylightFlowTableStatisticsServiceImplTest.java;h=0c33acdf4bfb17f357fb91531a72d84417783640;hb=73776c548ab153dee35ca4165ca0ef2413969704;hp=339bdbf76a60932c3c6bec77c17ccccddb15daed;hpb=9688b3b10ee4113753705f0080b29cd30e61a85d;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/OpendaylightFlowTableStatisticsServiceImplTest.java index 339bdbf76a..0c33acdf4b 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/OpendaylightFlowTableStatisticsServiceImplTest.java @@ -5,21 +5,22 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.statistics.services; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; + import com.google.common.util.concurrent.FutureCallback; -import java.math.BigInteger; import java.util.Collections; import java.util.concurrent.Future; 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.Matchers; import org.mockito.Mockito; -import org.opendaylight.openflowplugin.api.OFConstants; +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; @@ -31,21 +32,24 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 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.binding.Notification; 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}. */ public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractSingleStatsServiceTest { + private static final Uint8 TABLE_ID = Uint8.valueOf(123); - private static final Short TABLE_ID = (short) 123; @Captor private ArgumentCaptor requestInput; private OpendaylightFlowTableStatisticsServiceImpl flowTableStatisticsService; + @Override public void setUp() { flowTableStatisticsService = new OpendaylightFlowTableStatisticsServiceImpl(rqContextStack, deviceContext, new AtomicLong(), notificationPublishService); @@ -54,24 +58,24 @@ public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractSing @Test public void testGetFlowTablesStatistics() throws Exception { Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider) - .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class)); + .commitEntry(eq(Uint32.valueOf(42)), requestInput.capture(), any(FutureCallback.class)); GetFlowTablesStatisticsInputBuilder input = new GetFlowTablesStatisticsInputBuilder() .setNode(createNodeRef("unitProt:123")); rpcResult = RpcResultBuilder.success(Collections.singletonList( new MultipartReplyMessageBuilder() - .setVersion(OFConstants.OFP_VERSION_1_3) + .setVersion(EncodeConstants.OF_VERSION_1_3) .setMultipartReplyBody(new MultipartReplyTableCaseBuilder() .setMultipartReplyTable(new MultipartReplyTableBuilder() .setTableStats(Collections.singletonList(new TableStatsBuilder() - .setActiveCount(31L) - .setLookupCount(BigInteger.valueOf(32L)) - .setMatchedCount(BigInteger.valueOf(33L)) - .setMaxEntries(34L) + .setActiveCount(Uint32.valueOf(31)) + .setLookupCount(Uint64.valueOf(32)) + .setMatchedCount(Uint64.valueOf(33)) + .setMaxEntries(Uint32.valueOf(34)) .setName("test-table") - .setNwDstMask((short) 35) - .setNwSrcMask((short) 36) + .setNwDstMask(Uint8.valueOf(35)) + .setNwSrcMask(Uint8.valueOf(36)) .setTableId(TABLE_ID) .build())) .build()) @@ -87,12 +91,12 @@ public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractSing Assert.assertTrue(rpcResult.isSuccessful()); Assert.assertEquals(MultipartType.OFPMPTABLE, requestInput.getValue().getType()); - Mockito.verify(notificationPublishService).offerNotification(Matchers.any()); + Mockito.verify(notificationPublishService).offerNotification(ArgumentMatchers.any()); } @Test - public void testBuildRequest() throws Exception { - Xid xid = new Xid(42L); + public void testBuildRequest() { + Xid xid = new Xid(Uint32.valueOf(42L)); GetFlowTablesStatisticsInputBuilder input = new GetFlowTablesStatisticsInputBuilder() .setNode(createNodeRef("unitProt:123")); final OfHeader request = flowTableStatisticsService.buildRequest(xid, input.build()); @@ -101,7 +105,7 @@ public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractSing Assert.assertEquals(MultipartType.OFPMPTABLE, mpRequest.getType()); Assert.assertTrue(mpRequest.getMultipartRequestBody() instanceof MultipartRequestTableCase); final MultipartRequestTableCase mpRequestBody = - (MultipartRequestTableCase) (mpRequest.getMultipartRequestBody()); - Assert.assertTrue(mpRequestBody.getMultipartRequestTable().isEmpty()); + (MultipartRequestTableCase) mpRequest.getMultipartRequestBody(); + Assert.assertNotNull(mpRequestBody.getMultipartRequestTable().getEmpty()); } -} \ No newline at end of file +}