Mass replace CRLF->LF
[openflowjava.git] / openflow-protocol-api / src / test / java / org / opendaylight / openflowjava / protocol / api / keys / ActionDeserializerKeyTest.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;
10
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
14
15 /**
16  * @author michal.polkorab
17  *
18  */
19 public class ActionDeserializerKeyTest {
20
21     /**
22      * Test ActionDeserializerKey equals and hashCode
23      */
24     @Test
25     public void test() {
26         ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L);
27         ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L);
28         Assert.assertTrue("Wrong equals", key1.equals(key2));
29         Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode());
30         key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null);
31         Assert.assertFalse("Wrong equals", key1.equals(key2));
32         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
33         key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 55L);
34         Assert.assertFalse("Wrong equals", key1.equals(key2));
35         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
36         key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42L);
37         Assert.assertFalse("Wrong equals", key1.equals(key2));
38         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
39         key2 = new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 11, 42L);
40         Assert.assertFalse("Wrong equals", key1.equals(key2));
41         Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode());
42     }
43     
44     /**
45      * Test ActionDeserializerKey equals - additional test
46      */
47     @Test
48     public void testEquals(){
49         ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null);
50         ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L);
51
52         Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
53         Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object()));
54         Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2));
55         key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null);
56         Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2));
57     }
58
59     /**
60      * Test InstructionDeserializerKey toString()
61      */
62     @Test
63     public void testToString(){
64         ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null);
65
66         Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn"
67                 + ".opendaylight.openflow.common.action.rev130731.actions.grouping.Action msgType: 11"
68                 + " experimenterID: null", key1.toString());
69     }
70 }