MongoTailableIterator inactiveIterator = mongoConnector.getDocumentReader().getInactiveIterator(new MongoQuery());
Set<String> finishedDocumentIds = new HashSet<String>();
while(!finishedDocumentIds.equals(externalDocumentIds)) {
if(inactiveIterator.hasNext()) {
MongoDocument finishedDocument = inactiveIterator.next();
logger.info("Found finished document " + finishedDocument);
// Assert that the document was successfully processed
assertThat(finishedDocument.getStatus(), equalTo(Document.Status.PROCESSED));
// Here we assert that we indeed have passed through the staticField stage
assertThat((String) finishedDocument.getContentField("testField"), equalTo("Set by SetStaticFieldStage"));
finishedDocumentIds.add((String) finishedDocument.getContentField("externalDocId"));
} else {
// Wait for a little while before polling again.
Thread.sleep(100);
}
}