$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.assertFalse;
24import static org.junit.jupiter.api.Assertions.assertTrue;
25
26import org.junit.jupiter.api.Test;
27
29{
30
31//-----------------------------------------------------------------------------
32
33 @Test
34 public void testEquals() throws Exception
35 {
36 EmptyVertex v = new EmptyVertex();
37 v.addAP(APClass.make("apc:0"));
38 v.addAP(APClass.make("apc:0"));
39 v.addAP(APClass.make("apc:1"));
40
41 Object prop = new String("prop");
42
43 RelatedAPPair pA = new RelatedAPPair(v.getAP(0), v.getAP(1), prop,
44 "propIDString");
45 RelatedAPPair pB = new RelatedAPPair(v.getAP(0), v.getAP(1), prop,
46 "propIDString");
47
48 assertTrue(pA.equals(pA));
49 assertTrue(pA.equals(pB));
50 assertTrue(pB.equals(pA));
51 assertFalse(pA.equals(null));
52
53 pB = new RelatedAPPair(v.getAP(0), v.getAP(2), prop,
54 "propIDString");
55 assertTrue(pB.equals(pB));
56 assertFalse(pA.equals(pB));
57 assertFalse(pB.equals(pA));
58
59 pB = new RelatedAPPair(v.getAP(1), v.getAP(0), prop,
60 "propIDString");
61 assertTrue(pB.equals(pB));
62 assertFalse(pA.equals(pB));
63 assertFalse(pB.equals(pA));
64
65 pB = new RelatedAPPair(v.getAP(0), v.getAP(1), "different",
66 "propIDString");
67 assertTrue(pB.equals(pB));
68 assertFalse(pA.equals(pB));
69 assertFalse(pB.equals(pA));
70
71 pB = new RelatedAPPair(v.getAP(0), v.getAP(1), prop,
72 "different_IDString");
73 assertTrue(pB.equals(pB));
74 assertFalse(pA.equals(pB));
75 assertFalse(pB.equals(pA));
76 }
77
78//------------------------------------------------------------------------------
79
80}
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:1007