/** * Helper function to set the original selected contents in the updated annotations of this * document from the original list of annotations. * * @param doc the document for which to set the updated annotations original selected contents */ private void copyOriginalSelections(MockDocument doc) { // set the original selections of updated annotations from the original annotations of the // document for (Annotation updatedAnn : doc.getUpdatedAnnotations()) { if (updatedAnn.getState() != AnnotationState.UPDATED) { continue; } Annotation originalAnn = getAnnotation(updatedAnn.getId(), doc.getAnnotations()); updatedAnn.setOriginalSelection(originalAnn.getSelection()); } }
/** * Tests the update of a document. * * @throws IOException if anything goes wrong mocking the documents * @throws MaintainerServiceException if anything goes wrong maintaining the the document * annotations */ @Test public void testUpdate() throws IOException, MaintainerServiceException { // ignore the docName ftm, just test the marvelous setup MockDocument doc = ((TestDocumentFactory) setup.getDocFactory()).getDocument(docName); // TODO: this is not the place to put this code, but it's the most comfortable copyOriginalSelections(doc); annotationMaintainer.updateAnnotations(docName, doc.getSource(), doc.getModifiedSource()); // test the result assertSameAnnotations(doc.getUpdatedAnnotations(), doc.getAnnotations()); }