Merge "Spec: OFPGC_ADD_OR_MOD support in openflowplugin"
[openflowplugin.git] / openflowjava / 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  * Unit tests for ExperimenterDeserializerKeyFactory.
24  *
25  * @author michal.polkorab
26  */
27 public class ExperimenterDeserializerKeyFactoryTest {
28
29     @Test
30     public void testCreateExperimenterErrorDeserializerKey() throws Exception {
31         ExperimenterIdDeserializerKey createdKey;
32         ExperimenterIdDeserializerKey comparationKey;
33
34         createdKey = ExperimenterDeserializerKeyFactory
35                 .createExperimenterErrorDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L);
36         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ErrorMessage.class);
37         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
38     }
39
40     @Test
41     public void testCreateExperimenterMessageDeserializerKey() throws Exception {
42         ExperimenterIdDeserializerKey createdKey;
43         ExperimenterIdDeserializerKey comparationKey;
44
45         createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey(
46                 EncodeConstants.OF10_VERSION_ID, 43L, 1L);
47         comparationKey = new ExperimenterIdTypeDeserializerKey(EncodeConstants.OF10_VERSION_ID,
48                 43L, 1L, ExperimenterDataOfChoice.class);
49         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
50     }
51
52     @Test
53     public void testCreateMultipartReplyMessageDeserializerKey() throws Exception {
54         ExperimenterIdDeserializerKey createdKey;
55         ExperimenterIdDeserializerKey comparationKey;
56
57         createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey(
58                 EncodeConstants.OF10_VERSION_ID, 45L, 1L);
59         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
60                 45L, ExperimenterDataOfChoice.class);
61         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
62     }
63
64     @Test
65     public void testCreateMultipartReplyTFDeserializerKey() throws Exception {
66         ExperimenterIdDeserializerKey createdKey;
67         ExperimenterIdDeserializerKey comparationKey;
68
69         createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey(
70                 EncodeConstants.OF10_VERSION_ID, 46L);
71         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
72                 46L, TableFeatureProperties.class);
73         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
74     }
75
76     @Test
77     public void testCreateQueuePropertyDeserializerKey() throws Exception {
78         ExperimenterIdDeserializerKey createdKey;
79         ExperimenterIdDeserializerKey comparationKey;
80
81         createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey(
82                 EncodeConstants.OF10_VERSION_ID, 47L);
83         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
84                 47L, QueueProperty.class);
85         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
86     }
87
88     @Test
89     public void testCreateMeterBandDeserializerKey() throws Exception {
90         ExperimenterIdDeserializerKey createdKey;
91         ExperimenterIdDeserializerKey comparationKey;
92
93         createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey(
94                 EncodeConstants.OF10_VERSION_ID, 44L);
95         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
96                 44L, MeterBandExperimenterCase.class);
97         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
98     }
99
100     @Test
101     public void testCreateVendorMessageDeserializerKey() throws Exception {
102         ExperimenterIdDeserializerKey createdKey;
103         ExperimenterIdDeserializerKey comparationKey;
104
105         createdKey = ExperimenterDeserializerKeyFactory.createVendorMessageDeserializerKey(
106                 EncodeConstants.OF10_VERSION_ID, 43L);
107         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
108                 43L, ExperimenterDataOfChoice.class);
109         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
110     }
111
112     @Test
113     public void testCreateMultipartReplyVendorMessageDeserializerKey() throws Exception {
114         ExperimenterIdDeserializerKey createdKey;
115         ExperimenterIdDeserializerKey comparationKey;
116
117         createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyVendorMessageDeserializerKey(
118                 EncodeConstants.OF10_VERSION_ID, 43L);
119         comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID,
120                 43L, ExperimenterDataOfChoice.class);
121         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
122     }
123 }