use of de.tudarmstadt.ukp.clarin.webanno.api.annotation.rendering.model.VDocument in project webanno by webanno.
the class CasToBratJsonTest method testGenerateBratJsonGetDocument.
/**
* generate brat JSON data for the document
*/
@Test
public void testGenerateBratJsonGetDocument() throws Exception {
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
String jsonFilePath = "target/test-output/output_cas_to_json_document.json";
String file = "src/test/resources/tcf04-karin-wl.xml";
CAS cas = JCasFactory.createJCas().getCas();
CollectionReader reader = CollectionReaderFactory.createReader(TcfReader.class, TcfReader.PARAM_SOURCE_LOCATION, file);
reader.getNext(cas);
JCas jCas = cas.getJCas();
AnnotatorState state = new AnnotatorStateImpl(Mode.ANNOTATION);
state.getPreferences().setWindowSize(10);
state.setFirstVisibleUnit(WebAnnoCasUtil.getFirstSentence(jCas));
state.setProject(project);
VDocument vdoc = new VDocument();
preRenderer.render(vdoc, state, jCas, annotationSchemaService.listAnnotationLayer(project));
GetDocumentResponse response = new GetDocumentResponse();
BratRenderer.render(response, state, vdoc, jCas, annotationSchemaService);
JSONUtil.generatePrettyJson(jsonConverter, response, new File(jsonFilePath));
assertThat(linesOf(new File("src/test/resources/output_cas_to_json_document_expected.json"), "UTF-8")).isEqualTo(linesOf(new File(jsonFilePath), "UTF-8"));
}
Aggregations