From 5a558bb1f1569b9250bbe9d56524d2fc332603bb Mon Sep 17 00:00:00 2001 From: Marcus Fihlon Date: Sun, 3 Nov 2024 21:07:17 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Add=20a=20tests=20for=20exception?= =?UTF-8?q?=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcus Fihlon --- .../apus/event/SessionImportExceptionTest.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/test/java/swiss/fihlon/apus/event/SessionImportExceptionTest.java b/src/test/java/swiss/fihlon/apus/event/SessionImportExceptionTest.java index 88d2465..d6ecfcf 100644 --- a/src/test/java/swiss/fihlon/apus/event/SessionImportExceptionTest.java +++ b/src/test/java/swiss/fihlon/apus/event/SessionImportExceptionTest.java @@ -21,13 +21,25 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; class SessionImportExceptionTest { @Test @SuppressWarnings("java:S5778") - void testException() { + void testExceptionWithMessage() { + final var exception = assertThrows(SessionImportException.class, () -> { + throw new SessionImportException("Session Import Exception"); + }); + assertInstanceOf(SessionImportException.class, exception); + assertEquals("Session Import Exception", exception.getMessage()); + assertNull(exception.getCause()); + } + + @Test + @SuppressWarnings("java:S5778") + void testExceptionWithMessageAndCause() { final var exception = assertThrows(SessionImportException.class, () -> { throw new SessionImportException("Session Import Exception", new RuntimeException("Runtime Exception")); });