BUG-4283: experimenter msg support - deserialization part
[openflowjava.git] / openflowjava-util / src / test / java / org / opendaylight / openflowjava / util / ExperimenterDeserializerKeyFactoryTest.java
index 1b422d313166a51e469c9753a82175ebbebaaf14..a8cc83682a7d32bcc7d9641c917ded62a28e71aa 100644 (file)
@@ -11,84 +11,111 @@ package org.opendaylight.openflowjava.util;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
 
 /**
  * @author michal.polkorab
- *
  */
 public class ExperimenterDeserializerKeyFactoryTest {
 
-    /**
-     * Test ExperimenterDeserializerKeyFactory key creation
-     */
     @Test
-    public void test() {
-        ExperimenterIdDeserializerKey createdKey = ExperimenterDeserializerKeyFactory
+    public void testCreateExperimenterErrorDeserializerKey() throws Exception {
+        ExperimenterIdDeserializerKey createdKey;
+        ExperimenterIdDeserializerKey comparationKey;
+
+        createdKey = ExperimenterDeserializerKeyFactory
                 .createExperimenterErrorDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L);
-        ExperimenterIdDeserializerKey comparationKey =
-                new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ErrorMessage.class);
-        Assert.assertEquals("Wrong key created", comparationKey, createdKey);
-        createdKey = ExperimenterDeserializerKeyFactory.createExperimenterErrorDeserializerKey(
-                EncodeConstants.OF10_VERSION_ID, null);
-        comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
-                null, ErrorMessage.class);
-        Assert.assertEquals("Wrong key created", comparationKey, createdKey);
-        createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey(
-                EncodeConstants.OF10_VERSION_ID, 43L);
-        comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
-                43L, ExperimenterMessage.class);
+        comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ErrorMessage.class);
         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
+    }
+
+    @Test
+    public void testCreateExperimenterMessageDeserializerKey() throws Exception {
+        ExperimenterIdDeserializerKey createdKey;
+        ExperimenterIdDeserializerKey comparationKey;
+
         createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey(
-                EncodeConstants.OF10_VERSION_ID, null);
-        comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
-                null, ExperimenterMessage.class);
-        Assert.assertEquals("Wrong key created", comparationKey, createdKey);
-        createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey(
-                EncodeConstants.OF10_VERSION_ID, 44L);
-        comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
-                44L, MeterBandExperimenterCase.class);
-        Assert.assertEquals("Wrong key created", comparationKey, createdKey);
-        createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey(
-                EncodeConstants.OF10_VERSION_ID, null);
-        comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
-                null, MeterBandExperimenterCase.class);
+                EncodeConstants.OF10_VERSION_ID, 43L, 1L);
+        comparationKey = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID,
+                43L, 1L, ExperimenterDataOfChoice.class);
         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
+    }
+
+    @Test
+    public void testCreateMultipartReplyMessageDeserializerKey() throws Exception {
+        ExperimenterIdDeserializerKey createdKey;
+        ExperimenterIdDeserializerKey comparationKey;
+
         createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey(
-                EncodeConstants.OF10_VERSION_ID, 45L);
+                EncodeConstants.OF10_VERSION_ID, 45L, 1L);
         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
-                45L, MultipartReplyExperimenterCase.class);
+                45L, ExperimenterDataOfChoice.class);
         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
-        createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey(
-                EncodeConstants.OF10_VERSION_ID, null);
+    }
+
+    @Test
+    public void testCreateMultipartReplyTFDeserializerKey() throws Exception {
+        ExperimenterIdDeserializerKey createdKey;
+        ExperimenterIdDeserializerKey comparationKey;
+
+        createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey(
+                EncodeConstants.OF10_VERSION_ID, 46L);
         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
-                null, MultipartReplyExperimenterCase.class);
+                46L, TableFeatureProperties.class);
         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
-        createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey(
-                EncodeConstants.OF10_VERSION_ID, null);
+    }
+
+    @Test
+    public void testCreateQueuePropertyDeserializerKey() throws Exception {
+        ExperimenterIdDeserializerKey createdKey;
+        ExperimenterIdDeserializerKey comparationKey;
+
+        createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey(
+                EncodeConstants.OF10_VERSION_ID, 47L);
         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
-                null, TableFeatureProperties.class);
+                47L, QueueProperty.class);
         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
-        createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey(
-                EncodeConstants.OF10_VERSION_ID, null);
+    }
+
+    @Test
+    public void testCreateMeterBandDeserializerKey() throws Exception {
+        ExperimenterIdDeserializerKey createdKey;
+        ExperimenterIdDeserializerKey comparationKey;
+
+        createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey(
+                EncodeConstants.OF10_VERSION_ID, 44L);
         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
-                null, TableFeatureProperties.class);
+                44L, MeterBandExperimenterCase.class);
         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
-        createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey(
-                EncodeConstants.OF10_VERSION_ID, null);
+    }
+
+    @Test
+    public void testCreateVendorMessageDeserializerKey() throws Exception {
+        ExperimenterIdDeserializerKey createdKey;
+        ExperimenterIdDeserializerKey comparationKey;
+
+        createdKey = ExperimenterDeserializerKeyFactory.createVendorMessageDeserializerKey(
+                EncodeConstants.OF10_VERSION_ID, 43L);
         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
-                null, QueueProperty.class);
+                43L, ExperimenterDataOfChoice.class);
         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
-        createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey(
-                EncodeConstants.OF10_VERSION_ID, null);
+    }
+
+    @Test
+    public void testCreateMultipartReplyVendorMessageDeserializerKey() throws Exception {
+        ExperimenterIdDeserializerKey createdKey;
+        ExperimenterIdDeserializerKey comparationKey;
+
+        createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyVendorMessageDeserializerKey(
+                EncodeConstants.OF10_VERSION_ID, 43L);
         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
-                null, QueueProperty.class);
+                43L, ExperimenterDataOfChoice.class);
         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
     }
 }
\ No newline at end of file