JAL-2154 - rejig test pass code for breadth-first (or top down) repetition of fetch...
[jalview.git] / test / jalview / io / Jalview2xmlBase.java
1 package jalview.io;
2
3 import jalview.bin.Cache;
4 import jalview.datamodel.AlignmentAnnotation;
5 import jalview.datamodel.SequenceI;
6 import jalview.gui.Desktop;
7
8 import java.time.Instant;
9 import java.util.Date;
10
11 import org.testng.annotations.AfterClass;
12 import org.testng.annotations.BeforeClass;
13 import org.testng.annotations.BeforeTest;
14
15 public class Jalview2xmlBase
16 {
17
18   /**
19    * @throws java.lang.Exception
20    */
21   @BeforeClass(alwaysRun = true)
22   public static void setUpBeforeClass() throws Exception
23   {
24     jalview.bin.Jalview.main(new String[] { "-props",
25         "test/jalview/io/testProps_nodas.jvprops" });
26     jalview.bin.Cache.setProperty(
27             "JALVIEW_NEWS_RSS_LASTMODIFIED",
28             Cache.date_format.format(Date.from(Instant.now().plusSeconds(
29                     3600))));
30   }
31
32   /**
33    * @throws java.lang.Exception
34    */
35   @AfterClass(alwaysRun = true)
36   public static void tearDownAfterClass() throws Exception
37   {
38     jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
39   }
40
41   @BeforeTest(alwaysRun = true)
42   public static void clearDesktop()
43   {
44     if (Desktop.instance != null && Desktop.getAlignFrames() != null)
45     {
46       Desktop.instance.closeAll_actionPerformed(null);
47     }
48   }
49
50   public int countDsAnn(jalview.viewmodel.AlignmentViewport avp)
51   {
52     int numdsann = 0;
53     for (SequenceI sq : avp.getAlignment().getDataset().getSequences())
54     {
55       if (sq.getAnnotation() != null)
56       {
57         for (AlignmentAnnotation dssa : sq.getAnnotation())
58         {
59           if (dssa.isValidStruc())
60           {
61             numdsann++;
62           }
63         }
64       }
65     }
66     return numdsann;
67   }
68
69 }