--- /dev/null
+package jalview.datamodel;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
+import jalview.schemes.NucleotideColourScheme;
+
+import org.testng.annotations.Test;
+
+public class SequenceGroupTest
+{
+ @Test
+ public void testAddSequence()
+ {
+ 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.addSequence(null, false);
+ assertTrue(sg.getSequences().isEmpty());
+ sg.addSequence(seq1, false);
+ assertEquals(sg.getSequences().size(), 1);
+ assertTrue(sg.getSequences().contains(seq1));
+ // adding the same sequence again does nothing
+ sg.addSequence(seq1, false);
+ assertEquals(sg.getSequences().size(), 1);
+ assertTrue(sg.getSequences().contains(seq1));
+ sg.addSequence(seq2, false);
+ sg.addSequence(seq2, false);
+ sg.addSequence(seq3, false);
+ assertEquals(sg.getSequences().size(), 3);
+ assertTrue(sg.getSequences().contains(seq1));
+ assertTrue(sg.getSequences().contains(seq2));
+ assertTrue(sg.getSequences().contains(seq3));
+ }
+
+ @Test
+ 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);
+ assertEquals(sg.getSequences().size(), 2);
+ sg.addOrRemove(seq3, false);
+ assertEquals(sg.getSequences().size(), 3);
+ assertTrue(sg.getSequences().contains(seq1));
+ assertTrue(sg.getSequences().contains(seq2));
+ assertTrue(sg.getSequences().contains(seq3));
+ sg.addOrRemove(seq1, false);
+ assertEquals(sg.getSequences().size(), 2);
+ assertFalse(sg.getSequences().contains(seq1));
+ }
+
+ @Test
+ public void testGetColourScheme()
+ {
+ SequenceGroup sg = new SequenceGroup();
+ assertNotNull(sg.getGroupColourScheme());
+ assertNull(sg.getColourScheme());
+
+ sg.setGroupColourScheme(null);
+ assertNull(sg.getColourScheme());
+
+ NucleotideColourScheme scheme = new NucleotideColourScheme();
+ sg.setColourScheme(scheme);
+ assertSame(scheme, sg.getColourScheme());
+ }
+}