checkDoc = indexedDoc;
checkAuto = Automatons.fromReadable(indexedDoc);
}
for (int i = 0; i < NUM_INITIAL_MUTATIONS; i++) {
DocOp op = RandomDocOpGenerator.generate(random, params,
// FIXME(ohler): Add back schema constraints
// DocumentOperationValidator.DEFAULT_BLIP_SCHEMA_CONSTRAINTS,
autoDoc);
doc.consume(op);
checkDoc.consume(op);
}
String originalXml = DocOpUtil.toXmlString(doc.asOperation());
for (int i = 0; i < NUM_REVERSED_MUTATIONS_PER_RUN; i++) {
// Apply random mutation and revert it.
DocOp op = RandomDocOpGenerator.generate(random, params,
// FIXME(ohler): Add back schema constraints
// DocumentOperationValidator.DEFAULT_BLIP_SCHEMA_CONSTRAINTS,
autoDoc);
Nindo nindo = null;
String finalXml = null;
DocOp docOpCopy = null;
DocInitialization docAsOp = null;
try {
//System.out.println(" " + i);
//System.out.println("\n===" + iteration + "." + i + "===============================");
docAsOp = doc.asOperation();
validate(DocOpAutomaton.EMPTY_DOCUMENT, docAsOp);
IndexedDocument<Node, Element, Text> copy = DocProviders.POJO.build(docAsOp,
DocumentSchema.NO_SCHEMA_CONSTRAINTS);
BootstrapDocument copy2 = new BootstrapDocument();
copy2.consume(docAsOp);
// CONSUME
doc.consume(op);
checkDoc.consume(op);
finalXml = DocOpUtil.toXmlString(checkDocOpProvider.asOperation());
assertEquals(finalXml, DocOpUtil.toXmlString(doc.asOperation()));
// UNDO
DocOp inverted1 = DocOpInverter.invert(op);
validate(autoDoc, inverted1);
doc.consume(inverted1);
assertEquals(originalXml, DocOpUtil.toXmlString(doc.asOperation()));
// CONSUME NINDO
// TODO(danilatos): Both remove and don't remove the trailing skip, randomly
nindo = Nindo.fromDocOp(op, true);
docOpCopy = doc.consumeAndReturnInvertible(nindo);
assertEquals(finalXml, DocOpUtil.toXmlString(doc.asOperation()));
validate(Automatons.fromReadable(copy), docOpCopy);
validate(copy2, docOpCopy);
copy2.consume(docOpCopy);
assertEquals(finalXml, DocOpUtil.toXmlString(copy2.asOperation()));
// UNDO NINDO
DocOp inverted2 = DocOpInverter.invert(docOpCopy);
validate(checkAuto, inverted2);
validate(autoDoc, inverted2);
doc.consume(inverted2);
assertEquals(originalXml, DocOpUtil.toXmlString(doc.asOperation()));
checkDoc.consume(inverted2);