Fix checkstyle
[openflowplugin.git] / extension / openflowjava-extension-nicira-api / src / test / java / org / opendaylight / openflowjava / nx / api / NiciraActionSerializerKeyTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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 package org.opendaylight.openflowjava.nx.api;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
13
14 import org.junit.Test;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase;
17
18 public class NiciraActionSerializerKeyTest {
19
20
21     NiciraActionSerializerKey niciraActionSerializerKey;
22
23     private static final short VERSION = 4;
24
25
26     @Test
27     public void niciraActionSerializerKeyTest() {
28         niciraActionSerializerKey = new NiciraActionSerializerKey(VERSION, SubtypeClass.class);
29
30         assertEquals(VERSION, niciraActionSerializerKey.getVersion());
31         assertEquals(SubtypeClass.class, niciraActionSerializerKey.getSubtype());
32     }
33
34     /**
35      * If input param obj is NULL then FALSE should be returned.
36      */
37     @Test
38     public void equalsTest1() {
39         Object obj = null;
40         niciraActionSerializerKey = new NiciraActionSerializerKey(VERSION, SubtypeClass.class);
41
42         assertFalse(niciraActionSerializerKey.equals(obj));
43     }
44
45     /**
46      * If input param obj is NOT NULL but is instance of different class then FALSE should be returned.
47      */
48     @Test
49     public void equalsTest2() {
50         Object obj = new Object();
51         niciraActionSerializerKey = new NiciraActionSerializerKey(VERSION, SubtypeClass.class);
52
53         assertFalse(niciraActionSerializerKey.equals(obj));
54     }
55
56     /**
57      * If input param obj is instance of the same class but this.subtype is NULL then FALSE should be returned.
58      */
59     @Test
60     public void equalsTest3() {
61         NiciraActionSerializerKey obj = new NiciraActionSerializerKey(VERSION, SubtypeClass.class);
62         niciraActionSerializerKey = new NiciraActionSerializerKey(VERSION, null);
63
64         assertFalse(niciraActionSerializerKey.equals(obj));
65     }
66
67     /**
68      * If input param obj is instance of the same class but has different SUBTYPE then FALSE should be returned.
69      */
70     @Test
71     public void equalsTest4() {
72         NiciraActionSerializerKey obj = new NiciraActionSerializerKey(VERSION, SubtypeClass.class);
73         niciraActionSerializerKey = new NiciraActionSerializerKey(VERSION, PopVlanCase.class);
74
75         assertFalse(niciraActionSerializerKey.equals(obj));
76     }
77
78     /**
79      * If input param obj is instance of the same class but has different VERSION then FALSE should be returned.
80      */
81     @Test
82     public void equalsTest5() {
83         NiciraActionSerializerKey obj = new NiciraActionSerializerKey((short)5, SubtypeClass.class);
84         niciraActionSerializerKey = new NiciraActionSerializerKey(VERSION, SubtypeClass.class);
85
86         assertFalse(niciraActionSerializerKey.equals(obj));
87     }
88
89     /**
90      * If input param obj is instance of the same class and has same VERSION and SUBTYPE then TRUE should be returned.
91      */
92     @Test
93     public void equalsTest6() {
94         NiciraActionSerializerKey obj = new NiciraActionSerializerKey(VERSION, SubtypeClass.class);
95         niciraActionSerializerKey = new NiciraActionSerializerKey(VERSION, SubtypeClass.class);
96
97         assertTrue(niciraActionSerializerKey.equals(obj));
98     }
99
100     /**
101      * If input param obj is exactly same TRUE should be returned.
102      */
103     @Test
104     public void equalsTest7() {
105         niciraActionSerializerKey = new NiciraActionSerializerKey(VERSION, SubtypeClass.class);
106
107         assertTrue(niciraActionSerializerKey.equals(niciraActionSerializerKey));
108     }
109
110
111
112     private interface SubtypeClass extends ActionChoice {}
113
114
115 }