Search in sources :

Example 16 with ConvertedExpression

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\"");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Example 17 with ConvertedExpression

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 ) )");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Example 18 with ConvertedExpression

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\"");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Example 19 with ConvertedExpression

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\"");
}
Also used : Filter(io.jans.orm.search.filter.Filter) ConvertedExpression(io.jans.orm.couchbase.model.ConvertedExpression) Test(org.testng.annotations.Test)

Example 20 with ConvertedExpression

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\"");
}
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