Merge "Adding name param for forwarding enties:"
[groupbasedpolicy.git] / groupbasedpolicy / src / test / java / org / opendaylight / groupbasedpolicy / endpoint / EpKeyTest.java
1 /*
2  * Copyright (c) 2015 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
9 package org.opendaylight.groupbasedpolicy.endpoint;
10
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.opendaylight.groupbasedpolicy.dto.EpKey;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L2ContextId;
17
18 public class EpKeyTest {
19
20     private EpKey epKey;
21     private L2ContextId l2Context;
22     private MacAddress macAddress;
23
24     @Before
25     public void init() {
26         l2Context = new L2ContextId("l2ctxId");
27         macAddress = new MacAddress("00:00:00:00:00:01");
28         epKey = new EpKey(l2Context, macAddress);
29     }
30
31     @Test
32     public void testConstructor() {
33         Assert.assertEquals(l2Context, epKey.getL2Context());
34         Assert.assertEquals(macAddress, epKey.getMacAddress());
35     }
36
37     @Test
38     public void testEquals() {
39         Assert.assertTrue(epKey.equals(epKey));
40         Assert.assertFalse(epKey.equals(null));
41         Assert.assertFalse(epKey.equals(new Object()));
42
43         EpKey other;
44         MacAddress macAddressOther = new MacAddress("00:00:00:00:00:02");;
45         L2ContextId l2ContextIdOther = new L2ContextId("l2ctxId-other");
46         other = new EpKey(l2Context, macAddressOther);
47         Assert.assertFalse(epKey.equals(other));
48         other = new EpKey(l2ContextIdOther, macAddress);
49         Assert.assertFalse(epKey.equals(other));
50         other = new EpKey(l2Context, macAddress);
51         Assert.assertTrue(epKey.equals(other));
52
53         epKey = new EpKey(l2Context, null);
54         Assert.assertFalse(epKey.equals(other));
55         epKey = new EpKey(null, macAddress);
56         Assert.assertFalse(epKey.equals(other));
57         epKey = new EpKey(null, null);
58         Assert.assertFalse(epKey.equals(other));
59         other = new EpKey(null, null);
60         Assert.assertTrue(epKey.equals(other));
61     }
62
63     @Test
64     public void testToString() {
65         Assert.assertNotNull(epKey.toString());
66     }
67 }