// Next, we add three documents with a field "externalDocId" to let us identify them
Set<String> externalDocumentIds = createDocuments(3);
// Now we just have to wait for all three documents to end up in the "oldDocuments" repository
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"));