use of org.apache.cxf.jaxrs.ext.search.SearchCondition in project cxf by apache.
the class FiqlParserTest method testParseLocalDateTimeWithCustomFormat.
@Test
public void testParseLocalDateTimeWithCustomFormat() throws SearchParseException, ParseException {
Map<String, String> props = new HashMap<>();
props.put(SearchUtils.DATE_FORMAT_PROPERTY, "yyyy-MM-dd'T'HH:mm:ss");
props.put(SearchUtils.TIMEZONE_SUPPORT_PROPERTY, "false");
parser = new FiqlParser<>(Condition.class, props);
SearchCondition<Condition> filter = parser.parse("localDateTime=le=2010-03-11T18:00:00");
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
assertTrue(filter.isMet(new Condition("whatever", 15, null, LocalDateTime.parse("2010-03-11T18:00:00", df))));
assertTrue(filter.isMet(new Condition(null, null, null, LocalDateTime.parse("2010-03-10T22:22:00", df))));
assertFalse(filter.isMet(new Condition("blah", null, null, LocalDateTime.parse("2010-03-12T00:00:00", df))));
assertFalse(filter.isMet(new Condition(null, 123, null, LocalDateTime.parse("2010-03-12T00:00:00", df))));
}
use of org.apache.cxf.jaxrs.ext.search.SearchCondition in project cxf by apache.
the class FiqlParserTest method testParseDateWithCustomFormat.
@Test
public void testParseDateWithCustomFormat() throws SearchParseException, ParseException {
Map<String, String> props = new HashMap<>();
props.put(SearchUtils.DATE_FORMAT_PROPERTY, "yyyy-MM-dd'T'HH:mm:ss");
props.put(SearchUtils.TIMEZONE_SUPPORT_PROPERTY, "false");
parser = new FiqlParser<>(Condition.class, props);
SearchCondition<Condition> filter = parser.parse("time=le=2010-03-11T18:00:00");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
assertTrue(filter.isMet(new Condition("whatever", 15, df.parse("2010-03-11T18:00:00"))));
assertTrue(filter.isMet(new Condition(null, null, df.parse("2010-03-10T22:22:00"))));
assertFalse(filter.isMet(new Condition("blah", null, df.parse("2010-03-12T00:00:00"))));
assertFalse(filter.isMet(new Condition(null, 123, df.parse("2010-03-12T00:00:00"))));
}
use of org.apache.cxf.jaxrs.ext.search.SearchCondition in project cxf by apache.
the class FiqlParserTest method testParseLevel.
@Test
public void testParseLevel() throws SearchParseException {
SearchCondition<Condition> filter = parser.parse("level=gt=10");
assertTrue(filter.isMet(new Condition("whatever", 15, new Date())));
assertTrue(filter.isMet(new Condition(null, 15, null)));
assertFalse(filter.isMet(new Condition("blah", 5, new Date())));
assertFalse(filter.isMet(new Condition("foobar", 0, null)));
}
use of org.apache.cxf.jaxrs.ext.search.SearchCondition in project cxf by apache.
the class FiqlParserTest method testParseComplex2.
@Test
public void testParseComplex2() throws SearchParseException {
SearchCondition<Condition> filter = parser.parse("name==ami*,level=gt=10");
assertEquals(ConditionType.OR, filter.getConditionType());
List<SearchCondition<Condition>> conditions = filter.getSearchConditions();
assertEquals(2, conditions.size());
PrimitiveStatement st1 = conditions.get(0).getStatement();
PrimitiveStatement st2 = conditions.get(1).getStatement();
assertTrue((ConditionType.EQUALS.equals(st1.getCondition()) && ConditionType.GREATER_THAN.equals(st2.getCondition())) || (ConditionType.EQUALS.equals(st2.getCondition()) && ConditionType.GREATER_THAN.equals(st1.getCondition())));
assertTrue(filter.isMet(new Condition("ami", 0, new Date())));
assertTrue(filter.isMet(new Condition("foo", 20, null)));
assertFalse(filter.isMet(new Condition("foo", 0, null)));
}
use of org.apache.cxf.jaxrs.ext.search.SearchCondition in project cxf by apache.
the class FiqlParserTest method testParseDateWithDefaultFormat.
@Test
public void testParseDateWithDefaultFormat() throws SearchParseException, ParseException {
SearchCondition<Condition> filter = parser.parse("time=le=2010-03-11T18:00:00.000+00:00");
DateFormat df = new SimpleDateFormat(SearchUtils.DEFAULT_DATE_FORMAT);
assertTrue(filter.isMet(new Condition("whatever", 15, df.parse("2010-03-11T18:00:00.000+0000"))));
assertTrue(filter.isMet(new Condition(null, null, df.parse("2010-03-10T22:22:00.000+0000"))));
assertFalse(filter.isMet(new Condition("blah", null, df.parse("2010-03-12T00:00:00.000+0000"))));
assertFalse(filter.isMet(new Condition(null, 123, df.parse("2010-03-12T00:00:00.000+0000"))));
}
Aggregations