Added/updated tests

This commit is contained in:
Marvin Scham
2023-06-06 02:10:31 +02:00
parent d1bd6f6d9b
commit 39176b5dc0
4 changed files with 140 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
package de.rwu.easydrop.util;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail;
@@ -34,7 +35,9 @@ class ConfigImplTest {
}
@Test
void testGetProperty_ConfigNotLoaded() {
void testGetProperty_ConfigNotLoaded() throws Exception {
config.reset();
NoSuchElementException exception = assertThrows(NoSuchElementException.class, () -> {
config.getProperty(TESTDATA_KEY);
});
@@ -92,4 +95,19 @@ class ConfigImplTest {
assertEquals("Couldn't load required config file", exception.getMessage());
}
@Test
void testReset() throws ConfigurationException {
config.setConfigLocation("src/test/resources/testdata.properties");
config.loadConfig();
assertNotNull(config.getProperty(TESTDATA_KEY));
config.reset();
NoSuchElementException exception = assertThrows(NoSuchElementException.class, () -> {
config.getProperty(TESTDATA_KEY);
});
assertEquals("Config has not been loaded", exception.getMessage());
}
}