Final round of isFoo() migration
[openflowplugin.git] / extension / openflowplugin-extension-onf / src / test / java / org / opendaylight / openflowplugin / extension / onf / converter / BundleControlConverterTest.java
index 77d75f9a4315b5cb369ac2d34ba73904bba81acc..43905e1c01bb62a5049c8bbe97b7c59046a1509e 100644 (file)
@@ -5,14 +5,15 @@
  * 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.onf.converter;
 
+import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
+import org.opendaylight.openflowplugin.extension.api.ExtensionConvertorData;
 import org.opendaylight.openflowplugin.extension.api.path.MessagePath;
 import org.opendaylight.openflowplugin.extension.onf.BundleTestUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
@@ -28,6 +29,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.on
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnf;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnfBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.bundle.control.onf.OnfControlGroupingDataBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
 
 /**
  * Test for {@link org.opendaylight.openflowplugin.extension.onf.converter.BundleControlConverter}.
@@ -38,7 +41,8 @@ public class BundleControlConverterTest {
 
     @Test
     public void testGetExperimenterId() {
-        Assert.assertEquals("Wrong ExperimenterId.", new ExperimenterId(0x4F4E4600L), converter.getExperimenterId());
+        Assert.assertEquals("Wrong ExperimenterId.", new ExperimenterId(Uint32.valueOf(0x4F4E4600)),
+            converter.getExperimenterId());
     }
 
     @Test
@@ -68,7 +72,10 @@ public class BundleControlConverterTest {
 
     private void testConvertDown(final boolean withProperty) {
         final BundleControlSal original = createOFPMessage(withProperty);
-        final BundleControlOnf converted = converter.convert(original);
+        final ExtensionConvertorData data = new ExtensionConvertorData((short)1);
+        data.setXid(Uint32.valueOf(0L));
+        data.setDatapathId(Uint64.valueOf(BigInteger.ONE));
+        final BundleControlOnf converted = converter.convert(original, data);
         testConvert(original, converted, withProperty);
     }
 
@@ -93,8 +100,8 @@ public class BundleControlConverterTest {
         );
         Assert.assertEquals("Wrong flags",
                 new BundleFlags(
-                        ofpMessage.getSalControlData().getFlags().isAtomic(),
-                        ofpMessage.getSalControlData().getFlags().isOrdered()),
+                        ofpMessage.getSalControlData().getFlags().getAtomic(),
+                        ofpMessage.getSalControlData().getFlags().getOrdered()),
                         ofjMessage.getOnfControlGroupingData().getFlags()
         );
         if (withProperty) {
@@ -103,31 +110,35 @@ public class BundleControlConverterTest {
                     .getBundleProperty()
                     .get(0)
                     .getBundlePropertyEntry();
-            final BundlePropertyExperimenter convertedProperty = ((BundlePropertyExperimenter) ofjMessage
+            final BundlePropertyExperimenter convertedProperty = (BundlePropertyExperimenter) ofjMessage
                     .getOnfControlGroupingData()
                     .getBundleProperty()
                     .get(0)
-                    .getBundlePropertyEntry());
-            Assert.assertEquals("Wrong property ExperimenterId", new ExperimenterId(originalProperty.getExperimenter()), convertedProperty.getExperimenter());
-            Assert.assertEquals("Wrong property experimenter type", originalProperty.getExpType(), convertedProperty.getExpType());
-            Assert.assertEquals("Wrong property data", originalProperty.getBundlePropertyExperimenterData(), convertedProperty.getBundlePropertyExperimenterData());
+                    .getBundlePropertyEntry();
+            Assert.assertEquals("Wrong property ExperimenterId", new ExperimenterId(originalProperty.getExperimenter()),
+                    convertedProperty.getExperimenter());
+            Assert.assertEquals("Wrong property experimenter type", originalProperty.getExpType(),
+                    convertedProperty.getExpType());
+            Assert.assertEquals("Wrong property data", originalProperty.getBundlePropertyExperimenterData(),
+                    convertedProperty.getBundlePropertyExperimenterData());
         } else {
             Assert.assertTrue("Properties not empty",
                     ofjMessage
                             .getOnfControlGroupingData()
-                            .getBundleProperty()
+                            .nonnullBundleProperty()
                             .isEmpty());
         }
     }
 
     private static BundleControlSal createOFPMessage(final boolean withProperty) {
         final SalControlDataBuilder dataBuilder = new SalControlDataBuilder();
-        dataBuilder.setBundleId(new BundleId(1L));
+        dataBuilder.setBundleId(new BundleId(Uint32.ONE));
         dataBuilder.setType(BundleControlType.ONFBCTOPENREQUEST);
         dataBuilder.setFlags(new BundleFlags(true, false));
         List<BundleProperty> properties = new ArrayList<>();
         if (withProperty) {
-            properties.add(BundleTestUtils.createExperimenterProperty(Mockito.mock(BundlePropertyExperimenterData.class)));
+            properties.add(BundleTestUtils.createExperimenterProperty(
+                    Mockito.mock(BundlePropertyExperimenterData.class)));
         }
         dataBuilder.setBundleProperty(properties);
         return new BundleControlSalBuilder().setSalControlData(dataBuilder.build()).build();
@@ -136,15 +147,15 @@ public class BundleControlConverterTest {
     private static BundleControlOnf createOFJMessage(final boolean withProperty) {
         final BundleControlOnfBuilder builder = new BundleControlOnfBuilder();
         final OnfControlGroupingDataBuilder dataBuilder = new OnfControlGroupingDataBuilder();
-        dataBuilder.setBundleId(new BundleId(1L));
+        dataBuilder.setBundleId(new BundleId(Uint32.ONE));
         dataBuilder.setType(BundleControlType.ONFBCTOPENREPLY);
         dataBuilder.setFlags(new BundleFlags(false, false));
         List<BundleProperty> properties = new ArrayList<>();
         if (withProperty) {
-            properties.add(BundleTestUtils.createExperimenterProperty(Mockito.mock(BundlePropertyExperimenterData.class)));
+            properties.add(BundleTestUtils.createExperimenterProperty(
+                    Mockito.mock(BundlePropertyExperimenterData.class)));
         }
         dataBuilder.setBundleProperty(properties);
         return new BundleControlOnfBuilder().setOnfControlGroupingData(dataBuilder.build()).build();
     }
-
 }