Search in sources :

Example 1 with GetBucketReplicationConfigurationRequest

use of com.amazonaws.services.s3.model.GetBucketReplicationConfigurationRequest in project aws-sdk-android by aws-amplify.

the class BucketReplicationIntegrationTest method testSetAndRetrieveReplicationConfiguration.

public void testSetAndRetrieveReplicationConfiguration() {
    // Setting new configuration and retrieving.
    BucketReplicationConfiguration configuration = new BucketReplicationConfiguration();
    configuration.addRule(RULE1, new ReplicationRule().withPrefix("testPrefix1").withStatus(ReplicationRuleStatus.Enabled).withDestinationConfig(new ReplicationDestinationConfig().withBucketARN(DEST_BUCKET_ARN)));
    configuration.addRule(RULE2, new ReplicationRule().withPrefix("testPrefix2").withStatus(ReplicationRuleStatus.Enabled).withDestinationConfig(new ReplicationDestinationConfig().withBucketARN(DEST_BUCKET_ARN)));
    euS3.setBucketReplicationConfiguration(SOURCE_BUCKET_NAME, configuration);
    BucketReplicationConfiguration retrievedReplicationConfig = euS3.getBucketReplicationConfiguration(SOURCE_BUCKET_NAME);
    ReplicationRule replRule1 = retrievedReplicationConfig.getRule(RULE1);
    ReplicationRule replRule2 = retrievedReplicationConfig.getRule(RULE2);
    assertNotNull(replRule1);
    assertNotNull(replRule2);
    assertEquals("testPrefix1", replRule1.getPrefix());
    assertEquals(DEST_BUCKET_ARN, replRule1.getDestinationConfig().getBucketARN());
    assertEquals(ROLE, retrievedReplicationConfig.getRoleARN());
    assertEquals("testPrefix2", replRule2.getPrefix());
    assertEquals(DEST_BUCKET_ARN, replRule2.getDestinationConfig().getBucketARN());
    // disabling second rule.
    replRule2.setStatus(ReplicationRuleStatus.Disabled);
    BucketReplicationConfiguration updatedConfiguration = new BucketReplicationConfiguration().addRule(RULE1, replRule1).addRule(RULE2, replRule2).withRoleARN(ROLE);
    euS3.setBucketReplicationConfiguration(SOURCE_BUCKET_NAME, updatedConfiguration);
    GetBucketReplicationConfigurationRequest getBucketReplicationConfigurationRequest = new GetBucketReplicationConfigurationRequest(SOURCE_BUCKET_NAME);
    retrievedReplicationConfig = euS3.getBucketReplicationConfiguration(getBucketReplicationConfigurationRequest);
    replRule1 = retrievedReplicationConfig.getRule(RULE1);
    replRule2 = retrievedReplicationConfig.getRule(RULE2);
    assertNotNull(replRule1);
    assertNotNull(replRule2);
    assertEquals("testPrefix1", replRule1.getPrefix());
    assertEquals(DEST_BUCKET_ARN, replRule1.getDestinationConfig().getBucketARN());
    assertEquals(ReplicationRuleStatus.Enabled.toString(), replRule1.getStatus());
    assertEquals("testPrefix2", replRule2.getPrefix());
    assertEquals(DEST_BUCKET_ARN, replRule2.getDestinationConfig().getBucketARN());
    assertEquals(ReplicationRuleStatus.Disabled.toString(), replRule2.getStatus());
}
Also used : BucketReplicationConfiguration(com.amazonaws.services.s3.model.BucketReplicationConfiguration) ReplicationDestinationConfig(com.amazonaws.services.s3.model.ReplicationDestinationConfig) GetBucketReplicationConfigurationRequest(com.amazonaws.services.s3.model.GetBucketReplicationConfigurationRequest) ReplicationRule(com.amazonaws.services.s3.model.ReplicationRule)

Aggregations

BucketReplicationConfiguration (com.amazonaws.services.s3.model.BucketReplicationConfiguration)1 GetBucketReplicationConfigurationRequest (com.amazonaws.services.s3.model.GetBucketReplicationConfigurationRequest)1 ReplicationDestinationConfig (com.amazonaws.services.s3.model.ReplicationDestinationConfig)1 ReplicationRule (com.amazonaws.services.s3.model.ReplicationRule)1