AbortMultipartArchiveUploadCommand extends AbstractCommand { @Override public void exec(OptionSet options, GlacierUploaderOptionParser optionParser) { final String vaultName = options.valueOf(optionParser.vault); final String uploadId = options.valueOf(optionParser.abortUpload); try { abortUpload(vaultName, uploadId); } catch (AmazonServiceException e) { log.error("Something went wrong at Amazon while aborting the multipart upload with id " + uploadId + ". " + e.getLocalizedMessage(), e); } catch (AmazonClientException e) { log.error("Something went wrong with the Amazon Client.", e); } } AbortMultipartArchiveUploadCommand(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 { expect(client.abortMultipartUpload(isA(AbortMultipartUploadRequest.class))).andReturn(new AbortMultipartUploadResult()).times(1); replay(client); final OptionSet options = optionParser.parse("--abort-upload", UUID.randomUUID().toString()); final AbortMultipartArchiveUploadCommand command = new AbortMultipartArchiveUploadCommand(client, sqs, sns); assertTrue(command.valid(options, optionParser)); command.exec(options, optionParser); verify(client); }