@Test public void shouldSaveBudgetFileInfoAndArchiveItIfNoError() { BudgetFileInfo budgetFileInfo = new BudgetFileInfo("BudgetFile", false); File budgetFile = mock(File.class); mockStatic(MessageBuilder.class); MessageBuilder<File> messageBuilder = mock(MessageBuilder.class); when(MessageBuilder.withPayload(budgetFile)).thenReturn(messageBuilder); Message<File> budgetFileMessage = mock(Message.class); when(messageBuilder.build()).thenReturn(budgetFileMessage); postProcessHandler.process(budgetFileInfo, budgetFile); verify(budgetFileService).save(budgetFileInfo); verify(budgetFtpArchiveOutputChannel).send(budgetFileMessage); }
@Transactional public void process(BudgetFileInfo budgetFileInfo, File budgetFile) { budgetFileService.save(budgetFileInfo); Message<File> message = withPayload(budgetFile).build(); if (!budgetFileInfo.getProcessingError()) { budgetFtpArchiveOutputChannel.send(message); logger.debug("Budget file " + budgetFile.getName() + " archived"); } else { budgetFtpErrorChannel.send(message); logger.warn("Budget file " + budgetFile.getName() + " copied to error folder"); } if (!deleteQuietly(budgetFile)) { logger.error("Unable to delete temporary Budget file " + budgetFile.getName()); } }
BudgetFilePostProcessHandler { @Transactional public void process(BudgetFileInfo budgetFileInfo, File budgetFile) { budgetFileService.save(budgetFileInfo); Message<File> message = withPayload(budgetFile).build(); if (!budgetFileInfo.getProcessingError()) { budgetFtpArchiveOutputChannel.send(message); logger.debug("Budget file " + budgetFile.getName() + " archived"); } else { budgetFtpErrorChannel.send(message); logger.warn("Budget file " + budgetFile.getName() + " copied to error folder"); } if (!deleteQuietly(budgetFile)) { logger.error("Unable to delete temporary Budget file " + budgetFile.getName()); } } }
BudgetFilePostProcessHandler { @Transactional public void process(BudgetFileInfo budgetFileInfo, File budgetFile) { budgetFileService.save(budgetFileInfo); Message<File> message = withPayload(budgetFile).build(); if (!budgetFileInfo.getProcessingError()) { budgetFtpArchiveOutputChannel.send(message); logger.debug("Budget file " + budgetFile.getName() + " archived"); } else { budgetFtpErrorChannel.send(message); logger.warn("Budget file " + budgetFile.getName() + " copied to error folder"); } if (!deleteQuietly(budgetFile)) { logger.error("Unable to delete temporary Budget file " + budgetFile.getName()); } }  }
BudgetFilePostProcessHandler { @Transactional public void process(BudgetFileInfo budgetFileInfo, File budgetFile) { budgetFileService.save(budgetFileInfo); Message<File> message = withPayload(budgetFile).build(); if (!budgetFileInfo.getProcessingError()) { budgetFtpArchiveOutputChannel.send(message); logger.debug("Budget file " + budgetFile.getName() + " archived"); } else { budgetFtpErrorChannel.send(message); logger.warn("Budget file " + budgetFile.getName() + " copied to error folder"); } if (!deleteQuietly(budgetFile)) { logger.error("Unable to delete temporary Budget file " + budgetFile.getName()); } }  @Transactional void process(BudgetFileInfo budgetFileInfo, File budgetFile); }
BudgetFilePostProcessHandler { @Transactional public void process(BudgetFileInfo budgetFileInfo, File budgetFile) { budgetFileService.save(budgetFileInfo); Message<File> message = withPayload(budgetFile).build(); if (!budgetFileInfo.getProcessingError()) { budgetFtpArchiveOutputChannel.send(message); logger.debug("Budget file " + budgetFile.getName() + " archived"); } else { budgetFtpErrorChannel.send(message); logger.warn("Budget file " + budgetFile.getName() + " copied to error folder"); } if (!deleteQuietly(budgetFile)) { logger.error("Unable to delete temporary Budget file " + budgetFile.getName()); } }  @Transactional void process(BudgetFileInfo budgetFileInfo, File budgetFile);  }