--- /dev/null
+/**
+ * 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.nx.match.arp.tha.grouping.ArpThaValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpThaCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpThaCaseValueBuilder;
+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.NxAugMatchRpcAddFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmNxArpThaKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.arp.tha.grouping.NxmNxArpThaBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+/**
+ * Test for {@link ArpThaConvertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class ArpThaConvertorTest {
+
+ @Mock
+ private Extension extension;
+ @Mock
+ private MatchEntry matchEntry;
+
+ private static final MacAddress MAC_ADDRESS = MacAddress.getDefaultInstance("01:23:45:67:89:AB");
+
+ private ArpThaConvertor arpThaConvertor;
+
+ @Before
+ public void setUp() throws Exception {
+
+ final NxmNxArpThaBuilder nxArpThaBuilder = new NxmNxArpThaBuilder()
+ .setMacAddress(MAC_ADDRESS);
+ final NxAugMatchRpcAddFlowBuilder nxAugMatchRpcAddFlowBuilder = new NxAugMatchRpcAddFlowBuilder()
+ .setNxmNxArpTha(nxArpThaBuilder.build());
+ final Augmentation<Extension> extensionAugmentation = nxAugMatchRpcAddFlowBuilder.build();
+
+ when(extension.getAugmentation(Matchers.<Class<Augmentation<Extension>>>any())).thenReturn(extensionAugmentation);
+
+ arpThaConvertor = new ArpThaConvertor();
+ }
+
+ @Test
+ public void testConvertToOFJava() throws Exception {
+ final MatchEntry matchEntry = arpThaConvertor.convert(extension);
+ Assert.assertEquals(MAC_ADDRESS.getValue(), ((ArpThaCaseValue)matchEntry.getMatchEntryValue()).getArpThaValues().getMacAddress().getValue());
+ }
+
+ @Test
+ public void testConvertFromOFJava() throws Exception {
+ final ArpThaValuesBuilder arpThaValuesBuilder = new ArpThaValuesBuilder()
+ .setMacAddress(MAC_ADDRESS);
+ final ArpThaCaseValueBuilder arpThaCaseValueBuilder = new ArpThaCaseValueBuilder()
+ .setArpThaValues(arpThaValuesBuilder.build());
+ final ArpThaCaseValue arpThaCaseValue = arpThaCaseValueBuilder.build();
+
+ when(matchEntry.getMatchEntryValue()).thenReturn(arpThaCaseValue);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = arpThaConvertor.convert(matchEntry, MatchPath.PACKETRECEIVED_MATCH);
+ Assert.assertEquals(arpThaCaseValue.getArpThaValues().getMacAddress(), ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmNxArpTha().getMacAddress());
+ Assert.assertEquals(extensionAugment.getKey(), NxmNxArpThaKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = arpThaConvertor.convert(matchEntry, MatchPath.SWITCHFLOWREMOVED_MATCH);
+ Assert.assertEquals(arpThaCaseValue.getArpThaValues().getMacAddress(), ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment1.getAugmentationObject()).getNxmNxArpTha().getMacAddress());
+ Assert.assertEquals(extensionAugment.getKey(), NxmNxArpThaKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = arpThaConvertor.convert(matchEntry, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+ Assert.assertEquals(arpThaCaseValue.getArpThaValues().getMacAddress(), ((NxAugMatchNotifUpdateFlowStats)extensionAugment2.getAugmentationObject()).getNxmNxArpTha().getMacAddress());
+ Assert.assertEquals(extensionAugment.getKey(), NxmNxArpThaKey.class);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * 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.openflowplugin.extension.vendor.nicira.convertor.IpConverter;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+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.arp.tpa.grouping.ArpTpaValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpTpaCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpTpaCaseValueBuilder;
+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.NxAugMatchRpcAddFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.NxmOfArpTpaKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.arp.tpa.grouping.NxmOfArpTpaBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+/**
+ * Test for {@link ArpTpaConvertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class ArpTpaConvertorTest {
+
+ @Mock
+ private Extension extension;
+ @Mock
+ private MatchEntry matchEntry;
+
+ private static final Ipv4Address IPV4_ADDRESS = Ipv4Address.getDefaultInstance("1.2.3.4");
+
+ private ArpTpaConvertor arpTpaConvertor;
+
+ @Before
+ public void setUp() throws Exception {
+
+ final NxmOfArpTpaBuilder nxmOfArpTpaBuilder = new NxmOfArpTpaBuilder()
+ .setIpv4Address(IPV4_ADDRESS);
+ final NxAugMatchRpcAddFlowBuilder nxAugMatchRpcAddFlowBuilder = new NxAugMatchRpcAddFlowBuilder();
+ nxAugMatchRpcAddFlowBuilder.setNxmOfArpTpa(nxmOfArpTpaBuilder.build());
+
+ final Augmentation<Extension> extensionAugmentation = nxAugMatchRpcAddFlowBuilder.build();
+ when(extension.getAugmentation(Matchers.<Class<Augmentation<Extension>>>any())).thenReturn(extensionAugmentation);
+
+ arpTpaConvertor = new ArpTpaConvertor();
+ }
+
+ @Test
+ public void testConvertFromOFJava() throws Exception {
+ final MatchEntry matchEntry = arpTpaConvertor.convert(extension);
+ Assert.assertEquals(IpConverter.Ipv4AddressToLong(IPV4_ADDRESS), ((ArpTpaCaseValue)matchEntry.getMatchEntryValue()).getArpTpaValues().getValue().longValue());
+ }
+
+ @Test
+ public void testConvertToOFJava() throws Exception {
+ final ArpTpaValuesBuilder arpTpaValuesBuilder = new ArpTpaValuesBuilder()
+ .setValue(IpConverter.Ipv4AddressToLong(IPV4_ADDRESS));
+ final ArpTpaCaseValueBuilder arpTpaCaseValueBuilder = new ArpTpaCaseValueBuilder()
+ .setArpTpaValues(arpTpaValuesBuilder.build());
+
+ final ArpTpaCaseValue arpTpaCaseValue = arpTpaCaseValueBuilder.build();
+
+ when(matchEntry.getMatchEntryValue()).thenReturn(arpTpaCaseValue);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = arpTpaConvertor.convert(matchEntry, MatchPath.PACKETRECEIVED_MATCH);
+ Assert.assertEquals(IPV4_ADDRESS, ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmOfArpTpa().getIpv4Address());
+ Assert.assertEquals(extensionAugment.getKey(), NxmOfArpTpaKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = arpTpaConvertor.convert(matchEntry, MatchPath.SWITCHFLOWREMOVED_MATCH);
+ Assert.assertEquals(IPV4_ADDRESS, ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment1.getAugmentationObject()).getNxmOfArpTpa().getIpv4Address());
+ Assert.assertEquals(extensionAugment.getKey(), NxmOfArpTpaKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = arpTpaConvertor.convert(matchEntry, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+ Assert.assertEquals(IPV4_ADDRESS, ((NxAugMatchNotifUpdateFlowStats)extensionAugment2.getAugmentationObject()).getNxmOfArpTpa().getIpv4Address());
+ Assert.assertEquals(extensionAugment.getKey(), NxmOfArpTpaKey.class);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * 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.ct.state.grouping.CtStateValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtStateCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtStateCaseValueBuilder;
+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.NxmNxCtStateKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.ct.state.grouping.NxmNxCtStateBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+/**
+ * Test for {@link CtStateConvertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class CtStateConvertorTest {
+
+ @Mock
+ private Extension extension;
+ @Mock
+ private MatchEntry matchEntry;
+
+ private CtStateConvertor ctStateConvertor;
+
+ @Before
+ public void setUp() throws Exception {
+
+ final NxmNxCtStateBuilder nxmNxCtStateBuilder = new NxmNxCtStateBuilder()
+ .setCtState(1L)
+ .setMask(2L);
+ final NxAugMatchNotifUpdateFlowStatsBuilder nxAugMatchNotifUpdateFlowStatsBuilder = new NxAugMatchNotifUpdateFlowStatsBuilder();
+ nxAugMatchNotifUpdateFlowStatsBuilder.setNxmNxCtState(nxmNxCtStateBuilder.build());
+
+ final Augmentation<Extension> extensionAugmentation = nxAugMatchNotifUpdateFlowStatsBuilder.build();
+ when(extension.getAugmentation(Matchers.<Class<Augmentation<Extension>>>any())).thenReturn(extensionAugmentation);
+
+ ctStateConvertor = new CtStateConvertor();
+ }
+
+ @Test
+ public void testConvert() throws Exception {
+ final MatchEntry matchEntry = ctStateConvertor.convert(extension);
+ Assert.assertEquals(1L, ((CtStateCaseValue)matchEntry.getMatchEntryValue()).getCtStateValues().getCtState().longValue());
+ Assert.assertEquals(2L, ((CtStateCaseValue)matchEntry.getMatchEntryValue()).getCtStateValues().getMask().longValue());
+ }
+
+ @Test
+ public void testConvert1() throws Exception {
+
+ final CtStateValuesBuilder ctStateValuesBuilder = new CtStateValuesBuilder()
+ .setCtState(3L)
+ .setMask(4L);
+ final CtStateCaseValueBuilder ctStateCaseValueBuilder = new CtStateCaseValueBuilder()
+ .setCtStateValues(ctStateValuesBuilder.build());
+
+ final CtStateCaseValue ctStateCaseValue = ctStateCaseValueBuilder.build();
+
+ when(matchEntry.getMatchEntryValue()).thenReturn(ctStateCaseValue);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = ctStateConvertor.convert(matchEntry, MatchPath.PACKETRECEIVED_MATCH);
+ Assert.assertEquals(3L, ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmNxCtState().getCtState().longValue());
+ Assert.assertEquals(4L, ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmNxCtState().getMask().longValue());
+ Assert.assertEquals(extensionAugment.getKey(), NxmNxCtStateKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = ctStateConvertor.convert(matchEntry, MatchPath.SWITCHFLOWREMOVED_MATCH);
+ Assert.assertEquals(3L, ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment1.getAugmentationObject()).getNxmNxCtState().getCtState().longValue());
+ Assert.assertEquals(4L, ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment1.getAugmentationObject()).getNxmNxCtState().getMask().longValue());Assert.assertEquals(extensionAugment.getKey(), NxmNxCtStateKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = ctStateConvertor.convert(matchEntry, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+ Assert.assertEquals(3L, ((NxAugMatchNotifUpdateFlowStats)extensionAugment2.getAugmentationObject()).getNxmNxCtState().getCtState().longValue());
+ Assert.assertEquals(4L, ((NxAugMatchNotifUpdateFlowStats)extensionAugment2.getAugmentationObject()).getNxmNxCtState().getMask().longValue());
+ Assert.assertEquals(extensionAugment.getKey(), NxmNxCtStateKey.class);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * 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.ct.zone.grouping.CtZoneValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtZoneCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtZoneCaseValueBuilder;
+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.NxmNxCtZoneKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.ct.zone.grouping.NxmNxCtZoneBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+/**
+ * Test for {@link CtZoneConvertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class CtZoneConvertorTest {
+
+ @Mock
+ private Extension extension;
+ @Mock
+ private MatchEntry matchEntry;
+
+ private CtZoneConvertor ctZoneConvertor;
+
+ @Before
+ public void setUp() throws Exception {
+
+ final NxmNxCtZoneBuilder nxmNxCtZoneBuilder = new NxmNxCtZoneBuilder()
+ .setCtZone(1);
+ final NxAugMatchNotifUpdateFlowStatsBuilder nxAugMatchNotifUpdateFlowStatsBuilder = new NxAugMatchNotifUpdateFlowStatsBuilder();
+ nxAugMatchNotifUpdateFlowStatsBuilder.setNxmNxCtZone(nxmNxCtZoneBuilder.build());
+
+ final Augmentation<Extension> extensionAugmentation = nxAugMatchNotifUpdateFlowStatsBuilder.build();
+ when(extension.getAugmentation(Matchers.<Class<Augmentation<Extension>>>any())).thenReturn(extensionAugmentation);
+
+ ctZoneConvertor = new CtZoneConvertor();
+
+ }
+
+ @Test
+ public void testConvert() throws Exception {
+ final MatchEntry matchEntry = ctZoneConvertor.convert(extension);
+ Assert.assertEquals(1L, ((CtZoneCaseValue)matchEntry.getMatchEntryValue()).getCtZoneValues().getCtZone().longValue());
+ }
+
+ @Test
+ public void testConvert1() throws Exception {
+ final CtZoneValuesBuilder ctZoneValuesBuilder = new CtZoneValuesBuilder()
+ .setCtZone(2);
+ final CtZoneCaseValueBuilder ctZoneCaseValueBuilder = new CtZoneCaseValueBuilder()
+ .setCtZoneValues(ctZoneValuesBuilder.build());
+
+ final CtZoneCaseValue ctZoneCaseValue = ctZoneCaseValueBuilder.build();
+
+ when(matchEntry.getMatchEntryValue()).thenReturn(ctZoneCaseValue);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = ctZoneConvertor.convert(matchEntry, MatchPath.PACKETRECEIVED_MATCH);
+ Assert.assertEquals(2L, ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmNxCtZone().getCtZone().longValue());
+ Assert.assertEquals(extensionAugment.getKey(), NxmNxCtZoneKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = ctZoneConvertor.convert(matchEntry, MatchPath.SWITCHFLOWREMOVED_MATCH);
+ Assert.assertEquals(2L, ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment1.getAugmentationObject()).getNxmNxCtZone().getCtZone().longValue());
+ Assert.assertEquals(extensionAugment.getKey(), NxmNxCtZoneKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = ctZoneConvertor.convert(matchEntry, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+ Assert.assertEquals(2L, ((NxAugMatchNotifUpdateFlowStats)extensionAugment2.getAugmentationObject()).getNxmNxCtZone().getCtZone().longValue());
+ Assert.assertEquals(extensionAugment.getKey(), NxmNxCtZoneKey.class);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * 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.dst.grouping.EthDstValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.EthDstCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.EthDstCaseValueBuilder;
+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.NxmOfEthDstKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.eth.dst.grouping.NxmOfEthDstBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+/**
+ * Test for {@link EthDstConvertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class EthDstConvertorTest {
+
+ @Mock
+ private Extension extension;
+ @Mock
+ private MatchEntry matchEntry;
+
+ private static final MacAddress MAC_ADDRESS = MacAddress.getDefaultInstance("01:23:45:67:89:AB");
+
+ private EthDstConvertor ethDstConvertor;
+
+ @Before
+ public void setUp() throws Exception {
+
+ final NxmOfEthDstBuilder nxmOfEthDstBuilder = new NxmOfEthDstBuilder()
+ .setMacAddress(MAC_ADDRESS);
+ final NxAugMatchNotifUpdateFlowStatsBuilder nxAugMatchNotifUpdateFlowStatsBuilder = new NxAugMatchNotifUpdateFlowStatsBuilder();
+ nxAugMatchNotifUpdateFlowStatsBuilder.setNxmOfEthDst(nxmOfEthDstBuilder.build());
+
+ final Augmentation<Extension> extensionAugmentation = nxAugMatchNotifUpdateFlowStatsBuilder.build();
+ when(extension.getAugmentation(Matchers.<Class<Augmentation<Extension>>>any())).thenReturn(extensionAugmentation);
+
+ ethDstConvertor = new EthDstConvertor();
+
+ }
+
+ @Test
+ public void testConvert() throws Exception {
+ final MatchEntry matchEntry = ethDstConvertor.convert(extension);
+ Assert.assertEquals(MAC_ADDRESS, ((EthDstCaseValue)matchEntry.getMatchEntryValue()).getEthDstValues().getMacAddress());
+ }
+
+ @Test
+ public void testConvert1() throws Exception {
+ final EthDstValuesBuilder ethDstValuesBuilder = new EthDstValuesBuilder()
+ .setMacAddress(MAC_ADDRESS);
+ final EthDstCaseValueBuilder ethDstCaseValueBuilder = new EthDstCaseValueBuilder()
+ .setEthDstValues(ethDstValuesBuilder.build());
+
+ final EthDstCaseValue ethDstCaseValue = ethDstCaseValueBuilder.build();
+
+ when(matchEntry.getMatchEntryValue()).thenReturn(ethDstCaseValue);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = ethDstConvertor.convert(matchEntry, MatchPath.PACKETRECEIVED_MATCH);
+ Assert.assertEquals(MAC_ADDRESS, ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmOfEthDst().getMacAddress());
+ Assert.assertEquals(extensionAugment.getKey(), NxmOfEthDstKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = ethDstConvertor.convert(matchEntry, MatchPath.SWITCHFLOWREMOVED_MATCH);
+ Assert.assertEquals(MAC_ADDRESS, ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment1.getAugmentationObject()).getNxmOfEthDst().getMacAddress());
+ Assert.assertEquals(extensionAugment.getKey(), NxmOfEthDstKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = ethDstConvertor.convert(matchEntry, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+ Assert.assertEquals(MAC_ADDRESS, ((NxAugMatchNotifUpdateFlowStats)extensionAugment2.getAugmentationObject()).getNxmOfEthDst().getMacAddress());
+ Assert.assertEquals(extensionAugment.getKey(), NxmOfEthDstKey.class);
+ }
+}
\ No newline at end of file