Remove trailing whitespace
[openflowjava.git] / openflow-protocol-api / src / test / java / org / opendaylight / openflowjava / protocol / api / keys / experimenter / ExperimenterActionSerializerKeyTest.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.protocol.api.keys.experimenter;
10
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType;
15
16 /**
17  * @author michal.polkorab
18  *
19  */
20 public class ExperimenterActionSerializerKeyTest {
21
22
23     /**
24      * Test ExperimenterActionSerializerKey equals and hashCode
25      */
26     @Test
27     public void test() {
28         ExperimenterActionSerializerKey key1 =
29                 new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class);
30         ExperimenterActionSerializerKey key2 =
31                 new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class);
32         Assert.assertTrue("Wrong equals", key1.equals(key2));
33         Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode());
34         key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, TestSubType.class);
35         Assert.assertFalse("Wrong equals", key1.equals(key2));
36         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
37         key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, null, TestSubType.class);
38         Assert.assertFalse("Wrong equals", key1.equals(key2));
39         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
40         key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType.class);
41         Assert.assertFalse("Wrong equals", key1.equals(key2));
42         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
43         key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, null);
44         Assert.assertFalse("Wrong equals", key1.equals(key2));
45         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
46         key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType2.class);
47         Assert.assertFalse("Wrong equals", key1.equals(key2));
48         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
49     }
50
51     @Test
52     public void testEquals() {
53         ExperimenterActionSerializerKey key1;
54         ExperimenterActionSerializerKey key2;
55         key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, null);
56         Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
57         key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType2.class);
58         Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2));
59         key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class);
60         Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2));
61     }
62
63
64     private static class TestSubType extends ExperimenterActionSubType {
65         // empty class - only used in test for comparation
66     }
67
68     private static class TestSubType2 extends ExperimenterActionSubType {
69         // empty class - only used in test for comparation
70     }
71
72
73 }