RequestArchivesListCommand extends AbstractCommand { @Override public void exec(OptionSet options, GlacierUploaderOptionParser optionParser) { final String vaultName = options.valueOf(optionParser.vault); this.startInventoryListing(vaultName); } RequestArchivesListCommand(final AmazonGlacier client, final AmazonSQS sqs, final AmazonSNS sns); @Override void exec(OptionSet options, GlacierUploaderOptionParser optionParser); @Override boolean valid(OptionSet options, GlacierUploaderOptionParser optionParser);  }
@Test public void exec() throws Exception { final InitiateJobRequest jobRequest = createMock(InitiateJobRequest.class); final InitiateJobResult jobResult = new InitiateJobResult(); jobResult.setJobId(UUID.randomUUID().toString()); expect(client.initiateJob(isA(InitiateJobRequest.class))).andReturn(jobResult).times(1); replay(client); final OptionSet options = optionParser.parse("--vault", "vaultName", "--list-inventory"); final RequestArchivesListCommand command = new RequestArchivesListCommand(client, sqs, sns); assertTrue(command.valid(options, optionParser)); command.exec(options, optionParser); verify(client); }
@Test public void testVaultOverrideBySystemEnvironment() { final String vaultName = UUID.randomUUID().toString(); final Map<String, String> props = new HashMap<>(); props.put("vault", vaultName); final GlacierUploaderOptionParser optionParser = new GlacierUploaderOptionParser(new MapConfiguration(props)); final OptionSet options = optionParser.parse("--list-inventory"); Capture<? extends InitiateJobRequest> capturedJobRequest = newCapture(); expect(client.initiateJob(capture(capturedJobRequest))) .andReturn(new InitiateJobResult()) .times(1); replay(client); final RequestArchivesListCommand command = new RequestArchivesListCommand(client, sqs, sns); command.exec(options, optionParser); verify(client); assertEquals(capturedJobRequest.getValue().getVaultName(), vaultName); }