Create NoProviderFoundExceptionTest.java

This commit is contained in:
Ludy87 2025-08-10 12:17:56 +02:00
parent 100f9000d3
commit dace926400
No known key found for this signature in database
GPG Key ID: 92696155E0220F94

View File

@ -0,0 +1,33 @@
package stirling.software.proprietary.security.model.exception;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class NoProviderFoundExceptionTest {
@Test
void constructor_setsMessage_withoutCause() {
NoProviderFoundException ex = new NoProviderFoundException("no provider");
assertEquals("no provider", ex.getMessage());
assertNull(ex.getCause(), "Cause should be null for single-arg constructor");
}
@Test
void constructor_setsMessage_andCause() {
Throwable cause = new IllegalStateException("root");
NoProviderFoundException ex = new NoProviderFoundException("missing", cause);
assertEquals("missing", ex.getMessage());
assertSame(cause, ex.getCause());
}
@Test
void canBeThrownAndCaught_checkedException() {
try {
throw new NoProviderFoundException("boom");
} catch (NoProviderFoundException ex) {
assertEquals("boom", ex.getMessage());
}
}
}