From dbfdf8681002f775f9b0916ff746ae8efd42e675 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Mon, 1 Jun 2026 21:40:06 +0200 Subject: [PATCH] test(tutorial): cover malformed tutorial.yaml -> WorldLoadException --- .../thb/jeanluc/adventure/loader/TutorialLoaderTest.java | 8 ++++++++ Semesterprojekt/src/test/resources/badtut/tutorial.yaml | 5 +++++ 2 files changed, 13 insertions(+) create mode 100644 Semesterprojekt/src/test/resources/badtut/tutorial.yaml diff --git a/Semesterprojekt/src/test/java/thb/jeanluc/adventure/loader/TutorialLoaderTest.java b/Semesterprojekt/src/test/java/thb/jeanluc/adventure/loader/TutorialLoaderTest.java index 937306b..a167f6e 100644 --- a/Semesterprojekt/src/test/java/thb/jeanluc/adventure/loader/TutorialLoaderTest.java +++ b/Semesterprojekt/src/test/java/thb/jeanluc/adventure/loader/TutorialLoaderTest.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test; import thb.jeanluc.adventure.model.Tutorial; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; class TutorialLoaderTest { @@ -24,4 +25,11 @@ class TutorialLoaderTest { assertThat(t.isEmpty()).isTrue(); assertThat(t.steps()).isEmpty(); } + + @Test + void malformedFileThrowsWorldLoadException() { + // /badtut/tutorial.yaml has 'steps: 12345' (scalar where a list is required) + assertThatThrownBy(() -> new TutorialLoader("/badtut").load()) + .isInstanceOf(WorldLoadException.class); + } } diff --git a/Semesterprojekt/src/test/resources/badtut/tutorial.yaml b/Semesterprojekt/src/test/resources/badtut/tutorial.yaml new file mode 100644 index 0000000..97dcc56 --- /dev/null +++ b/Semesterprojekt/src/test/resources/badtut/tutorial.yaml @@ -0,0 +1,5 @@ +# Malformed on purpose: 'steps' must be a list, not a scalar. +# Used by TutorialLoaderTest to verify parse errors become WorldLoadException. +intro: "bad" +steps: 12345 +closingTips: "bad"