com.aspose.words

Class Revision

  • java.lang.Object
    • com.aspose.words.Revision
public class Revision 
extends java.lang.Object

Represents a revision (tracked change) in a document node or style. Use RevisionType to check the type of this revision.

Example:

Shows how to check if a document has revisions.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Normal editing of the document does not count as a revision
builder.write("This does not count as a revision. ");
Assert.assertFalse(doc.hasRevisions());

// In order for our edits to count as revisions, we need to declare an author and start tracking them
doc.startTrackRevisions("John Doe", new Date());
builder.write("This is revision #1. ");

// This flag corresponds to the "Track Changes" option being turned on in Microsoft Word, to track the editing manually
// done there and not the programmatic changes we are about to do here
Assert.assertFalse(doc.getTrackRevisions());

// As well as nodes in the document, revisions get referenced in this collection
Assert.assertTrue(doc.hasRevisions());
Assert.assertEquals(doc.getRevisions().getCount(), 1);

Revision revision = doc.getRevisions().get(0);
Assert.assertEquals(revision.getAuthor(), "John Doe");
Assert.assertEquals(revision.getParentNode().getText(), "This is revision #1. ");
Assert.assertEquals(revision.getRevisionType(), RevisionType.INSERTION);
Assert.assertEquals(DocumentHelper.getDateWithoutTimeUsingFormat(revision.getDateTime()), DocumentHelper.getDateWithoutTimeUsingFormat(new Date()));
Assert.assertEquals(revision.getGroup(), doc.getRevisions().getGroups().get(0));

// Deleting content also counts as a revision
// The most recent revisions are put at the start of the collection
doc.getFirstSection().getBody().getFirstParagraph().getRuns().get(0).remove();
Assert.assertEquals(doc.getRevisions().get(0).getRevisionType(), RevisionType.DELETION);
Assert.assertEquals(doc.getRevisions().getCount(), 2);

// Insert revisions are treated as document text by the GetText() method before they are accepted,
// since they are still nodes with text and are in the body
Assert.assertEquals(doc.getText().trim(), "This does not count as a revision. This is revision #1.");

// Accepting the deletion revision will assimilate it into the paragraph text and remove it from the collection
doc.getRevisions().get(0).accept();
Assert.assertEquals(doc.getRevisions().getCount(), 1);

// Once the delete revision is accepted, the nodes that it concerns are removed and their text will not show up here
Assert.assertEquals(doc.getText().trim(), "This is revision #1.");

// The second insertion revision is now at index 0, which we can reject to ignore and discard it
doc.getRevisions().get(0).reject();
Assert.assertEquals(doc.getRevisions().getCount(), 0);
Assert.assertEquals(doc.getText().trim(), "");

// This takes us back to not counting changes as revisions
doc.stopTrackRevisions();

builder.writeln("This also does not count as a revision.");
Assert.assertEquals(doc.getRevisions().getCount(), 0);

doc.save(getArtifactsDir() + "Document.Revisions.docx");

Property Getters/Setters Summary
java.lang.StringgetAuthor()
void
setAuthor(java.lang.Stringvalue)
           Gets or sets the author of this revision. Can not be empty string or null.
java.util.DategetDateTime()
void
setDateTime(java.util.Datevalue)
           Gets or sets the date/time of this revision.
RevisionGroupgetGroup()
Gets the revision group. Returns null if the revision does not belong to any group.
NodegetParentNode()
Gets the immediate parent node (owner) of this revision. This property will work for any revision type other than RevisionType.STYLE_DEFINITION_CHANGE.
StylegetParentStyle()
Gets the immediate parent style (owner) of this revision. This property will work for only for the RevisionType.STYLE_DEFINITION_CHANGE revision type.
intgetRevisionType()
Gets the type of this revision. The value of the property is RevisionType integer constant.
 
Method Summary
voidaccept()
Accepts this revision.
voidreject()
Reject this revision.
 

    • Property Getters/Setters Detail

      • getAuthor/setAuthor

        public java.lang.String getAuthor() / public void setAuthor(java.lang.String value)
        
        Gets or sets the author of this revision. Can not be empty string or null.

        Example:

        Shows how to check if a document has revisions.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Normal editing of the document does not count as a revision
        builder.write("This does not count as a revision. ");
        Assert.assertFalse(doc.hasRevisions());
        
        // In order for our edits to count as revisions, we need to declare an author and start tracking them
        doc.startTrackRevisions("John Doe", new Date());
        builder.write("This is revision #1. ");
        
        // This flag corresponds to the "Track Changes" option being turned on in Microsoft Word, to track the editing manually
        // done there and not the programmatic changes we are about to do here
        Assert.assertFalse(doc.getTrackRevisions());
        
        // As well as nodes in the document, revisions get referenced in this collection
        Assert.assertTrue(doc.hasRevisions());
        Assert.assertEquals(doc.getRevisions().getCount(), 1);
        
        Revision revision = doc.getRevisions().get(0);
        Assert.assertEquals(revision.getAuthor(), "John Doe");
        Assert.assertEquals(revision.getParentNode().getText(), "This is revision #1. ");
        Assert.assertEquals(revision.getRevisionType(), RevisionType.INSERTION);
        Assert.assertEquals(DocumentHelper.getDateWithoutTimeUsingFormat(revision.getDateTime()), DocumentHelper.getDateWithoutTimeUsingFormat(new Date()));
        Assert.assertEquals(revision.getGroup(), doc.getRevisions().getGroups().get(0));
        
        // Deleting content also counts as a revision
        // The most recent revisions are put at the start of the collection
        doc.getFirstSection().getBody().getFirstParagraph().getRuns().get(0).remove();
        Assert.assertEquals(doc.getRevisions().get(0).getRevisionType(), RevisionType.DELETION);
        Assert.assertEquals(doc.getRevisions().getCount(), 2);
        
        // Insert revisions are treated as document text by the GetText() method before they are accepted,
        // since they are still nodes with text and are in the body
        Assert.assertEquals(doc.getText().trim(), "This does not count as a revision. This is revision #1.");
        
        // Accepting the deletion revision will assimilate it into the paragraph text and remove it from the collection
        doc.getRevisions().get(0).accept();
        Assert.assertEquals(doc.getRevisions().getCount(), 1);
        
        // Once the delete revision is accepted, the nodes that it concerns are removed and their text will not show up here
        Assert.assertEquals(doc.getText().trim(), "This is revision #1.");
        
        // The second insertion revision is now at index 0, which we can reject to ignore and discard it
        doc.getRevisions().get(0).reject();
        Assert.assertEquals(doc.getRevisions().getCount(), 0);
        Assert.assertEquals(doc.getText().trim(), "");
        
        // This takes us back to not counting changes as revisions
        doc.stopTrackRevisions();
        
        builder.writeln("This also does not count as a revision.");
        Assert.assertEquals(doc.getRevisions().getCount(), 0);
        
        doc.save(getArtifactsDir() + "Document.Revisions.docx");
      • getDateTime/setDateTime

        public java.util.Date getDateTime() / public void setDateTime(java.util.Date value)
        
        Gets or sets the date/time of this revision.

        Example:

        Shows how to check if a document has revisions.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Normal editing of the document does not count as a revision
        builder.write("This does not count as a revision. ");
        Assert.assertFalse(doc.hasRevisions());
        
        // In order for our edits to count as revisions, we need to declare an author and start tracking them
        doc.startTrackRevisions("John Doe", new Date());
        builder.write("This is revision #1. ");
        
        // This flag corresponds to the "Track Changes" option being turned on in Microsoft Word, to track the editing manually
        // done there and not the programmatic changes we are about to do here
        Assert.assertFalse(doc.getTrackRevisions());
        
        // As well as nodes in the document, revisions get referenced in this collection
        Assert.assertTrue(doc.hasRevisions());
        Assert.assertEquals(doc.getRevisions().getCount(), 1);
        
        Revision revision = doc.getRevisions().get(0);
        Assert.assertEquals(revision.getAuthor(), "John Doe");
        Assert.assertEquals(revision.getParentNode().getText(), "This is revision #1. ");
        Assert.assertEquals(revision.getRevisionType(), RevisionType.INSERTION);
        Assert.assertEquals(DocumentHelper.getDateWithoutTimeUsingFormat(revision.getDateTime()), DocumentHelper.getDateWithoutTimeUsingFormat(new Date()));
        Assert.assertEquals(revision.getGroup(), doc.getRevisions().getGroups().get(0));
        
        // Deleting content also counts as a revision
        // The most recent revisions are put at the start of the collection
        doc.getFirstSection().getBody().getFirstParagraph().getRuns().get(0).remove();
        Assert.assertEquals(doc.getRevisions().get(0).getRevisionType(), RevisionType.DELETION);
        Assert.assertEquals(doc.getRevisions().getCount(), 2);
        
        // Insert revisions are treated as document text by the GetText() method before they are accepted,
        // since they are still nodes with text and are in the body
        Assert.assertEquals(doc.getText().trim(), "This does not count as a revision. This is revision #1.");
        
        // Accepting the deletion revision will assimilate it into the paragraph text and remove it from the collection
        doc.getRevisions().get(0).accept();
        Assert.assertEquals(doc.getRevisions().getCount(), 1);
        
        // Once the delete revision is accepted, the nodes that it concerns are removed and their text will not show up here
        Assert.assertEquals(doc.getText().trim(), "This is revision #1.");
        
        // The second insertion revision is now at index 0, which we can reject to ignore and discard it
        doc.getRevisions().get(0).reject();
        Assert.assertEquals(doc.getRevisions().getCount(), 0);
        Assert.assertEquals(doc.getText().trim(), "");
        
        // This takes us back to not counting changes as revisions
        doc.stopTrackRevisions();
        
        builder.writeln("This also does not count as a revision.");
        Assert.assertEquals(doc.getRevisions().getCount(), 0);
        
        doc.save(getArtifactsDir() + "Document.Revisions.docx");
      • getGroup

        public RevisionGroup getGroup()
        
        Gets the revision group. Returns null if the revision does not belong to any group. Revision has no group if revision type is RevisionType.StyleDefinitionChange or if the revision is not longer exist in document context (accepted/rejected).

        Example:

        Shows how to check if a document has revisions.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Normal editing of the document does not count as a revision
        builder.write("This does not count as a revision. ");
        Assert.assertFalse(doc.hasRevisions());
        
        // In order for our edits to count as revisions, we need to declare an author and start tracking them
        doc.startTrackRevisions("John Doe", new Date());
        builder.write("This is revision #1. ");
        
        // This flag corresponds to the "Track Changes" option being turned on in Microsoft Word, to track the editing manually
        // done there and not the programmatic changes we are about to do here
        Assert.assertFalse(doc.getTrackRevisions());
        
        // As well as nodes in the document, revisions get referenced in this collection
        Assert.assertTrue(doc.hasRevisions());
        Assert.assertEquals(doc.getRevisions().getCount(), 1);
        
        Revision revision = doc.getRevisions().get(0);
        Assert.assertEquals(revision.getAuthor(), "John Doe");
        Assert.assertEquals(revision.getParentNode().getText(), "This is revision #1. ");
        Assert.assertEquals(revision.getRevisionType(), RevisionType.INSERTION);
        Assert.assertEquals(DocumentHelper.getDateWithoutTimeUsingFormat(revision.getDateTime()), DocumentHelper.getDateWithoutTimeUsingFormat(new Date()));
        Assert.assertEquals(revision.getGroup(), doc.getRevisions().getGroups().get(0));
        
        // Deleting content also counts as a revision
        // The most recent revisions are put at the start of the collection
        doc.getFirstSection().getBody().getFirstParagraph().getRuns().get(0).remove();
        Assert.assertEquals(doc.getRevisions().get(0).getRevisionType(), RevisionType.DELETION);
        Assert.assertEquals(doc.getRevisions().getCount(), 2);
        
        // Insert revisions are treated as document text by the GetText() method before they are accepted,
        // since they are still nodes with text and are in the body
        Assert.assertEquals(doc.getText().trim(), "This does not count as a revision. This is revision #1.");
        
        // Accepting the deletion revision will assimilate it into the paragraph text and remove it from the collection
        doc.getRevisions().get(0).accept();
        Assert.assertEquals(doc.getRevisions().getCount(), 1);
        
        // Once the delete revision is accepted, the nodes that it concerns are removed and their text will not show up here
        Assert.assertEquals(doc.getText().trim(), "This is revision #1.");
        
        // The second insertion revision is now at index 0, which we can reject to ignore and discard it
        doc.getRevisions().get(0).reject();
        Assert.assertEquals(doc.getRevisions().getCount(), 0);
        Assert.assertEquals(doc.getText().trim(), "");
        
        // This takes us back to not counting changes as revisions
        doc.stopTrackRevisions();
        
        builder.writeln("This also does not count as a revision.");
        Assert.assertEquals(doc.getRevisions().getCount(), 0);
        
        doc.save(getArtifactsDir() + "Document.Revisions.docx");
      • getParentNode

        public Node getParentNode()
        
        Gets the immediate parent node (owner) of this revision. This property will work for any revision type other than RevisionType.STYLE_DEFINITION_CHANGE. If this revision relates to change of Style formatting, use ParentStyle instead.

        Example:

        Shows how to process revision-related properties of Inline nodes.
        Document doc = new Document(getMyDir() + "Inline.Revisions.docx");
        
        // This document has 6 revisions
        Assert.assertEquals(doc.getRevisions().getCount(), 6);
        
        // The parent node of a revision is the run that the revision concerns, which is an Inline node
        Run run = (Run) doc.getRevisions().get(0).getParentNode();
        
        // Get the parent paragraph
        Paragraph firstParagraph = run.getParentParagraph();
        RunCollection runs = firstParagraph.getRuns();
        
        Assert.assertEquals(runs.getCount(), 6);
        
        // The text in the run at index #2 was typed after revisions were tracked, so it will count as an insert revision
        // The font was changed, so it will also be a format revision
        Assert.assertTrue(runs.get(2).isInsertRevision());
        Assert.assertTrue(runs.get(2).isFormatRevision());
        
        // If one node was moved from one place to another while changes were tracked,
        // the node will be placed at the departure location as a "move to revision",
        // and a "move from revision" node will be left behind at the origin, in case we want to reject changes
        // Highlighting text and dragging it to another place with the mouse and cut-and-pasting (but not copy-pasting) both count as "move revisions"
        // The node with the "IsMoveToRevision" flag is the arrival of the move operation, and the node with the "IsMoveFromRevision" flag is the departure point
        Assert.assertTrue(runs.get(1).isMoveToRevision());
        Assert.assertTrue(runs.get(4).isMoveFromRevision());
        
        // If an Inline node gets deleted while changes are being tracked, it will leave behind a node with the IsDeleteRevision flag set to true until changes are accepted
        Assert.assertTrue(runs.get(5).isDeleteRevision());
      • getParentStyle

        public Style getParentStyle()
        
        Gets the immediate parent style (owner) of this revision. This property will work for only for the RevisionType.STYLE_DEFINITION_CHANGE revision type. If this revision relates to changes on document nodes, use ParentNode instead.

        Example:

        Shows how to look through a document's revisions.
        // Open a document that contains revisions and get its revision collection
        Document doc = new Document(getMyDir() + "Document.Revisions.docx");
        RevisionCollection revisions = doc.getRevisions();
        
        // This collection itself has a collection of revision groups, which are merged sequences of adjacent revisions
        System.out.println(MessageFormat.format("{0} revision groups:", revisions.getGroups().getCount()));
        
        // We can iterate over the collection of groups and access the text that the revision concerns
        Iterator<RevisionGroup> e = revisions.getGroups().iterator();
        while (e.hasNext()) {
            RevisionGroup currentRevisionGroup = e.next();
            System.out.println(MessageFormat.format("\tGroup type \"{0}\", ", currentRevisionGroup.getRevisionType()) +
                    MessageFormat.format("author: {0}, contents: [{1}]", currentRevisionGroup.getAuthor(), currentRevisionGroup.getText().trim()));
        }
        
        // The collection of revisions is considerably larger than the condensed form we printed above,
        // depending on how many Runs the text has been segmented into during editing in Microsoft Word,
        // since each Run affected by a revision gets its own Revision object
        System.out.println(MessageFormat.format("\n{0} revisions:", revisions.getCount()));
        
        Iterator<Revision> e1 = revisions.iterator();
        
        while (e1.hasNext()) {
            Revision currentRevision = e1.next();
        
            // A StyleDefinitionChange strictly affects styles and not document nodes, so in this case the ParentStyle
            // attribute will always be used, while the ParentNode will always be null
            // Since all other changes affect nodes, ParentNode will conversely be in use and ParentStyle will be null
            if (currentRevision.getRevisionType() == RevisionType.STYLE_DEFINITION_CHANGE) {
                System.out.println(MessageFormat.format("\tRevision type \"{0}\", ", currentRevision.getRevisionType()) +
                        MessageFormat.format("author: {0}, style: [{1}]", currentRevision.getAuthor(), currentRevision.getParentStyle().getName()));
            } else {
                System.out.println(MessageFormat.format("\tRevision type \"{0}\", ", currentRevision.getRevisionType()) +
                        MessageFormat.format("author: {0}, contents: [{1}]", currentRevision.getAuthor(), currentRevision.getParentNode().getText().trim()));
            }
        }
        
        // While the collection of revision groups provides a clearer overview of all revisions that took place in the document,
        // the changes must be accepted/rejected by the revisions themselves, the RevisionCollection, or the document
        // In this case we will reject all revisions via the collection, reverting the document to its original form, which we will then save
        revisions.rejectAll();
        Assert.assertEquals(revisions.getCount(), 0);
        
        doc.save(getArtifactsDir() + "Document.RevisionCollection.docx");
      • getRevisionType

        public int getRevisionType()
        
        Gets the type of this revision. The value of the property is RevisionType integer constant.

        Example:

        Shows how to check if a document has revisions.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Normal editing of the document does not count as a revision
        builder.write("This does not count as a revision. ");
        Assert.assertFalse(doc.hasRevisions());
        
        // In order for our edits to count as revisions, we need to declare an author and start tracking them
        doc.startTrackRevisions("John Doe", new Date());
        builder.write("This is revision #1. ");
        
        // This flag corresponds to the "Track Changes" option being turned on in Microsoft Word, to track the editing manually
        // done there and not the programmatic changes we are about to do here
        Assert.assertFalse(doc.getTrackRevisions());
        
        // As well as nodes in the document, revisions get referenced in this collection
        Assert.assertTrue(doc.hasRevisions());
        Assert.assertEquals(doc.getRevisions().getCount(), 1);
        
        Revision revision = doc.getRevisions().get(0);
        Assert.assertEquals(revision.getAuthor(), "John Doe");
        Assert.assertEquals(revision.getParentNode().getText(), "This is revision #1. ");
        Assert.assertEquals(revision.getRevisionType(), RevisionType.INSERTION);
        Assert.assertEquals(DocumentHelper.getDateWithoutTimeUsingFormat(revision.getDateTime()), DocumentHelper.getDateWithoutTimeUsingFormat(new Date()));
        Assert.assertEquals(revision.getGroup(), doc.getRevisions().getGroups().get(0));
        
        // Deleting content also counts as a revision
        // The most recent revisions are put at the start of the collection
        doc.getFirstSection().getBody().getFirstParagraph().getRuns().get(0).remove();
        Assert.assertEquals(doc.getRevisions().get(0).getRevisionType(), RevisionType.DELETION);
        Assert.assertEquals(doc.getRevisions().getCount(), 2);
        
        // Insert revisions are treated as document text by the GetText() method before they are accepted,
        // since they are still nodes with text and are in the body
        Assert.assertEquals(doc.getText().trim(), "This does not count as a revision. This is revision #1.");
        
        // Accepting the deletion revision will assimilate it into the paragraph text and remove it from the collection
        doc.getRevisions().get(0).accept();
        Assert.assertEquals(doc.getRevisions().getCount(), 1);
        
        // Once the delete revision is accepted, the nodes that it concerns are removed and their text will not show up here
        Assert.assertEquals(doc.getText().trim(), "This is revision #1.");
        
        // The second insertion revision is now at index 0, which we can reject to ignore and discard it
        doc.getRevisions().get(0).reject();
        Assert.assertEquals(doc.getRevisions().getCount(), 0);
        Assert.assertEquals(doc.getText().trim(), "");
        
        // This takes us back to not counting changes as revisions
        doc.stopTrackRevisions();
        
        builder.writeln("This also does not count as a revision.");
        Assert.assertEquals(doc.getRevisions().getCount(), 0);
        
        doc.save(getArtifactsDir() + "Document.Revisions.docx");
    • Method Detail

      • accept

        public void accept()
                   throws java.lang.Exception
        Accepts this revision.

        Example:

        Shows how to check if a document has revisions.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Normal editing of the document does not count as a revision
        builder.write("This does not count as a revision. ");
        Assert.assertFalse(doc.hasRevisions());
        
        // In order for our edits to count as revisions, we need to declare an author and start tracking them
        doc.startTrackRevisions("John Doe", new Date());
        builder.write("This is revision #1. ");
        
        // This flag corresponds to the "Track Changes" option being turned on in Microsoft Word, to track the editing manually
        // done there and not the programmatic changes we are about to do here
        Assert.assertFalse(doc.getTrackRevisions());
        
        // As well as nodes in the document, revisions get referenced in this collection
        Assert.assertTrue(doc.hasRevisions());
        Assert.assertEquals(doc.getRevisions().getCount(), 1);
        
        Revision revision = doc.getRevisions().get(0);
        Assert.assertEquals(revision.getAuthor(), "John Doe");
        Assert.assertEquals(revision.getParentNode().getText(), "This is revision #1. ");
        Assert.assertEquals(revision.getRevisionType(), RevisionType.INSERTION);
        Assert.assertEquals(DocumentHelper.getDateWithoutTimeUsingFormat(revision.getDateTime()), DocumentHelper.getDateWithoutTimeUsingFormat(new Date()));
        Assert.assertEquals(revision.getGroup(), doc.getRevisions().getGroups().get(0));
        
        // Deleting content also counts as a revision
        // The most recent revisions are put at the start of the collection
        doc.getFirstSection().getBody().getFirstParagraph().getRuns().get(0).remove();
        Assert.assertEquals(doc.getRevisions().get(0).getRevisionType(), RevisionType.DELETION);
        Assert.assertEquals(doc.getRevisions().getCount(), 2);
        
        // Insert revisions are treated as document text by the GetText() method before they are accepted,
        // since they are still nodes with text and are in the body
        Assert.assertEquals(doc.getText().trim(), "This does not count as a revision. This is revision #1.");
        
        // Accepting the deletion revision will assimilate it into the paragraph text and remove it from the collection
        doc.getRevisions().get(0).accept();
        Assert.assertEquals(doc.getRevisions().getCount(), 1);
        
        // Once the delete revision is accepted, the nodes that it concerns are removed and their text will not show up here
        Assert.assertEquals(doc.getText().trim(), "This is revision #1.");
        
        // The second insertion revision is now at index 0, which we can reject to ignore and discard it
        doc.getRevisions().get(0).reject();
        Assert.assertEquals(doc.getRevisions().getCount(), 0);
        Assert.assertEquals(doc.getText().trim(), "");
        
        // This takes us back to not counting changes as revisions
        doc.stopTrackRevisions();
        
        builder.writeln("This also does not count as a revision.");
        Assert.assertEquals(doc.getRevisions().getCount(), 0);
        
        doc.save(getArtifactsDir() + "Document.Revisions.docx");
      • reject

        public void reject()
                   throws java.lang.Exception
        Reject this revision.

        Example:

        Shows how to check if a document has revisions.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Normal editing of the document does not count as a revision
        builder.write("This does not count as a revision. ");
        Assert.assertFalse(doc.hasRevisions());
        
        // In order for our edits to count as revisions, we need to declare an author and start tracking them
        doc.startTrackRevisions("John Doe", new Date());
        builder.write("This is revision #1. ");
        
        // This flag corresponds to the "Track Changes" option being turned on in Microsoft Word, to track the editing manually
        // done there and not the programmatic changes we are about to do here
        Assert.assertFalse(doc.getTrackRevisions());
        
        // As well as nodes in the document, revisions get referenced in this collection
        Assert.assertTrue(doc.hasRevisions());
        Assert.assertEquals(doc.getRevisions().getCount(), 1);
        
        Revision revision = doc.getRevisions().get(0);
        Assert.assertEquals(revision.getAuthor(), "John Doe");
        Assert.assertEquals(revision.getParentNode().getText(), "This is revision #1. ");
        Assert.assertEquals(revision.getRevisionType(), RevisionType.INSERTION);
        Assert.assertEquals(DocumentHelper.getDateWithoutTimeUsingFormat(revision.getDateTime()), DocumentHelper.getDateWithoutTimeUsingFormat(new Date()));
        Assert.assertEquals(revision.getGroup(), doc.getRevisions().getGroups().get(0));
        
        // Deleting content also counts as a revision
        // The most recent revisions are put at the start of the collection
        doc.getFirstSection().getBody().getFirstParagraph().getRuns().get(0).remove();
        Assert.assertEquals(doc.getRevisions().get(0).getRevisionType(), RevisionType.DELETION);
        Assert.assertEquals(doc.getRevisions().getCount(), 2);
        
        // Insert revisions are treated as document text by the GetText() method before they are accepted,
        // since they are still nodes with text and are in the body
        Assert.assertEquals(doc.getText().trim(), "This does not count as a revision. This is revision #1.");
        
        // Accepting the deletion revision will assimilate it into the paragraph text and remove it from the collection
        doc.getRevisions().get(0).accept();
        Assert.assertEquals(doc.getRevisions().getCount(), 1);
        
        // Once the delete revision is accepted, the nodes that it concerns are removed and their text will not show up here
        Assert.assertEquals(doc.getText().trim(), "This is revision #1.");
        
        // The second insertion revision is now at index 0, which we can reject to ignore and discard it
        doc.getRevisions().get(0).reject();
        Assert.assertEquals(doc.getRevisions().getCount(), 0);
        Assert.assertEquals(doc.getText().trim(), "");
        
        // This takes us back to not counting changes as revisions
        doc.stopTrackRevisions();
        
        builder.writeln("This also does not count as a revision.");
        Assert.assertEquals(doc.getRevisions().getCount(), 0);
        
        doc.save(getArtifactsDir() + "Document.Revisions.docx");