• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  *  http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 package software.amazon.awssdk.http;
17 
18 
19 import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
20 
21 import nl.jqno.equalsverifier.EqualsVerifier;
22 import org.junit.jupiter.api.Test;
23 import software.amazon.awssdk.utils.AttributeMap;
24 
25 class SdkHttpExecutionAttributesTest {
26 
27     @Test
equalsAndHashcode()28     void equalsAndHashcode() {
29         AttributeMap one = AttributeMap.empty();
30         AttributeMap two = AttributeMap.builder().put(TestExecutionAttribute.TEST_KEY_FOO, "test").build();
31 
32         EqualsVerifier.forClass(SdkHttpExecutionAttributes.class)
33                       .withNonnullFields("attributes")
34                       .withPrefabValues(AttributeMap.class, one, two)
35                       .verify();
36     }
37 
38     @Test
getAttribute_shouldReturnCorrectValue()39     void getAttribute_shouldReturnCorrectValue() {
40         SdkHttpExecutionAttributes attributes = SdkHttpExecutionAttributes.builder()
41                                                                           .put(TestExecutionAttribute.TEST_KEY_FOO, "test")
42                                                                           .build();
43         assertThat(attributes.getAttribute(TestExecutionAttribute.TEST_KEY_FOO)).isEqualTo("test");
44     }
45 
46     private static final class TestExecutionAttribute<T> extends SdkHttpExecutionAttribute<T> {
47 
48         private static final TestExecutionAttribute<String> TEST_KEY_FOO = new TestExecutionAttribute<>(String.class);
49 
TestExecutionAttribute(Class valueType)50         private TestExecutionAttribute(Class valueType) {
51             super(valueType);
52         }
53     }
54 }
55