@ -43,6 +43,7 @@ import org.springframework.mock.env.MockPropertySource;
import static org.assertj.core.api.Assertions.assertThat ;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType ;
import static org.mockito.ArgumentMatchers.any ;
import static org.mockito.ArgumentMatchers.anyBoolean ;
import static org.mockito.ArgumentMatchers.eq ;
import static org.mockito.BDDMockito.given ;
import static org.mockito.Mockito.mock ;
@ -119,7 +120,7 @@ class ConfigDataEnvironmentContributorsTests {
Map < ConfigDataResolutionResult , ConfigData > imported = new LinkedHashMap < > ( ) ;
imported . put ( new ConfigDataResolutionResult ( LOCATION_1 , new TestConfigDataResource ( "a" ) , false ) ,
new ConfigData ( Arrays . asList ( propertySource ) ) ) ;
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( locations ) ))
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( locations ) , anyBoolean ( ) ))
. willReturn ( imported ) ;
ConfigDataEnvironmentContributor contributor = ConfigDataEnvironmentContributor . ofInitialImport ( LOCATION_1 ) ;
ConfigDataEnvironmentContributors contributors = new ConfigDataEnvironmentContributors ( this . logFactory ,
@ -142,14 +143,14 @@ class ConfigDataEnvironmentContributorsTests {
Map < ConfigDataResolutionResult , ConfigData > initialImported = new LinkedHashMap < > ( ) ;
initialImported . put ( new ConfigDataResolutionResult ( LOCATION_1 , new TestConfigDataResource ( "a" ) , false ) ,
new ConfigData ( Arrays . asList ( initialPropertySource ) ) ) ;
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( initialLocations ) ))
. willReturn ( initialImported ) ;
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( initialLocations ) ,
anyBoolean ( ) ) ) . willReturn ( initialImported ) ;
List < ConfigDataLocation > secondLocations = Arrays . asList ( LOCATION_2 ) ;
MockPropertySource secondPropertySource = new MockPropertySource ( ) ;
Map < ConfigDataResolutionResult , ConfigData > secondImported = new LinkedHashMap < > ( ) ;
secondImported . put ( new ConfigDataResolutionResult ( LOCATION_2 , new TestConfigDataResource ( "b" ) , false ) ,
new ConfigData ( Arrays . asList ( secondPropertySource ) ) ) ;
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( secondLocations ) ))
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( secondLocations ) , anyBoolean ( ) ))
. willReturn ( secondImported ) ;
ConfigDataEnvironmentContributor contributor = ConfigDataEnvironmentContributor . ofInitialImport ( LOCATION_1 ) ;
ConfigDataEnvironmentContributors contributors = new ConfigDataEnvironmentContributors ( this . logFactory ,
@ -176,13 +177,13 @@ class ConfigDataEnvironmentContributorsTests {
Map < ConfigDataResolutionResult , ConfigData > imported = new LinkedHashMap < > ( ) ;
imported . put ( new ConfigDataResolutionResult ( LOCATION_1 , new TestConfigDataResource ( "a'" ) , false ) ,
new ConfigData ( Arrays . asList ( propertySource ) ) ) ;
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( locations ) ))
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( locations ) , anyBoolean ( ) ))
. willReturn ( imported ) ;
ConfigDataEnvironmentContributor contributor = ConfigDataEnvironmentContributor . ofInitialImport ( LOCATION_1 ) ;
ConfigDataEnvironmentContributors contributors = new ConfigDataEnvironmentContributors ( this . logFactory ,
this . bootstrapContext , Arrays . asList ( existingContributor , contributor ) ) ;
contributors . withProcessedImports ( this . importer , this . activationContext ) ;
verify ( this . importer ) . resolveAndLoad ( any ( ) , this . locationResolverContext . capture ( ) , any ( ) , any ( ) );
verify ( this . importer ) . resolveAndLoad ( any ( ) , this . locationResolverContext . capture ( ) , any ( ) , any ( ) , anyBoolean ( ) );
ConfigDataLocationResolverContext context = this . locationResolverContext . getValue ( ) ;
assertThat ( context . getBinder ( ) . bind ( "test" , String . class ) . get ( ) ) . isEqualTo ( "springboot" ) ;
}
@ -196,20 +197,21 @@ class ConfigDataEnvironmentContributorsTests {
Map < ConfigDataResolutionResult , ConfigData > initialImported = new LinkedHashMap < > ( ) ;
initialImported . put ( new ConfigDataResolutionResult ( LOCATION_1 , new TestConfigDataResource ( "a" ) , false ) ,
new ConfigData ( Arrays . asList ( initialPropertySource ) ) ) ;
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( initialLocations ) ))
. willReturn ( initialImported ) ;
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( initialLocations ) ,
anyBoolean ( ) ) ) . willReturn ( initialImported ) ;
List < ConfigDataLocation > secondLocations = Arrays . asList ( LOCATION_2 ) ;
MockPropertySource secondPropertySource = new MockPropertySource ( ) ;
Map < ConfigDataResolutionResult , ConfigData > secondImported = new LinkedHashMap < > ( ) ;
secondImported . put ( new ConfigDataResolutionResult ( LOCATION_2 , new TestConfigDataResource ( "b" ) , false ) ,
new ConfigData ( Arrays . asList ( secondPropertySource ) ) ) ;
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( secondLocations ) ))
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( secondLocations ) , anyBoolean ( ) ))
. willReturn ( secondImported ) ;
ConfigDataEnvironmentContributor contributor = ConfigDataEnvironmentContributor . ofInitialImport ( LOCATION_1 ) ;
ConfigDataEnvironmentContributors contributors = new ConfigDataEnvironmentContributors ( this . logFactory ,
this . bootstrapContext , Arrays . asList ( contributor ) ) ;
contributors . withProcessedImports ( this . importer , this . activationContext ) ;
verify ( this . importer ) . resolveAndLoad ( any ( ) , this . locationResolverContext . capture ( ) , any ( ) , eq ( secondLocations ) ) ;
verify ( this . importer ) . resolveAndLoad ( any ( ) , this . locationResolverContext . capture ( ) , any ( ) , eq ( secondLocations ) ,
anyBoolean ( ) ) ;
ConfigDataLocationResolverContext context = this . locationResolverContext . getValue ( ) ;
assertThat ( context . getParent ( ) ) . hasToString ( "a" ) ;
}
@ -226,13 +228,13 @@ class ConfigDataEnvironmentContributorsTests {
Map < ConfigDataResolutionResult , ConfigData > imported = new LinkedHashMap < > ( ) ;
imported . put ( new ConfigDataResolutionResult ( LOCATION_1 , new TestConfigDataResource ( "a'" ) , false ) ,
new ConfigData ( Arrays . asList ( propertySource ) ) ) ;
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( locations ) ))
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( locations ) , anyBoolean ( ) ))
. willReturn ( imported ) ;
ConfigDataEnvironmentContributor contributor = ConfigDataEnvironmentContributor . ofInitialImport ( LOCATION_1 ) ;
ConfigDataEnvironmentContributors contributors = new ConfigDataEnvironmentContributors ( this . logFactory ,
this . bootstrapContext , Arrays . asList ( existingContributor , contributor ) ) ;
contributors . withProcessedImports ( this . importer , this . activationContext ) ;
verify ( this . importer ) . resolveAndLoad ( any ( ) , this . locationResolverContext . capture ( ) , any ( ) , any ( ) );
verify ( this . importer ) . resolveAndLoad ( any ( ) , this . locationResolverContext . capture ( ) , any ( ) , any ( ) , anyBoolean ( ) );
ConfigDataLocationResolverContext context = this . locationResolverContext . getValue ( ) ;
assertThat ( context . getBootstrapContext ( ) ) . isSameAs ( this . bootstrapContext ) ;
}
@ -249,13 +251,13 @@ class ConfigDataEnvironmentContributorsTests {
Map < ConfigDataResolutionResult , ConfigData > imported = new LinkedHashMap < > ( ) ;
imported . put ( new ConfigDataResolutionResult ( LOCATION_1 , new TestConfigDataResource ( "a'" ) , false ) ,
new ConfigData ( Arrays . asList ( propertySource ) ) ) ;
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( locations ) ))
given ( this . importer . resolveAndLoad ( eq ( this . activationContext ) , any ( ) , any ( ) , eq ( locations ) , anyBoolean ( ) ))
. willReturn ( imported ) ;
ConfigDataEnvironmentContributor contributor = ConfigDataEnvironmentContributor . ofInitialImport ( LOCATION_1 ) ;
ConfigDataEnvironmentContributors contributors = new ConfigDataEnvironmentContributors ( this . logFactory ,
this . bootstrapContext , Arrays . asList ( existingContributor , contributor ) ) ;
contributors . withProcessedImports ( this . importer , this . activationContext ) ;
verify ( this . importer ) . resolveAndLoad ( any ( ) , any ( ) , this . loaderContext . capture ( ) , any ( ) );
verify ( this . importer ) . resolveAndLoad ( any ( ) , any ( ) , this . loaderContext . capture ( ) , any ( ) , anyBoolean ( ) );
ConfigDataLoaderContext context = this . loaderContext . getValue ( ) ;
assertThat ( context . getBootstrapContext ( ) ) . isSameAs ( this . bootstrapContext ) ;
}