ExpressionConvertImpl implements ExpressionConvert<Filter> { @Override public Filter convert( Expression expression, Locale locale, EntityModel entityModel) throws ExpressionVisitException { Format format = FastDateFormatFactoryUtil.getSimpleDateFormat( PropsUtil.get(PropsKeys.INDEX_DATE_FORMAT_PATTERN)); return (Filter)expression.accept( new ExpressionVisitorImpl(format, locale, entityModel)); }  @Override Filter convert(
			Expression expression, Locale locale, EntityModel entityModel);  }
@Test public void testConvertBinaryExpressionWithEqOnPrimitiveField() throws ExpressionVisitException { BinaryExpression binaryExpression = new BinaryExpressionImpl( new MemberExpressionImpl( new PrimitivePropertyExpressionImpl("title")), BinaryExpression.Operation.EQ, new LiteralExpressionImpl("test", LiteralExpression.Type.STRING)); TermFilter termFilter = (TermFilter)_expressionConvertImpl.convert( binaryExpression, LocaleUtil.getDefault(), _entityModel); Assert.assertEquals("title", termFilter.getField()); Assert.assertEquals("test", termFilter.getValue()); }
@Test public void testConvertListExpressionWithInOnPrimitiveField() throws ExpressionVisitException { ListExpression listExpression = new ListExpressionImpl( new MemberExpressionImpl( new PrimitivePropertyExpressionImpl("title")), ListExpression.Operation.IN, Collections.singletonList( new LiteralExpressionImpl( "test", LiteralExpression.Type.STRING))); TermsFilter termsFilter = (TermsFilter)_expressionConvertImpl.convert( listExpression, LocaleUtil.getDefault(), _entityModel); Assert.assertEquals("title", termsFilter.getField()); String[] values = termsFilter.getValues(); Assert.assertEquals("test", values[0]); }
@Test public void testConvertMemberExpressionWithLambdaAnyEqOnCollectionField() throws ExpressionVisitException { MemberExpression memberExpression = new MemberExpressionImpl( new CollectionPropertyExpressionImpl( new PrimitivePropertyExpressionImpl("keywords"), new LambdaFunctionExpressionImpl( LambdaFunctionExpression.Type.ANY, "k", new BinaryExpressionImpl( new MemberExpressionImpl( new LambdaVariableExpressionImpl("k")), BinaryExpression.Operation.EQ, new LiteralExpressionImpl( "'keyword1'", LiteralExpression.Type.STRING))))); TermFilter termFilter = (TermFilter)_expressionConvertImpl.convert( memberExpression, LocaleUtil.getDefault(), _entityModel); Assert.assertNotNull(termFilter); Assert.assertEquals("keywords.raw", termFilter.getField()); Assert.assertEquals("keyword1", termFilter.getValue()); }