Search in sources :

Example 1 with Options

use of org.springframework.boot.context.config.ConfigData.Options in project spring-boot by spring-projects.

the class ConfigDataTests method optionsWithoutReturnsNewOptions.

@Test
void optionsWithoutReturnsNewOptions() {
    Options options = Options.of(Option.IGNORE_IMPORTS, Option.IGNORE_PROFILES);
    Options without = options.without(Option.IGNORE_PROFILES);
    assertThat(options.asSet()).containsExactly(Option.IGNORE_IMPORTS, Option.IGNORE_PROFILES);
    assertThat(without.asSet()).containsExactly(Option.IGNORE_IMPORTS);
}
Also used : PropertySourceOptions(org.springframework.boot.context.config.ConfigData.PropertySourceOptions) Options(org.springframework.boot.context.config.ConfigData.Options) Test(org.junit.jupiter.api.Test)

Example 2 with Options

use of org.springframework.boot.context.config.ConfigData.Options in project spring-boot by spring-projects.

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 : PropertySourceOptions(org.springframework.boot.context.config.ConfigData.PropertySourceOptions) Options(org.springframework.boot.context.config.ConfigData.Options) Option(org.springframework.boot.context.config.ConfigData.Option) Test(org.junit.jupiter.api.Test)

Example 3 with Options

use of org.springframework.boot.context.config.ConfigData.Options in project spring-boot by spring-projects.

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) PropertySource(org.springframework.core.env.PropertySource) PropertySourceOptions(org.springframework.boot.context.config.ConfigData.PropertySourceOptions) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) List(java.util.List) MapPropertySource(org.springframework.core.env.MapPropertySource) Option(org.springframework.boot.context.config.ConfigData.Option) Assertions.assertThatIllegalArgumentException(org.assertj.core.api.Assertions.assertThatIllegalArgumentException) Collections(java.util.Collections) Options(org.springframework.boot.context.config.ConfigData.Options) Mockito.mock(org.mockito.Mockito.mock) PropertySourceOptions(org.springframework.boot.context.config.ConfigData.PropertySourceOptions) Options(org.springframework.boot.context.config.ConfigData.Options) MapPropertySource(org.springframework.core.env.MapPropertySource) PropertySourceOptions(org.springframework.boot.context.config.ConfigData.PropertySourceOptions) Test(org.junit.jupiter.api.Test)

Example 4 with Options

use of org.springframework.boot.context.config.ConfigData.Options in project spring-boot by spring-projects.

the class ConfigDataTests method optionsWithReturnsNewOptions.

@Test
void optionsWithReturnsNewOptions() {
    Options options = Options.of(Option.IGNORE_IMPORTS);
    Options with = options.with(Option.IGNORE_PROFILES);
    assertThat(options.asSet()).containsExactly(Option.IGNORE_IMPORTS);
    assertThat(with.asSet()).containsExactly(Option.IGNORE_IMPORTS, Option.IGNORE_PROFILES);
}
Also used : PropertySourceOptions(org.springframework.boot.context.config.ConfigData.PropertySourceOptions) Options(org.springframework.boot.context.config.ConfigData.Options) Test(org.junit.jupiter.api.Test)

Example 5 with Options

use of org.springframework.boot.context.config.ConfigData.Options in project spring-boot by spring-projects.

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 : PropertySourceOptions(org.springframework.boot.context.config.ConfigData.PropertySourceOptions) Options(org.springframework.boot.context.config.ConfigData.Options) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)5 Options (org.springframework.boot.context.config.ConfigData.Options)5 PropertySourceOptions (org.springframework.boot.context.config.ConfigData.PropertySourceOptions)5 Option (org.springframework.boot.context.config.ConfigData.Option)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatIllegalArgumentException (org.assertj.core.api.Assertions.assertThatIllegalArgumentException)1 Mockito.mock (org.mockito.Mockito.mock)1 MapPropertySource (org.springframework.core.env.MapPropertySource)1 PropertySource (org.springframework.core.env.PropertySource)1