BundleInstanceS3StorageOptions extends BaseEC2RequestOptions { @Override public Multimap<String, String> buildFormParameters() { if (getAwsAccessKeyId() == null) { checkState(creds != null, "creds should have been injected"); bucketOwnedBy(creds.get().identity); } return super.buildFormParameters(); }  @Override Multimap<String, String> buildFormParameters(); BundleInstanceS3StorageOptions bucketOwnedBy(String ccessKeyId); String getAwsAccessKeyId();  }
@Test(expectedExceptions = IllegalStateException.class) public void testNullBucketOwnedByNotInjected() { BundleInstanceS3StorageOptions options = new BundleInstanceS3StorageOptions(); assertEquals(options.buildFormParameters().get("Storage.S3.AWSAccessKeyId"), ImmutableList.of()); }
@Test public void testNullBucketOwnedBy() { BundleInstanceS3StorageOptions options = new BundleInstanceS3StorageOptions(); options.creds = Suppliers.ofInstance(new Credentials("foo", null)); assertEquals(options.buildFormParameters().get("Storage.S3.AWSAccessKeyId"), ImmutableList.of("foo")); }