From 0b3321cc4766a619b86f1feb59ee211d7c6bccb5 Mon Sep 17 00:00:00 2001 From: Nicolas Senave Date: Tue, 16 Jul 2024 17:07:53 +0200 Subject: [PATCH] chore: refactor some test --- .../java/fr/insee/eno/core/DDIToLunaticTest.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/eno-core/src/test/java/fr/insee/eno/core/DDIToLunaticTest.java b/eno-core/src/test/java/fr/insee/eno/core/DDIToLunaticTest.java index 247a0688a..ab944c668 100644 --- a/eno-core/src/test/java/fr/insee/eno/core/DDIToLunaticTest.java +++ b/eno-core/src/test/java/fr/insee/eno/core/DDIToLunaticTest.java @@ -14,6 +14,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; +import java.io.IOException; import java.io.InputStream; import java.util.List; @@ -50,13 +51,16 @@ void transformQuestionnaire_nonNullOutput(String questionnaireId) throws DDIPars } @Test - void ddiWithTableWithNestedCodeListHeader_shouldThrowException() { + void ddiWithTableWithNestedCodeListHeader_shouldThrowException() throws IOException { // Given - InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream( - "functional/ddi/ddi-l8x6fhtd.xml"); - EnoParameters enoParameters = EnoParameters.of(Context.DEFAULT, ModeParameter.CAWI, Format.LUNATIC); - // When + Then - assertThrows(UnauthorizedHeaderException.class, () -> DDIToLunatic.transform(inputStream, enoParameters)); + try (InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream( + "functional/ddi/ddi-l8x6fhtd.xml")) { + EnoParameters enoParameters = EnoParameters.of(Context.DEFAULT, ModeParameter.CAWI, Format.LUNATIC); + // When + Then + assertThrows(UnauthorizedHeaderException.class, () -> DDIToLunatic.transform(inputStream, enoParameters)); + } catch (IOException e) { + throw new IOException("IOException occurred with test DDI file 'l8x6fhtd'."); + } } @Test