2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
21 package jalview.analysis;
23 import static org.testng.AssertJUnit.assertFalse;
24 import static org.testng.AssertJUnit.assertTrue;
26 import jalview.analysis.SequenceIdMatcher.SeqIdName;
27 import jalview.datamodel.SequenceI;
28 import jalview.gui.JvOptionPane;
30 import org.testng.annotations.BeforeClass;
31 import org.testng.annotations.Test;
33 public class SequenceIdMatcherTest
36 @BeforeClass(alwaysRun = true)
37 public void setUpJvOptionPane()
39 JvOptionPane.setInteractiveMode(false);
40 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
45 * Test the method that checks for one sequence id starting with the other,
46 * followed by an 'allowed' separator character
48 @Test(groups = "Functional")
49 public void test_seqIdNameEquals()
51 SequenceIdMatcher sequenceIdMatcher = new SequenceIdMatcher(
55 * target name = matcher name + word separator...
57 SeqIdName testee = sequenceIdMatcher.new SeqIdName("A12345");
58 assertTrue(testee.equals("A12345"));
59 assertTrue(testee.equals("A12345~"));
60 assertTrue(testee.equals("A12345."));
61 assertTrue(testee.equals("A12345 "));
62 assertTrue(testee.equals("A12345|"));
63 assertTrue(testee.equals("A12345#"));
64 assertTrue(testee.equals("A12345\\"));
65 assertTrue(testee.equals("A12345/"));
66 assertTrue(testee.equals("A12345<"));
67 assertTrue(testee.equals("A12345>"));
68 assertTrue(testee.equals("A12345!"));
69 assertTrue(testee.equals("A12345\""));
70 assertTrue(testee.equals("A12345" + String.valueOf((char) 0x00A4)));
71 assertTrue(testee.equals("A12345$a"));
72 assertTrue(testee.equals("A12345%b"));
73 assertTrue(testee.equals("A12345^cd"));
74 assertTrue(testee.equals("A12345*efg"));
75 assertTrue(testee.equals("A12345)^&!"));
76 assertTrue(testee.equals("A12345}01&*"));
77 assertTrue(testee.equals("A12345[A23456"));
78 assertTrue(testee.equals("A12345@|Uniprot"));
79 assertTrue(testee.equals("A12345'whatever you want here"));
80 assertTrue(testee.equals("A12345,"));
81 assertTrue(testee.equals("A12345?"));
82 assertTrue(testee.equals("A12345_"));
84 * case insensitive matching
86 assertTrue(testee.equals("a12345"));
89 * matcher name = target name + word separator...
91 testee = sequenceIdMatcher.new SeqIdName("A12345#");
92 assertTrue(testee.equals("A12345"));
95 * case insensitive matching
97 assertTrue(testee.equals("a12345"));
100 * miscellaneous failing cases
102 testee = sequenceIdMatcher.new SeqIdName("A12345");
103 assertFalse(testee.equals((Object) null));
104 assertFalse(testee.equals(""));
105 assertFalse(testee.equals("A12346|A12345"));
107 * case insensitive matching
109 assertTrue(testee.equals("a12345"));
111 testee = sequenceIdMatcher.new SeqIdName("A12345?B23456");
112 assertFalse(testee.equals("B23456"));
113 assertFalse(testee.equals("A12345|"));
114 assertFalse(testee.equals("A12345?"));
116 testee = sequenceIdMatcher.new SeqIdName("A12345<");
117 assertFalse(testee.equals("A12345?"));
118 assertTrue(testee.equals("A12345<")); // bug? inconsistent
120 * case insensitive matching
122 assertTrue(testee.equals("a12345"));
124 testee = sequenceIdMatcher.new SeqIdName("UNIPROT|A12345");
125 assertFalse(testee.equals("A12345"));
126 assertFalse(testee.equals("UNIPROT|B98765"));
127 assertFalse(testee.equals("UNIPROT|"));
128 assertTrue(testee.equals("UNIPROT"));