WordTemplate implements Template<E> { @Override public void validate() throws InvalidTemplateException { prepareDocument(); document.validate(contextFactory.createTemplateContext(this)); } 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 public void validate() throws IOException { WordTemplate<String> wordTemplate = createWordTemplate("org/wte4j/impl/simpleTemplate.docx"); when(templateContext.validate("value")).thenReturn(ExpressionError.ILLEGAL_CONTENT_KEY); try { wordTemplate.validate(); fail("InvalidTemplateExcption expected"); } catch (InvalidTemplateException e) { assertEquals(ExpressionError.ILLEGAL_CONTENT_KEY, e.getErrors().get("value")); } }