use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.
the class CouchbaseFilterConverterTest method checkMultivaluedPresenceFilters.
@Test
public void checkMultivaluedPresenceFilters() throws SearchException {
// Presence -- String
Filter filterPresence1 = Filter.createPresenceFilter("uid").multiValued();
ConvertedExpression expressionPresence1 = simpleConverter.convertToCouchbaseFilter(filterPresence1, null, null);
String queryPresence1 = toSelectSQL(expressionPresence1);
assertEquals(queryPresence1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY uid_ IN uid SATISFIES uid_ IS NOT MISSING END");
// Presence -- String -- Multivalued = 3
Filter filterPresence2 = Filter.createPresenceFilter("uid").multiValued(3);
ConvertedExpression expressionPresence2 = simpleConverter.convertToCouchbaseFilter(filterPresence2, null, null);
String queryPresence2 = toSelectSQL(expressionPresence2);
assertEquals(queryPresence2, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY uid_ IN uid SATISFIES uid_ IS NOT MISSING END");
}
use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.
the class CouchbaseFilterConverterTest method checkPresenceFilters.
@Test
public void checkPresenceFilters() throws SearchException {
// Presence -- String
Filter filterPresence = Filter.createPresenceFilter("uid");
ConvertedExpression expressionPresence = simpleConverter.convertToCouchbaseFilter(filterPresence, null, null);
String queryPresence = toSelectSQL(expressionPresence);
assertEquals(queryPresence, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE uid IS NOT MISSING");
}
use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.
the class CouchbaseFilterConverterTest method checkEqFilters.
@Test
public void checkEqFilters() throws SearchException {
// EQ -- String
Filter filterEq1 = Filter.createEqualityFilter("uid", "test");
ConvertedExpression expressionEq1 = simpleConverter.convertToCouchbaseFilter(filterEq1, null, null);
String queryEq1 = toSelectSQL(expressionEq1);
assertEquals(queryEq1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ( ( uid = \"test\" ) OR ( \"test\" IN uid ) )");
// EQ -- Integer
Filter filterEq2 = Filter.createEqualityFilter("age", 23);
ConvertedExpression expressionEq2 = simpleConverter.convertToCouchbaseFilter(filterEq2, null, null);
String queryEq2 = toSelectSQL(expressionEq2);
assertEquals(queryEq2, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ( ( age = 23 ) OR ( 23 IN age ) )");
// EQ -- Long
Filter filterEq3 = Filter.createEqualityFilter("age", 23L);
ConvertedExpression expressionEq3 = simpleConverter.convertToCouchbaseFilter(filterEq3, null, null);
String queryEq3 = toSelectSQL(expressionEq3);
assertEquals(queryEq3, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ( ( age = 23 ) OR ( 23 IN age ) )");
// EQ -- Date
Filter filterEq4 = Filter.createEqualityFilter("added", getUtcDateFromMillis(1608130698398L));
ConvertedExpression expressionEq4 = simpleConverter.convertToCouchbaseFilter(filterEq4, null, null);
String queryEq4 = toSelectSQL(expressionEq4);
assertEquals(queryEq4, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ( ( added = \"Wed Dec 16 14:58:18 UTC 2020\" ) OR ( \"Wed Dec 16 14:58:18 UTC 2020\" IN added ) )");
}
use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.
the class CouchbaseFilterConverterTest method checkMultivaluedSubWithLowerFilters.
@Test
public void checkMultivaluedSubWithLowerFilters() throws SearchException {
Filter filterSub1 = Filter.createSubstringFilter(Filter.createLowercaseFilter("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 LOWER(uid_) LIKE \"%test%\" END");
Filter filterSub2 = Filter.createSubstringFilter(Filter.createLowercaseFilter("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 LOWER(uid_) LIKE \"a%test%\" END");
Filter filterSub3 = Filter.createSubstringFilter(Filter.createLowercaseFilter("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 LOWER(uid_) LIKE \"%test%z\" END");
Filter filterSub4 = Filter.createSubstringFilter(Filter.createLowercaseFilter("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 LOWER(uid_) LIKE \"%test%z\" END");
}
use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.
the class CouchbaseFilterConverterTest method checkMultivaluedGeFilters.
@Test
public void checkMultivaluedGeFilters() throws SearchException {
// GE -- String
Filter filterGe1 = Filter.createGreaterOrEqualFilter("uid", "test").multiValued();
ConvertedExpression expressionGe1 = simpleConverter.convertToCouchbaseFilter(filterGe1, null, null);
String queryGe1 = toSelectSQL(expressionGe1);
assertEquals(queryGe1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY uid_ IN uid SATISFIES uid_ >= \"test\" END");
// GE -- Integer
Filter filterGe2 = Filter.createGreaterOrEqualFilter("age", 23).multiValued();
ConvertedExpression expressionGe2 = simpleConverter.convertToCouchbaseFilter(filterGe2, null, null);
String queryGe2 = toSelectSQL(expressionGe2);
assertEquals(queryGe2, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY age_ IN age SATISFIES age_ >= 23 END");
// GE -- Long
Filter filterGe3 = Filter.createGreaterOrEqualFilter("age", 23L).multiValued();
ConvertedExpression expressionGe3 = simpleConverter.convertToCouchbaseFilter(filterGe3, null, null);
String queryGe3 = toSelectSQL(expressionGe3);
assertEquals(queryGe3, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY age_ IN age SATISFIES age_ >= 23 END");
// GE -- Date
Filter filterGe4 = Filter.createGreaterOrEqualFilter("added", getUtcDateFromMillis(1608130698398L)).multiValued();
ConvertedExpression expressionGe4 = simpleConverter.convertToCouchbaseFilter(filterGe4, null, null);
String queryGe4 = toSelectSQL(expressionGe4);
assertEquals(queryGe4, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY added_ IN added SATISFIES added_ >= \"Wed Dec 16 14:58:18 UTC 2020\" END");
// GE -- Date
Filter filterGe5 = Filter.createGreaterOrEqualFilter("added", getUtcDateFromMillis(1608130698398L)).multiValued(3);
ConvertedExpression expressionGe5 = simpleConverter.convertToCouchbaseFilter(filterGe5, null, null);
String queryGe5 = toSelectSQL(expressionGe5);
assertEquals(queryGe5, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY added_ IN added SATISFIES added_ >= \"Wed Dec 16 14:58:18 UTC 2020\" END");
}
Aggregations