@Test public void testExceptions() throws ResourceInitializationException, AnalysisEngineProcessException { String sourceViewName = "SourceView"; String destinationViewName = "DestinationView"; AnalysisEngine viewCreator = AnalysisEngineFactory.createEngine( ViewTextCopierAnnotator.class, typeSystemDescription, ViewTextCopierAnnotator.PARAM_SOURCE_VIEW_NAME, sourceViewName, ViewTextCopierAnnotator.PARAM_DESTINATION_VIEW_NAME, destinationViewName); Throwable thrown = catchThrowable(() -> { HideOutput hider = null; try { hider = new HideOutput(); viewCreator.process(jCas); } finally { if (hider != null) { hider.restoreOutput(); } } }); assertThat(thrown) .as("Exception thrown when source view does not exist") .hasRootCauseInstanceOf(CASRuntimeException.class) .hasStackTraceContaining("No sofaFS with name SourceView found"); }
@Override public void process(final JCas jCas) throws AnalysisEngineProcessException { try { final JCas sourceView = jCas.getView(sourceViewName); JCas destinationView; try { destinationView = jCas.getView(destinationViewName); } catch (CASRuntimeException ce) { destinationView = jCas.createView(destinationViewName); } destinationView.setDocumentText(sourceView.getDocumentText()); } catch (CASException e) { throw new AnalysisEngineProcessException(e); } }
ViewTextCopierAnnotator extends JCasAnnotator_ImplBase { @Override public void process(final JCas jCas) throws AnalysisEngineProcessException { try { final JCas sourceView = jCas.getView(sourceViewName); JCas destinationView; try { destinationView = jCas.getView(destinationViewName); } catch (CASRuntimeException ce) { destinationView = jCas.createView(destinationViewName); } destinationView.setDocumentText(sourceView.getDocumentText()); } catch (CASException e) { throw new AnalysisEngineProcessException(e); } } }
ViewTextCopierAnnotator extends JCasAnnotator_ImplBase { @Override public void process(final JCas jCas) throws AnalysisEngineProcessException { try { final JCas sourceView = jCas.getView(sourceViewName); JCas destinationView; try { destinationView = jCas.getView(destinationViewName); } catch (CASRuntimeException ce) { destinationView = jCas.createView(destinationViewName); } destinationView.setDocumentText(sourceView.getDocumentText()); } catch (CASException e) { throw new AnalysisEngineProcessException(e); } }  }
ViewTextCopierAnnotator extends JCasAnnotator_ImplBase { @Override public void process(final JCas jCas) throws AnalysisEngineProcessException { try { final JCas sourceView = jCas.getView(sourceViewName); JCas destinationView; try { destinationView = jCas.getView(destinationViewName); } catch (CASRuntimeException ce) { destinationView = jCas.createView(destinationViewName); } destinationView.setDocumentText(sourceView.getDocumentText()); } catch (CASException e) { throw new AnalysisEngineProcessException(e); } }  @Override void process(final JCas jCas); }
ViewTextCopierAnnotator extends JCasAnnotator_ImplBase { @Override public void process(final JCas jCas) throws AnalysisEngineProcessException { try { final JCas sourceView = jCas.getView(sourceViewName); JCas destinationView; try { destinationView = jCas.getView(destinationViewName); } catch (CASRuntimeException ce) { destinationView = jCas.createView(destinationViewName); } destinationView.setDocumentText(sourceView.getDocumentText()); } catch (CASException e) { throw new AnalysisEngineProcessException(e); } }  @Override void process(final JCas jCas); static final String PARAM_SOURCE_VIEW_NAME; static final String PARAM_DESTINATION_VIEW_NAME; }