ListVaultCommand extends AbstractCommand { @Override public void exec(OptionSet options, GlacierUploaderOptionParser optionParser) { listVaults(); } ListVaultCommand(AmazonGlacier client, AmazonSQS sqs, AmazonSNS sns);  ListVaultCommand(final AmazonGlacier client, final AmazonSQS sqs, final AmazonSNS sns, final VaultPrinter vaultPrinter, final OutputStream out); @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 ListVaultsResult vaultList = new ListVaultsResult(); final DescribeVaultOutput describeVaultOutput = new DescribeVaultOutput(); describeVaultOutput.setVaultName(vaultName); vaultList.setVaultList(Arrays.asList(describeVaultOutput)); expect(client.listVaults(isA(ListVaultsRequest.class))).andReturn(vaultList).times(1); replay(client); final OptionSet options = optionParser.parse("--list-vaults"); final ListVaultCommand command = new ListVaultCommand(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); }