X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Futil%2Fmatcher%2FConditionTest.java;h=227c92517171f759d6434dc73ba898c001eef663;hb=e9a1c2c372f4bbf6cf658de3dba73ef326b20c20;hp=9d8b2259c79fdd8ebe3f830fca4f9b81c640717d;hpb=f8b17a9e7363b8a9e7cd12d61bc6d611c7c97d7d;p=jalview.git diff --git a/test/jalview/util/matcher/ConditionTest.java b/test/jalview/util/matcher/ConditionTest.java index 9d8b225..227c925 100644 --- a/test/jalview/util/matcher/ConditionTest.java +++ b/test/jalview/util/matcher/ConditionTest.java @@ -1,6 +1,27 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.util.matcher; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; import java.util.Locale; @@ -16,6 +37,8 @@ public class ConditionTest assertEquals(Condition.NotContains.toString(), "Does not contain"); assertEquals(Condition.Matches.toString(), "Matches"); assertEquals(Condition.NotMatches.toString(), "Does not match"); + assertEquals(Condition.Present.toString(), "Is present"); + assertEquals(Condition.NotPresent.toString(), "Is not present"); assertEquals(Condition.LT.toString(), "<"); assertEquals(Condition.LE.toString(), "<="); assertEquals(Condition.GT.toString(), ">"); @@ -28,4 +51,46 @@ public class ConditionTest */ assertEquals(Condition.NE.toString(), "not ="); } + + @Test(groups = "Functional") + public void testGetStableName() + { + assertEquals(Condition.Contains.getStableName(), "Contains"); + assertEquals(Condition.NotContains.getStableName(), "NotContains"); + assertEquals(Condition.Matches.getStableName(), "Matches"); + assertEquals(Condition.NotMatches.getStableName(), "NotMatches"); + assertEquals(Condition.Present.getStableName(), "Present"); + assertEquals(Condition.NotPresent.getStableName(), "NotPresent"); + assertEquals(Condition.LT.getStableName(), "LT"); + assertEquals(Condition.LE.getStableName(), "LE"); + assertEquals(Condition.GT.getStableName(), "GT"); + assertEquals(Condition.GE.getStableName(), "GE"); + assertEquals(Condition.EQ.getStableName(), "EQ"); + assertEquals(Condition.NE.getStableName(), "NE"); + } + + @Test(groups = "Functional") + public void testFromString() + { + assertEquals(Condition.fromString("Contains"), Condition.Contains); + // not case sensitive + assertEquals(Condition.fromString("contains"), Condition.Contains); + assertEquals(Condition.fromString("CONTAINS"), Condition.Contains); + assertEquals(Condition.fromString("NotContains"), + Condition.NotContains); + assertEquals(Condition.fromString("Matches"), Condition.Matches); + assertEquals(Condition.fromString("NotMatches"), Condition.NotMatches); + assertEquals(Condition.fromString("Present"), Condition.Present); + assertEquals(Condition.fromString("NotPresent"), Condition.NotPresent); + assertEquals(Condition.fromString("LT"), Condition.LT); + assertEquals(Condition.fromString("LE"), Condition.LE); + assertEquals(Condition.fromString("GT"), Condition.GT); + assertEquals(Condition.fromString("GE"), Condition.GE); + assertEquals(Condition.fromString("EQ"), Condition.EQ); + assertEquals(Condition.fromString("NE"), Condition.NE); + + assertNull(Condition.fromString("Equals")); + assertNull(Condition.fromString("")); + assertNull(Condition.fromString(null)); + } }