### Question:
MongoQueryConverter { protected List<Criteria> mergeCriteria(Map<String, List<NeutralCriteria>> criteriaForFields) { LOG.debug(">>>MongoQueryConverter.mergeCriteria()"); List<Criteria> criteriaList = new ArrayList<Criteria>(); if (criteriaForFields != null) { for (Map.Entry<String, List<NeutralCriteria>> e : criteriaForFields.entrySet()) { List<NeutralCriteria> list = e.getValue(); if (list != null) { Criteria fullCriteria = null; for (NeutralCriteria criteria : list) { fullCriteria = operatorImplementations.get( criteria.getOperator()).generateCriteria(criteria, fullCriteria); } criteriaList.add(fullCriteria); } } } return criteriaList; } MongoQueryConverter(); Query convert(String entityName, NeutralQuery neutralQuery); Query convert(String entityName, NeutralQuery neutralQuery, boolean allFields); List<Criteria> convertToCriteria(String entityName, NeutralQuery neutralQuery, NeutralSchema entitySchema);  }### Answer:
@Test public void testMergeCriteria() { NeutralCriteria neutralCriteria1 = new NeutralCriteria("eventDate", ">=", "2011-09-08"); NeutralCriteria neutralCriteria2 = new NeutralCriteria("eventDate", "<=", "2012-04-08"); List<NeutralCriteria> list = new ArrayList<NeutralCriteria>(); list.add(neutralCriteria1); list.add(neutralCriteria2); Map<String, List<NeutralCriteria>> map = new HashMap<String, List<NeutralCriteria>>(); map.put("eventDate", list); List<Criteria> criteriaMerged = mongoQueryConverter.mergeCriteria(map); assertNotNull("Should not be null", criteriaMerged); assertNotNull("Should not be null", criteriaMerged.get(0)); DBObject obj = criteriaMerged.get(0).getCriteriaObject(); assertTrue("Should not be null", obj.containsField("body.eventDate")); DBObject criteria = (DBObject) obj.get("body.eventDate"); assertNotNull("Should not be null", criteria.get("$gte")); assertNotNull("Should not be null", criteria.get("$lte")); }
@Test public void testNullMergeCriteria() { List<Criteria> criteriaMerged = mongoQueryConverter.mergeCriteria(null); assertNotNull("Should not be null", criteriaMerged); assertEquals("Should match", 0, criteriaMerged.size()); }