X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fstructure%2FStructureMappingTest.java;h=808e662143fefaaa653163b9014e6c6ea5bfad24;hb=refs%2Fheads%2Fimprovement%2FJAL-3847_some_attempts_to_set_gradle_and_groovy_versions;hp=f26c5f196cb613c0154d3677935788ada5f0c565;hpb=82d0da843f8697597679b852f3ec47f4fd21a94b;p=jalview.git
diff --git a/test/jalview/structure/StructureMappingTest.java b/test/jalview/structure/StructureMappingTest.java
index f26c5f1..808e662 100644
--- a/test/jalview/structure/StructureMappingTest.java
+++ b/test/jalview/structure/StructureMappingTest.java
@@ -1,8 +1,34 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.structure;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
+import jalview.datamodel.Mapping;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceI;
+import jalview.util.MapList;
+
import java.util.HashMap;
import java.util.List;
@@ -11,9 +37,9 @@ import org.testng.annotations.Test;
public class StructureMappingTest
{
@Test(groups = "Functional")
- public void testgetPDBResNumRanges()
+ public void testGetPDBResNumRanges()
{
- HashMap map = new HashMap();
+ HashMap map = new HashMap<>();
StructureMapping mapping = new StructureMapping(null, null, null, null,
map, null);
@@ -43,4 +69,75 @@ public class StructureMappingTest
assertEquals(ranges.get(1)[0], 15);
assertEquals(ranges.get(1)[1], 15);
}
+
+ @Test(groups = "Functional")
+ public void testEquals()
+ {
+ SequenceI seq1 = new Sequence("seq1", "ABCDE");
+ SequenceI seq2 = new Sequence("seq1", "ABCDE");
+ String pdbFile = "a/b/file1.pdb";
+ String pdbId = "1a70";
+ String chain = "A";
+ String mappingDetails = "these are the mapping details, honest";
+ HashMap map = new HashMap<>();
+
+ Mapping seqToPdbMapping = new Mapping(seq1,
+ new MapList(new int[]
+ { 1, 5 }, new int[] { 2, 6 }, 1, 1));
+ StructureMapping sm1 = new StructureMapping(seq1, pdbFile, pdbId, chain,
+ map, mappingDetails, seqToPdbMapping);
+ assertFalse(sm1.equals(null));
+ assertFalse(sm1.equals("x"));
+
+ StructureMapping sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain,
+ map, mappingDetails, seqToPdbMapping);
+ assertTrue(sm1.equals(sm2));
+ assertTrue(sm2.equals(sm1));
+ assertEquals(sm1.hashCode(), sm2.hashCode());
+
+ // with different sequence
+ sm2 = new StructureMapping(seq2, pdbFile, pdbId, chain, map,
+ mappingDetails, seqToPdbMapping);
+ assertFalse(sm1.equals(sm2));
+ assertFalse(sm2.equals(sm1));
+
+ // with different file
+ sm2 = new StructureMapping(seq1, "a/b/file2.pdb", pdbId, chain, map,
+ mappingDetails, seqToPdbMapping);
+ assertFalse(sm1.equals(sm2));
+ assertFalse(sm2.equals(sm1));
+
+ // with different pdbid (case sensitive)
+ sm2 = new StructureMapping(seq1, pdbFile, "1A70", chain, map,
+ mappingDetails, seqToPdbMapping);
+ assertFalse(sm1.equals(sm2));
+ assertFalse(sm2.equals(sm1));
+
+ // with different chain
+ sm2 = new StructureMapping(seq1, pdbFile, pdbId, "B", map,
+ mappingDetails, seqToPdbMapping);
+ assertFalse(sm1.equals(sm2));
+ assertFalse(sm2.equals(sm1));
+
+ // map is ignore for this test
+ sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain, null,
+ mappingDetails, seqToPdbMapping);
+ assertTrue(sm1.equals(sm2));
+ assertTrue(sm2.equals(sm1));
+
+ // with different mapping details
+ sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain, map,
+ "different details!", seqToPdbMapping);
+ assertFalse(sm1.equals(sm2));
+ assertFalse(sm2.equals(sm1));
+
+ // with different seq to pdb mapping
+ Mapping map2 = new Mapping(seq1,
+ new MapList(new int[]
+ { 1, 5 }, new int[] { 3, 7 }, 1, 1));
+ sm2 = new StructureMapping(seq1, pdbFile, pdbId, chain, map,
+ mappingDetails, map2);
+ assertFalse(sm1.equals(sm2));
+ assertFalse(sm2.equals(sm1));
+ }
}