From 8265140e97adaf4062d25b0850b8421263bc1899 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 22 May 2013 18:06:21 +0100 Subject: [PATCH] JAL-1295 JAL-1297 enhance test to check graph visiblity and graphGroup set equivalence --- test/jalview/io/StockholmFileTest.java | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/test/jalview/io/StockholmFileTest.java b/test/jalview/io/StockholmFileTest.java index 2a57ae1..9beb174 100644 --- a/test/jalview/io/StockholmFileTest.java +++ b/test/jalview/io/StockholmFileTest.java @@ -1,6 +1,7 @@ package jalview.io; -import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; @@ -9,8 +10,9 @@ import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import java.io.File; -import java.io.IOException; -import java.io.InputStream; +import java.util.BitSet; +import java.util.HashMap; +import java.util.Map; import org.junit.Test; @@ -133,6 +135,7 @@ public class StockholmFileTest // we might want to revise this in future int aa_new_size = (aa_new == null ? 0 : aa_new.length), aa_original_size = (aa_original == null ? 0 : aa_original.length); + Map orig_groups=new HashMap(),new_groups=new HashMap(); if (aa_new != null && aa_original != null) { @@ -141,6 +144,20 @@ public class StockholmFileTest if (aa_new.length>i) { assertTrue("Different alignment annotation at position "+i, equalss(aa_original[i], aa_new[i])); + // compare graphGroup or graph properties - needed to verify JAL-1299 + assertTrue("Graph type not identical.",aa_original[i].graph==aa_new[i].graph); + assertTrue("Visibility not identical.", aa_original[i].visible==aa_new[i].visible); + // graphGroup may differ, but pattern should be the same + Integer o_ggrp=new Integer(aa_original[i].graphGroup+2),n_ggrp=new Integer(aa_new[i].graphGroup+2); + BitSet orig_g=orig_groups.get(o_ggrp),new_g=new_groups.get(n_ggrp); + if (orig_g==null) { + orig_groups.put(o_ggrp,orig_g= new BitSet()); + } + if (new_g==null) { + new_groups.put(n_ggrp, new_g=new BitSet()); + } + assertTrue("Graph Group pattern differs at annotation "+i, orig_g.equals(new_g)); + orig_g.set(i); new_g.set(i); } else { System.err.println("No matching annotation row for "+aa_original[i].toString()); } @@ -255,8 +272,6 @@ public class StockholmFileTest System.err.println("Different lengths for annotation row elements: "+annot_or.annotations.length +"!="+ annot_new.annotations.length); return false; } - // TODO: does not compare graphGroup or graph properties - // TODO: does not compare visibility for (int i = 0; i < annot_or.annotations.length; i++) { Annotation an_or=annot_or.annotations[i],an_new=annot_new.annotations[i]; -- 1.7.10.2