ListJobsCommand extends AbstractCommand { @Override public void exec(OptionSet options, GlacierUploaderOptionParser optionParser) { log.info("Listing jobs..."); final String vaultName = options.valueOf(optionParser.vault); final ListJobsRequest req = new ListJobsRequest(vaultName); final ListJobsResult jobOutputResult = client.listJobs(req); for (GlacierJobDescription job : jobOutputResult.getJobList()) { printer.printJob(job, out); } log.info("Done."); } ListJobsCommand(AmazonGlacier client, AmazonSQS sqs, AmazonSNS sns);  ListJobsCommand(final AmazonGlacier client, final AmazonSQS sqs, final AmazonSNS sns, final JobPrinter printer);  ListJobsCommand(final AmazonGlacier client, final AmazonSQS sqs, final AmazonSNS sns, final JobPrinter printer, final OutputStream out); @Override void exec(OptionSet options, GlacierUploaderOptionParser optionParser); @Override boolean valid(OptionSet options, GlacierUploaderOptionParser optionParser);  }
@Test public void exec() { final String jobId = UUID.randomUUID().toString(); final ListJobsResult jobResult = new ListJobsResult(); final GlacierJobDescription jobDescription = new GlacierJobDescription(); jobDescription.setJobId(jobId); jobDescription.setCompleted(true); jobResult.setJobList(Arrays.asList(jobDescription)); expect(client.listJobs(isA(ListJobsRequest.class))).andReturn(jobResult).times(1); replay(client); final OptionSet options = optionParser.parse("--vault", "vaultName", "--list-jobs", UUID.randomUUID().toString()); final ListJobsCommand command = new ListJobsCommand(client, sqs, sns, new JobPrinter() { @Override public void printJob(final GlacierJobDescription job, final OutputStream o) { assertEquals(jobId, job.getJobId()); } }); assertTrue(command.valid(options, optionParser)); command.exec(options, optionParser); verify(client); }