Clover icon

Coverage Report

  1. Project Clover database Mon Nov 18 2024 09:56:54 GMT
  2. Package jalview.util.matcher

File ConditionTest.java

 

Code metrics

0
43
3
1
96
64
3
0.07
14.33
3
1

Classes

Class Line # Actions
ConditionTest 30 43 3
1.0100%
 

Contributing tests

This file is covered by 3 tests. .

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