X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=extension%2Fopenflowplugin-extension-nicira%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fextension%2Fvendor%2Fnicira%2Fconvertor%2Fmatch%2FUdpSrcConvertorTest.java;h=a73ec77162ed75ae44ff64a0fa9b51f8f6de7ff0;hb=b4f4b4b702e2ccd8a7c62fd2a5c184c5b1cbe665;hp=ce9d0ca2837f67bbfc7886fbef4d46a5ed2c0fdb;hpb=01f801a1a86ce4f8b2bc656196ef2b60eeafd593;p=openflowplugin.git diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpSrcConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpSrcConvertorTest.java index ce9d0ca283..a73ec77162 100644 --- a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpSrcConvertorTest.java +++ b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/UdpSrcConvertorTest.java @@ -14,21 +14,22 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Matchers; +import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowplugin.extension.api.ExtensionAugment; import org.opendaylight.openflowplugin.extension.api.path.MatchPath; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.udp.src.grouping.UdpSrcValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.UdpSrcCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.UdpSrcCaseValueBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNodesNodeTableFlowBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifPacketIn; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifSwitchFlowRemoved; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifUpdateFlowStats; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchNotifUpdateFlowStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxAugMatchRpcGetFlowStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfUdpSrcKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.udp.src.grouping.NxmOfUdpSrcBuilder; import org.opendaylight.yangtools.yang.binding.Augmentation; @@ -52,20 +53,24 @@ public class UdpSrcConvertorTest { final NxmOfUdpSrcBuilder nxmOfUdpSrcBuilder = new NxmOfUdpSrcBuilder() .setMask(1) .setPort(DEFAULT_PORT); - final NxAugMatchNotifUpdateFlowStatsBuilder nxAugMatchNotifUpdateFlowStatsBuilder = new NxAugMatchNotifUpdateFlowStatsBuilder(); + final NxAugMatchNodesNodeTableFlowBuilder nxAugMatchNotifUpdateFlowStatsBuilder = + new NxAugMatchNodesNodeTableFlowBuilder(); nxAugMatchNotifUpdateFlowStatsBuilder.setNxmOfUdpSrc(nxmOfUdpSrcBuilder.build()); final Augmentation extensionAugmentation = nxAugMatchNotifUpdateFlowStatsBuilder.build(); - when(extension.getAugmentation(Matchers.>>any())).thenReturn(extensionAugmentation); + when(extension.augmentation(ArgumentMatchers.>>any())) + .thenReturn(extensionAugmentation); udpSrcConvertor = new UdpSrcConvertor(); } @Test public void testConvert() throws Exception { - final MatchEntry matchEntry = udpSrcConvertor.convert(extension); - Assert.assertEquals(Integer.valueOf(1), ((UdpSrcCaseValue)matchEntry.getMatchEntryValue()).getUdpSrcValues().getMask()); - Assert.assertEquals(DEFAULT_PORT, ((UdpSrcCaseValue)matchEntry.getMatchEntryValue()).getUdpSrcValues().getPort()); + final MatchEntry converted = udpSrcConvertor.convert(extension); + Assert.assertEquals(Integer.valueOf(1), + ((UdpSrcCaseValue) converted.getMatchEntryValue()).getUdpSrcValues().getMask()); + Assert.assertEquals(DEFAULT_PORT, + ((UdpSrcCaseValue) converted.getMatchEntryValue()).getUdpSrcValues().getPort()); } @Test @@ -80,20 +85,37 @@ public class UdpSrcConvertorTest { when(matchEntry.getMatchEntryValue()).thenReturn(udpSrcCaseValue); - final ExtensionAugment> extensionAugment = udpSrcConvertor.convert(matchEntry, MatchPath.PACKETRECEIVED_MATCH); - Assert.assertEquals(Integer.valueOf(2), ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmOfUdpSrc().getMask()); - Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmOfUdpSrc().getPort()); + final ExtensionAugment> extensionAugment = udpSrcConvertor.convert(matchEntry, + MatchPath.PACKET_RECEIVED_MATCH); + Assert.assertEquals(Integer.valueOf(2), + ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmOfUdpSrc().getMask()); + Assert.assertEquals(DEFAULT_PORT, + ((NxAugMatchNotifPacketIn) extensionAugment.getAugmentationObject()).getNxmOfUdpSrc().getPort()); Assert.assertEquals(extensionAugment.getKey(), NxmOfUdpSrcKey.class); - final ExtensionAugment> extensionAugment1 = udpSrcConvertor.convert(matchEntry, MatchPath.SWITCHFLOWREMOVED_MATCH); - Assert.assertEquals(Integer.valueOf(2), ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment1.getAugmentationObject()).getNxmOfUdpSrc().getMask()); - Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment1.getAugmentationObject()).getNxmOfUdpSrc().getPort()); + final ExtensionAugment> extensionAugment1 = udpSrcConvertor + .convert(matchEntry, MatchPath.SWITCH_FLOW_REMOVED_MATCH); + Assert.assertEquals(Integer.valueOf(2), + ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()).getNxmOfUdpSrc() + .getMask()); + Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNotifSwitchFlowRemoved) extensionAugment1.getAugmentationObject()) + .getNxmOfUdpSrc().getPort()); Assert.assertEquals(extensionAugment.getKey(), NxmOfUdpSrcKey.class); - final ExtensionAugment> extensionAugment2 = udpSrcConvertor.convert(matchEntry, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH); - Assert.assertEquals(Integer.valueOf(2), ((NxAugMatchNotifUpdateFlowStats)extensionAugment2.getAugmentationObject()).getNxmOfUdpSrc().getMask()); - Assert.assertEquals(DEFAULT_PORT, ((NxAugMatchNotifUpdateFlowStats)extensionAugment2.getAugmentationObject()).getNxmOfUdpSrc().getPort()); + final ExtensionAugment> extensionAugment2 = udpSrcConvertor + .convert(matchEntry, MatchPath.FLOWS_STATISTICS_UPDATE_MATCH); + Assert.assertEquals(Integer.valueOf(2), + ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmOfUdpSrc().getMask()); + Assert.assertEquals(DEFAULT_PORT, + ((NxAugMatchNodesNodeTableFlow) extensionAugment2.getAugmentationObject()).getNxmOfUdpSrc().getPort()); Assert.assertEquals(extensionAugment.getKey(), NxmOfUdpSrcKey.class); - } -} \ No newline at end of file + final ExtensionAugment> extensionAugment3 = udpSrcConvertor + .convert(matchEntry, MatchPath.FLOWS_STATISTICS_RPC_MATCH); + Assert.assertEquals(Integer.valueOf(2), + ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmOfUdpSrc().getMask()); + Assert.assertEquals(DEFAULT_PORT, + ((NxAugMatchRpcGetFlowStats) extensionAugment3.getAugmentationObject()).getNxmOfUdpSrc().getPort()); + Assert.assertEquals(extensionAugment.getKey(), NxmOfUdpSrcKey.class); + } +}