Bug-5543 - Bo: Update JUnit tests part 8 92/40692/4
authormiroslav.macko <miroslav.macko@pantheon.tech>
Wed, 22 Jun 2016 11:36:20 +0000 (13:36 +0200)
committerMiroslav Macko <miroslav.macko@pantheon.tech>
Thu, 30 Jun 2016 04:43:47 +0000 (04:43 +0000)
Added tests for openflowplugin-extension-nicira

Change-Id: I2dbce0294a8f0301aa6a1fa7554bb38ea018b1a0
Signed-off-by: miroslav.macko <miroslav.macko@pantheon.tech>
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/EthSrcConvertorTest.java [new file with mode: 0644]
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/EthTypeConvertorTest.java [new file with mode: 0644]
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc1ConvertorTest.java [new file with mode: 0644]
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc2ConvertorTest.java [new file with mode: 0644]
extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc3ConvertorTest.java [new file with mode: 0644]

diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/EthSrcConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/EthSrcConvertorTest.java
new file mode 100644 (file)
index 0000000..d22b3d6
--- /dev/null
@@ -0,0 +1,93 @@
+/**
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.extension.vendor.nicira.convertor.match;
+
+import static org.mockito.Mockito.when;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+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.yang.types.rev100924.MacAddress;
+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.eth.src.grouping.EthSrcValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.EthSrcCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.EthSrcCaseValueBuilder;
+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.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.NxmOfEthSrcKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.eth.src.grouping.NxmOfEthSrcBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+/**
+ * Test for {@link EthSrcConvertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class EthSrcConvertorTest {
+
+    @Mock
+    private Extension extension;
+    @Mock
+    private MatchEntry matchEntry;
+
+    private static final MacAddress MAC_ADDRESS =  MacAddress.getDefaultInstance("01:23:45:67:89:AB");
+
+    private EthSrcConvertor ethSrcConvertor;
+
+    @Before
+    public void setUp() throws Exception {
+        final NxmOfEthSrcBuilder nxmOfEthSrcBuilder = new NxmOfEthSrcBuilder()
+                .setMacAddress(MAC_ADDRESS);
+        final NxAugMatchNotifUpdateFlowStatsBuilder nxAugMatchNotifUpdateFlowStatsBuilder = new NxAugMatchNotifUpdateFlowStatsBuilder();
+        nxAugMatchNotifUpdateFlowStatsBuilder.setNxmOfEthSrc(nxmOfEthSrcBuilder.build());
+
+        final Augmentation<Extension> extensionAugmentation = nxAugMatchNotifUpdateFlowStatsBuilder.build();
+        when(extension.getAugmentation(Matchers.<Class<Augmentation<Extension>>>any())).thenReturn(extensionAugmentation);
+
+        ethSrcConvertor = new EthSrcConvertor();
+    }
+
+    @Test
+    public void testConvert() throws Exception {
+        final MatchEntry matchEntry = ethSrcConvertor.convert(extension);
+        Assert.assertEquals(MAC_ADDRESS, ((EthSrcCaseValue)matchEntry.getMatchEntryValue()).getEthSrcValues().getMacAddress());
+    }
+
+    @Test
+    public void testConvert1() throws Exception {
+        final EthSrcValuesBuilder ethSrcValuesBuilder = new EthSrcValuesBuilder()
+                .setMacAddress(MAC_ADDRESS);
+        final EthSrcCaseValueBuilder ethSrcCaseValueBuilder = new EthSrcCaseValueBuilder()
+                .setEthSrcValues(ethSrcValuesBuilder.build());
+
+        final EthSrcCaseValue ethSrcCaseValue = ethSrcCaseValueBuilder.build();
+
+        when(matchEntry.getMatchEntryValue()).thenReturn(ethSrcCaseValue);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = ethSrcConvertor.convert(matchEntry, MatchPath.PACKETRECEIVED_MATCH);
+        Assert.assertEquals(MAC_ADDRESS, ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmOfEthSrc().getMacAddress());
+        Assert.assertEquals(extensionAugment.getKey(), NxmOfEthSrcKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = ethSrcConvertor.convert(matchEntry, MatchPath.SWITCHFLOWREMOVED_MATCH);
+        Assert.assertEquals(MAC_ADDRESS, ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment1.getAugmentationObject()).getNxmOfEthSrc().getMacAddress());
+        Assert.assertEquals(extensionAugment.getKey(), NxmOfEthSrcKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = ethSrcConvertor.convert(matchEntry, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+        Assert.assertEquals(MAC_ADDRESS, ((NxAugMatchNotifUpdateFlowStats)extensionAugment2.getAugmentationObject()).getNxmOfEthSrc().getMacAddress());
+        Assert.assertEquals(extensionAugment.getKey(), NxmOfEthSrcKey.class);
+    }
+}
\ No newline at end of file
diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/EthTypeConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/EthTypeConvertorTest.java
new file mode 100644 (file)
index 0000000..9e92bf4
--- /dev/null
@@ -0,0 +1,93 @@
+/**
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.extension.vendor.nicira.convertor.match;
+
+import static org.mockito.Mockito.when;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+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.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.eth.type.grouping.EthTypeValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.EthTypeCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.EthTypeCaseValueBuilder;
+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.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.NxmOfEthTypeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.eth.type.grouping.NxmOfEthTypeBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+/**
+ * Test for {@link EthTypeConvertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class EthTypeConvertorTest {
+
+    @Mock
+    private Extension extension;
+    @Mock
+    private MatchEntry matchEntry;
+
+    private EthTypeConvertor ethTypeConvertor;
+
+    @Before
+    public void setUp() throws Exception {
+
+        final NxmOfEthTypeBuilder nxmOfEthTypeBuilder = new NxmOfEthTypeBuilder()
+                .setValue(1);
+        final NxAugMatchNotifUpdateFlowStatsBuilder nxAugMatchNotifUpdateFlowStatsBuilder = new NxAugMatchNotifUpdateFlowStatsBuilder();
+        nxAugMatchNotifUpdateFlowStatsBuilder.setNxmOfEthType(nxmOfEthTypeBuilder.build());
+
+        final Augmentation<Extension> extensionAugmentation = nxAugMatchNotifUpdateFlowStatsBuilder.build();
+        when(extension.getAugmentation(Matchers.<Class<Augmentation<Extension>>>any())).thenReturn(extensionAugmentation);
+
+        ethTypeConvertor = new EthTypeConvertor();
+
+    }
+
+    @Test
+    public void testConvert() throws Exception {
+        final MatchEntry matchEntry = ethTypeConvertor.convert(extension);
+        Assert.assertEquals(1, ((EthTypeCaseValue)matchEntry.getMatchEntryValue()).getEthTypeValues().getValue().intValue());
+    }
+
+    @Test
+    public void testConvert1() throws Exception {
+        final EthTypeValuesBuilder ethTypeValuesBuilder = new EthTypeValuesBuilder()
+                .setValue(Integer.valueOf(1));
+        final EthTypeCaseValueBuilder ethTypeCaseValueBuilder = new EthTypeCaseValueBuilder()
+                .setEthTypeValues(ethTypeValuesBuilder.build());
+
+        final EthTypeCaseValue ethTypeCaseValue = ethTypeCaseValueBuilder.build();
+
+        when(matchEntry.getMatchEntryValue()).thenReturn(ethTypeCaseValue);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = ethTypeConvertor.convert(matchEntry, MatchPath.PACKETRECEIVED_MATCH);
+        Assert.assertEquals(1, ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmOfEthType().getValue().intValue());
+        Assert.assertEquals(extensionAugment.getKey(), NxmOfEthTypeKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = ethTypeConvertor.convert(matchEntry, MatchPath.SWITCHFLOWREMOVED_MATCH);
+        Assert.assertEquals(1, ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment1.getAugmentationObject()).getNxmOfEthType().getValue().intValue());
+        Assert.assertEquals(extensionAugment.getKey(), NxmOfEthTypeKey.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = ethTypeConvertor.convert(matchEntry, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+        Assert.assertEquals(1, ((NxAugMatchNotifUpdateFlowStats)extensionAugment2.getAugmentationObject()).getNxmOfEthType().getValue().intValue());
+        Assert.assertEquals(extensionAugment.getKey(), NxmOfEthTypeKey.class);
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc1ConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc1ConvertorTest.java
new file mode 100644 (file)
index 0000000..088ba52
--- /dev/null
@@ -0,0 +1,91 @@
+/**
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.extension.vendor.nicira.convertor.match;
+
+import static org.mockito.Mockito.when;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+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.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._1.grouping.Nshc1ValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc1CaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc1CaseValueBuilder;
+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.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.NxmNxNshc1Key;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._1.grouping.NxmNxNshc1Builder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+/**
+ * Test for {@link Nshc1Convertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class Nshc1ConvertorTest {
+
+    @Mock
+    private Extension extension;
+    @Mock
+    private MatchEntry matchEntry;
+
+    private Nshc1Convertor nshc1Convertor;
+
+    @Before
+    public void setUp() throws Exception {
+        final NxmNxNshc1Builder nxmNxNshc1Builder = new NxmNxNshc1Builder()
+                .setValue(1L);
+        final NxAugMatchNotifUpdateFlowStatsBuilder nxAugMatchNotifUpdateFlowStatsBuilder = new NxAugMatchNotifUpdateFlowStatsBuilder();
+        nxAugMatchNotifUpdateFlowStatsBuilder.setNxmNxNshc1(nxmNxNshc1Builder.build());
+
+        final Augmentation<Extension> extensionAugmentation = nxAugMatchNotifUpdateFlowStatsBuilder.build();
+        when(extension.getAugmentation(Matchers.<Class<Augmentation<Extension>>>any())).thenReturn(extensionAugmentation);
+
+        nshc1Convertor = new Nshc1Convertor();
+    }
+
+    @Test
+    public void testConvert() throws Exception {
+        final MatchEntry matchEntry = nshc1Convertor.convert(extension);
+        Assert.assertEquals(1, ((Nshc1CaseValue)matchEntry.getMatchEntryValue()).getNshc1Values().getNshc().intValue());
+    }
+
+    @Test
+    public void testConvert1() throws Exception {
+        final Nshc1ValuesBuilder nshc1ValuesBuilder = new Nshc1ValuesBuilder()
+                .setNshc(Long.valueOf(1));
+        final Nshc1CaseValueBuilder nshc1CaseValueBuilder = new Nshc1CaseValueBuilder()
+                .setNshc1Values(nshc1ValuesBuilder.build());
+
+        final Nshc1CaseValue nshc1CaseValue = nshc1CaseValueBuilder.build();
+
+        when(matchEntry.getMatchEntryValue()).thenReturn(nshc1CaseValue);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = nshc1Convertor.convert(matchEntry, MatchPath.PACKETRECEIVED_MATCH);
+        Assert.assertEquals(1, ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmNxNshc1().getValue().intValue());
+        Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc1Key.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = nshc1Convertor.convert(matchEntry, MatchPath.SWITCHFLOWREMOVED_MATCH);
+        Assert.assertEquals(1, ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment1.getAugmentationObject()).getNxmNxNshc1().getValue().intValue());
+        Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc1Key.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = nshc1Convertor.convert(matchEntry, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+        Assert.assertEquals(1, ((NxAugMatchNotifUpdateFlowStats)extensionAugment2.getAugmentationObject()).getNxmNxNshc1().getValue().intValue());
+        Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc1Key.class);
+    }
+
+}
\ No newline at end of file
diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc2ConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc2ConvertorTest.java
new file mode 100644 (file)
index 0000000..d0c5949
--- /dev/null
@@ -0,0 +1,91 @@
+/**
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.extension.vendor.nicira.convertor.match;
+
+import static org.mockito.Mockito.when;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+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.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._2.grouping.Nshc2ValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc2CaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc2CaseValueBuilder;
+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.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.NxmNxNshc2Key;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._2.grouping.NxmNxNshc2Builder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+/**
+ * Test for {@link Nshc2Convertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class Nshc2ConvertorTest {
+    @Mock
+    private Extension extension;
+    @Mock
+    private MatchEntry matchEntry;
+
+    private Nshc2Convertor nshc2Convertor;
+
+    @Before
+    public void setUp() throws Exception {
+        final NxmNxNshc2Builder nxmNxNshc2Builder = new NxmNxNshc2Builder()
+                .setValue(1L);
+        final NxAugMatchNotifUpdateFlowStatsBuilder nxAugMatchNotifUpdateFlowStatsBuilder = new NxAugMatchNotifUpdateFlowStatsBuilder();
+        nxAugMatchNotifUpdateFlowStatsBuilder.setNxmNxNshc2(nxmNxNshc2Builder.build());
+
+        final Augmentation<Extension> extensionAugmentation = nxAugMatchNotifUpdateFlowStatsBuilder.build();
+        when(extension.getAugmentation(Matchers.<Class<Augmentation<Extension>>>any())).thenReturn(extensionAugmentation);
+
+        nshc2Convertor = new Nshc2Convertor();
+    }
+
+    @Test
+    public void testConvert() throws Exception {
+        final MatchEntry matchEntry = nshc2Convertor.convert(extension);
+        Assert.assertEquals(1, ((Nshc2CaseValue)matchEntry.getMatchEntryValue()).getNshc2Values().getNshc().intValue());
+    }
+
+    @Test
+    public void testConvert1() throws Exception {
+        final Nshc2ValuesBuilder nshc2ValuesBuilder = new Nshc2ValuesBuilder()
+                .setNshc(Long.valueOf(1));
+        final Nshc2CaseValueBuilder nshc2CaseValueBuilder = new Nshc2CaseValueBuilder()
+                .setNshc2Values(nshc2ValuesBuilder.build());
+
+        final Nshc2CaseValue nshc2CaseValue = nshc2CaseValueBuilder.build();
+
+        when(matchEntry.getMatchEntryValue()).thenReturn(nshc2CaseValue);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = nshc2Convertor.convert(matchEntry, MatchPath.PACKETRECEIVED_MATCH);
+        Assert.assertEquals(1, ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmNxNshc2().getValue().intValue());
+        Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc2Key.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = nshc2Convertor.convert(matchEntry, MatchPath.SWITCHFLOWREMOVED_MATCH);
+        Assert.assertEquals(1, ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment1.getAugmentationObject()).getNxmNxNshc2().getValue().intValue());
+        Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc2Key.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = nshc2Convertor.convert(matchEntry, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+        Assert.assertEquals(1, ((NxAugMatchNotifUpdateFlowStats)extensionAugment2.getAugmentationObject()).getNxmNxNshc2().getValue().intValue());
+        Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc2Key.class);
+    }
+
+
+}
\ No newline at end of file
diff --git a/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc3ConvertorTest.java b/extension/openflowplugin-extension-nicira/src/test/java/org/opendaylight/openflowplugin/extension/vendor/nicira/convertor/match/Nshc3ConvertorTest.java
new file mode 100644 (file)
index 0000000..3fa4928
--- /dev/null
@@ -0,0 +1,91 @@
+/**
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.extension.vendor.nicira.convertor.match;
+
+import static org.mockito.Mockito.when;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+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.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.nshc._3.grouping.Nshc3ValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc3CaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc3CaseValueBuilder;
+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.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.NxmNxNshc3Key;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.nshc._3.grouping.NxmNxNshc3Builder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+/**
+ * Test for {@link Nshc3Convertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class Nshc3ConvertorTest {
+
+    @Mock
+    private Extension extension;
+    @Mock
+    private MatchEntry matchEntry;
+
+    private Nshc3Convertor nshc3Convertor;
+
+    @Before
+    public void setUp() throws Exception {
+        final NxmNxNshc3Builder nxmNxNshc3Builder = new NxmNxNshc3Builder()
+                .setValue(1L);
+        final NxAugMatchNotifUpdateFlowStatsBuilder nxAugMatchNotifUpdateFlowStatsBuilder = new NxAugMatchNotifUpdateFlowStatsBuilder();
+        nxAugMatchNotifUpdateFlowStatsBuilder.setNxmNxNshc3(nxmNxNshc3Builder.build());
+
+        final Augmentation<Extension> extensionAugmentation = nxAugMatchNotifUpdateFlowStatsBuilder.build();
+        when(extension.getAugmentation(Matchers.<Class<Augmentation<Extension>>>any())).thenReturn(extensionAugmentation);
+
+        nshc3Convertor = new Nshc3Convertor();
+    }
+
+    @Test
+    public void testConvert() throws Exception {
+        final MatchEntry matchEntry = nshc3Convertor.convert(extension);
+        Assert.assertEquals(1, ((Nshc3CaseValue)matchEntry.getMatchEntryValue()).getNshc3Values().getNshc().intValue());
+    }
+
+    @Test
+    public void testConvert1() throws Exception {
+        final Nshc3ValuesBuilder nshc3ValuesBuilder = new Nshc3ValuesBuilder()
+                .setNshc(Long.valueOf(1));
+        final Nshc3CaseValueBuilder nshc3CaseValueBuilder = new Nshc3CaseValueBuilder()
+                .setNshc3Values(nshc3ValuesBuilder.build());
+
+        final Nshc3CaseValue nshc3CaseValue = nshc3CaseValueBuilder.build();
+
+        when(matchEntry.getMatchEntryValue()).thenReturn(nshc3CaseValue);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = nshc3Convertor.convert(matchEntry, MatchPath.PACKETRECEIVED_MATCH);
+        Assert.assertEquals(1, ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmNxNshc3().getValue().intValue());
+        Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc3Key.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = nshc3Convertor.convert(matchEntry, MatchPath.SWITCHFLOWREMOVED_MATCH);
+        Assert.assertEquals(1, ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment1.getAugmentationObject()).getNxmNxNshc3().getValue().intValue());
+        Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc3Key.class);
+
+        final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = nshc3Convertor.convert(matchEntry, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+        Assert.assertEquals(1, ((NxAugMatchNotifUpdateFlowStats)extensionAugment2.getAugmentationObject()).getNxmNxNshc3().getValue().intValue());
+        Assert.assertEquals(extensionAugment.getKey(), NxmNxNshc3Key.class);
+    }
+
+}
\ No newline at end of file