3939
4040class 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