AstToMongoDBQuery { public Query createQuery() { List<List<Predicate>> predicates = opaCompilerResponse.getResult().getQueries(); List<Criteria> criteriaList = predicates.stream() .map(this::chainCriteriaByAndOperator) .collect(toList()); Criteria chainedCriterias = chainCriteriaByOrOperator(criteriaList); return query(chainedCriterias); } AstToMongoDBQuery(OpaCompilerResponse opaCompilerResponse); Query createQuery();  }
@Test void shouldCreateMongoDBQuery() { Query query = target.createQuery(); assertThat(query, is(notNullValue())); String result = query.getQueryObject().toJson(); assertThat(result, is("{\"$or\": [{\"owner\": \"alice\", \"name\": \"fluffy\"}, {\"veterinarian\": \"alice\", \"clinic\": \"SOMA\", \"name\": \"fluffy\"}]}")); }