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.datamodel;
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertFalse;
25 import static org.testng.AssertJUnit.assertTrue;
27 import jalview.gui.JvOptionPane;
29 import org.testng.annotations.BeforeClass;
30 import org.testng.annotations.Test;
32 public class MatchTest
35 @BeforeClass(alwaysRun = true)
36 public void setUpJvOptionPane()
38 JvOptionPane.setInteractiveMode(false);
39 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
42 @Test(groups = { "Functional" })
43 public void testToString()
45 SequenceI seq = new Sequence("Seq1", "abcdefghijklm");
46 SearchResultMatchI m = new SearchResults().new Match(seq, 3, 5);
47 assertEquals("Seq1/3-5", m.toString());
50 @Test(groups = { "Functional" })
51 public void testEquals()
53 SequenceI seq1 = new Sequence("", "abcdefghijklm");
54 SequenceI seq2 = new Sequence("", "abcdefghijklm");
55 SearchResultsI sr1 = new SearchResults();
56 SearchResultsI sr2 = new SearchResults();
58 assertFalse(sr1.equals(null));
59 assertFalse(sr1.equals(seq1));
60 assertTrue(sr1.equals(sr1));
61 assertTrue(sr1.equals(sr2));
62 assertTrue(sr2.equals(sr1));
64 sr1.addResult(seq1, 1, 1);
65 assertFalse(sr1.equals(sr2));
66 assertFalse(sr2.equals(sr1));
68 sr2.addResult(seq1, 1, 1);
69 assertTrue(sr1.equals(sr2));
70 assertTrue(sr2.equals(sr1));
73 * same match but on different sequences - not equal
75 SearchResultsI sr3 = new SearchResults();
76 sr3.addResult(seq2, 1, 1);
77 assertFalse(sr1.equals(sr3));
78 assertFalse(sr3.equals(sr1));
81 * same sequence but different end position - not equal
83 sr1.addResult(seq1, 3, 4);
84 sr2.addResult(seq1, 3, 5);
85 assertFalse(sr1.equals(sr2));
88 * same sequence but different start position - not equal
90 sr1 = new SearchResults();
91 sr2 = new SearchResults();
92 sr1.addResult(seq1, 3, 4);
93 sr2.addResult(seq1, 2, 4);
94 assertFalse(sr1.equals(sr2));