$darkmode
DENOPTIM
RelatedAPPairTest.java
Go to the documentation of this file.
1package denoptim.graph;
2
3
4/*
5 * DENOPTIM
6 * Copyright (C) 2019 Vishwesh Venkatraman <vishwesh.venkatraman@ntnu.no>
7 * and Marco Foscato <marco.foscato@uib.no>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published
11 * by the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
18 *
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23import static org.junit.jupiter.api.Assertions.assertEquals;
24import static org.junit.jupiter.api.Assertions.assertFalse;
25import static org.junit.jupiter.api.Assertions.assertNotEquals;
26import static org.junit.jupiter.api.Assertions.assertNull;
27import static org.junit.jupiter.api.Assertions.assertTrue;
28
29import org.junit.jupiter.api.Test;
30
32{
33
34//-----------------------------------------------------------------------------
35
36 @Test
37 public void testEquals() throws Exception
38 {
39 EmptyVertex v = new EmptyVertex();
40 v.addAP(APClass.make("apc:0"));
41 v.addAP(APClass.make("apc:0"));
42 v.addAP(APClass.make("apc:1"));
43
44 Object prop = new String("prop");
45
46 RelatedAPPair pA = new RelatedAPPair(v.getAP(0), v.getAP(1), prop,
47 "propIDString");
48 RelatedAPPair pB = new RelatedAPPair(v.getAP(0), v.getAP(1), prop,
49 "propIDString");
50
51 assertTrue(pA.equals(pA));
52 assertTrue(pA.equals(pB));
53 assertTrue(pB.equals(pA));
54 assertFalse(pA.equals(null));
55
56 pB = new RelatedAPPair(v.getAP(0), v.getAP(2), prop,
57 "propIDString");
58 assertTrue(pB.equals(pB));
59 assertFalse(pA.equals(pB));
60 assertFalse(pB.equals(pA));
61
62 pB = new RelatedAPPair(v.getAP(1), v.getAP(0), prop,
63 "propIDString");
64 assertTrue(pB.equals(pB));
65 assertFalse(pA.equals(pB));
66 assertFalse(pB.equals(pA));
67
68 pB = new RelatedAPPair(v.getAP(0), v.getAP(1), "different",
69 "propIDString");
70 assertTrue(pB.equals(pB));
71 assertFalse(pA.equals(pB));
72 assertFalse(pB.equals(pA));
73
74 pB = new RelatedAPPair(v.getAP(0), v.getAP(1), prop,
75 "different_IDString");
76 assertTrue(pB.equals(pB));
77 assertFalse(pA.equals(pB));
78 assertFalse(pB.equals(pA));
79 }
80
81//------------------------------------------------------------------------------
82
83}
static APClass make(String ruleAndSubclass)
Creates an APClass if it does not exist already, or returns the reference to the existing instance.
Definition: APClass.java:164
An empty vertex has the behaviors of a vertex, but has no molecular structure.
void addAP()
Adds an attachment point with no APClass or other attribute.
AttachmentPoint getAP(int i)
Get attachment point i on this vertex.
Definition: Vertex.java:1008