--- /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.action;
+
+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.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionSetNsi;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.set.nsi.grouping.NxActionSetNsi;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.flows.statistics.update.flow.and.statistics.map.list.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionSetNsiNotifFlowsStatisticsUpdateApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.flows.statistics.update.flow.and.statistics.map.list.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionSetNsiNotifFlowsStatisticsUpdateWriteActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.group.desc.stats.updated.group.desc.stats.buckets.bucket.action.action.NxActionSetNsiNotifGroupDescStatsUpdatedCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionSetNsiNodesNodeTableFlowWriteActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nsi.grouping.NxSetNsi;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test for {@link SetNsiConvertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class SetNsiConvertorTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SetNsiConvertorTest.class);
+
+ @Mock
+ private NxActionSetNsiNodesNodeTableFlowWriteActionsCase actionsCase;
+ @Mock
+ private Action action;
+ private SetNsiConvertor setNsiConvertor;
+
+ @Before
+ public void setUp() throws Exception {
+ final NxSetNsi nxSetNsi = Mockito.mock(NxSetNsi.class);
+ when(actionsCase.getNxSetNsi()).thenReturn(nxSetNsi);
+ when(nxSetNsi.getNsi()).thenReturn((short) 1);
+
+ final ActionSetNsi actionSetNsi = Mockito.mock(ActionSetNsi.class);
+ final NxActionSetNsi nxActionSetNsi = Mockito.mock(NxActionSetNsi.class);
+ when(nxActionSetNsi.getNsi()).thenReturn((short) 3);
+ when(actionSetNsi.getNxActionSetNsi()).thenReturn(nxActionSetNsi);
+ when(action.getActionChoice()).thenReturn(actionSetNsi);
+
+ setNsiConvertor = new SetNsiConvertor();
+ }
+
+ @Test
+ public void testConvert() throws Exception {
+ final ActionSetNsi actionSetNsi = (ActionSetNsi) setNsiConvertor.convert(actionsCase).getActionChoice();
+ Assert.assertEquals(1, actionSetNsi.getNxActionSetNsi().getNsi().intValue());
+ }
+
+ @Test
+ public void testConvert1() throws Exception {
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult
+ = setNsiConvertor.convert(action, ActionPath.NODES_NODE_TABLE_FLOW_INSTRUCTIONS_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION_EXTENSIONLIST_EXTENSION);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult1
+ = setNsiConvertor.convert(action, ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult2
+ = setNsiConvertor.convert(action, ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult3
+ = setNsiConvertor.convert(action, ActionPath.GROUPDESCSTATSUPDATED_GROUPDESCSTATS_BUCKETS_BUCKET_ACTION);
+
+ Assert.assertEquals(3, ((NxActionSetNsiNodesNodeTableFlowWriteActionsCase) actionResult).getNxSetNsi().getNsi().intValue());
+ Assert.assertEquals(3, ((NxActionSetNsiNotifFlowsStatisticsUpdateWriteActionsCase) actionResult1).getNxSetNsi().getNsi().intValue());
+ Assert.assertEquals(3, ((NxActionSetNsiNotifFlowsStatisticsUpdateApplyActionsCase) actionResult2).getNxSetNsi().getNsi().intValue());
+ Assert.assertEquals(3, ((NxActionSetNsiNotifGroupDescStatsUpdatedCase) actionResult3).getNxSetNsi().getNsi().intValue());
+ }
+
+}
\ 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.action;
+
+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.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionSetNsp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.set.nsp.grouping.NxActionSetNsp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.flows.statistics.update.flow.and.statistics.map.list.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionSetNspNotifFlowsStatisticsUpdateApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.flows.statistics.update.flow.and.statistics.map.list.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionSetNspNotifFlowsStatisticsUpdateWriteActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.group.desc.stats.updated.group.desc.stats.buckets.bucket.action.action.NxActionSetNspNotifGroupDescStatsUpdatedCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionSetNspNodesNodeTableFlowWriteActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.set.nsp.grouping.NxSetNsp;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test for {@link SetNspConvertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class SetNspConvertorTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SetNspConvertorTest.class);
+
+ @Mock
+ private NxActionSetNspNodesNodeTableFlowWriteActionsCase actionsCase;
+ @Mock
+ private Action action;
+
+ private SetNspConvertor setNspConvertor;
+
+ @Before
+ public void setUp() throws Exception {
+ final NxSetNsp nxSetNsp = Mockito.mock(NxSetNsp.class);
+ when(actionsCase.getNxSetNsp()).thenReturn(nxSetNsp);
+ when(nxSetNsp.getNsp()).thenReturn(1L);
+
+ final ActionSetNsp actionSetNsp = Mockito.mock(ActionSetNsp.class);
+ final NxActionSetNsp nxActionSetNsp = Mockito.mock(NxActionSetNsp.class);
+ when(nxActionSetNsp.getNsp()).thenReturn(3L);
+ when(actionSetNsp.getNxActionSetNsp()).thenReturn(nxActionSetNsp);
+ when(action.getActionChoice()).thenReturn(actionSetNsp);
+
+ setNspConvertor = new SetNspConvertor();
+ }
+
+ @Test
+ public void testConvert() throws Exception {
+ final ActionSetNsp actionSetNsp = (ActionSetNsp) setNspConvertor.convert(actionsCase).getActionChoice();
+ Assert.assertEquals(Long.valueOf(1L), actionSetNsp.getNxActionSetNsp().getNsp());
+ }
+
+ @Test
+ public void testConvert1() throws Exception {
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult
+ = setNspConvertor.convert(action, ActionPath.NODES_NODE_TABLE_FLOW_INSTRUCTIONS_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION_EXTENSIONLIST_EXTENSION);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult1
+ = setNspConvertor.convert(action, ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult2
+ = setNspConvertor.convert(action, ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult3
+ = setNspConvertor.convert(action, ActionPath.GROUPDESCSTATSUPDATED_GROUPDESCSTATS_BUCKETS_BUCKET_ACTION);
+
+ Assert.assertEquals(Long.valueOf(3L), ((NxActionSetNspNodesNodeTableFlowWriteActionsCase) actionResult).getNxSetNsp().getNsp());
+ Assert.assertEquals(Long.valueOf(3L), ((NxActionSetNspNotifFlowsStatisticsUpdateWriteActionsCase) actionResult1).getNxSetNsp().getNsp());
+ Assert.assertEquals(Long.valueOf(3L), ((NxActionSetNspNotifFlowsStatisticsUpdateApplyActionsCase) actionResult2).getNxSetNsp().getNsp());
+ Assert.assertEquals(Long.valueOf(3L), ((NxActionSetNspNotifGroupDescStatsUpdatedCase) actionResult3).getNxSetNsp().getNsp());
+ }
+
+}
\ 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.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.op._case.ArpOpBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpOpCaseValue;
+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.NxmOfArpOpKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.arp.op.grouping.NxmOfArpOpBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test for {@link ArpOpConvertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class ArpOpConvertorTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ArpOpConvertorTest.class);
+
+ @Mock
+ private Extension extension;
+ @Mock
+ private MatchEntry matchEntry;
+
+ private ArpOpConvertor arpOpConvertor;
+
+ @Before
+ public void setUp() throws Exception {
+ arpOpConvertor = new ArpOpConvertor();
+ }
+
+ @Test
+ public void testConvertToOFJava() throws Exception {
+ final NxmOfArpOpBuilder nxmOfArpOpBuilder = new NxmOfArpOpBuilder()
+ .setValue(2);
+ final NxAugMatchRpcAddFlowBuilder nxAugMatchRpcAddFlowBuilder = new NxAugMatchRpcAddFlowBuilder();
+ nxAugMatchRpcAddFlowBuilder.setNxmOfArpOp(nxmOfArpOpBuilder.build());
+
+ final Augmentation<Extension> extensionAugmentation = nxAugMatchRpcAddFlowBuilder.build();
+ when(extension.getAugmentation(Matchers.<Class<Augmentation<Extension>>>any())).thenReturn(extensionAugmentation);
+
+ final MatchEntry matchEntry = arpOpConvertor.convert(extension);
+ Assert.assertEquals(nxAugMatchRpcAddFlowBuilder.getNxmOfArpOp().getValue(), ((ArpOpCaseValue)matchEntry.getMatchEntryValue()).getArpOpValues().getValue());
+ }
+
+ @Test
+ public void testConvertFromOFJava() throws Exception {
+ final ArpOpBuilder arpOpBuilder = new ArpOpBuilder()
+ .setOpCode(2);
+ final ArpOpCaseBuilder arpOpCaseBuilder = new ArpOpCaseBuilder()
+ .setArpOp(arpOpBuilder.build());
+ final ArpOpCase arpOpCase = arpOpCaseBuilder.build();
+
+ when(matchEntry.getMatchEntryValue()).thenReturn(arpOpCase);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = arpOpConvertor.convert(matchEntry, MatchPath.PACKETRECEIVED_MATCH);
+ Assert.assertEquals(arpOpCase.getArpOp().getOpCode(), ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmOfArpOp().getValue());
+ Assert.assertEquals(extensionAugment.getKey(), NxmOfArpOpKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = arpOpConvertor.convert(matchEntry, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+ Assert.assertEquals(arpOpCase.getArpOp().getOpCode(), ((NxAugMatchNotifUpdateFlowStats)extensionAugment1.getAugmentationObject()).getNxmOfArpOp().getValue());
+ Assert.assertEquals(extensionAugment1.getKey(), NxmOfArpOpKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = arpOpConvertor.convert(matchEntry, MatchPath.SWITCHFLOWREMOVED_MATCH);
+ Assert.assertEquals(arpOpCase.getArpOp().getOpCode(), ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment2.getAugmentationObject()).getNxmOfArpOp().getValue());
+ Assert.assertEquals(extensionAugment2.getKey(), NxmOfArpOpKey.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.nx.match.arp.sha.grouping.ArpShaValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpShaCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpShaCaseValueBuilder;
+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.NxmNxArpShaKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.nx.arp.sha.grouping.NxmNxArpShaBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test for {@link ArpShaConvertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class ArpShaConvertorTest {
+
+ @Mock
+ private Extension extension;
+ @Mock
+ private MatchEntry matchEntry;
+
+ private ArpShaConvertor arpShaConvertor;
+
+ private static final MacAddress MAC_ADDRESS = MacAddress.getDefaultInstance("01:23:45:67:89:AB");
+
+ private static final Logger LOG = LoggerFactory.getLogger(ArpShaConvertorTest.class);
+
+ @Before
+ public void setUp() throws Exception {
+ final NxmNxArpShaBuilder nxmNxArpShaBuilder = new NxmNxArpShaBuilder()
+ .setMacAddress(MAC_ADDRESS);
+ final NxAugMatchRpcAddFlowBuilder nxAugMatchRpcAddFlowBuilder = new NxAugMatchRpcAddFlowBuilder()
+ .setNxmNxArpSha(nxmNxArpShaBuilder.build());
+ final Augmentation<Extension> extensionAugmentation = nxAugMatchRpcAddFlowBuilder.build();
+
+ when(extension.getAugmentation(Matchers.<Class<Augmentation<Extension>>>any())).thenReturn(extensionAugmentation);
+
+ arpShaConvertor = new ArpShaConvertor();
+ }
+
+ @Test
+ public void testConvertToOFJava() throws Exception {
+ final MatchEntry matchEntry = arpShaConvertor.convert(extension);
+ Assert.assertEquals(MAC_ADDRESS.getValue(), ((ArpShaCaseValue)matchEntry.getMatchEntryValue()).getArpShaValues().getMacAddress().getValue());
+ }
+
+ @Test
+ public void testConvertFromOFJava() throws Exception {
+ final ArpShaValuesBuilder arpShaValuesBuilder = new ArpShaValuesBuilder()
+ .setMacAddress(MAC_ADDRESS);
+ final ArpShaCaseValueBuilder arpShaCaseValueBuilder = new ArpShaCaseValueBuilder()
+ .setArpShaValues(arpShaValuesBuilder.build());
+ final ArpShaCaseValue arpShaCaseValue = arpShaCaseValueBuilder.build();
+
+ when(matchEntry.getMatchEntryValue()).thenReturn(arpShaCaseValue);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = arpShaConvertor.convert(matchEntry, MatchPath.PACKETRECEIVED_MATCH);
+ Assert.assertEquals(arpShaCaseValue.getArpShaValues().getMacAddress(), ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmNxArpSha().getMacAddress());
+ Assert.assertEquals(extensionAugment.getKey(), NxmNxArpShaKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = arpShaConvertor.convert(matchEntry, MatchPath.SWITCHFLOWREMOVED_MATCH);
+ Assert.assertEquals(arpShaCaseValue.getArpShaValues().getMacAddress(), ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment1.getAugmentationObject()).getNxmNxArpSha().getMacAddress());
+ Assert.assertEquals(extensionAugment.getKey(), NxmNxArpShaKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = arpShaConvertor.convert(matchEntry, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+ Assert.assertEquals(arpShaCaseValue.getArpShaValues().getMacAddress(), ((NxAugMatchNotifUpdateFlowStats)extensionAugment2.getAugmentationObject()).getNxmNxArpSha().getMacAddress());
+ Assert.assertEquals(extensionAugment.getKey(), NxmNxArpShaKey.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.spa.grouping.ArpSpaValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpSpaCaseValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpSpaCaseValueBuilder;
+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.NxmOfArpSpaKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.match.rev140714.nxm.of.arp.spa.grouping.NxmOfArpSpaBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+
+/**
+ * Test for {@link ArpSpaConvertor}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class ArpSpaConvertorTest {
+
+ @Mock
+ private Extension extension;
+ @Mock
+ private MatchEntry matchEntry;
+
+ private static final Ipv4Address IPV4_ADDRESS = Ipv4Address.getDefaultInstance("1.2.3.4");
+
+ private ArpSpaConvertor arpSpaConvertor;
+
+ @Before
+ public void setUp() throws Exception {
+ arpSpaConvertor = new ArpSpaConvertor();
+ }
+
+ @Test
+ public void testConvertToOFJava() throws Exception {
+ final NxmOfArpSpaBuilder nxmOfArpSpaBuilder = new NxmOfArpSpaBuilder()
+ .setIpv4Address(IPV4_ADDRESS);
+ final NxAugMatchRpcAddFlowBuilder nxAugMatchRpcAddFlowBuilder = new NxAugMatchRpcAddFlowBuilder();
+ nxAugMatchRpcAddFlowBuilder.setNxmOfArpSpa(nxmOfArpSpaBuilder.build());
+
+ final Augmentation<Extension> extensionAugmentation = nxAugMatchRpcAddFlowBuilder.build();
+ when(extension.getAugmentation(Matchers.<Class<Augmentation<Extension>>>any())).thenReturn(extensionAugmentation);
+
+ final MatchEntry matchEntry = arpSpaConvertor.convert(extension);
+ Assert.assertEquals(IpConverter.Ipv4AddressToLong(IPV4_ADDRESS), ((ArpSpaCaseValue)matchEntry.getMatchEntryValue()).getArpSpaValues().getValue().longValue());
+ }
+
+ @Test
+ public void testConvertFromOFJava() throws Exception {
+ final ArpSpaValuesBuilder arpSpaValuesBuilder = new ArpSpaValuesBuilder()
+ .setValue(IpConverter.Ipv4AddressToLong(IPV4_ADDRESS));
+ final ArpSpaCaseValueBuilder arpSpaCaseValueBuilder = new ArpSpaCaseValueBuilder()
+ .setArpSpaValues(arpSpaValuesBuilder.build());
+
+ final ArpSpaCaseValue arpSpaCaseValue = arpSpaCaseValueBuilder.build();
+
+ when(matchEntry.getMatchEntryValue()).thenReturn(arpSpaCaseValue);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment = arpSpaConvertor.convert(matchEntry, MatchPath.PACKETRECEIVED_MATCH);
+ Assert.assertEquals(IPV4_ADDRESS, ((NxAugMatchNotifPacketIn)extensionAugment.getAugmentationObject()).getNxmOfArpSpa().getIpv4Address());
+ Assert.assertEquals(extensionAugment.getKey(), NxmOfArpSpaKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment1 = arpSpaConvertor.convert(matchEntry, MatchPath.SWITCHFLOWREMOVED_MATCH);
+ Assert.assertEquals(IPV4_ADDRESS, ((NxAugMatchNotifSwitchFlowRemoved)extensionAugment1.getAugmentationObject()).getNxmOfArpSpa().getIpv4Address());
+ Assert.assertEquals(extensionAugment.getKey(), NxmOfArpSpaKey.class);
+
+ final ExtensionAugment<? extends Augmentation<Extension>> extensionAugment2 = arpSpaConvertor.convert(matchEntry, MatchPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_MATCH);
+ Assert.assertEquals(IPV4_ADDRESS, ((NxAugMatchNotifUpdateFlowStats)extensionAugment2.getAugmentationObject()).getNxmOfArpSpa().getIpv4Address());
+ Assert.assertEquals(extensionAugment.getKey(), NxmOfArpSpaKey.class);
+
+ }
+
+}
\ No newline at end of file