HttpDownloadFileTasklet implements Tasklet { public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { try (InputStream inputStream = inputFile.getInputStream()) { Path destinationPath = destinationFolder.getFile().toPath(); Path outputFile = destinationPath.resolve(getFileName()); if (!Files.exists(destinationPath)) { Files.createDirectories(destinationPath); } Files.copy(inputStream, outputFile, StandardCopyOption.REPLACE_EXISTING); contribution.incrementWriteCount(1); } return RepeatStatus.FINISHED; }  RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext); void setInputFile(Resource inputFile); void setDestinationFolder(Resource destinationFolder);  }
@Test public void testExecute() throws Exception { StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution(); StepContribution stepContribution = new StepContribution(stepExecution); ChunkContext chunkContext = new ChunkContext(new StepContext(stepExecution)); RepeatStatus repeatStatus = tasklet.execute(stepContribution, chunkContext); assertEquals(RepeatStatus.FINISHED, repeatStatus); assertEquals(1, stepContribution.getWriteCount()); assertEquals(1, getFiles().count()); }