assertEquals(Condition.NotContains.toString(), "Does not contain");
assertEquals(Condition.Matches.toString(), "Matches");
assertEquals(Condition.NotMatches.toString(), "Does not match");
- assertEquals(Condition.LT.toString(), "Is less than");
- assertEquals(Condition.LE.toString(), "Is less than or equal to");
- assertEquals(Condition.GT.toString(), "Is greater than");
- assertEquals(Condition.GE.toString(), "Is greater than or equal to");
- assertEquals(Condition.EQ.toString(), "Is equal to");
- assertEquals(Condition.NE.toString(), "Is not equal to");
+ assertEquals(Condition.LT.toString(), "<");
+ assertEquals(Condition.LE.toString(), "<=");
+ assertEquals(Condition.GT.toString(), ">");
+ assertEquals(Condition.GE.toString(), ">=");
+ assertEquals(Condition.EQ.toString(), "=");
+ assertEquals(Condition.NE.toString(), "not =");
/*
- * repeat call to get coverage of cached value
+ * repeat call to get coverage of value caching
*/
- assertEquals(Condition.NE.toString(), "Is not equal to");
+ assertEquals(Condition.NE.toString(), "not =");
}
}
* a numeric matcher - MatcherTest covers more conditions
*/
KeyedMatcherI km = new KeyedMatcher("AF", Condition.GE, -2F);
- assertTrue(km.matches(key -> "-2"));
- assertTrue(km.matches(key -> "-1"));
- assertFalse(km.matches(key -> "-3"));
- assertFalse(km.matches(key -> ""));
- assertFalse(km.matches(key -> "junk"));
- assertFalse(km.matches(key -> null));
+ KeyedMatcherSetI kms = new KeyedMatcherSet();
+ kms.and(km);
+ assertTrue(kms.matches(key -> "-2"));
+ assertTrue(kms.matches(key -> "-1"));
+ assertFalse(kms.matches(key -> "-3"));
+ assertFalse(kms.matches(key -> ""));
+ assertFalse(kms.matches(key -> "junk"));
+ assertFalse(kms.matches(key -> null));
/*
* a string pattern matcher
*/
km = new KeyedMatcher("AF", Condition.Contains, "Cat");
- assertTrue(km.matches(key -> "AF".equals(key) ? "raining cats and dogs"
+ kms = new KeyedMatcherSet();
+ kms.and(km);
+ assertTrue(kms
+ .matches(key -> "AF".equals(key) ? "raining cats and dogs"
: "showers"));
}
public void testToString()
{
KeyedMatcherI km1 = new KeyedMatcher("AF", Condition.LT, 1.2f);
- assertEquals(km1.toString(), "AF LT 1.2");
+ assertEquals(km1.toString(), "AF < 1.2");
KeyedMatcher km2 = new KeyedMatcher("CLIN_SIG", Condition.NotContains, "path");
- assertEquals(km2.toString(), "CLIN_SIG NotContains PATH");
+ assertEquals(km2.toString(), "CLIN_SIG Does not contain PATH");
/*
* AND them
KeyedMatcherSetI kms = new KeyedMatcherSet();
assertEquals(kms.toString(), "");
kms.and(km1);
- assertEquals(kms.toString(), "(AF LT 1.2)");
+ assertEquals(kms.toString(), "(AF < 1.2)");
kms.and(km2);
assertEquals(kms.toString(),
- "(AF LT 1.2) AND (CLIN_SIG NotContains PATH)");
+ "(AF < 1.2) AND (CLIN_SIG Does not contain PATH)");
/*
* OR them
kms = new KeyedMatcherSet();
assertEquals(kms.toString(), "");
kms.or(km1);
- assertEquals(kms.toString(), "(AF LT 1.2)");
+ assertEquals(kms.toString(), "(AF < 1.2)");
kms.or(km2);
assertEquals(kms.toString(),
- "(AF LT 1.2) OR (CLIN_SIG NotContains PATH)");
- }
-
- /**
- * @return
- */
- protected KeyedMatcher km3()
- {
- return new KeyedMatcher("CSQ", Condition.Contains, "benign");
+ "(AF < 1.2) OR (CLIN_SIG Does not contain PATH)");
}
@Test
kms.or(km1);
assertTrue(kms.matches(vp));
}
+
+ @Test
+ public void testIsEmpty()
+ {
+ KeyedMatcherI km = new KeyedMatcher("AF", Condition.GE, -2F);
+ KeyedMatcherSetI kms = new KeyedMatcherSet();
+ assertTrue(kms.isEmpty());
+ kms.and(km);
+ assertFalse(kms.isEmpty());
+ }
}