Search in sources :

Example 1 with Options

use of cn.taketoday.framework.context.config.ConfigData.Options in project today-infrastructure by TAKETODAY.

the class ConfigDataTests method optionsOfUsesCopyOfOptions.

@Test
void optionsOfUsesCopyOfOptions() {
    Option[] array = { Option.IGNORE_IMPORTS, Option.IGNORE_PROFILES };
    Options options = Options.of(array);
    array[0] = Option.PROFILE_SPECIFIC;
    assertThat(options.asSet()).containsExactly(Option.IGNORE_IMPORTS, Option.IGNORE_PROFILES);
}
Also used : Options(cn.taketoday.framework.context.config.ConfigData.Options) PropertySourceOptions(cn.taketoday.framework.context.config.ConfigData.PropertySourceOptions) Option(cn.taketoday.framework.context.config.ConfigData.Option) Test(org.junit.jupiter.api.Test)

Example 2 with Options

use of cn.taketoday.framework.context.config.ConfigData.Options in project today-infrastructure by TAKETODAY.

the class ConfigDataTests method optionsOfCreatesOptions.

@Test
void optionsOfCreatesOptions() {
    Options options = Options.of(Option.IGNORE_IMPORTS, Option.IGNORE_PROFILES);
    assertThat(options.asSet()).containsExactly(Option.IGNORE_IMPORTS, Option.IGNORE_PROFILES);
}
Also used : Options(cn.taketoday.framework.context.config.ConfigData.Options) PropertySourceOptions(cn.taketoday.framework.context.config.ConfigData.PropertySourceOptions) Test(org.junit.jupiter.api.Test)

Example 3 with Options

use of cn.taketoday.framework.context.config.ConfigData.Options in project today-infrastructure by TAKETODAY.

the class ConfigDataTests method getOptionsReturnsOptionsFromPropertySourceOptions.

@Test
void getOptionsReturnsOptionsFromPropertySourceOptions() {
    MapPropertySource source1 = new MapPropertySource("test", Collections.emptyMap());
    MapPropertySource source2 = new MapPropertySource("test", Collections.emptyMap());
    Options options1 = Options.of(Option.IGNORE_IMPORTS);
    Options options2 = Options.of(Option.IGNORE_PROFILES);
    PropertySourceOptions propertySourceOptions = (source) -> (source != source1) ? options2 : options1;
    ConfigData configData = new ConfigData(Arrays.asList(source1, source2), propertySourceOptions);
    assertThat(configData.getOptions(source1)).isEqualTo(options1);
    assertThat(configData.getOptions(source2)).isEqualTo(options2);
}
Also used : Arrays(java.util.Arrays) MapPropertySource(cn.taketoday.core.env.MapPropertySource) Option(cn.taketoday.framework.context.config.ConfigData.Option) Options(cn.taketoday.framework.context.config.ConfigData.Options) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) PropertySource(cn.taketoday.core.env.PropertySource) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) List(java.util.List) Assertions.assertThatIllegalArgumentException(org.assertj.core.api.Assertions.assertThatIllegalArgumentException) PropertySourceOptions(cn.taketoday.framework.context.config.ConfigData.PropertySourceOptions) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) Options(cn.taketoday.framework.context.config.ConfigData.Options) PropertySourceOptions(cn.taketoday.framework.context.config.ConfigData.PropertySourceOptions) MapPropertySource(cn.taketoday.core.env.MapPropertySource) PropertySourceOptions(cn.taketoday.framework.context.config.ConfigData.PropertySourceOptions) Test(org.junit.jupiter.api.Test)

Example 4 with Options

use of cn.taketoday.framework.context.config.ConfigData.Options in project today-infrastructure by TAKETODAY.

the class ConfigDataEnvironmentContributor method ofUnboundImport.

/**
 * Factory method to create an {@link Kind#UNBOUND_IMPORT unbound import} contributor.
 * This contributor has been actively imported from another contributor and may itself
 * import further contributors later.
 *
 * @param location the location of this contributor
 * @param resource the config data resource
 * @param profileSpecific if the contributor is from a profile specific import
 * @param configData the config data
 * @param propertySourceIndex the index of the property source that should be used
 * @return a new {@link ConfigDataEnvironmentContributor} instance
 */
static ConfigDataEnvironmentContributor ofUnboundImport(@Nullable ConfigDataLocation location, @Nullable ConfigDataResource resource, boolean profileSpecific, ConfigData configData, int propertySourceIndex) {
    PropertySource<?> propertySource = configData.getPropertySources().get(propertySourceIndex);
    Options options = configData.getOptions(propertySource);
    ConfigurationPropertySource configurationPropertySource = ConfigurationPropertySource.from(propertySource);
    return new ConfigDataEnvironmentContributor(Kind.UNBOUND_IMPORT, location, resource, profileSpecific, propertySource, configurationPropertySource, null, options, null);
}
Also used : Options(cn.taketoday.framework.context.config.ConfigData.Options) ConfigurationPropertySource(cn.taketoday.context.properties.source.ConfigurationPropertySource)

Example 5 with Options

use of cn.taketoday.framework.context.config.ConfigData.Options in project today-framework by TAKETODAY.

the class ConfigDataTests method optionsOfCreatesOptions.

@Test
void optionsOfCreatesOptions() {
    Options options = Options.of(Option.IGNORE_IMPORTS, Option.IGNORE_PROFILES);
    assertThat(options.asSet()).containsExactly(Option.IGNORE_IMPORTS, Option.IGNORE_PROFILES);
}
Also used : Options(cn.taketoday.framework.context.config.ConfigData.Options) PropertySourceOptions(cn.taketoday.framework.context.config.ConfigData.PropertySourceOptions) Test(org.junit.jupiter.api.Test)

Aggregations

Options (cn.taketoday.framework.context.config.ConfigData.Options)12 PropertySourceOptions (cn.taketoday.framework.context.config.ConfigData.PropertySourceOptions)10 Test (org.junit.jupiter.api.Test)10 Option (cn.taketoday.framework.context.config.ConfigData.Option)4 ConfigurationPropertySource (cn.taketoday.context.properties.source.ConfigurationPropertySource)2 MapPropertySource (cn.taketoday.core.env.MapPropertySource)2 PropertySource (cn.taketoday.core.env.PropertySource)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 List (java.util.List)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Assertions.assertThatIllegalArgumentException (org.assertj.core.api.Assertions.assertThatIllegalArgumentException)2 Mockito.mock (org.mockito.Mockito.mock)2