@Test
public void buildTest() throws Exception {

    OrderByDBObjectBuilder orderByDBObjectBuilder = new OrderByDBObjectBuilder(false, getOrderBy("mock"));
    DBObject fakeOrderBy = new BasicDBObject("fake", 5);
    // Aggregation build
    Whitebox.setInternalState(orderByDBObjectBuilder, "orderByQuery", fakeOrderBy);
    Whitebox.setInternalState(orderByDBObjectBuilder, "useAggregation", true);
    DBObject orderByCommand = orderByDBObjectBuilder.build();
    assertTrue("The orderBy command should have a root $sort", orderByCommand.keySet().contains("$sort"));
    assertEquals("The value is not the expected", fakeOrderBy, orderByCommand.get("$sort"));
    // Basic build
    Whitebox.setInternalState(orderByDBObjectBuilder, "orderByQuery", fakeOrderBy);
    Whitebox.setInternalState(orderByDBObjectBuilder, "useAggregation", false);
    orderByCommand = orderByDBObjectBuilder.build();
    assertFalse("The orderBy command should not have a root $sort", orderByCommand.keySet().contains("$sort"));
    assertEquals("The value is not the expected", fakeOrderBy, orderByCommand);
}