Clover icon

Coverage Report

  1. Project Clover database Wed Nov 13 2024 16:12:26 GMT
  2. Package jalview.analysis

File SequenceIdMatcherTest.java

 

Code metrics

0
51
2
1
129
71
2
0.04
25.5
2
1

Classes

Class Line # Actions
SequenceIdMatcherTest 33 51 2
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.analysis;
22   
23    import static org.testng.AssertJUnit.assertFalse;
24    import static org.testng.AssertJUnit.assertTrue;
25   
26    import jalview.analysis.SequenceIdMatcher.SeqIdName;
27    import jalview.datamodel.SequenceI;
28    import jalview.gui.JvOptionPane;
29   
30    import org.testng.annotations.BeforeClass;
31    import org.testng.annotations.Test;
32   
 
33    public class SequenceIdMatcherTest
34    {
35   
 
36  1 toggle @BeforeClass(alwaysRun = true)
37    public void setUpJvOptionPane()
38    {
39  1 JvOptionPane.setInteractiveMode(false);
40  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
41    }
42   
43    /**
44    * Test the method that checks for one sequence id starting with the other,
45    * followed by an 'allowed' separator character
46    */
 
47  1 toggle @Test(groups = "Functional")
48    public void test_seqIdNameEquals()
49    {
50  1 SequenceIdMatcher sequenceIdMatcher = new SequenceIdMatcher(
51    new SequenceI[] {});
52   
53    /*
54    * target name = matcher name + word separator...
55    */
56  1 SeqIdName testee = sequenceIdMatcher.new SeqIdName("A12345");
57  1 assertTrue(testee.equals("A12345"));
58  1 assertTrue(testee.equals("A12345~"));
59  1 assertTrue(testee.equals("A12345."));
60  1 assertTrue(testee.equals("A12345 "));
61  1 assertTrue(testee.equals("A12345|"));
62  1 assertTrue(testee.equals("A12345#"));
63  1 assertTrue(testee.equals("A12345\\"));
64  1 assertTrue(testee.equals("A12345/"));
65  1 assertTrue(testee.equals("A12345<"));
66  1 assertTrue(testee.equals("A12345>"));
67  1 assertTrue(testee.equals("A12345!"));
68  1 assertTrue(testee.equals("A12345\""));
69  1 assertTrue(testee.equals("A12345" + String.valueOf((char) 0x00A4)));
70  1 assertTrue(testee.equals("A12345$a"));
71  1 assertTrue(testee.equals("A12345%b"));
72  1 assertTrue(testee.equals("A12345^cd"));
73  1 assertTrue(testee.equals("A12345*efg"));
74  1 assertTrue(testee.equals("A12345)^&!"));
75  1 assertTrue(testee.equals("A12345}01&*"));
76  1 assertTrue(testee.equals("A12345[A23456"));
77  1 assertTrue(testee.equals("A12345@|Uniprot"));
78  1 assertTrue(testee.equals("A12345'whatever you want here"));
79  1 assertTrue(testee.equals("A12345,"));
80  1 assertTrue(testee.equals("A12345?"));
81  1 assertTrue(testee.equals("A12345_"));
82    /*
83    * case insensitive matching
84    */
85  1 assertTrue(testee.equals("a12345"));
86   
87    /*
88    * matcher name = target name + word separator...
89    */
90  1 testee = sequenceIdMatcher.new SeqIdName("A12345#");
91  1 assertTrue(testee.equals("A12345"));
92   
93    /*
94    * case insensitive matching
95    */
96  1 assertTrue(testee.equals("a12345"));
97   
98    /*
99    * miscellaneous failing cases
100    */
101  1 testee = sequenceIdMatcher.new SeqIdName("A12345");
102  1 assertFalse(testee.equals((Object) null));
103  1 assertFalse(testee.equals(""));
104  1 assertFalse(testee.equals("A12346|A12345"));
105    /*
106    * case insensitive matching
107    */
108  1 assertTrue(testee.equals("a12345"));
109   
110  1 testee = sequenceIdMatcher.new SeqIdName("A12345?B23456");
111  1 assertFalse(testee.equals("B23456"));
112  1 assertFalse(testee.equals("A12345|"));
113  1 assertFalse(testee.equals("A12345?"));
114   
115  1 testee = sequenceIdMatcher.new SeqIdName("A12345<");
116  1 assertFalse(testee.equals("A12345?"));
117  1 assertTrue(testee.equals("A12345<")); // bug? inconsistent
118    /*
119    * case insensitive matching
120    */
121  1 assertTrue(testee.equals("a12345"));
122   
123  1 testee = sequenceIdMatcher.new SeqIdName("UNIPROT|A12345");
124  1 assertFalse(testee.equals("A12345"));
125  1 assertFalse(testee.equals("UNIPROT|B98765"));
126  1 assertFalse(testee.equals("UNIPROT|"));
127  1 assertTrue(testee.equals("UNIPROT"));
128    }
129    }