JAL-1270 constructor test added
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 30 Nov 2015 09:28:43 +0000 (09:28 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 30 Nov 2015 09:28:43 +0000 (09:28 +0000)
test/jalview/datamodel/AlignmentTest.java

index 8abc03e..5d299bb 100644 (file)
@@ -22,6 +22,7 @@ package jalview.datamodel;
 
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertSame;
 import static org.testng.AssertJUnit.assertTrue;
 
 import jalview.io.AppletFormatAdapter;
@@ -29,6 +30,7 @@ import jalview.io.FormatAdapter;
 import jalview.util.MapList;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.Iterator;
 
 import org.testng.annotations.BeforeMethod;
@@ -385,4 +387,27 @@ public class AlignmentTest
     assertEquals("c--CCGgg-TT--T------AA-A", al1.getSequenceAt(1)
             .getSequenceAsString());
   }
+
+  @Test(groups = "Functional")
+  public void testCopyConstructor() throws IOException
+  {
+    AlignmentI protein = loadAlignment(AA_SEQS_1, FormatAdapter.PASTE);
+    protein.setDataset(null);
+    AlignedCodonFrame acf = new AlignedCodonFrame();
+    protein.getDataset().setCodonFrames(Collections.singleton(acf));
+    AlignmentI copy = new Alignment(protein);
+
+    /*
+     * copy has different aligned sequences but the same dataset sequences
+     */
+    assertFalse(copy.getSequenceAt(0) == protein.getSequenceAt(0));
+    assertFalse(copy.getSequenceAt(1) == protein.getSequenceAt(1));
+    assertSame(copy.getSequenceAt(0).getDatasetSequence(), protein
+            .getSequenceAt(0).getDatasetSequence());
+    assertSame(copy.getSequenceAt(1).getDatasetSequence(), protein
+            .getSequenceAt(1).getDatasetSequence());
+    // and the same alignment dataset (?)
+    // or a new one with the same dataset sequences?
+    assertSame(copy.getDataset(), protein.getDataset());
+  }
 }