UploadMultipartArchiveCommand extends AbstractCommand { @Override public void exec(OptionSet options, GlacierUploaderOptionParser optionParser) { final String vaultName = options.valueOf(optionParser.vault); final List<File> optionsFiles = options.valuesOf(optionParser.multipartUpload); final Long partSize = options.valueOf(optionParser.partSize); final List<String> nonOptions = options.nonOptionArguments(); final List<File> files = optionParser.mergeNonOptionsFiles(optionsFiles, nonOptions); for (File uploadFile : files) { this.upload(vaultName, uploadFile, partSize); } } UploadMultipartArchiveCommand(AmazonGlacier client, AmazonSQS sqs, AmazonSNS sns); @Override void exec(OptionSet options, GlacierUploaderOptionParser optionParser); @Override boolean valid(OptionSet options, GlacierUploaderOptionParser optionParser);  }
@Test public void testExec() throws IOException { final File tempFile = File.createTempFile("this is a test with whitespaces", ".txt"); tempFile.deleteOnExit(); try(FileWriter fw = new FileWriter(tempFile)) { fw.write(UUID.randomUUID().toString()); } final OptionSet options = optionParser.parse("--vault", "dummy", "-m", tempFile.getAbsolutePath(), "--partsize", "1234"); final InitiateMultipartUploadResult initiateResult = new InitiateMultipartUploadResult(); initiateResult.setUploadId(UUID.randomUUID().toString()); expect(client.initiateMultipartUpload(isA(InitiateMultipartUploadRequest.class))).andReturn(initiateResult).times(1); expect(client.uploadMultipartPart(isA(UploadMultipartPartRequest.class))).andReturn(new UploadMultipartPartResult()).times(1); expect(client.completeMultipartUpload(isA(CompleteMultipartUploadRequest.class))).andReturn(new CompleteMultipartUploadResult()).times(1); replay(client, sqs, sns); final UploadMultipartArchiveCommand command = new UploadMultipartArchiveCommand(client, sqs, sns); assertTrue(command.valid(options, optionParser)); command.exec(options, optionParser); verify(client, sqs, sns); }