Skip to content

Commit 3a45c65

Browse files
committed
fix pmd findings.
1 parent e24b6ed commit 3a45c65

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

powertools-parameters/powertools-parameters-appconfig/src/main/java/software/amazon/lambda/powertools/parameters/appconfig/AppConfigProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class AppConfigProvider extends BaseProvider {
4646
private final AppConfigDataClient client;
4747
private final String application;
4848
private final String environment;
49-
private final HashMap<String, EstablishedSession> establishedSessions = new HashMap<>();
49+
private final Map<String, EstablishedSession> establishedSessions = new HashMap<>();
5050

5151
AppConfigProvider(CacheManager cacheManager, TransformationManager transformationManager,
5252
AppConfigDataClient client, String environment, String application) {
@@ -118,7 +118,7 @@ protected Map<String, String> getMultipleValues(String path) {
118118
"Retrieving multiple parameter values is not supported with the AWS App Config Provider");
119119
}
120120

121-
private static class EstablishedSession {
121+
private static final class EstablishedSession {
122122
private final String nextSessionToken;
123123
private final String lastConfigurationValue;
124124

powertools-parameters/powertools-parameters-appconfig/src/test/java/software/amazon/lambda/powertools/parameters/appconfig/AppConfigProviderTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939

4040
class AppConfigProviderTest {
4141

42-
private final String environmentName = "test";
43-
private final String applicationName = "fakeApp";
44-
private final String defaultTestKey = "key1";
42+
private static final String ENVIRONMENT_NAME = "test";
43+
private static final String DEFAULT_TEST_KEY = "key1";
44+
private static final String APPLICATION_NAME = "fakeApp";
4545

4646
@Mock
4747
AppConfigDataClient client;
@@ -59,8 +59,8 @@ void init() {
5959

6060
provider = AppConfigProvider.builder()
6161
.withClient(client)
62-
.withApplication(applicationName)
63-
.withEnvironment(environmentName)
62+
.withApplication(APPLICATION_NAME)
63+
.withEnvironment(ENVIRONMENT_NAME)
6464
.withCacheManager(new CacheManager())
6565
.withTransformationManager(new TransformationManager())
6666
.build();
@@ -103,10 +103,10 @@ void getValueRetrievesValue() {
103103
.thenReturn(firstResponse, secondResponse, thirdResponse, forthResponse);
104104

105105
// Act
106-
String returnedValue1 = provider.getValue(defaultTestKey);
107-
String returnedValue2 = provider.getValue(defaultTestKey);
108-
String returnedValue3 = provider.getValue(defaultTestKey);
109-
String returnedValue4 = provider.getValue(defaultTestKey);
106+
String returnedValue1 = provider.getValue(DEFAULT_TEST_KEY);
107+
String returnedValue2 = provider.getValue(DEFAULT_TEST_KEY);
108+
String returnedValue3 = provider.getValue(DEFAULT_TEST_KEY);
109+
String returnedValue4 = provider.getValue(DEFAULT_TEST_KEY);
110110

111111
// Assert
112112
assertThat(returnedValue1).isEqualTo(firstResponse.configuration().asUtf8String());
@@ -115,9 +115,9 @@ void getValueRetrievesValue() {
115115
.asUtf8String()); // Third response is mocked to return null and should re-use previous value
116116
assertThat(returnedValue4).isEqualTo(secondResponse.configuration()
117117
.asUtf8String()); // Forth response is mocked to return empty and should re-use previous value
118-
assertThat(startSessionRequestCaptor.getValue().applicationIdentifier()).isEqualTo(applicationName);
119-
assertThat(startSessionRequestCaptor.getValue().environmentIdentifier()).isEqualTo(environmentName);
120-
assertThat(startSessionRequestCaptor.getValue().configurationProfileIdentifier()).isEqualTo(defaultTestKey);
118+
assertThat(startSessionRequestCaptor.getValue().applicationIdentifier()).isEqualTo(APPLICATION_NAME);
119+
assertThat(startSessionRequestCaptor.getValue().environmentIdentifier()).isEqualTo(ENVIRONMENT_NAME);
120+
assertThat(startSessionRequestCaptor.getValue().configurationProfileIdentifier()).isEqualTo(DEFAULT_TEST_KEY);
121121
assertThat(getLatestConfigurationRequestCaptor.getAllValues().get(0).configurationToken()).isEqualTo(
122122
firstSession.initialConfigurationToken());
123123
assertThat(getLatestConfigurationRequestCaptor.getAllValues().get(1).configurationToken()).isEqualTo(
@@ -141,7 +141,7 @@ void getValueNoValueExists() {
141141
.thenReturn(response);
142142

143143
// Act
144-
String returnedValue = provider.getValue(defaultTestKey);
144+
String returnedValue = provider.getValue(DEFAULT_TEST_KEY);
145145

146146
// Assert
147147
assertThat(returnedValue).isNull();
@@ -204,7 +204,7 @@ void testAppConfigProviderBuilderMissingEnvironment_throwsException() {
204204
// Act & Assert
205205
assertThatIllegalStateException().isThrownBy(() -> AppConfigProvider.builder()
206206
.withCacheManager(new CacheManager())
207-
.withApplication(applicationName)
207+
.withApplication(APPLICATION_NAME)
208208
.withClient(client)
209209
.build())
210210
.withMessage("No environment provided; please provide one");
@@ -215,7 +215,7 @@ void testAppConfigProviderBuilderMissingApplication_throwsException() {
215215
// Act & Assert
216216
assertThatIllegalStateException().isThrownBy(() -> AppConfigProvider.builder()
217217
.withCacheManager(new CacheManager())
218-
.withEnvironment(environmentName)
218+
.withEnvironment(ENVIRONMENT_NAME)
219219
.withClient(client)
220220
.build())
221221
.withMessage("No application provided; please provide one");

0 commit comments

Comments
 (0)