-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move tests into CustomConfigurationProviderTest
- Loading branch information
Showing
5 changed files
with
103 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...test/java/de/focus_shift/jollyday/core/configuration/CustomConfigurationProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package de.focus_shift.jollyday.core.configuration; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
|
||
import java.util.Properties; | ||
|
||
import static de.focus_shift.jollyday.core.configuration.CustomConfigurationProvider.CONFIG_PROVIDERS_PROPERTY; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class CustomConfigurationProviderTest { | ||
|
||
private CustomConfigurationProvider sut; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
sut = new CustomConfigurationProvider(); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvSource(value = { | ||
"de.focus_shift.jollyday.core.configuration.CustomConfigurationProviderTest$TestProvider:value", | ||
"de.focus_shift.jollyday.core.configuration.CustomConfigurationProviderTest$TestProvider,de.focus_shift.jollyday.core.configuration.CustomConfigurationProviderTest$SecondTestProvider:second-value", | ||
"de.focus_shift.jollyday.core.configuration.CustomConfigurationProviderTest$TestProvider, java.lang.String: value", | ||
}, delimiter = ':') | ||
void ensuresToOverridePropertiesAndIgnoreExceptions(final String classList, final String property) { | ||
System.setProperty(CONFIG_PROVIDERS_PROPERTY, classList); | ||
|
||
final Properties properties = sut.getProperties(); | ||
assertThat(properties.getProperty("key")).isEqualTo(property); | ||
|
||
System.clearProperty(CONFIG_PROVIDERS_PROPERTY); | ||
} | ||
|
||
@Test | ||
void ensuresToDoNothingIfConfigProvidersPropertyIsNotSet() { | ||
System.clearProperty(CONFIG_PROVIDERS_PROPERTY); | ||
|
||
final Properties properties = sut.getProperties(); | ||
assertThat(properties).isEmpty(); | ||
} | ||
|
||
@Test | ||
void ensuresCorrectConfigProvidersPropertyKey() { | ||
assertThat(CONFIG_PROVIDERS_PROPERTY).isEqualTo("de.focus_shift.jollyday.config.providers"); | ||
} | ||
|
||
static class TestProvider implements ConfigurationProvider { | ||
|
||
private final Properties properties = new Properties(); | ||
|
||
TestProvider() { | ||
properties.setProperty("key", "value"); | ||
} | ||
|
||
@Override | ||
public Properties getProperties() { | ||
return properties; | ||
} | ||
} | ||
|
||
static class SecondTestProvider implements ConfigurationProvider { | ||
|
||
private final Properties properties = new Properties(); | ||
|
||
SecondTestProvider() { | ||
properties.setProperty("key", "second-value"); | ||
} | ||
|
||
@Override | ||
public Properties getProperties() { | ||
return properties; | ||
} | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
jollyday-core/src/test/java/de/focus_shift/jollyday/core/configuration/TestProvider.java
This file was deleted.
Oops, something went wrong.