@SuppressWarnings("unchecked") @Test public void buildAggregationTest() throws Exception { FilterDBObjectBuilder filterDBObjectBuilder = new FilterDBObjectBuilder(true, Collections.EMPTY_LIST); DBObject dbObject = QueryBuilder.start(COLUMN_1).greaterThanEquals(5).get(); Whitebox.setInternalState(filterDBObjectBuilder, "filterQuery", dbObject); Whitebox.setInternalState(filterDBObjectBuilder, "useAggregation", true); DBObject filterQuery = filterDBObjectBuilder.build(); assertNotNull("The filter query is null", filterQuery); assertEquals("There should be a query only over 1 field", 1, filterQuery.keySet().size()); assertTrue("The query should contain '$match'", filterQuery.containsField("$match")); DBObject condition = (DBObject) ((DBObject) filterQuery.get("$match")).get(COLUMN_1); assertTrue("The query does not contain '$gte'", condition.containsField("$gte")); assertEquals("The value of '$gte' key should be 5", 5, condition.get("$gte")); }
public DBObject build() { DBObject container; if (useAggregationPipeline()) { container = new BasicDBObject(); container.put("$match", filterQuery); } else { container = filterQuery; } return container; }
FilterDBObjectBuilder extends DBObjectBuilder { public DBObject build() { DBObject container; if (useAggregationPipeline()) { container = new BasicDBObject(); container.put("$match", filterQuery); } else { container = filterQuery; } return container; } }
FilterDBObjectBuilder extends DBObjectBuilder { public DBObject build() { DBObject container; if (useAggregationPipeline()) { container = new BasicDBObject(); container.put("$match", filterQuery); } else { container = filterQuery; } return container; } FilterDBObjectBuilder(boolean useAggregation, Collection<Filter> filterCollection); }
FilterDBObjectBuilder extends DBObjectBuilder { public DBObject build() { DBObject container; if (useAggregationPipeline()) { container = new BasicDBObject(); container.put("$match", filterQuery); } else { container = filterQuery; } return container; } FilterDBObjectBuilder(boolean useAggregation, Collection<Filter> filterCollection); DBObject build(); }
FilterDBObjectBuilder extends DBObjectBuilder { public DBObject build() { DBObject container; if (useAggregationPipeline()) { container = new BasicDBObject(); container.put("$match", filterQuery); } else { container = filterQuery; } return container; } FilterDBObjectBuilder(boolean useAggregation, Collection<Filter> filterCollection); DBObject build();  }