use of cn.taketoday.mock.env.MockEnvironment in project today-infrastructure by TAKETODAY.
the class StandardConfigDataLocationResolverTests method setup.
@BeforeEach
void setup() {
this.environment = new MockEnvironment();
this.environmentBinder = Binder.get(this.environment);
this.resolver = new StandardConfigDataLocationResolver(this.environmentBinder, this.resourceLoader);
}
use of cn.taketoday.mock.env.MockEnvironment in project today-infrastructure by TAKETODAY.
the class ProfilesTests method getActiveWhenNoEnvironmentProfilesAndEnvironmentProperty.
@Test
void getActiveWhenNoEnvironmentProfilesAndEnvironmentProperty() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("context.profiles.active", "a,b,c");
Binder binder = Binder.get(environment);
Profiles profiles = new Profiles(environment, binder, null);
assertThat(profiles.getActive()).containsExactly("a", "b", "c");
}
use of cn.taketoday.mock.env.MockEnvironment in project today-infrastructure by TAKETODAY.
the class ProfilesTests method getAcceptedWithProfileGroups.
@Test
void getAcceptedWithProfileGroups() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("context.profiles.active", "a,b,c");
environment.setProperty("context.profiles.group.a", "e,f");
environment.setProperty("context.profiles.group.e", "x,y");
environment.setDefaultProfiles("g", "h", "i");
Binder binder = Binder.get(environment);
Profiles profiles = new Profiles(environment, binder, null);
assertThat(profiles.getAccepted()).containsExactly("a", "e", "x", "y", "f", "b", "c");
}
use of cn.taketoday.mock.env.MockEnvironment in project today-infrastructure by TAKETODAY.
the class ProfilesTests method getDefaultWhenDefaultEnvironmentProfileAndBinderProperty.
@Test
void getDefaultWhenDefaultEnvironmentProfileAndBinderProperty() {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("context.profiles.default", "default");
List<ConfigurationPropertySource> sources = new ArrayList<>();
ConfigurationPropertySources.get(environment).forEach(sources::add);
sources.add(new MapConfigurationPropertySource(Collections.singletonMap("context.profiles.default", "a,b,c")));
Binder binder = new Binder(sources);
Profiles profiles = new Profiles(environment, binder, null);
assertThat(profiles.getDefault()).containsExactly("default");
}
use of cn.taketoday.mock.env.MockEnvironment in project today-infrastructure by TAKETODAY.
the class ProfilesTests method isActiveWhenNoActiveAndDefaultDoesNotContainProfileReturnsFalse.
@Test
void isActiveWhenNoActiveAndDefaultDoesNotContainProfileReturnsFalse() {
MockEnvironment environment = new MockEnvironment();
environment.setDefaultProfiles("d", "e", "f");
Binder binder = Binder.get(environment);
Profiles profiles1 = new Profiles(environment, binder, null);
Profiles profiles = profiles1;
assertThat(profiles.isAccepted("x")).isFalse();
}
Aggregations