2 * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
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
9 package org.opendaylight.openflowjava.protocol.api.keys;
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
16 * @author michal.polkorab
19 public class ActionDeserializerKeyTest {
22 * Test ActionDeserializerKey equals and hashCode
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());
45 * Test ActionDeserializerKey equals - additional 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);
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));
60 * Test InstructionDeserializerKey toString()
63 public void testToString(){
64 ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null);
66 Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn"
67 + ".opendaylight.openflow.common.action.rev150203.actions.grouping.Action msgType: 11"
68 + " experimenterID: null", key1.toString());