Remove trailing whitespace
[openflowjava.git] / openflow-protocol-impl / src / test / java / org / opendaylight / openflowjava / protocol / impl / deserialization / MessageTypeCodeKeyTest.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.impl.deserialization;
10
11 import org.junit.Assert;
12 import org.junit.Test;
13
14
15 /**
16  *
17  * @author madamjak
18  *
19  */
20 public class MessageTypeCodeKeyTest {
21
22     /**
23      * Tests equals and hashCode
24      */
25     @Test
26     public void testEqualsAndHashcode(){
27         short msgType1 = 12;
28         short msgVersion1 = 34;
29         short msgType2 = 21;
30         short msgVersion2 = 43;
31         MessageTypeCodeKey key1 = new MessageTypeCodeKey(msgVersion1, msgType1);
32
33         Assert.assertTrue("Wrong - equals to same object", key1.equals(key1));
34         Assert.assertFalse("Wrong - equals to null", key1.equals(null));
35         Assert.assertFalse("Wrong - equals to different class", key1.equals(new Object()));
36
37         MessageTypeCodeKey key2 = new MessageTypeCodeKey(msgVersion1, msgType1);
38         Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode());
39         Assert.assertTrue("Wrong - equals to mirror object", key1.equals(key2));
40
41         key2 = new MessageTypeCodeKey(msgVersion2, msgType2);
42         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
43         Assert.assertFalse("Wrong - equals by msgType", key1.equals(key2));
44
45         key2 = new MessageTypeCodeKey(msgVersion2, msgType1);
46         Assert.assertFalse("Wrong - equals by msgVersion", key1.equals(key2));
47         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
48     }
49
50     /**
51      * Tests getters
52      */
53     @Test
54     public void testGetter(){
55         short msgType = 12;
56         short msgVersion = 34;
57         MessageTypeCodeKey key1 = new MessageTypeCodeKey(msgVersion, msgType);
58
59         Assert.assertEquals(msgType, key1.getMsgType());
60         Assert.assertEquals(msgVersion, key1.getMsgVersion());
61     }
62 }