|
|
|
@ -44,7 +44,6 @@ 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;
|
|
|
|
@ -122,7 +121,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), anyBoolean()))
|
|
|
|
|
given(this.importer.resolveAndLoad(eq(this.activationContext), any(), any(), eq(locations)))
|
|
|
|
|
.willReturn(imported);
|
|
|
|
|
ConfigDataEnvironmentContributor contributor = ConfigDataEnvironmentContributor.ofInitialImport(LOCATION_1);
|
|
|
|
|
ConfigDataEnvironmentContributors contributors = new ConfigDataEnvironmentContributors(this.logFactory,
|
|
|
|
@ -145,14 +144,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),
|
|
|
|
|
anyBoolean())).willReturn(initialImported);
|
|
|
|
|
given(this.importer.resolveAndLoad(eq(this.activationContext), any(), any(), eq(initialLocations)))
|
|
|
|
|
.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), anyBoolean()))
|
|
|
|
|
given(this.importer.resolveAndLoad(eq(this.activationContext), any(), any(), eq(secondLocations)))
|
|
|
|
|
.willReturn(secondImported);
|
|
|
|
|
ConfigDataEnvironmentContributor contributor = ConfigDataEnvironmentContributor.ofInitialImport(LOCATION_1);
|
|
|
|
|
ConfigDataEnvironmentContributors contributors = new ConfigDataEnvironmentContributors(this.logFactory,
|
|
|
|
@ -179,13 +178,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), anyBoolean()))
|
|
|
|
|
given(this.importer.resolveAndLoad(eq(this.activationContext), any(), any(), eq(locations)))
|
|
|
|
|
.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(), anyBoolean());
|
|
|
|
|
verify(this.importer).resolveAndLoad(any(), this.locationResolverContext.capture(), any(), any());
|
|
|
|
|
ConfigDataLocationResolverContext context = this.locationResolverContext.getValue();
|
|
|
|
|
assertThat(context.getBinder().bind("test", String.class).get()).isEqualTo("springboot");
|
|
|
|
|
}
|
|
|
|
@ -199,21 +198,20 @@ 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),
|
|
|
|
|
anyBoolean())).willReturn(initialImported);
|
|
|
|
|
given(this.importer.resolveAndLoad(eq(this.activationContext), any(), any(), eq(initialLocations)))
|
|
|
|
|
.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), anyBoolean()))
|
|
|
|
|
given(this.importer.resolveAndLoad(eq(this.activationContext), any(), any(), eq(secondLocations)))
|
|
|
|
|
.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),
|
|
|
|
|
anyBoolean());
|
|
|
|
|
verify(this.importer).resolveAndLoad(any(), this.locationResolverContext.capture(), any(), eq(secondLocations));
|
|
|
|
|
ConfigDataLocationResolverContext context = this.locationResolverContext.getValue();
|
|
|
|
|
assertThat(context.getParent()).hasToString("a");
|
|
|
|
|
}
|
|
|
|
@ -230,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), anyBoolean()))
|
|
|
|
|
given(this.importer.resolveAndLoad(eq(this.activationContext), any(), any(), eq(locations)))
|
|
|
|
|
.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(), anyBoolean());
|
|
|
|
|
verify(this.importer).resolveAndLoad(any(), this.locationResolverContext.capture(), any(), any());
|
|
|
|
|
ConfigDataLocationResolverContext context = this.locationResolverContext.getValue();
|
|
|
|
|
assertThat(context.getBootstrapContext()).isSameAs(this.bootstrapContext);
|
|
|
|
|
}
|
|
|
|
@ -253,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), anyBoolean()))
|
|
|
|
|
given(this.importer.resolveAndLoad(eq(this.activationContext), any(), any(), eq(locations)))
|
|
|
|
|
.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(), anyBoolean());
|
|
|
|
|
verify(this.importer).resolveAndLoad(any(), any(), this.loaderContext.capture(), any());
|
|
|
|
|
ConfigDataLoaderContext context = this.loaderContext.getValue();
|
|
|
|
|
assertThat(context.getBootstrapContext()).isSameAs(this.bootstrapContext);
|
|
|
|
|
}
|
|
|
|
|