use of software.amazon.awssdk.core.interceptor.ExecutionAttribute in project aws-sdk-java-v2 by aws.
the class ClientOverrideConfigurationTest method executionAttributes_createsCopy.
@Test
public void executionAttributes_createsCopy() {
ExecutionAttributes executionAttributes = new ExecutionAttributes();
ExecutionAttribute testAttribute = attr("TestAttribute");
String expectedValue = "Value1";
executionAttributes.putAttribute(testAttribute, expectedValue);
ClientOverrideConfiguration overrideConfig = ClientOverrideConfiguration.builder().executionAttributes(executionAttributes).build();
executionAttributes.putAttribute(testAttribute, "Value2");
assertThat(overrideConfig.executionAttributes().getAttribute(testAttribute)).isEqualTo(expectedValue);
}
use of software.amazon.awssdk.core.interceptor.ExecutionAttribute in project aws-sdk-java-v2 by aws.
the class ClientOverrideConfigurationTest method executionAttributes_listPreviouslyAdded_appendedToList.
@Test
public void executionAttributes_listPreviouslyAdded_appendedToList() {
ExecutionAttributes executionAttributes = new ExecutionAttributes();
for (int i = 0; i < 5; i++) {
executionAttributes.putAttribute(attr("Attribute" + i), mock(Object.class));
}
ClientOverrideConfiguration.Builder builder = ClientOverrideConfiguration.builder();
builder.executionAttributes(executionAttributes);
ExecutionAttribute addedAttribute = attr("AddedAttribute");
Object addedValue = mock(Object.class);
builder.putExecutionAttribute(addedAttribute, addedValue);
ClientOverrideConfiguration overrideConfig = builder.build();
assertThat(overrideConfig.executionAttributes().getAttribute(addedAttribute)).isEqualTo(addedValue);
}
use of software.amazon.awssdk.core.interceptor.ExecutionAttribute in project aws-sdk-java-v2 by aws.
the class DefaultClientBuilderTest method buildIncludesClientOverrides.
@Test
public void buildIncludesClientOverrides() {
List<ExecutionInterceptor> interceptors = new ArrayList<>();
ExecutionInterceptor interceptor = new ExecutionInterceptor() {
};
interceptors.add(interceptor);
RetryPolicy retryPolicy = RetryPolicy.builder().build();
Map<String, List<String>> headers = new HashMap<>();
List<String> headerValues = new ArrayList<>();
headerValues.add("value");
headers.put("client-override-test", headerValues);
List<MetricPublisher> metricPublishers = new ArrayList<>();
MetricPublisher metricPublisher = new MetricPublisher() {
@Override
public void publish(MetricCollection metricCollection) {
}
@Override
public void close() {
}
};
metricPublishers.add(metricPublisher);
ExecutionAttribute<String> execAttribute = new ExecutionAttribute<>("test");
ExecutionAttributes executionAttributes = ExecutionAttributes.builder().put(execAttribute, "value").build();
Signer signer = (request, execAttributes) -> request;
String suffix = "suffix";
String prefix = "prefix";
Duration apiCallTimeout = Duration.ofMillis(42);
Duration apiCallAttemptTimeout = Duration.ofMillis(43);
ProfileFile profileFile = ProfileFile.builder().content(new StringInputStream("")).type(ProfileFile.Type.CONFIGURATION).build();
String profileName = "name";
ClientOverrideConfiguration overrideConfig = ClientOverrideConfiguration.builder().executionInterceptors(interceptors).retryPolicy(retryPolicy).headers(headers).putAdvancedOption(SIGNER, signer).putAdvancedOption(USER_AGENT_SUFFIX, suffix).putAdvancedOption(USER_AGENT_PREFIX, prefix).apiCallTimeout(apiCallTimeout).apiCallAttemptTimeout(apiCallAttemptTimeout).putAdvancedOption(DISABLE_HOST_PREFIX_INJECTION, Boolean.TRUE).defaultProfileFile(profileFile).defaultProfileName(profileName).metricPublishers(metricPublishers).executionAttributes(executionAttributes).putAdvancedOption(ENDPOINT_OVERRIDDEN_OVERRIDE, Boolean.TRUE).build();
SdkClientConfiguration config = testClientBuilder().overrideConfiguration(overrideConfig).build().clientConfiguration;
assertThat(config.option(EXECUTION_INTERCEPTORS)).contains(interceptor);
assertThat(config.option(RETRY_POLICY)).isEqualTo(retryPolicy);
assertThat(config.option(ADDITIONAL_HTTP_HEADERS).get("client-override-test")).isEqualTo(headerValues);
assertThat(config.option(SIGNER)).isEqualTo(signer);
assertThat(config.option(USER_AGENT_SUFFIX)).isEqualTo(suffix);
assertThat(config.option(USER_AGENT_PREFIX)).isEqualTo(prefix);
assertThat(config.option(API_CALL_TIMEOUT)).isEqualTo(apiCallTimeout);
assertThat(config.option(API_CALL_ATTEMPT_TIMEOUT)).isEqualTo(apiCallAttemptTimeout);
assertThat(config.option(DISABLE_HOST_PREFIX_INJECTION)).isEqualTo(Boolean.TRUE);
assertThat(config.option(PROFILE_FILE)).isEqualTo(profileFile);
assertThat(config.option(PROFILE_NAME)).isEqualTo(profileName);
assertThat(config.option(METRIC_PUBLISHERS)).contains(metricPublisher);
assertThat(config.option(EXECUTION_ATTRIBUTES).getAttribute(execAttribute)).isEqualTo("value");
assertThat(config.option(ENDPOINT_OVERRIDDEN)).isEqualTo(Boolean.TRUE);
}
use of software.amazon.awssdk.core.interceptor.ExecutionAttribute in project aws-sdk-java-v2 by aws.
the class RequestOverrideConfigurationTest method executionAttributes_createsCopy.
@Test
public void executionAttributes_createsCopy() {
ExecutionAttributes executionAttributes = new ExecutionAttributes();
ExecutionAttribute testAttribute = attr("TestAttribute");
String expectedValue = "Value1";
executionAttributes.putAttribute(testAttribute, expectedValue);
SdkRequestOverrideConfiguration overrideConfig = SdkRequestOverrideConfiguration.builder().executionAttributes(executionAttributes).build();
executionAttributes.putAttribute(testAttribute, "Value2");
assertThat(overrideConfig.executionAttributes().getAttribute(testAttribute)).isEqualTo(expectedValue);
}
use of software.amazon.awssdk.core.interceptor.ExecutionAttribute in project aws-sdk-java-v2 by aws.
the class RequestOverrideConfigurationTest method executionAttributes_listPreviouslyAdded_appendedToList.
@Test
public void executionAttributes_listPreviouslyAdded_appendedToList() {
ExecutionAttributes executionAttributes = new ExecutionAttributes();
for (int i = 0; i < 5; i++) {
executionAttributes.putAttribute(attr("Attribute" + i), mock(Object.class));
}
SdkRequestOverrideConfiguration.Builder builder = SdkRequestOverrideConfiguration.builder();
builder.executionAttributes(executionAttributes);
ExecutionAttribute addedAttribute = attr("AddedAttribute");
Object addedValue = mock(Object.class);
builder.putExecutionAttribute(addedAttribute, addedValue);
SdkRequestOverrideConfiguration overrideConfig = builder.build();
assertThat(overrideConfig.executionAttributes().getAttribute(addedAttribute)).isEqualTo(addedValue);
}
Aggregations