// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
//     private RSQLParser rsqlParser;
// 
//     public DefaultFilterParser() {
//         rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
//     }
// 
//     @Override
//     public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
//         E filterParam = filterContext.getFilterParam();
//         return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
//     }
// }
// 
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
//     <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
// 
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
//     private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
//             .add(RSQLOperators.EQUAL,
//                     RSQLOperators.NOT_EQUAL,
//                     RSQLOperators.GREATER_THAN,
//                     RSQLOperators.GREATER_THAN_OR_EQUAL,
//                     RSQLOperators.LESS_THAN,
//                     RSQLOperators.LESS_THAN_OR_EQUAL)
//             .build();
// 
//     public static String build(String selector, ComparisonOperator op, String... args) {
//         validateArgument(args);
//         if (singleArgOps.contains(op)) {
//             return selector + op.getSymbol() + args[0];
//         } else {
//             return selector + op.getSymbol() + buildArguments(args);
//         }
//     }
// 
//     public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
//         validateArgument(args);
//         String[] rqlFilters = new String[op.getSymbols().length];
// 
//         int index = 0;
//         for (String symbol : op.getSymbols()) {
//             if (singleArgOps.contains(op)) {
//                 rqlFilters[index] = selector + symbol + args[0];
//             } else {
//                 rqlFilters[index] = selector + symbol + buildArguments(args);
//             }
//             index++;
//         }
// 
//         return rqlFilters;
//     }
// 
//     private static void validateArgument(String[] args) {
//         Preconditions.checkNotNull(args);
//         Preconditions.checkArgument(args.length > 0);
//         for (String arg : args) {
//             Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
//         }
//     }
// 
//     public static String buildArguments(String... args) {
//         return "(" + Joiner.on(",").join(args) + ")";
//     }
// }
// 
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
//     return new FilterContext<T, E>()
//             .setFilterBuilder(builder)
//             .setFilterParam(filterParam);
// }


import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.HashMap;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.Maps;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import com.querydsl.core.types.dsl.Expressions;
        assertTrue(predicate instanceof BooleanOperation);
        BooleanOperation booleanOperation = (BooleanOperation) predicate;

        assertEquals(2, booleanOperation.getArgs().size());
        assertEquals("!startsWithIgnoreCase(name,Khi)", booleanOperation.getArg(0).toString());
        assertEquals("name is null", booleanOperation.getArg(1).toString());
        assertEquals(Ops.OR, booleanOperation.getOperator());
    }

    @Test
    public void testParse_StringNotEndsWith() {
        String rqlFilter = "name!=*Khi";
        FilterParser filterParser = new DefaultFilterParser();
        Predicate predicate = filterParser.parse(rqlFilter, withBuilderAndParam(new QuerydslFilterBuilder(), createFilterParam("name")));
        assertNotNull(predicate);
        assertTrue(predicate instanceof BooleanOperation);
        BooleanOperation booleanOperation = (BooleanOperation) predicate;

        assertEquals(2, booleanOperation.getArgs().size());
        assertEquals("!endsWithIgnoreCase(name,Khi)", booleanOperation.getArg(0).toString());
        assertEquals("name is null", booleanOperation.getArg(1).toString());
        assertEquals(Ops.OR, booleanOperation.getOperator());
    }

    @Test
    public void testParse_StringNotContainsWith() {
        String rqlFilter = "name!=*Khi*";
        FilterParser filterParser = new DefaultFilterParser();
        Predicate predicate = filterParser.parse(rqlFilter, withBuilderAndParam(new QuerydslFilterBuilder(), createFilterParam("name")));
        assertNotNull(predicate);
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
//     private RSQLParser rsqlParser;
// 
//     public DefaultFilterParser() {
//         rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
//     }
// 
//     @Override
//     public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
//         E filterParam = filterContext.getFilterParam();
//         return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
//     }
// }
// 
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
//     <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
// 
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
//     private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
//             .add(RSQLOperators.EQUAL,
//                     RSQLOperators.NOT_EQUAL,
//                     RSQLOperators.GREATER_THAN,
//                     RSQLOperators.GREATER_THAN_OR_EQUAL,
//                     RSQLOperators.LESS_THAN,
//                     RSQLOperators.LESS_THAN_OR_EQUAL)
//             .build();
// 
//     public static String build(String selector, ComparisonOperator op, String... args) {
//         validateArgument(args);
//         if (singleArgOps.contains(op)) {
//             return selector + op.getSymbol() + args[0];
//         } else {
//             return selector + op.getSymbol() + buildArguments(args);
//         }
//     }
// 
//     public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
//         validateArgument(args);
//         String[] rqlFilters = new String[op.getSymbols().length];
// 
//         int index = 0;
//         for (String symbol : op.getSymbols()) {
//             if (singleArgOps.contains(op)) {
//                 rqlFilters[index] = selector + symbol + args[0];
//             } else {
//                 rqlFilters[index] = selector + symbol + buildArguments(args);
//             }
//             index++;
//         }
// 
//         return rqlFilters;
//     }
// 
//     private static void validateArgument(String[] args) {
//         Preconditions.checkNotNull(args);
//         Preconditions.checkArgument(args.length > 0);
//         for (String arg : args) {
//             Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
//         }
//     }
// 
//     public static String buildArguments(String... args) {
//         return "(" + Joiner.on(",").join(args) + ")";
//     }
// }
// 
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
//     return new FilterContext<T, E>()
//             .setFilterBuilder(builder)
//             .setFilterParam(filterParam);
// }


// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_StringPath_Test.java
import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.HashMap;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.Maps;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import com.querydsl.core.types.dsl.Expressions;

        assertTrue(predicate instanceof BooleanOperation);
        BooleanOperation booleanOperation = (BooleanOperation) predicate;

        assertEquals(2, booleanOperation.getArgs().size());
        assertEquals("!startsWithIgnoreCase(name,Khi)", booleanOperation.getArg(0).toString());
        assertEquals("name is null", booleanOperation.getArg(1).toString());
        assertEquals(Ops.OR, booleanOperation.getOperator());
    }

    @Test
    public void testParse_StringNotEndsWith() {
        String rqlFilter = "name!=*Khi";
        FilterParser filterParser = new DefaultFilterParser();
        Predicate predicate = filterParser.parse(rqlFilter, withBuilderAndParam(new QuerydslFilterBuilder(), createFilterParam("name")));
        assertNotNull(predicate);
        assertTrue(predicate instanceof BooleanOperation);
        BooleanOperation booleanOperation = (BooleanOperation) predicate;

        assertEquals(2, booleanOperation.getArgs().size());
        assertEquals("!endsWithIgnoreCase(name,Khi)", booleanOperation.getArg(0).toString());
        assertEquals("name is null", booleanOperation.getArg(1).toString());
        assertEquals(Ops.OR, booleanOperation.getOperator());
    }

    @Test
    public void testParse_StringNotContainsWith() {
        String rqlFilter = "name!=*Khi*";
        FilterParser filterParser = new DefaultFilterParser();
        Predicate predicate = filterParser.parse(rqlFilter, withBuilderAndParam(new QuerydslFilterBuilder(), createFilterParam("name")));
        assertNotNull(predicate);
        assertTrue(predicate instanceof BooleanOperation);