public class PropertyFilterTest {
@Test
public void createFilter() {
//Boolean EQ filter
PropertyFilter booleanEqFilter = new PropertyFilter("EQB_foo", "true");
assertEquals(MatchType.EQ, booleanEqFilter.getMatchType());
assertEquals(Boolean.class, booleanEqFilter.getPropertyClass());
assertEquals(true, booleanEqFilter.getMatchValue());
//Date LT filter
PropertyFilter dateLtFilter = new PropertyFilter("LTD_foo", "2046-01-01");
assertEquals(MatchType.LT, dateLtFilter.getMatchType());
assertEquals(Date.class, dateLtFilter.getPropertyClass());
assertEquals("foo", dateLtFilter.getPropertyName());
assertEquals(new DateTime(2046, 1, 1, 0, 0, 0, 0).toDate(), dateLtFilter.getMatchValue());
//Integer GT filter
PropertyFilter intGtFilter = new PropertyFilter("GTI_foo", "123");
assertEquals(MatchType.GT, intGtFilter.getMatchType());
assertEquals(Integer.class, intGtFilter.getPropertyClass());
assertEquals("foo", intGtFilter.getPropertyName());
assertEquals(123, intGtFilter.getMatchValue());
//Double LE filter
PropertyFilter doubleLeFilter = new PropertyFilter("LEN_foo", "12.33");
assertEquals(MatchType.LE, doubleLeFilter.getMatchType());
assertEquals(Double.class, doubleLeFilter.getPropertyClass());
assertEquals("foo", doubleLeFilter.getPropertyName());
assertEquals(12.33, doubleLeFilter.getMatchValue());
//Long GE filter
PropertyFilter longGeFilter = new PropertyFilter("GEL_foo", "123456789");
assertEquals(MatchType.GE, longGeFilter.getMatchType());
assertEquals(Long.class, longGeFilter.getPropertyClass());
assertEquals("foo", longGeFilter.getPropertyName());
assertEquals(123456789L, longGeFilter.getMatchValue());
//Like OR filter
PropertyFilter likeOrFilter = new PropertyFilter("LIKES_foo_OR_bar", "hello");
assertEquals(MatchType.LIKE, likeOrFilter.getMatchType());
assertEquals(String.class, likeOrFilter.getPropertyClass());
assertArrayEquals(new String[] { "foo", "bar" }, likeOrFilter.getPropertyNames());
assertEquals("hello", likeOrFilter.getMatchValue());
}