use of org.bson.io.BsonInput in project mongo-java-driver by mongodb.
the class DocumentCodecTest method testIterableContainingDocumentsEncoding.
@Test
public void testIterableContainingDocumentsEncoding() throws IOException {
DocumentCodec documentCodec = new DocumentCodec();
Document doc = new Document();
List<Document> listOfDocuments = asList(new Document("intVal", 1), new Document("anotherInt", 2));
doc.put("array", listOfDocuments);
documentCodec.encode(writer, doc, EncoderContext.builder().build());
BsonInput bsonInput = createInputBuffer();
Document decodedDocument = documentCodec.decode(new BsonBinaryReader(bsonInput), DecoderContext.builder().build());
assertEquals(doc, decodedDocument);
}
Aggregations