BUG-4283: experimenter msg support - deserialization part
[openflowjava.git] / openflowjava-util / src / test / java / org / opendaylight / openflowjava / util / ExperimenterDeserializerKeyFactoryTest.java
1 /*
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.openflowjava.util;
10
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey;
14 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey;
15 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
21
22 /**
23  * @author michal.polkorab
24  */
25 public class ExperimenterDeserializerKeyFactoryTest {
26
27     @Test
28     public void testCreateExperimenterErrorDeserializerKey() throws Exception {
29         ExperimenterIdDeserializerKey createdKey;
30         ExperimenterIdDeserializerKey comparationKey;
31
32         createdKey = ExperimenterDeserializerKeyFactory
33                 .createExperimenterErrorDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L);
34         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ErrorMessage.class);
35         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
36     }
37
38     @Test
39     public void testCreateExperimenterMessageDeserializerKey() throws Exception {
40         ExperimenterIdDeserializerKey createdKey;
41         ExperimenterIdDeserializerKey comparationKey;
42
43         createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey(
44                 EncodeConstants.OF10_VERSION_ID, 43L, 1L);
45         comparationKey = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID,
46                 43L, 1L, ExperimenterDataOfChoice.class);
47         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
48     }
49
50     @Test
51     public void testCreateMultipartReplyMessageDeserializerKey() throws Exception {
52         ExperimenterIdDeserializerKey createdKey;
53         ExperimenterIdDeserializerKey comparationKey;
54
55         createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey(
56                 EncodeConstants.OF10_VERSION_ID, 45L, 1L);
57         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
58                 45L, ExperimenterDataOfChoice.class);
59         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
60     }
61
62     @Test
63     public void testCreateMultipartReplyTFDeserializerKey() throws Exception {
64         ExperimenterIdDeserializerKey createdKey;
65         ExperimenterIdDeserializerKey comparationKey;
66
67         createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey(
68                 EncodeConstants.OF10_VERSION_ID, 46L);
69         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
70                 46L, TableFeatureProperties.class);
71         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
72     }
73
74     @Test
75     public void testCreateQueuePropertyDeserializerKey() throws Exception {
76         ExperimenterIdDeserializerKey createdKey;
77         ExperimenterIdDeserializerKey comparationKey;
78
79         createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey(
80                 EncodeConstants.OF10_VERSION_ID, 47L);
81         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
82                 47L, QueueProperty.class);
83         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
84     }
85
86     @Test
87     public void testCreateMeterBandDeserializerKey() throws Exception {
88         ExperimenterIdDeserializerKey createdKey;
89         ExperimenterIdDeserializerKey comparationKey;
90
91         createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey(
92                 EncodeConstants.OF10_VERSION_ID, 44L);
93         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
94                 44L, MeterBandExperimenterCase.class);
95         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
96     }
97
98     @Test
99     public void testCreateVendorMessageDeserializerKey() throws Exception {
100         ExperimenterIdDeserializerKey createdKey;
101         ExperimenterIdDeserializerKey comparationKey;
102
103         createdKey = ExperimenterDeserializerKeyFactory.createVendorMessageDeserializerKey(
104                 EncodeConstants.OF10_VERSION_ID, 43L);
105         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
106                 43L, ExperimenterDataOfChoice.class);
107         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
108     }
109
110     @Test
111     public void testCreateMultipartReplyVendorMessageDeserializerKey() throws Exception {
112         ExperimenterIdDeserializerKey createdKey;
113         ExperimenterIdDeserializerKey comparationKey;
114
115         createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyVendorMessageDeserializerKey(
116                 EncodeConstants.OF10_VERSION_ID, 43L);
117         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
118                 43L, ExperimenterDataOfChoice.class);
119         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
120     }
121 }