### Question:
QuerySqlTranslator { protected static boolean isOperatorFoundInClause(String operator, List<Object> clause) { boolean found = false; for (Object rawTerm : clause){ if (rawTerm instanceof Map) { Map term = (Map) rawTerm; if (term.size() == 1 && term.values().toArray()[0] instanceof Map) { Map predicate = (Map) term.values().toArray()[0]; if (predicate.get(NOT) != null && predicate.get(NOT) instanceof Map) { return isOperatorFoundInClause(operator, Collections .<Object>singletonList(predicate)); } } } } for (Object rawTerm : clause){ if (rawTerm instanceof Map) { Map term = (Map) rawTerm; if (term.size() == 1 && term.values().toArray()[0] instanceof Map) { Map predicate = (Map) term.values().toArray()[0]; if (predicate.get(operator) != null) { found = true; break; } } } } return found; }  static QueryNode translateQuery(Map<String, Object> query,
                                           List<Index> indexes,
                                           Boolean[] indexesCoverQuery);  }### Answer:
@Test public void findsOperatorInClauseList() throws QueryException { Map<String, Object> nameMap = new HashMap<String, Object>(); Map<String, Object> nameEqMap = new HashMap<String, Object>(); nameEqMap.put("$eq", "mike"); nameMap.put("name", nameEqMap); Map<String, Object> petMap = new HashMap<String, Object>(); Map<String, Object> petSizeMap = new HashMap<String, Object>(); petSizeMap.put("$size", 2); petMap.put("pet", petSizeMap); Map<String, Object> ageMap = new HashMap<String, Object>(); Map<String, Object> ageGteMap = new HashMap<String, Object>(); ageGteMap.put("$gte", 2); ageMap.put("age", ageGteMap); List<Object> clause = Arrays.<Object>asList(nameMap, petMap, ageMap); assertThat(QuerySqlTranslator.isOperatorFoundInClause("$size", clause), is(true)); }
@Test public void doesNotFindOperatorWhenNotInClauseList() throws QueryException { Map<String, Object> nameMap = new HashMap<String, Object>(); Map<String, Object> nameEqMap = new HashMap<String, Object>(); nameEqMap.put("$eq", "mike"); nameMap.put("name", nameEqMap); Map<String, Object> petMap = new HashMap<String, Object>(); Map<String, Object> petEqMap = new HashMap<String, Object>(); petEqMap.put("$eq", "cat"); petMap.put("pet", petEqMap); Map<String, Object> ageMap = new HashMap<String, Object>(); Map<String, Object> ageGteMap = new HashMap<String, Object>(); ageGteMap.put("$gte", 2); ageMap.put("age", ageGteMap); List<Object> clause = Arrays.<Object>asList(nameMap, petMap, ageMap); assertThat(QuerySqlTranslator.isOperatorFoundInClause("$size", clause), is(false)); }