2 * Copyright © 2018 Orange 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.transportpce.renderer;
11 import java.util.Arrays;
12 import java.util.Collection;
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.junit.runner.RunWith;
16 import org.junit.runners.Parameterized;
18 @RunWith(Parameterized.class)
19 public class NodeIdPairTest {
21 private NodeIdPair firstPair;
22 private Object secondPair;
23 private boolean equality;
25 public NodeIdPairTest(NodeIdPair firstPair, Object secondPair, boolean equality) {
26 this.firstPair = firstPair;
27 this.secondPair = secondPair;
28 this.equality = equality;
31 @Parameterized.Parameters
32 public static Collection nodes() {
33 NodeIdPair same = new NodeIdPair("nodeS", "CLIENT");
34 return Arrays.asList(new Object[][] {
35 { new NodeIdPair("",""), null, false },
36 { new NodeIdPair("",""), "", false },
37 { new NodeIdPair("node1","PP"), new NodeIdPair("node2","PP"), false },
38 { new NodeIdPair("node1","PP"), new NodeIdPair("node1","TTP"), false },
39 { new NodeIdPair(null,"PP"), new NodeIdPair(null,"TTP"), false },
40 { new NodeIdPair(null,"PP"), new NodeIdPair("node2","TTP"), false },
41 { new NodeIdPair("node1",null), new NodeIdPair("node1","NETWORK"), false },
42 { new NodeIdPair("node1",null), new NodeIdPair("node1",null), true },
43 { new NodeIdPair("node1","TTP"), new NodeIdPair("node1","TTP"), true },
44 { new NodeIdPair(null,null), new NodeIdPair(null,null), true },
50 public void equalityTest() {
51 Assert.assertEquals(this.equality, firstPair.equals(this.secondPair));
52 if ((this.secondPair != null) && this.firstPair.getClass().equals(this.secondPair.getClass())) {
53 Assert.assertEquals(this.equality, this.firstPair.hashCode() == this.secondPair.hashCode());