Skip to content

Commit

Permalink
Test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
martenrebane committed Sep 25, 2023
1 parent f8f6967 commit 9411c5a
Showing 1 changed file with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;
import java.util.Optional;

@RunWith(MockitoJUnitRunner.class)
public class ConfigurationPropertiesTest {
Expand All @@ -23,23 +25,18 @@ public class ConfigurationPropertiesTest {

@Test
public void loadProperties() throws IOException {
ClassLoader classLoader = getClass().getClassLoader();
if (classLoader != null) {
try (InputStream inputStream = classLoader.getResourceAsStream(ConfigurationProperties.PROPERTIES_FILE_NAME);
InputStream assetStream = assetManager.open(anyString())) {
if (inputStream != null) {
when(assetStream).thenReturn(inputStream);

ConfigurationProperties configurationProperties = new ConfigurationProperties(assetManager);

assertEquals("https://id.eesti.ee/", configurationProperties.getCentralConfigurationServiceUrl());
assertSame(4, configurationProperties.getConfigurationUpdateInterval());
} else {
throw new IllegalStateException("Unable to get properties file name");
}
}
} else {
throw new IllegalStateException("Unable to get ClassLoader");
ClassLoader classLoader = Optional.ofNullable(getClass().getClassLoader())
.orElseThrow(() -> new IllegalStateException("Unable to get ClassLoader"));
try (InputStream inputStream = Objects.requireNonNull(
classLoader.getResourceAsStream(ConfigurationProperties.PROPERTIES_FILE_NAME),
"Unable to open properties file"
)) {
when(assetManager.open(anyString())).thenReturn(inputStream);

ConfigurationProperties configurationProperties = new ConfigurationProperties(assetManager);

assertEquals("https://id.eesti.ee/", configurationProperties.getCentralConfigurationServiceUrl());
assertSame(4, configurationProperties.getConfigurationUpdateInterval());
}
}
}

0 comments on commit 9411c5a

Please sign in to comment.