use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.
the class CouchbaseFilterConverterTest method checkSubFilters.
@Test
public void checkSubFilters() throws SearchException {
Filter filterSub1 = Filter.createSubstringFilter("uid", null, new String[] { "test" }, null);
ConvertedExpression expressionSub1 = simpleConverter.convertToCouchbaseFilter(filterSub1, null, null);
String querySub1 = toSelectSQL(expressionSub1);
assertEquals(querySub1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE uid LIKE \"%test%\"");
Filter filterSub2 = Filter.createSubstringFilter("uid", "a", new String[] { "test" }, null);
ConvertedExpression expressionSub2 = simpleConverter.convertToCouchbaseFilter(filterSub2, null, null);
String querySub2 = toSelectSQL(expressionSub2);
assertEquals(querySub2, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE uid LIKE \"a%test%\"");
Filter filterSub3 = Filter.createSubstringFilter("uid", null, new String[] { "test" }, "z");
ConvertedExpression expressionSub3 = simpleConverter.convertToCouchbaseFilter(filterSub3, null, null);
String querySub3 = toSelectSQL(expressionSub3);
assertEquals(querySub3, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE uid LIKE \"%test%z\"");
}
use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.
the class CouchbaseFilterConverterTest method checkNotFilters.
@Test
public void checkNotFilters() throws SearchException {
Filter notFilter1 = Filter.createNOTFilter(Filter.createLessOrEqualFilter("age", 23));
ConvertedExpression expressionNot1 = simpleConverter.convertToCouchbaseFilter(notFilter1, null, null);
String queryUserUid1 = toSelectSQL(expressionNot1);
assertEquals(queryUserUid1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ( NOT age <= 23 )");
Filter notFilter2 = Filter.createNOTFilter(Filter.createANDFilter(Filter.createLessOrEqualFilter("age", 23), Filter.createGreaterOrEqualFilter("age", 25)));
ConvertedExpression expressionNot2 = simpleConverter.convertToCouchbaseFilter(notFilter2, null, null);
String queryUserUid2 = toSelectSQL(expressionNot2);
assertEquals(queryUserUid2, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ( NOT ( age <= 23 AND age >= 25 ) )");
}
use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.
the class CouchbaseFilterConverterTest method checkLowerFilters.
@Test
public void checkLowerFilters() throws SearchException {
Filter userUidFilter1 = Filter.createEqualityFilter(Filter.createLowercaseFilter("uid"), "test");
ConvertedExpression expressionUserUid1 = simpleConverter.convertToCouchbaseFilter(userUidFilter1, null, null);
String queryUserUid1 = toSelectSQL(expressionUserUid1);
assertEquals(queryUserUid1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE LOWER(uid) = \"test\"");
}
use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.
the class CouchbaseFilterConverterTest method checkSinglevaluedLowerFilters.
@Test
public void checkSinglevaluedLowerFilters() throws SearchException {
Filter userUidFilter = Filter.createEqualityFilter(Filter.createLowercaseFilter("uid"), "test").multiValued(false);
ConvertedExpression expressionUserUid = simpleConverter.convertToCouchbaseFilter(userUidFilter, null, null);
String queryUserUid = toSelectSQL(expressionUserUid);
assertEquals(queryUserUid, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE LOWER(uid) = \"test\"");
}
use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.
the class CouchbaseFilterConverterTest method checkGeFilters.
@Test
public void checkGeFilters() throws SearchException {
// LE -- String
Filter filterGe1 = Filter.createGreaterOrEqualFilter("uid", "test");
ConvertedExpression expressionGe1 = simpleConverter.convertToCouchbaseFilter(filterGe1, null, null);
String queryGe1 = toSelectSQL(expressionGe1);
assertEquals(queryGe1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE uid >= \"test\"");
// LE -- Integer
Filter filterGe2 = Filter.createGreaterOrEqualFilter("age", 23);
ConvertedExpression expressionGe2 = simpleConverter.convertToCouchbaseFilter(filterGe2, null, null);
String queryGe2 = toSelectSQL(expressionGe2);
assertEquals(queryGe2, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE age >= 23");
// LE -- Long
Filter filterGe3 = Filter.createGreaterOrEqualFilter("age", 23L);
ConvertedExpression expressionGe3 = simpleConverter.convertToCouchbaseFilter(filterGe3, null, null);
String queryGe3 = toSelectSQL(expressionGe3);
assertEquals(queryGe3, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE age >= 23");
// LE -- Date
Filter filterGe4 = Filter.createGreaterOrEqualFilter("added", getUtcDateFromMillis(1608130698398L));
ConvertedExpression expressionGe4 = simpleConverter.convertToCouchbaseFilter(filterGe4, null, null);
String queryGe4 = toSelectSQL(expressionGe4);
assertEquals(queryGe4, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE added >= \"Wed Dec 16 14:58:18 UTC 2020\"");
}
Aggregations