2 * Copyright (c) 2015 Cisco Systems, Inc. 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.groupbasedpolicy.endpoint;
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.rev130715.MacAddress;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L2ContextId;
18 public class EpKeyTest {
21 private L2ContextId l2Context;
22 private MacAddress macAddress;
26 l2Context = new L2ContextId("l2ctxId");
27 macAddress = new MacAddress("00:00:00:00:00:01");
28 epKey = new EpKey(l2Context, macAddress);
32 public void testConstructor() {
33 Assert.assertEquals(l2Context, epKey.getL2Context());
34 Assert.assertEquals(macAddress, epKey.getMacAddress());
38 public void testEquals() {
39 Assert.assertTrue(epKey.equals(epKey));
40 Assert.assertFalse(epKey.equals(null));
41 Assert.assertFalse(epKey.equals(new Object()));
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));
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));
64 public void testToString() {
65 Assert.assertNotNull(epKey.toString());