Bump mdsal to 5.0.2
[openflowplugin.git] / extension / openflowplugin-extension-nicira / src / test / java / org / opendaylight / openflowplugin / extension / vendor / nicira / convertor / action / OutputRegConvertorTest.java
index e00fee65ae5953169534853bc960ed0277a15328..80f0bab162bc2777614d9069746d5e523802e3c9 100644 (file)
@@ -1,11 +1,10 @@
-/**
+/*
  * 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;
@@ -31,7 +30,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.ni
 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.NxActionOutputRegNodesNodeTableFlowWriteActionsCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.NxOutputReg;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.Src;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcNxTunIdCaseBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,21 +53,22 @@ public class OutputRegConvertorTest {
     private OutputRegConvertor outputRegConvertor;
 
     @Before
-    public void setUp() throws Exception {
+    public void setUp() {
         final NxOutputReg nxOutputReg = Mockito.mock(NxOutputReg.class);
         final Src src = Mockito.mock(Src.class);
 
-        when(src.getOfsNbits()).thenReturn(1);
+        when(src.getOfsNbits()).thenReturn(Uint16.valueOf(1));
         when(nxOutputReg.getSrc()).thenReturn(src);
-        when(nxOutputReg.getSrc().getSrcChoice()).thenReturn(Mockito.mock(SrcNxTunIdCase.class));
-        when(nxOutputReg.getMaxLen()).thenReturn(2);
+        when(nxOutputReg.getSrc().getSrcChoice()).thenReturn(new SrcNxTunIdCaseBuilder().build());
+        when(nxOutputReg.getMaxLen()).thenReturn(Uint16.valueOf(2));
         when(actionsCase.getNxOutputReg()).thenReturn(nxOutputReg);
 
         final ActionOutputReg actionOutputReg = Mockito.mock(ActionOutputReg.class);
         final NxActionOutputReg nxActionOutputReg = Mockito.mock(NxActionOutputReg.class);
-        when(nxActionOutputReg.getSrc()).thenReturn(NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong());
-        when(nxActionOutputReg.getMaxLen()).thenReturn(3);
-        when(nxActionOutputReg.getNBits()).thenReturn(4);
+        when(nxActionOutputReg.getSrc()).thenReturn(
+            Uint32.valueOf(NiciraMatchCodecs.TUN_ID_CODEC.getHeaderWithoutHasMask().toLong()));
+        when(nxActionOutputReg.getMaxLen()).thenReturn(Uint16.valueOf(3));
+        when(nxActionOutputReg.getNBits()).thenReturn(Uint16.valueOf(4));
         when(actionOutputReg.getNxActionOutputReg()).thenReturn(nxActionOutputReg);
         when(action.getActionChoice()).thenReturn(actionOutputReg);
 
@@ -74,15 +76,15 @@ public class OutputRegConvertorTest {
     }
 
     @Test
-    public void testConvert() throws Exception {
+    public void testConvert() {
         final ActionOutputReg actionOutputReg =
                 (ActionOutputReg) outputRegConvertor.convert(actionsCase).getActionChoice();
-        Assert.assertEquals(Integer.valueOf(1), actionOutputReg.getNxActionOutputReg().getNBits());
-        Assert.assertEquals(Integer.valueOf(2), actionOutputReg.getNxActionOutputReg().getMaxLen());
+        Assert.assertEquals(Uint16.valueOf(1), actionOutputReg.getNxActionOutputReg().getNBits());
+        Assert.assertEquals(Uint16.valueOf(2), actionOutputReg.getNxActionOutputReg().getMaxLen());
     }
 
     @Test
-    public void testConvert1() throws Exception {
+    public void testConvert1() {
         final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult
                 = outputRegConvertor.convert(action, ActionPath.FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS);
         final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult1
@@ -96,41 +98,41 @@ public class OutputRegConvertorTest {
         final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult5
                 = outputRegConvertor.convert(action, ActionPath.FLOWS_STATISTICS_RPC_WRITE_ACTIONS);
 
-        Assert.assertEquals(Integer.valueOf(3),
+        Assert.assertEquals(Uint16.valueOf(3),
                 ((NxActionOutputRegNotifFlowsStatisticsUpdateApplyActionsCase) actionResult).getNxOutputReg()
                         .getMaxLen());
-        Assert.assertEquals(Integer.valueOf(4),
+        Assert.assertEquals(Uint16.valueOf(4),
                 ((NxActionOutputRegNotifFlowsStatisticsUpdateApplyActionsCase) actionResult).getNxOutputReg().getSrc()
                         .getOfsNbits());
 
-        Assert.assertEquals(Integer.valueOf(3),
+        Assert.assertEquals(Uint16.valueOf(3),
                 ((NxActionOutputRegNodesNodeTableFlowWriteActionsCase) actionResult1).getNxOutputReg().getMaxLen());
-        Assert.assertEquals(Integer.valueOf(4), ((NxActionOutputRegNodesNodeTableFlowWriteActionsCase) actionResult1)
+        Assert.assertEquals(Uint16.valueOf(4), ((NxActionOutputRegNodesNodeTableFlowWriteActionsCase) actionResult1)
                 .getNxOutputReg().getSrc().getOfsNbits());
 
-        Assert.assertEquals(Integer.valueOf(3),
+        Assert.assertEquals(Uint16.valueOf(3),
                 ((NxActionOutputRegNotifFlowsStatisticsUpdateWriteActionsCase) actionResult2).getNxOutputReg()
                         .getMaxLen());
-        Assert.assertEquals(Integer.valueOf(4),
+        Assert.assertEquals(Uint16.valueOf(4),
                 ((NxActionOutputRegNotifFlowsStatisticsUpdateWriteActionsCase) actionResult2).getNxOutputReg().getSrc()
                         .getOfsNbits());
 
-        Assert.assertEquals(Integer.valueOf(3),
+        Assert.assertEquals(Uint16.valueOf(3),
                 ((NxActionOutputRegNotifGroupDescStatsUpdatedCase) actionResult3).getNxOutputReg().getMaxLen());
-        Assert.assertEquals(Integer.valueOf(4), ((NxActionOutputRegNotifGroupDescStatsUpdatedCase) actionResult3)
+        Assert.assertEquals(Uint16.valueOf(4), ((NxActionOutputRegNotifGroupDescStatsUpdatedCase) actionResult3)
                 .getNxOutputReg().getSrc().getOfsNbits());
 
-        Assert.assertEquals(Integer.valueOf(3),
+        Assert.assertEquals(Uint16.valueOf(3),
                 ((NxActionOutputRegNotifDirectStatisticsUpdateApplyActionsCase) actionResult4).getNxOutputReg()
                         .getMaxLen());
-        Assert.assertEquals(Integer.valueOf(4),
+        Assert.assertEquals(Uint16.valueOf(4),
                 ((NxActionOutputRegNotifDirectStatisticsUpdateApplyActionsCase) actionResult4).getNxOutputReg().getSrc()
                         .getOfsNbits());
 
-        Assert.assertEquals(Integer.valueOf(3),
+        Assert.assertEquals(Uint16.valueOf(3),
                 ((NxActionOutputRegNotifDirectStatisticsUpdateWriteActionsCase) actionResult5).getNxOutputReg()
                         .getMaxLen());
-        Assert.assertEquals(Integer.valueOf(4),
+        Assert.assertEquals(Uint16.valueOf(4),
                 ((NxActionOutputRegNotifDirectStatisticsUpdateWriteActionsCase) actionResult5).getNxOutputReg().getSrc()
                         .getOfsNbits());
     }