JAL-4245 Test getRootDataset method improvement/JAL-4245-return-null-from-getRootDataset
authorMateusz Warowny <mmzwarowny@dundee.ac.uk>
Wed, 26 Jul 2023 14:18:09 +0000 (16:18 +0200)
committerMateusz Warowny <mmzwarowny@dundee.ac.uk>
Wed, 26 Jul 2023 14:18:09 +0000 (16:18 +0200)
test/jalview/datamodel/SequenceTest.java

index 7133455..529c80b 100644 (file)
@@ -1600,6 +1600,43 @@ public class SequenceTest
     assertTrue(found.contains(sfI));
   }
 
+  @Test(groups = { "Functional"} )
+  public void testGetRootDatasetSequence_datasetIsNull_returnNull()
+  {
+    Sequence dseq = new Sequence("test", "ABCDEF");
+    assertNull(dseq.getRootDatasetSequence());
+  }
+
+  @Test(groups = { "Functional" })
+  public void testGetRootDatasetSequence_datasetImplicit_returnDataset()
+  {
+    Sequence seq = new Sequence("test", "--AB-CDEF");
+    SequenceI dseq = seq.createDatasetSequence();
+    assertEquals(seq.getRootDatasetSequence(), dseq);
+  }
+
+  @Test(groups = { "Functional" })
+  public void testGetRootDatasetSequence_datasetExplicit_returnDataset()
+  {
+    Sequence seq = new Sequence("test", "--AB-CDEF");
+    Sequence dseq = new Sequence("test", "ABCDEF");
+    seq.setDatasetSequence(dseq);
+    assertEquals(seq.getRootDatasetSequence(), dseq);
+  }
+
+  @Test(groups = { "Functional" })
+  public void testGetRootDatasetSequence_nestedDatasets_returnLastDataset()
+  {
+    Sequence seq = new Sequence("test", "--AB-CDEFE");
+    Sequence dseq = new Sequence("test", "ABCDEF");
+    seq.setDatasetSequence(dseq);
+    Sequence ddseq = new Sequence("test", "ABCDEF");
+    dseq.setDatasetSequence(ddseq);
+    assertEquals(seq.getDatasetSequence(), dseq);
+    assertEquals(seq.getRootDatasetSequence(), ddseq);
+  }
+
+
   @Test(groups = { "Functional" })
   public void testFindIndex_withCursor()
   {