From 7b928cacb8aa11d0ece7e7c0eaa02c2b25cb7c0f Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 30 Nov 2015 09:28:43 +0000 Subject: [PATCH] JAL-1270 constructor test added --- test/jalview/datamodel/AlignmentTest.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/jalview/datamodel/AlignmentTest.java b/test/jalview/datamodel/AlignmentTest.java index 8abc03e..5d299bb 100644 --- a/test/jalview/datamodel/AlignmentTest.java +++ b/test/jalview/datamodel/AlignmentTest.java @@ -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()); + } } -- 1.7.10.2