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