Search in sources :

Example 6 with ConvertedExpression

use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.

the class CouchbaseFilterConverterTest method checkMultivaluedLowerFilters.

@Test
public void checkMultivaluedLowerFilters() throws SearchException {
    Filter userUidFilter = Filter.createEqualityFilter(Filter.createLowercaseFilter("uid"), "test").multiValued();
    ConvertedExpression expressionUserUid = simpleConverter.convertToCouchbaseFilter(userUidFilter, null, null);
    String queryUserUid = toSelectSQL(expressionUserUid);
    assertEquals(queryUserUid, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY uid_ IN uid SATISFIES LOWER(uid_) = \"test\" END");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Example 7 with ConvertedExpression

use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.

the class CouchbaseFilterConverterTest method checkMultivaluedLeFilters.

@Test
public void checkMultivaluedLeFilters() throws SearchException {
    // LE -- String
    Filter filterLe1 = Filter.createLessOrEqualFilter("uid", "test").multiValued();
    ConvertedExpression expressionLe1 = simpleConverter.convertToCouchbaseFilter(filterLe1, null, null);
    String queryLe1 = toSelectSQL(expressionLe1);
    assertEquals(queryLe1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY uid_ IN uid SATISFIES uid_ <= \"test\" END");
    // LE -- Integer
    Filter filterLe2 = Filter.createLessOrEqualFilter("age", 23).multiValued();
    ConvertedExpression expressionLe2 = simpleConverter.convertToCouchbaseFilter(filterLe2, null, null);
    String queryLe2 = toSelectSQL(expressionLe2);
    assertEquals(queryLe2, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY age_ IN age SATISFIES age_ <= 23 END");
    // LE -- Long
    Filter filterLe3 = Filter.createLessOrEqualFilter("age", 23L).multiValued();
    ConvertedExpression expressionLe3 = simpleConverter.convertToCouchbaseFilter(filterLe3, null, null);
    String queryLe3 = toSelectSQL(expressionLe3);
    assertEquals(queryLe3, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY age_ IN age SATISFIES age_ <= 23 END");
    // LE -- Date
    Filter filterLe4 = Filter.createLessOrEqualFilter("added", getUtcDateFromMillis(1608130698398L)).multiValued();
    ConvertedExpression expressionLe4 = simpleConverter.convertToCouchbaseFilter(filterLe4, null, null);
    String queryLe4 = toSelectSQL(expressionLe4);
    assertEquals(queryLe4, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY added_ IN added SATISFIES added_ <= \"Wed Dec 16 14:58:18 UTC 2020\" END");
    // LE -- Date
    Filter filterLe5 = Filter.createLessOrEqualFilter("added", getUtcDateFromMillis(1608130698398L)).multiValued(3);
    ConvertedExpression expressionLe5 = simpleConverter.convertToCouchbaseFilter(filterLe5, null, null);
    String queryLe5 = toSelectSQL(expressionLe5);
    assertEquals(queryLe5, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ANY added_ IN added SATISFIES added_ <= \"Wed Dec 16 14:58:18 UTC 2020\" END");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Example 8 with ConvertedExpression

use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.

the class CouchbaseFilterConverterTest method checkOrFilters.

@Test
public void checkOrFilters() throws SearchException {
    Filter filterEq1 = Filter.createEqualityFilter("uid", "test");
    Filter filterPresence1 = Filter.createPresenceFilter("mail");
    Filter filterLe1 = Filter.createLessOrEqualFilter("age", 23);
    Filter filterOr1 = Filter.createORFilter(filterPresence1, filterEq1, filterLe1);
    ConvertedExpression expressionAnd1 = simpleConverter.convertToCouchbaseFilter(filterOr1, null, null);
    String queryAnd1 = toSelectSQL(expressionAnd1);
    assertEquals(queryAnd1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ( mail IS NOT MISSING OR ( ( uid = \"test\" ) OR ( \"test\" IN uid ) ) OR age <= 23 )");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Example 9 with ConvertedExpression

use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.

the class CouchbaseFilterConverterTest method checkLeFilters.

@Test
public void checkLeFilters() throws SearchException {
    // LE -- String
    Filter filterLe1 = Filter.createLessOrEqualFilter("uid", "test");
    ConvertedExpression expressionLe1 = simpleConverter.convertToCouchbaseFilter(filterLe1, null, null);
    String queryLe1 = toSelectSQL(expressionLe1);
    assertEquals(queryLe1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE uid <= \"test\"");
    // LE -- Integer
    Filter filterLe2 = Filter.createLessOrEqualFilter("age", 23);
    ConvertedExpression expressionLe2 = simpleConverter.convertToCouchbaseFilter(filterLe2, null, null);
    String queryLe2 = toSelectSQL(expressionLe2);
    assertEquals(queryLe2, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE age <= 23");
    // LE -- Long
    Filter filterLe3 = Filter.createLessOrEqualFilter("age", 23L);
    ConvertedExpression expressionLe3 = simpleConverter.convertToCouchbaseFilter(filterLe3, null, null);
    String queryLe3 = toSelectSQL(expressionLe3);
    assertEquals(queryLe3, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE age <= 23");
    // LE -- Date
    Filter filterLe4 = Filter.createLessOrEqualFilter("added", getUtcDateFromMillis(1608130698398L));
    ConvertedExpression expressionLe4 = simpleConverter.convertToCouchbaseFilter(filterLe4, null, null);
    String queryLe4 = toSelectSQL(expressionLe4);
    assertEquals(queryLe4, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE added <= \"Wed Dec 16 14:58:18 UTC 2020\"");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Example 10 with ConvertedExpression

use of io.jans.orm.couchbase.model.ConvertedExpression in project jans by JanssenProject.

the class CouchbaseFilterConverterTest method checkAndFilters.

@Test
public void checkAndFilters() throws SearchException {
    Filter filterEq1 = Filter.createEqualityFilter("uid", "test");
    Filter filterPresence1 = Filter.createPresenceFilter("mail");
    Filter filterLe1 = Filter.createLessOrEqualFilter("age", 23);
    Filter filterAnd1 = Filter.createANDFilter(filterPresence1, filterEq1, filterLe1);
    ConvertedExpression expressionAnd1 = simpleConverter.convertToCouchbaseFilter(filterAnd1, null, null);
    String queryAnd1 = toSelectSQL(expressionAnd1);
    assertEquals(queryAnd1, "SELECT jans_doc.* FROM `jans` AS jans_doc WHERE ( mail IS NOT MISSING AND ( ( uid = \"test\" ) OR ( \"test\" IN uid ) ) AND age <= 23 )");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Aggregations

ConvertedExpression (io.jans.orm.couchbase.model.ConvertedExpression)27 Filter (io.jans.orm.search.filter.Filter)27 Test (org.testng.annotations.Test)21 SearchException (io.jans.orm.exception.operation.SearchException)6 AuthenticationException (io.jans.orm.exception.AuthenticationException)5 EntryDeleteException (io.jans.orm.exception.EntryDeleteException)5 EntryPersistenceException (io.jans.orm.exception.EntryPersistenceException)5 MappingException (io.jans.orm.exception.MappingException)5 PropertyAnnotation (io.jans.orm.reflect.property.PropertyAnnotation)5 DateTimeException (java.time.DateTimeException)5 DateTimeParseException (java.time.format.DateTimeParseException)5 JsonObject (com.couchbase.client.java.document.json.JsonObject)4 ParsedKey (io.jans.orm.impl.model.ParsedKey)3 JsonArray (com.couchbase.client.java.document.json.JsonArray)1 Expression (com.couchbase.client.java.query.dsl.Expression)1 Sort (com.couchbase.client.java.query.dsl.Sort)1 FilterType (io.jans.orm.search.filter.FilterType)1 ISO_INSTANT (java.time.format.DateTimeFormatter.ISO_INSTANT)1 ArrayList (java.util.ArrayList)1