/** @see DATAMONGO-1552 */
  @Test
  public void shouldRenderBucketOutputOperators() {

    BucketOperation operation =
        Aggregation.bucket("field") //
            .andOutputCount()
            .as("titles");

    DBObject dbObject = operation.toDBObject(Aggregation.DEFAULT_CONTEXT);
    assertThat(extractOutput(dbObject), is(JSON.parse("{ titles : { $sum: 1 } }")));
  }
  /** @see DATAMONGO-1552 */
  @Test
  public void shouldRenderBucketOutputExpressions() {

    BucketOperation operation =
        Aggregation.bucket("field") //
            .andOutputExpression("(netPrice + surCharge) * taxrate * [0]", 2)
            .as("grossSalesPrice") //
            .andOutput("title")
            .push()
            .as("titles");

    DBObject dbObject = operation.toDBObject(Aggregation.DEFAULT_CONTEXT);
    assertThat(
        extractOutput(dbObject),
        is(
            JSON.parse(
                "{ \"grossSalesPrice\" : { \"$multiply\" : [ { \"$add\" : [ \"$netPrice\" , \"$surCharge\"]} , \"$taxrate\" , 2]} , \"titles\" : { $push: \"$title\" } }}")));
  }