@Test
public void testBuildLogLocation() {

    // No bucket override
    assertThat(LogStorageInfos.buildLogLocation(JobGenerator.oneBatchTask(), DEFAULT_LOG_LOCATION)).isEqualTo(DEFAULT_LOG_LOCATION);
    // Plain custom bucket name
    assertThat(LogStorageInfos.buildLogLocation(newTask("bucketA", "pathB"), DEFAULT_LOG_LOCATION)).isEqualTo(
            new S3LogLocation(
                    DEFAULT_LOG_LOCATION.getAccountName(),
                    DEFAULT_LOG_LOCATION.getAccountId(),
                    DEFAULT_LOG_LOCATION.getRegion(),
                    "bucketA",
                    "pathB/defaultKey"
            )
    );
    // Custom bucket name with S3 ARN.
    assertThat(LogStorageInfos.buildLogLocation(
            newTask("arn:aws:s3:us-west-2:123456789012:accesspoint/test", "pathB"),
            DEFAULT_LOG_LOCATION)
    ).isEqualTo(
            new S3LogLocation(
                    "123456789012",
                    "123456789012",
                    "us-west-2",
                    "arn:aws:s3:us-west-2:123456789012:accesspoint/test",
                    "pathB/defaultKey"
            )
    );
}