211186d75c964d655149eafdd9e0e248dd47a183
[openflowjava.git] / openflowjava-util / src / test / java / org / opendaylight / openflowjava / util / ExperimenterSerializerKeyFactoryTest.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.ExperimenterIdSerializerKey;
14 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeSerializerKey;
15 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
19
20 /**
21  * Test ExperimenterSerializerKeyFactory key creation
22  * @author michal.polkorab
23  *
24  */
25 public class ExperimenterSerializerKeyFactoryTest {
26
27     @Test
28     public void testCreateExperimenterMessageSerializerKey() throws Exception {
29         ExperimenterIdSerializerKey<?> createdKey;
30         ExperimenterIdSerializerKey<?> comparationKey;
31
32         createdKey = ExperimenterSerializerKeyFactory
33                 .createExperimenterMessageSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, 1L);
34         comparationKey = new ExperimenterIdTypeSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
35                 42L, 1L, ExperimenterDataOfChoice.class);
36         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
37     }
38
39     @Test
40     public void testCreateMultipartRequestSerializerKey() throws Exception {
41         ExperimenterIdSerializerKey<?> createdKey;
42         ExperimenterIdSerializerKey<?> comparationKey;
43
44         createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey(
45                 EncodeConstants.OF10_VERSION_ID, 44L, 1L);
46         comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
47                 44L, ExperimenterDataOfChoice.class);
48         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
49     }
50
51     @Test
52     public void testCreateMultipartRequestTFSerializerKey() throws Exception {
53         ExperimenterIdSerializerKey<?> createdKey;
54         ExperimenterIdSerializerKey<?> comparationKey;
55
56         createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey(
57                 EncodeConstants.OF10_VERSION_ID, 45L);
58         comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
59                 45L, TableFeatureProperties.class);
60         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
61     }
62
63     @Test
64     public void testCreateMeterBandSerializerKey() throws Exception {
65         ExperimenterIdSerializerKey<?> createdKey;
66         ExperimenterIdSerializerKey<?> comparationKey;
67
68         createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey(
69                 EncodeConstants.OF10_VERSION_ID, 43L);
70         comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID,
71                 43L, MeterBandExperimenterCase.class);
72         Assert.assertEquals("Wrong key created", comparationKey, createdKey);
73     }
74 }