From 2e8b81840f787672e560c36ba67031e7b9b9455e Mon Sep 17 00:00:00 2001 From: Ludy87 Date: Sun, 10 Aug 2025 14:04:20 +0200 Subject: [PATCH] Create UnsupportedClaimExceptionTest.java --- .../UnsupportedClaimExceptionTest.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 app/common/src/test/java/stirling/software/common/model/exception/UnsupportedClaimExceptionTest.java diff --git a/app/common/src/test/java/stirling/software/common/model/exception/UnsupportedClaimExceptionTest.java b/app/common/src/test/java/stirling/software/common/model/exception/UnsupportedClaimExceptionTest.java new file mode 100644 index 000000000..aabbef267 --- /dev/null +++ b/app/common/src/test/java/stirling/software/common/model/exception/UnsupportedClaimExceptionTest.java @@ -0,0 +1,45 @@ +package stirling.software.common.model.exception; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +@DisplayName("Tests for UnsupportedClaimException") +class UnsupportedClaimExceptionTest { + + @Test + @DisplayName("should store message passed to constructor") + void shouldStoreMessageFromConstructor() { + String expectedMessage = "This claim is not supported"; + UnsupportedClaimException exception = new UnsupportedClaimException(expectedMessage); + + // Verify the stored message + assertEquals( + expectedMessage, + exception.getMessage(), + "Constructor should correctly store the provided message"); + } + + @Test + @DisplayName("should be instance of RuntimeException") + void shouldBeInstanceOfRuntimeException() { + UnsupportedClaimException exception = new UnsupportedClaimException("msg"); + + // Verify that it inherits from RuntimeException + assertTrue( + exception instanceof RuntimeException, + "UnsupportedClaimException should extend RuntimeException"); + } + + @Test + @DisplayName("should allow null message without throwing exception") + void shouldAllowNullMessage() { + UnsupportedClaimException exception = new UnsupportedClaimException(null); + + // Null message should be stored as null + assertNull( + exception.getMessage(), + "Constructor should accept null message and store it as null"); + } +}