DeleteArchiveCommand extends AbstractCommand { @Override public void exec(OptionSet options, GlacierUploaderOptionParser optionParser) { final String vaultName = options.valueOf(optionParser.vault); final String archiveId = options.valueOf(optionParser.deleteArchive); this.delete(vaultName, archiveId); } DeleteArchiveCommand(AmazonGlacier client, AmazonSQS sqs, AmazonSNS sns); @Override void exec(OptionSet options, GlacierUploaderOptionParser optionParser); @Override boolean valid(OptionSet options, GlacierUploaderOptionParser optionParser);  }
@Test public void exec() throws Exception { final String vaultName = "dummyVaultName"; final String archiveId = UUID.randomUUID().toString(); final Capture<DeleteArchiveRequest> capturedRequest = newCapture(); expect(client.deleteArchive(capture(capturedRequest))).andReturn(new DeleteArchiveResult()).times(1); replay(client); final OptionSet options = optionParser.parse("--vault", vaultName, "--delete", archiveId); final DeleteArchiveCommand command = new DeleteArchiveCommand(client, sqs, sns); assertTrue(command.valid(options, optionParser)); command.exec(options, optionParser); verify(client); assertEquals(vaultName, capturedRequest.getValue().getVaultName()); assertEquals(archiveId, capturedRequest.getValue().getArchiveId()); }