DodDocumentService implements IDodDocumentService { @Override public Future<Document> retrieveConvertAndStoreRTFDocument(String complexNoteUrl, PatientIds patientIds, String eventId, Document vprDocument) { logger.debug("retrieveConvertAndStoreRTFDocument begin"); return createDodDocumentCommandInstance(complexNoteUrl, patientIds, eventId, vprDocument).queue(); }  @Autowired void setDodDocumentConfiguration(DodDocumentConfiguration dodDocumentConfiguration); @Override Future<Document> convertAndStoreCDADocument(String cdaNote, PatientIds patientIds, String eventId, Document vprDocument); @Override Future<Document> retrieveConvertAndStoreRTFDocument(String complexNoteUrl, PatientIds patientIds,
                                                               String eventId, Document vprDocument); @Override Boolean deleteDodDocuments(String pid);  }
@Test public void testFailure() { testDodDocumentService = new DodDocumentService() { protected RtfDocumentCommand createDodDocumentCommandInstance(String complexNoteUrl, PatientIds patientIds, String eventId, Document vprDocument) { DodDocumentConfiguration config = new DodDocumentConfiguration(mockEnvironment); config.setRetrieveDoDDocumentService(mockRetrieveDodDocumentService); config.setConvertDocumentService(mockConvertDocumentService); config.setDocumentStorageServicePath(STORAGE_SERVICE_PATH); return new RtfDocumentCommand(config, complexNoteUrl, patientIds, eventId, vprDocument) { protected File getStorageDir() { return new File(STORAGE_PATH); } protected void writeToFile(byte[] inputBytes, File destFile) { throw new DodDocumentException("Cannot write original DoD document to disk"); } protected File storeHtmlFile(File htmlFile, File storageDir) { return htmlFile; } protected String readFileToString(File inputFile) throws IOException { return NOTE_TEXT; } }; } }; Future<Document> docFuture = testDodDocumentService.retrieveConvertAndStoreRTFDocument("note.url", patientIds, "docFuture", vprDocument); try { docFuture.get(); fail("Exception should have been thrown"); } catch (Exception e) { assertTrue(e.getCause() instanceof HystrixRuntimeException); } }