use of org.apache.cxf.jaxrs.ext.search.SearchCondition in project cxf by apache.
the class FiqlParserTest method testParseOffsetDateTimeWithDefaultFormat.
@Test
public void testParseOffsetDateTimeWithDefaultFormat() throws SearchParseException, ParseException {
SearchCondition<Condition> filter = parser.parse("offsetDateTime=le=2010-03-11T18:00:00+01:00");
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
assertTrue(filter.isMet(new Condition("whatever", 15, null, OffsetDateTime.parse("2010-03-11T18:00:00+0100", df))));
assertTrue(filter.isMet(new Condition(null, null, null, OffsetDateTime.parse("2010-03-10T22:22:00+0100", df))));
assertFalse(filter.isMet(new Condition("blah", null, null, OffsetDateTime.parse("2010-03-12T00:00:00+0100", df))));
assertFalse(filter.isMet(new Condition(null, 123, null, OffsetDateTime.parse("2010-03-12T00:00:00+0100", df))));
}
use of org.apache.cxf.jaxrs.ext.search.SearchCondition in project cxf by apache.
the class FiqlParserTest method doTestParseName2.
private void doTestParseName2(String exp) throws SearchParseException {
SearchCondition<Condition> filter = parser.parse(exp);
assertTrue(filter.isMet(new Condition("king", 10, new Date(), "king2")));
assertTrue(filter.isMet(new Condition("king", 0, null, "king2")));
assertFalse(filter.isMet(new Condition("diamond", 10, new Date(), "theking2")));
assertFalse(filter.isMet(new Condition("diamond", 0, null, "theking2")));
}
use of org.apache.cxf.jaxrs.ext.search.SearchCondition in project cxf by apache.
the class FiqlParserTest method testParseInstantDuration.
@Test
public void testParseInstantDuration() throws Exception {
SearchCondition<Condition> filter = parser.parse("localDateTime=gt=-PT1M");
LocalDateTime now = LocalDateTime.now();
LocalDateTime tenMinutesAgo = now.minusMinutes(10);
assertTrue(filter.isMet(new Condition(null, null, null, now)));
assertFalse(filter.isMet(new Condition(null, null, null, tenMinutesAgo)));
}
use of org.apache.cxf.jaxrs.ext.search.SearchCondition in project cxf by apache.
the class ODataParser method parse.
@Override
@SuppressWarnings("unchecked")
public SearchCondition<T> parse(String searchExpression) throws SearchParseException {
try {
final T condition = conditionClass.newInstance();
final FilterExpression expression = parser.parseFilterString(searchExpression);
final FilterExpressionVisitor visitor = new FilterExpressionVisitor(condition);
return (SearchCondition<T>) expression.accept(visitor);
} catch (ODataMessageException | ODataApplicationException | InstantiationException | IllegalAccessException ex) {
throw new SearchParseException(ex);
}
}
use of org.apache.cxf.jaxrs.ext.search.SearchCondition in project cxf by apache.
the class FiqlParserTest method doTestParseName.
private void doTestParseName(String exp) throws SearchParseException {
SearchCondition<Condition> filter = parser.parse(exp);
assertTrue(filter.isMet(new Condition("king", 10, new Date())));
assertTrue(filter.isMet(new Condition("king", 0, null)));
assertFalse(filter.isMet(new Condition("diamond", 10, new Date())));
assertFalse(filter.isMet(new Condition("diamond", 0, null)));
}
Aggregations