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.util.matcher;
23 import static org.testng.Assert.assertEquals;
24 import static org.testng.Assert.assertNull;
26 import java.util.Locale;
28 import org.testng.annotations.Test;
30 public class ConditionTest
32 @Test(groups = "Functional")
33 public void testToString()
35 Locale.setDefault(Locale.UK);
36 assertEquals(Condition.Contains.toString(), "Contains");
37 assertEquals(Condition.NotContains.toString(), "Does not contain");
38 assertEquals(Condition.Matches.toString(), "Matches");
39 assertEquals(Condition.NotMatches.toString(), "Does not match");
40 assertEquals(Condition.Present.toString(), "Is present");
41 assertEquals(Condition.NotPresent.toString(), "Is not present");
42 assertEquals(Condition.LT.toString(), "<");
43 assertEquals(Condition.LE.toString(), "<=");
44 assertEquals(Condition.GT.toString(), ">");
45 assertEquals(Condition.GE.toString(), ">=");
46 assertEquals(Condition.EQ.toString(), "=");
47 assertEquals(Condition.NE.toString(), "not =");
50 * repeat call to get coverage of value caching
52 assertEquals(Condition.NE.toString(), "not =");
55 @Test(groups = "Functional")
56 public void testGetStableName()
58 assertEquals(Condition.Contains.getStableName(), "Contains");
59 assertEquals(Condition.NotContains.getStableName(), "NotContains");
60 assertEquals(Condition.Matches.getStableName(), "Matches");
61 assertEquals(Condition.NotMatches.getStableName(), "NotMatches");
62 assertEquals(Condition.Present.getStableName(), "Present");
63 assertEquals(Condition.NotPresent.getStableName(), "NotPresent");
64 assertEquals(Condition.LT.getStableName(), "LT");
65 assertEquals(Condition.LE.getStableName(), "LE");
66 assertEquals(Condition.GT.getStableName(), "GT");
67 assertEquals(Condition.GE.getStableName(), "GE");
68 assertEquals(Condition.EQ.getStableName(), "EQ");
69 assertEquals(Condition.NE.getStableName(), "NE");
72 @Test(groups = "Functional")
73 public void testFromString()
75 assertEquals(Condition.fromString("Contains"), Condition.Contains);
77 assertEquals(Condition.fromString("contains"), Condition.Contains);
78 assertEquals(Condition.fromString("CONTAINS"), Condition.Contains);
79 assertEquals(Condition.fromString("NotContains"),
80 Condition.NotContains);
81 assertEquals(Condition.fromString("Matches"), Condition.Matches);
82 assertEquals(Condition.fromString("NotMatches"), Condition.NotMatches);
83 assertEquals(Condition.fromString("Present"), Condition.Present);
84 assertEquals(Condition.fromString("NotPresent"), Condition.NotPresent);
85 assertEquals(Condition.fromString("LT"), Condition.LT);
86 assertEquals(Condition.fromString("LE"), Condition.LE);
87 assertEquals(Condition.fromString("GT"), Condition.GT);
88 assertEquals(Condition.fromString("GE"), Condition.GE);
89 assertEquals(Condition.fromString("EQ"), Condition.EQ);
90 assertEquals(Condition.fromString("NE"), Condition.NE);
92 assertNull(Condition.fromString("Equals"));
93 assertNull(Condition.fromString(""));
94 assertNull(Condition.fromString(null));