WordTemplate implements Template<E> { @Override public void toTestDocument(OutputStream out) throws InvalidTemplateException, IOException { TemplateContext<E> context = contextFactory.createTemplateContext(this); prepareDocument(); document.updateDynamicContent(context); document.writeAsOpenXML(out); } WordTemplate(TemplateData template, TemplateContextFactory contextFactory); @Override void toDocument(E data, OutputStream out); @Override void toTestDocument(OutputStream out); @Override void toPDFDocument(E data, OutputStream out); @Override String getDocumentName(); @Override Class<?> getInputType(); @Override Map<String, String> getProperties(); String getLanguage(); Locale getLocale(); User getLockingUser(); Date getCreatedAt(); User getEditor(); Date getEditedAt(); @Override void update(InputStream in, User editor); @Override Map<String, MappingDetail> getContentMapping(); @Override List<String> listContentIds(); @Override void validate(); @Override void write(File file); @Override void write(OutputStream out); TemplateData getTemplateData();  }
@Test(expected = InvalidTemplateException.class) public void toTestDocumentWithInvalidTemplate() throws IOException, Docx4JException { InvalidExpressionException error = new InvalidExpressionException(ExpressionError.FORMATTER_TYPE_MISSMATCH); when(templateContext.resolveValue(anyString())).thenThrow(error); WordTemplate<String> wordTemplate = createWordTemplate("org/wte4j/impl/dateValueTemplate.docx"); OutputStream out = new ByteArrayOutputStream(); wordTemplate.toTestDocument(out); }