AstToMongoDBQuery { Criteria initialCriteria(SqlPredicate sqlPredicate) { String attributeName = getAttributeName(sqlPredicate); Criteria criteria = where(attributeName); criteria = createComparisonCriteria(sqlPredicate, criteria); return criteria; } AstToMongoDBQuery(OpaCompilerResponse opaCompilerResponse); Query createQuery();  }
@Test void shouldConvertSqlPredicateEqualOperatorToMongoDbCriteria() { SqlPredicate sqlPredicate1 = new SqlPredicate("pets.owner", "=", "alice"); Criteria result = target.initialCriteria(sqlPredicate1); String resultInString = result.getCriteriaObject().toJson(); assertThat(resultInString, is("{\"owner\": \"alice\"}")); }
@Test void shouldConvertSqlPredicateLessThanOperatorToMongoDbCriteria() { SqlPredicate sqlPredicate1 = new SqlPredicate("pets.owner", "<", 3); Criteria result = target.initialCriteria(sqlPredicate1); String resultInString = result.getCriteriaObject().toJson(); assertThat(resultInString, is("{\"owner\": {\"$lt\": 3}}")); }
@Test void shouldConvertSqlPredicateLessThanOrEqualToOperatorToMongoDbCriteria() { SqlPredicate sqlPredicate1 = new SqlPredicate("pets.owner", "<=", 5.14); Criteria result = target.initialCriteria(sqlPredicate1); String resultInString = result.getCriteriaObject().toJson(); assertThat(resultInString, is("{\"owner\": {\"$lte\": 5.14}}")); }
@Test void shouldConvertSqlPredicateGreaterThanOperatorToMongoDbCriteria() { SqlPredicate sqlPredicate1 = new SqlPredicate("pets.owner", ">", 4L); Criteria result = target.initialCriteria(sqlPredicate1); String resultInString = result.getCriteriaObject().toJson(); assertThat(resultInString, is("{\"owner\": {\"$gt\": {\"$numberLong\": \"4\"}}}")); }
@Test void shouldConvertSqlPredicateGreaterThanOrEqualToOperatorToMongoDbCriteria() { SqlPredicate sqlPredicate1 = new SqlPredicate("pets.owner", ">=", 4); Criteria result = target.initialCriteria(sqlPredicate1); String resultInString = result.getCriteriaObject().toJson(); assertThat(resultInString, is("{\"owner\": {\"$gte\": 4}}")); }