search = new TextNavigation("SIMPLE", doc);
int i = 0;
while (search.hasNext()) {
TextSelection item = (TextSelection) search.nextSelection();
ParagraphSelection nextParagraphSelection=new ParagraphSelection(item);
Paragraph paragraph=sourcedoc.getParagraphByIndex(0, true);
nextParagraphSelection.replaceWithParagraph(paragraph);
i++;
}
search = new TextNavigation("Hello1 from SIMPLE source document!", doc);
int j = 0;
while (search.hasNext()) {
search.nextSelection();
j++;
}
Assert.assertTrue(i == j);
//2 Task1, #1 at the start of original Paragraph, #2 replace original Paragraph
search = new TextNavigation("Task1", doc);
i = 0;
while (search.hasNext()) {
TextSelection item = (TextSelection) search.nextSelection();
ParagraphSelection nextParagraphSelection=new ParagraphSelection(item);
Paragraph paragraph=sourcedoc.getParagraphByIndex(1, true);
nextParagraphSelection.replaceWithParagraph(paragraph);
i++;
}
search = new TextNavigation("Hello2 from source document!", doc);
j = 0;
while (search.hasNext()) {
search.nextSelection();
j++;
}
Assert.assertTrue(i == j);
//1 Container, #1 at the end of original Paragraph,
search = new TextNavigation("Container", doc);
i = 0;
while (search.hasNext()) {
TextSelection item = (TextSelection) search.nextSelection();
ParagraphSelection nextParagraphSelection=new ParagraphSelection(item);
Paragraph paragraph=sourcedoc.getParagraphByIndex(2, true);
nextParagraphSelection.replaceWithParagraph(paragraph);
i++;
}
search = new TextNavigation("Hello3 from source document!", doc);
j = 0;