Create UnsupportedClaimExceptionTest.java

This commit is contained in:
Ludy87 2025-08-10 14:04:20 +02:00
parent b1bb5d6a07
commit 2e8b81840f
No known key found for this signature in database
GPG Key ID: 92696155E0220F94

View File

@ -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");
}
}