DownloadArchiveCommand extends AbstractCommand { @Override public void exec(OptionSet options, GlacierUploaderOptionParser optionParser) { final String vaultName = options.valueOf(optionParser.vault); final String archiveId = options.valueOf(optionParser.download); final File targetFile = options.valueOf(optionParser.targetFile); this.download(vaultName, archiveId, targetFile); } DownloadArchiveCommand(AmazonGlacier client, AmazonSQS sqs, AmazonSNS sns);  DownloadArchiveCommand(final AmazonGlacier client, final AmazonSQS sqs, final AmazonSNS sns, final ArchiveTransferManager atm); @Override void exec(OptionSet options, GlacierUploaderOptionParser optionParser); @Override boolean valid(OptionSet options, GlacierUploaderOptionParser optionParser);  }
@Test public void exec() throws Exception { final String vaultName = UUID.randomUUID().toString(); final String archiveId = UUID.randomUUID().toString(); final String targetName = UUID.randomUUID().toString(); final ArchiveTransferManager atm = createMock(ArchiveTransferManager.class); atm.download(vaultName, archiveId, new File(targetName)); expectLastCall().times(1); replay(atm); final OptionSet options = optionParser.parse("--vault", vaultName, "--download", archiveId, "--target", targetName); final DownloadArchiveCommand command = new DownloadArchiveCommand(client, sqs, sns, atm); assertTrue(command.valid(options, optionParser)); command.exec(options, optionParser); verify(atm); }