WordTemplateRepository implements TemplateRepository { @Override public void delete(Template<?> template) { PersistentTemplate unwrapped = unwrap(template); if (unwrapped.isLocked()) { throw new LockingException("Template is locked"); } delete(unwrapped); if (isFileStoreSet()) { fileStore.deleteFile(unwrapped.getTemplateFileName()); } } WordTemplateRepository();  WordTemplateRepository(EntityManager em, TemplateContextFactory contextFactory); void setFileStore(FileStore fileStore); @Override TemplateQuery queryTemplates(); @Override Template<Object> getTemplate(String documentName, String language); @Override Template<E> getTemplate(String documentName, String language,
			Class<? extends E> inputType); @Override Template<E> lockForEdit(Template<E> aTemplate, User user); @Override Template<E> unlock(Template<E> template); @Override Template<E> persist(Template<E> toPersist); @Override void delete(Template<?> template); @Transactional List<Template<Object>> execute(WordTemplateQuery query);  }
@Test @Transactional public void deleteTemplate() { WordTemplate<?> template = unlockedTemplate(); repository.delete(template); assertFalse(isVersionIncontext(template)); }
@Test @Transactional public void deleteLockedTemplate() { WordTemplate<?> template = lockedTemplate(); try { repository.delete(template); fail("Exception expected. Locked templates must not be deleted"); } catch (LockingException e) { assertTrue(isVersionIncontext(template)); } }