CreateVaultCommand extends AbstractCommand { @Override public void exec(OptionSet options, GlacierUploaderOptionParser optionParser) { final String vaultName = options.valueOf(optionParser.vault); this.createVault(vaultName); } CreateVaultCommand(AmazonGlacier client, AmazonSQS sqs, AmazonSNS sns);  CreateVaultCommand(final AmazonGlacier client, final AmazonSQS sqs, final AmazonSNS sns, final VaultPrinter printer, final OutputStream out); @Override void exec(OptionSet options, GlacierUploaderOptionParser optionParser); @Override boolean valid(OptionSet options, GlacierUploaderOptionParser optionParser);  }
@Test public void exec() throws Exception { final CreateVaultResult createVaultResult = new CreateVaultResult(); createVaultResult.setLocation("dummyLocation"); expect(client.createVault(isA(CreateVaultRequest.class))).andReturn(createVaultResult).times(1); expect(client.describeVault(isA(DescribeVaultRequest.class))).andReturn(new DescribeVaultResult()).times(1); replay(client); final String vaultName = "dummyVaultName"; final OptionSet options = optionParser.parse("--vault", vaultName, "--create"); final CreateVaultCommand command = new CreateVaultCommand(client, sqs, sns, new VaultPrinter() { @Override public void printVault(final DescribeVaultOutput output, final OutputStream o) { assertEquals(vaultName, output.getVaultName()); } }, System.out); assertTrue(command.valid(options, optionParser)); command.exec(options, optionParser); verify(client); }