JAL_1641 updated test -- added test for annotations
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 12 May 2015 10:37:40 +0000 (11:37 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 12 May 2015 10:37:40 +0000 (11:37 +0100)
test/jalview/io/JSONFileTest.java

index 0f957ea..d2960d9 100644 (file)
@@ -24,6 +24,8 @@ public class JSONFileTest
 
   private int TEST_GRP_HEIGHT = 0;
 
+  private int TEST_ANOT_HEIGHT = 0;
+
   @Before
   public void setUp() throws Exception
   {
@@ -123,6 +125,7 @@ public class JSONFileTest
     // Alignment al = new Alignment(seqs);
     TEST_SEQ_HEIGHT = jsonFile.seqs.size();
     TEST_GRP_HEIGHT = jsonFile.seqGroups.size();
+    TEST_ANOT_HEIGHT = jsonFile.annotations.size();
   }
 
   @After
@@ -171,8 +174,36 @@ public class JSONFileTest
           ++matchedCounter;
         }
       }
-      Assert.assertTrue(matchedCounter == TEST_GRP_HEIGHT);
     }
+    Assert.assertTrue(matchedCounter == TEST_GRP_HEIGHT);
+
+    matchedCounter = 0;
+    for (AlignmentAnnotation in : jsonFile.annotations)
+    {
+      for (AlignmentAnnotation out : output.annotations)
+      {
+        try
+        {
+          // System.out.println("label >>>>> " + in.label + " | " + out.label);
+          // System.out.println("label >>>>> " + in.description + " | "
+          // + out.description);
+          // System.out.println("label >>>>> " + in.annotations.length + " | "
+          // + out.annotations.length);
+          if (in.label.equals(out.label)
+                  && in.description.equals(out.description)
+                && in.annotations.length == out.annotations.length)
+        {
+          ++matchedCounter;
+        }
+        } catch (Exception e)
+        {
+          e.printStackTrace();
+        }
+      }
+    }
+    // System.out.println("matched >>>>> " + matchedCounter + " | "
+    // + TEST_ANOT_HEIGHT);
+    Assert.assertTrue(matchedCounter == TEST_ANOT_HEIGHT);
 
   }