GoogleCloudStorageOptions { public static Builder builder() { return new AutoValue_GoogleCloudStorageOptions.Builder() .setGrpcEnabled(ENABLE_GRPC_DEFAULT) .setStorageRootUrl(STORAGE_ROOT_URL_DEFAULT) .setStorageServicePath(STORAGE_SERVICE_PATH_DEFAULT) .setAutoRepairImplicitDirectoriesEnabled(AUTO_REPAIR_IMPLICIT_DIRECTORIES_DEFAULT) .setInferImplicitDirectoriesEnabled(INFER_IMPLICIT_DIRECTORIES_DEFAULT) .setMaxWaitMillisForEmptyObjectCreation(MAX_WAIT_MILLIS_FOR_EMPTY_OBJECT_CREATION) .setMaxListItemsPerCall(MAX_LIST_ITEMS_PER_CALL_DEFAULT) .setMaxRequestsPerBatch(MAX_REQUESTS_PER_BATCH_DEFAULT) .setBatchThreads(BATCH_THREADS_DEFAULT) .setMaxHttpRequestRetries(MAX_HTTP_REQUEST_RETRIES) .setHttpRequestConnectTimeout(HTTP_REQUEST_CONNECT_TIMEOUT) .setHttpRequestReadTimeout(HTTP_REQUEST_READ_TIMEOUT) .setTransportType(HttpTransportFactory.DEFAULT_TRANSPORT_TYPE) .setCopyWithRewriteEnabled(COPY_WITH_REWRITE_DEFAULT) .setMaxBytesRewrittenPerCall(MAX_BYTES_REWRITTEN_PER_CALL_DEFAULT) .setCopyMaxRequestsPerBatch(COPY_MAX_REQUESTS_PER_BATCH_DEFAULT) .setCopyBatchThreads(COPY_BATCH_THREADS_DEFAULT) .setOverwriteGenerationMismatchIgnored(OVERWRITE_GENERATION_MISMATCH_IGNORED_DEFAULT) .setReadChannelOptions(GoogleCloudStorageReadOptions.DEFAULT) .setWriteChannelOptions(AsyncWriteChannelOptions.DEFAULT) .setRequesterPaysOptions(RequesterPaysOptions.DEFAULT) .setCooperativeLockingOptions(CooperativeLockingOptions.DEFAULT) .setHttpRequestHeaders(HTTP_REQUEST_HEADERS_DEFAULT) .setAuthorizationHandlerImplClass(AUTHORIZATION_HANDLER_IMPL_CLASS_DEFAULT) .setAuthorizationHandlerProperties(AUTHORIZATION_HANDLER_PROPERTIES_DEFAULT); }  static Builder builder(); abstract Builder toBuilder(); abstract boolean isGrpcEnabled(); abstract String getStorageRootUrl(); abstract String getStorageServicePath(); @Nullable abstract String getProjectId(); @Nullable abstract String getAppName(); abstract boolean isAutoRepairImplicitDirectoriesEnabled(); abstract boolean isInferImplicitDirectoriesEnabled(); abstract int getMaxWaitMillisForEmptyObjectCreation(); abstract long getMaxListItemsPerCall(); abstract long getMaxRequestsPerBatch(); abstract int getBatchThreads(); abstract long getCopyMaxRequestsPerBatch(); abstract int getCopyBatchThreads(); abstract int getMaxHttpRequestRetries(); abstract int getHttpRequestConnectTimeout(); abstract int getHttpRequestReadTimeout(); abstract HttpTransportFactory.HttpTransportType getTransportType(); @Nullable abstract String getProxyAddress(); @Nullable abstract RedactedString getProxyUsername(); @Nullable abstract RedactedString getProxyPassword(); abstract boolean isCopyWithRewriteEnabled(); abstract long getMaxBytesRewrittenPerCall(); abstract boolean isOverwriteGenerationMismatchIgnored(); abstract GoogleCloudStorageReadOptions getReadChannelOptions(); abstract AsyncWriteChannelOptions getWriteChannelOptions(); abstract RequesterPaysOptions getRequesterPaysOptions(); abstract CooperativeLockingOptions getCooperativeLockingOptions(); abstract ImmutableMap<String, String> getHttpRequestHeaders(); @Nullable abstract String getEncryptionAlgorithm(); @Nullable abstract RedactedString getEncryptionKey(); @Nullable abstract RedactedString getEncryptionKeyHash(); RetryHttpInitializerOptions toRetryHttpInitializerOptions(); @Nullable abstract Class<? extends AuthorizationHandler> getAuthorizationHandlerImplClass(); abstract Map<String, String> getAuthorizationHandlerProperties(); void throwIfNotValid(); static final boolean ENABLE_GRPC_DEFAULT; static final String STORAGE_ROOT_URL_DEFAULT; static final String STORAGE_SERVICE_PATH_DEFAULT; static final boolean AUTO_REPAIR_IMPLICIT_DIRECTORIES_DEFAULT; static final boolean INFER_IMPLICIT_DIRECTORIES_DEFAULT; static final int MAX_WAIT_MILLIS_FOR_EMPTY_OBJECT_CREATION; static final long MAX_LIST_ITEMS_PER_CALL_DEFAULT; static final long MAX_REQUESTS_PER_BATCH_DEFAULT; static final int BATCH_THREADS_DEFAULT; static final int MAX_HTTP_REQUEST_RETRIES; static final int HTTP_REQUEST_CONNECT_TIMEOUT; static final int HTTP_REQUEST_READ_TIMEOUT; static final boolean COPY_WITH_REWRITE_DEFAULT; static final int MAX_BYTES_REWRITTEN_PER_CALL_DEFAULT; static final long COPY_MAX_REQUESTS_PER_BATCH_DEFAULT; static final int COPY_BATCH_THREADS_DEFAULT; static final boolean OVERWRITE_GENERATION_MISMATCH_IGNORED_DEFAULT; static final ImmutableMap<String, String> HTTP_REQUEST_HEADERS_DEFAULT; static final Class<? extends AuthorizationHandler> AUTHORIZATION_HANDLER_IMPL_CLASS_DEFAULT; static final Map<String, String> AUTHORIZATION_HANDLER_PROPERTIES_DEFAULT; static final GoogleCloudStorageOptions DEFAULT; }
@Test public void build_throwsException_whenMaxBytesRewrittenPerCallNotMbMultiple() { long maxBytesRewrittenPerCall = 1; GoogleCloudStorageOptions.Builder builder = GoogleCloudStorageOptions.builder().setMaxBytesRewrittenPerCall(maxBytesRewrittenPerCall); IllegalArgumentException e = assertThrows(IllegalArgumentException.class, builder::build); assertThat(e) .hasMessageThat() .isEqualTo( "maxBytesRewrittenPerCall must be an integral multiple of 1 MiB (1048576), but was: " + maxBytesRewrittenPerCall); }
@Test public void build_throwsException_whenProxyNotSetAndPasswordNotNull() { GoogleCloudStorageOptions.Builder builder = GoogleCloudStorageOptions.builder() .setProxyPassword(RedactedString.create("proxy-password")); IllegalArgumentException e = assertThrows(IllegalArgumentException.class, builder::build); assertThat(e) .hasMessageThat() .isEqualTo( "if proxyAddress is null then proxyUsername and proxyPassword should be null too"); }
@Test public void build_throwsException_whenProxyNotSetAndUsernameNotNull() { GoogleCloudStorageOptions.Builder builder = GoogleCloudStorageOptions.builder() .setProxyUsername(RedactedString.create("proxy-username")); IllegalArgumentException e = assertThrows(IllegalArgumentException.class, builder::build); assertThat(e) .hasMessageThat() .isEqualTo( "if proxyAddress is null then proxyUsername and proxyPassword should be null too"); }
@Test public void build_throwsException_whenProxySetAndUsernameNull() { GoogleCloudStorageOptions.Builder builder = GoogleCloudStorageOptions.builder() .setProxyAddress("proxy-address") .setProxyPassword(RedactedString.create("proxy-password")) .setProxyUsername(null); IllegalArgumentException e = assertThrows(IllegalArgumentException.class, builder::build); assertThat(e) .hasMessageThat() .isEqualTo("both proxyUsername and proxyPassword should be null or not null together"); }
@Test public void build_throwsException_whenProxySetAndPasswordNull() { GoogleCloudStorageOptions.Builder builder = GoogleCloudStorageOptions.builder() .setProxyAddress("proxy-address") .setProxyPassword(null) .setProxyUsername(RedactedString.create("proxy-username")); IllegalArgumentException e = assertThrows(IllegalArgumentException.class, builder::build); assertThat(e) .hasMessageThat() .isEqualTo("both proxyUsername and proxyPassword should be null or not null together"); }
@Test public void encryptionKey_hide_whenSetEncryptionKey() { GoogleCloudStorageOptions.Builder builder = GoogleCloudStorageOptions.builder() .setEncryptionAlgorithm("AES256") .setEncryptionKey(RedactedString.create("test-key")) .setEncryptionKeyHash(RedactedString.create("test-key-hash")); GoogleCloudStorageOptions options = builder.build(); String optionsString = options.toString(); assertThat(optionsString).contains("encryptionKey=<redacted>"); assertThat(optionsString).contains("encryptionKeyHash=<redacted>"); }