OQLFilterBuilder { public static Filter<Object> getFilter(String expression) { return getFilter(expression, new FilterFactory<Object>() { @Override public Filter<Object> createFullTextFilter(String expression) { throw new RuntimeException("Full text search not implemented"); } @Override public Filter<Object> createAttributeFilter(String operator, String attribute, String value) { return new Filter<Object>() { @Override public boolean test(Object input) { try { return value.equals(PropertyUtils.getProperty(input, attribute)); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | NestedNullException e) { return false; } } }; } }); }  static Filter<Object> getFilter(String expression); static Filter<T> getFilter(String expression, FilterFactory<T> factory);  }
@Test public void test() { Filter<Object> filter = OQLFilterBuilder.getFilter("property1=prop1"); boolean test = filter.test(new Bean()); Assert.assertTrue(test); }
@Test public void test2() { Filter<Object> filter = OQLFilterBuilder.getFilter("property1=prop1 and bean1.property1=prop1"); boolean test = filter.test(new Bean()); Assert.assertTrue(test); }
@Test public void test3() { Filter<Object> filter = OQLFilterBuilder.getFilter("property1=prop1 and bean1.property1=prop1 and map1.property2=prop2"); boolean test = filter.test(new Bean()); Assert.assertTrue(test); }
@Test public void test4() { Filter<Object> filter = OQLFilterBuilder.getFilter("property1=wrongValue and bean1.property1=prop1 and map1.property2=prop2"); boolean test = filter.test(new Bean()); Assert.assertFalse(test); }
@Test public void test5() { Filter<Object> filter = OQLFilterBuilder.getFilter("map1.wrongProperty=prop2"); boolean test = filter.test(new Bean()); Assert.assertFalse(test); }
@Test public void test6() { Filter<Object> filter = OQLFilterBuilder.getFilter(""); boolean test = filter.test(new Bean()); Assert.assertTrue(test); }
@Test public void test7() { Filter<Object> filter = OQLFilterBuilder.getFilter(null); boolean test = filter.test(new Bean()); Assert.assertTrue(test); }
@Test public void test8() { Filter<Object> filter = OQLFilterBuilder.getFilter("not(property1=prop1)"); boolean test = filter.test(new Bean()); Assert.assertFalse(test); }
@Test public void test9() { Filter<Object> filter = OQLFilterBuilder.getFilter("not(property1=prop1) or bean1.property1=prop1"); boolean test = filter.test(new Bean()); Assert.assertTrue(test); }
@Test public void test10() { Filter<Object> filter = OQLFilterBuilder.getFilter("property1=\"prop1\""); boolean test = filter.test(new Bean()); Assert.assertTrue(test); }
@Test public void test11() { Filter<Object> filter = OQLFilterBuilder.getFilter("property2=\"prop with some \"\"\"\"\""); boolean test = filter.test(new Bean()); Assert.assertTrue(test); }