MongoQuerySortElement implements QuerySortElement { public void append(Document document) { document.put(field, value); } MongoQuerySortElement(String field, Object value); void append(Document document);  }
@Test void append() { String field = "my_field"; int value = 1; Document document = new Document(); MongoQuerySortElement element = new MongoQuerySortElement(field, value); element.append(document); assertEquals(field, document.keySet().iterator().next()); assertEquals(value, (int) document.getInteger(field)); }