@Test public void testDefaults() throws Exception { Config config = newConfig(); config.set("_command", BUCKET + "/" + KEY); when(taskRequest.getConfig()).thenReturn(config); ObjectMetadata objectMetadata = new ObjectMetadata(); objectMetadata.setContentType(CONTENT_TYPE); objectMetadata.setContentLength(CONTENT_LENGTH); objectMetadata.setUserMetadata(USER_METADATA); Operator operator = factory.newOperator(newContext(projectPath, taskRequest)); when(s3Client.getObjectMetadata(objectMetadataRequestCaptor.capture())).thenReturn(objectMetadata); TaskResult taskResult = operator.run(); verify(s3ClientFactory).create(credentialsCaptor.capture(), clientConfigurationCaptor.capture()); ClientConfiguration clientConfiguration = clientConfigurationCaptor.getValue(); assertThat(clientConfiguration.getProxyHost(), is(nullValue())); assertThat(clientConfiguration.getProxyPort(), is(-1)); assertThat(clientConfiguration.getProxyUsername(), is(nullValue())); assertThat(clientConfiguration.getProxyPassword(), is(nullValue())); verify(s3Client).setS3ClientOptions(s3ClientOptionsCaptor.capture()); S3ClientOptions s3ClientOptions = s3ClientOptionsCaptor.getValue(); assertThat(s3ClientOptions.isPathStyleAccess(), is(false)); AWSCredentials credentials = credentialsCaptor.getValue(); assertThat(credentials.getAWSAccessKeyId(), is(ACCESS_KEY_ID)); assertThat(credentials.getAWSSecretKey(), is(SECRET_ACCESS_KEY)); GetObjectMetadataRequest objectMetadataRequest = objectMetadataRequestCaptor.getValue(); assertThat(objectMetadataRequest.getKey(), is(KEY)); assertThat(objectMetadataRequest.getBucketName(), is(BUCKET)); assertThat(objectMetadataRequest.getSSECustomerKey(), is(nullValue())); Config expectedStoreParams = newConfig(); expectedStoreParams .getNestedOrSetEmpty("s3") .getNestedOrSetEmpty("last_object") .set("metadata", objectMetadata.getRawMetadata()) .set("user_metadata", objectMetadata.getUserMetadata()); assertThat(taskResult.getStoreParams(), is(expectedStoreParams)); }
@Override public Operator newOperator(OperatorContext context) { return new S3WaitOperator(context); }
S3WaitOperatorFactory implements OperatorFactory { @Override public Operator newOperator(OperatorContext context) { return new S3WaitOperator(context); } }
S3WaitOperatorFactory implements OperatorFactory { @Override public Operator newOperator(OperatorContext context) { return new S3WaitOperator(context); } @Inject  S3WaitOperatorFactory(@Environment Map<String, String> environment); @VisibleForTesting  S3WaitOperatorFactory(
            AmazonS3ClientFactory s3ClientFactory,
            Map<String, String> environment); }
S3WaitOperatorFactory implements OperatorFactory { @Override public Operator newOperator(OperatorContext context) { return new S3WaitOperator(context); } @Inject  S3WaitOperatorFactory(@Environment Map<String, String> environment); @VisibleForTesting  S3WaitOperatorFactory(
            AmazonS3ClientFactory s3ClientFactory,
            Map<String, String> environment); String getType(); @Override Operator newOperator(OperatorContext context); }
S3WaitOperatorFactory implements OperatorFactory { @Override public Operator newOperator(OperatorContext context) { return new S3WaitOperator(context); } @Inject  S3WaitOperatorFactory(@Environment Map<String, String> environment); @VisibleForTesting  S3WaitOperatorFactory(
            AmazonS3ClientFactory s3ClientFactory,
            Map<String, String> environment); String getType(); @Override Operator newOperator(OperatorContext context);  }