Paragraph paragraph = newDoc.addParagraph("Paragraph1");
paragraph.addComment("This is a comment for Paragraph1", "Simple ODF");
Node firstChildNode = paragraph.getOdfElement().getFirstChild();
Assert.assertTrue(firstChildNode instanceof OfficeAnnotationElement);
OfficeAnnotationElement comment = (OfficeAnnotationElement) firstChildNode;
Assert.assertEquals("Simple ODF", comment.getFirstChild().getTextContent());
Assert.assertEquals("This is a comment for Paragraph1", comment.getLastChild().getTextContent());
Assert.assertTrue(firstChildNode instanceof OfficeAnnotationElement);
paragraph = newDoc.addParagraph("Paragraph2");
paragraph.addComment("This is a comment for Paragraph2", null);
firstChildNode = paragraph.getOdfElement().getFirstChild();
Assert.assertTrue(firstChildNode instanceof OfficeAnnotationElement);
comment = (OfficeAnnotationElement) firstChildNode;
Assert.assertEquals(System.getProperty("user.name"), comment.getFirstChild().getTextContent());
Assert.assertEquals("This is a comment for Paragraph2", comment.getLastChild().getTextContent());
newDoc.save(ResourceUtilities.newTestOutputFile("AddCommentOutput.odt"));
} catch (Exception e) {
Logger.getLogger(TextDocumentTest.class.getName()).log(Level.SEVERE, null, e);
Assert.fail();