295ba4e3a864b64ef46bdde71baf5cc04514b86c
[openflowjava.git] / openflow-protocol-api / src / test / java / org / opendaylight / openflowjava / protocol / api / keys / InstructionSerializerKeyTest.java
1 /*\r
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.openflowjava.protocol.api.keys;\r
10 \r
11 import org.junit.Assert;\r
12 import org.junit.Test;\r
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;\r
16 \r
17 /**\r
18  * @author michal.polkorab\r
19  *\r
20  */\r
21 public class InstructionSerializerKeyTest {\r
22 \r
23     /**\r
24      * Test InstructionSerializerKey equals and hashCode\r
25      */\r
26     @Test\r
27     public void test() {\r
28         InstructionSerializerKey<?> key1 =\r
29                 new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);\r
30                 InstructionSerializerKey<?> key2 =\r
31                 new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);\r
32         Assert.assertTrue("Wrong equals", key1.equals(key2));\r
33         Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
34         key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null);\r
35         Assert.assertFalse("Wrong equals", key1.equals(key2));\r
36         Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
37         key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L);\r
38         Assert.assertFalse("Wrong equals", key1.equals(key2));\r
39         Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
40         key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, WriteActions.class, 42L);\r
41         Assert.assertFalse("Wrong equals", key1.equals(key2));\r
42         Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
43         key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 55L);\r
44         Assert.assertFalse("Wrong equals", key1.equals(key2));\r
45         Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
46         key2 = new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ApplyActions.class, 42L);\r
47         Assert.assertFalse("Wrong equals", key1.equals(key2));\r
48         Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());\r
49     }\r
50 }