use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.
the class CouchbaseFilterConverterTest method checkMultivaluedSubFilters.
@Test
public void checkMultivaluedSubFilters() throws SearchException {
Filter filterSub1 = Filter.createSubstringFilter("uid", null, new String[] { "test" }, null).multiValued();
ConvertedExpression expressionSub1 = simpleConverter.convertToCouchbaseFilter(filterSub1, null, null);
String querySub1 = toSelectSQL(expressionSub1);
assertEquals(querySub1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY uid_ IN uid SATISFIES uid_ LIKE \"%test%\" END");
Filter filterSub2 = Filter.createSubstringFilter("uid", "a", new String[] { "test" }, null).multiValued();
ConvertedExpression expressionSub2 = simpleConverter.convertToCouchbaseFilter(filterSub2, null, null);
String querySub2 = toSelectSQL(expressionSub2);
assertEquals(querySub2, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY uid_ IN uid SATISFIES uid_ LIKE \"a%test%\" END");
Filter filterSub3 = Filter.createSubstringFilter("uid", null, new String[] { "test" }, "z").multiValued();
ConvertedExpression expressionSub3 = simpleConverter.convertToCouchbaseFilter(filterSub3, null, null);
String querySub3 = toSelectSQL(expressionSub3);
assertEquals(querySub3, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY uid_ IN uid SATISFIES uid_ LIKE \"%test%z\" END");
Filter filterSub4 = Filter.createSubstringFilter("uid", null, new String[] { "test" }, "z").multiValued(3);
ConvertedExpression expressionSub4 = simpleConverter.convertToCouchbaseFilter(filterSub4, null, null);
String querySub4 = toSelectSQL(expressionSub4);
assertEquals(querySub4, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY uid_ IN uid SATISFIES uid_ LIKE \"%test%z\" END");
}
use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.
the class CouchbaseFilterConverterTest method checkOrWithLowerCaseFilter.
@Test
public void checkOrWithLowerCaseFilter() throws SearchException {
boolean useLowercaseFilter = true;
String[] targetArray = new String[] { "test_value" };
Filter descriptionFilter, displayNameFilter;
if (useLowercaseFilter) {
descriptionFilter = Filter.createSubstringFilter(Filter.createLowercaseFilter("description"), null, targetArray, null);
displayNameFilter = Filter.createSubstringFilter(Filter.createLowercaseFilter("displayName"), null, targetArray, null);
} else {
descriptionFilter = Filter.createSubstringFilter("description", null, targetArray, null);
displayNameFilter = Filter.createSubstringFilter("displayName", null, targetArray, null);
}
Filter searchFilter = Filter.createORFilter(descriptionFilter, displayNameFilter);
Filter typeFilter = Filter.createEqualityFilter("jansScrTyp", "person_authentication");
Filter filter = Filter.createANDFilter(searchFilter, typeFilter);
ConvertedExpression expression = simpleConverter.convertToCouchbaseFilter(filter, null, null);
String query = toSelectSQL(expression);
assertEquals(query, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ( ( LOWER(description) LIKE \"%test_value%\" OR LOWER(displayName) LIKE \"%test_value%\" ) AND ( ( jansScrTyp = \"person_authentication\" ) OR ( \"person_authentication\" IN jansScrTyp ) ) )");
}
Aggregations