X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fdatamodel%2FSequenceGroupTest.java;h=622ebb9c3a5a6a3ff087c7ed1bb04d13b5127b16;hb=a7169b1c72607f3c9357195b4999869650a2a891;hp=f6d40282f1af8c2ad02e234f41264d12eaf71899;hpb=3b239d86dc3a1bf3aa07c0ad3d38aeca57b54ada;p=jalview.git
diff --git a/test/jalview/datamodel/SequenceGroupTest.java b/test/jalview/datamodel/SequenceGroupTest.java
index f6d4028..622ebb9 100644
--- a/test/jalview/datamodel/SequenceGroupTest.java
+++ b/test/jalview/datamodel/SequenceGroupTest.java
@@ -1,3 +1,23 @@
+/*
+ * 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.datamodel;
import static org.testng.Assert.assertEquals;
@@ -9,18 +29,22 @@ import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
+import jalview.analysis.Conservation;
import jalview.schemes.NucleotideColourScheme;
import jalview.schemes.PIDColourScheme;
import java.awt.Color;
-
-import junit.extensions.PA;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import org.testng.annotations.Test;
+import junit.extensions.PA;
+
public class SequenceGroupTest
{
- @Test(groups={"Functional"})
+ @Test(groups = { "Functional" })
public void testAddSequence()
{
SequenceGroup sg = new SequenceGroup();
@@ -48,16 +72,16 @@ public class SequenceGroupTest
assertTrue(sg.getSequences().contains(seq3));
}
- @Test(groups={"Functional"})
+ @Test(groups = { "Functional" })
public void testAddOrRemove()
{
SequenceGroup sg = new SequenceGroup();
assertTrue(sg.getSequences().isEmpty());
-
+
SequenceI seq1 = new Sequence("seq1", "abc");
SequenceI seq2 = new Sequence("seq2", "abc");
SequenceI seq3 = new Sequence(seq1);
-
+
sg.addOrRemove(seq1, false);
assertEquals(sg.getSequences().size(), 1);
sg.addOrRemove(seq2, false);
@@ -72,7 +96,7 @@ public class SequenceGroupTest
assertFalse(sg.getSequences().contains(seq1));
}
- @Test(groups={"Functional"})
+ @Test(groups = { "Functional" })
public void testGetColourScheme()
{
SequenceGroup sg = new SequenceGroup();
@@ -87,7 +111,7 @@ public class SequenceGroupTest
assertSame(scheme, sg.getColourScheme());
}
- @Test(groups={"Functional"})
+ @Test(groups = { "Functional" })
public void testSetContext()
{
SequenceGroup sg1 = new SequenceGroup();
@@ -232,6 +256,11 @@ public class SequenceGroupTest
sg.setName("g1");
sg.setDescription("desc");
sg.setColourScheme(new PIDColourScheme());
+ Conservation cons = new Conservation("Cons", 2,
+ Collections. emptyList(), 3, 12);
+ PA.setValue(cons, "consSequence", new Sequence("s", "abc"));
+ sg.getGroupColourScheme().setConservation(cons);
+ sg.getGroupColourScheme().setConsensus(new Profiles(null));
sg.setDisplayBoxes(false);
sg.setDisplayText(false);
sg.setColourText(true);
@@ -255,6 +284,10 @@ public class SequenceGroupTest
assertEquals(sg2.getDescription(), sg.getDescription());
assertNotSame(sg2.getGroupColourScheme(), sg.getGroupColourScheme());
assertSame(sg2.getColourScheme(), sg.getColourScheme());
+ assertSame(PA.getValue(sg2.getGroupColourScheme(), "consensus"),
+ PA.getValue(sg.getGroupColourScheme(), "consensus"));
+ assertSame(PA.getValue(sg2.getGroupColourScheme(), "conservation"),
+ PA.getValue(sg.getGroupColourScheme(), "conservation"));
assertEquals(sg2.getDisplayBoxes(), sg.getDisplayBoxes());
assertEquals(sg2.getDisplayText(), sg.getDisplayText());
assertEquals(sg2.getColourText(), sg.getColourText());
@@ -290,4 +323,36 @@ public class SequenceGroupTest
*/
assertNull(sg2.getContext());
}
+
+ @Test(groups = { "Functional" })
+ public void testConstructor_list()
+ {
+ SequenceI s1 = new Sequence("abcde", "fg");
+ SequenceI s2 = new Sequence("foo", "bar");
+ List seqs = new ArrayList();
+ seqs.add(s1);
+ seqs.add(s2);
+ SequenceGroup sg = new SequenceGroup(seqs);
+
+ /*
+ * verify sg has a copy of the original list
+ */
+ List sgList = sg.getSequences();
+ assertNotSame(sgList, seqs);
+ assertEquals(sgList, seqs);
+
+ /*
+ * add to sgList, original is unchanged
+ */
+ sg.addSequence(new Sequence("bar", "foo"), false);
+ assertEquals(sgList.size(), 3);
+ assertEquals(seqs.size(), 2);
+
+ /*
+ * delete from original, sgList is unchanged
+ */
+ seqs.remove(s1);
+ assertEquals(sgList.size(), 3);
+ assertEquals(seqs.size(), 1);
+ }
}