diff --git a/src/test/java/de/gwdg/metadataqa/api/configuration/ConfigurationReaderTest.java b/src/test/java/de/gwdg/metadataqa/api/configuration/ConfigurationReaderTest.java index ac4fa950..75b91d7f 100644 --- a/src/test/java/de/gwdg/metadataqa/api/configuration/ConfigurationReaderTest.java +++ b/src/test/java/de/gwdg/metadataqa/api/configuration/ConfigurationReaderTest.java @@ -1,15 +1,22 @@ package de.gwdg.metadataqa.api.configuration; +import com.jayway.jsonpath.InvalidJsonException; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import java.io.FileNotFoundException; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; public class ConfigurationReaderTest { + @Rule + public ExpectedException thrown = ExpectedException.none(); + @Test public void readSchemaJson() { } @@ -27,6 +34,17 @@ public void readMeasurementJson() throws FileNotFoundException { } @Test + public void readNonexistentConfiguration() throws FileNotFoundException { + thrown.expect(FileNotFoundException.class); + thrown.expectMessage("src/test/resources/configuration/measurement/non-existent-configuration.json (No such file or directory)"); + + MeasurementConfiguration configuration = ConfigurationReader + .readMeasurementJson("src/test/resources/configuration/measurement/non-existent-configuration.json"); + + fail("Should throw an exception if the JSON file is not existent."); + } + + @Test public void readMeasurementYaml() throws FileNotFoundException { MeasurementConfiguration configuration = ConfigurationReader .readMeasurementYaml("src/test/resources/configuration/measurement/configuration.yaml");