From e83d87b60627a9354b6738e758de11995ce0a8b4 Mon Sep 17 00:00:00 2001 From: Siphalor Date: Wed, 17 Dec 2025 23:20:17 +0100 Subject: [PATCH] test(construct): Adjust unit tests to changed exception handling --- .../impl/TweedConstructFactoryImplTest.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tweed5/construct/src/test/java/de/siphalor/tweed5/construct/impl/TweedConstructFactoryImplTest.java b/tweed5/construct/src/test/java/de/siphalor/tweed5/construct/impl/TweedConstructFactoryImplTest.java index b1c027b..cba3fcc 100644 --- a/tweed5/construct/src/test/java/de/siphalor/tweed5/construct/impl/TweedConstructFactoryImplTest.java +++ b/tweed5/construct/src/test/java/de/siphalor/tweed5/construct/impl/TweedConstructFactoryImplTest.java @@ -77,19 +77,22 @@ class TweedConstructFactoryImplTest { //noinspection unchecked,RedundantCast assertThatThrownBy(() -> factory.construct((Class) (Class) MissingInheritance.class) - ).isInstanceOf(IllegalArgumentException.class).hasMessageContaining(DummyBase.class.getName()); + ).rootCause().isInstanceOf(IllegalArgumentException.class).hasMessageContaining(DummyBase.class.getName()); } @Test void constructPrivateConstructor() { val factory = TweedConstructFactoryImpl.builder(DummyBase.class).typedArg(Integer.class).build(); - assertThatThrownBy(() -> factory.construct(PrivateConstructor.class)).isInstanceOf(IllegalStateException.class); + assertThatThrownBy(() -> factory.construct(PrivateConstructor.class)) + .rootCause() + .isInstanceOf(IllegalStateException.class); } @Test void constructConflictingConstructors() { val factory = TweedConstructFactoryImpl.builder(DummyBase.class).typedArg(Integer.class).build(); assertThatThrownBy(() -> factory.construct(ConstructorConflict.class)) + .rootCause() .isInstanceOf(IllegalStateException.class); } @@ -97,6 +100,7 @@ class TweedConstructFactoryImplTest { void constructConflictingStatics() { val factory = TweedConstructFactoryImpl.builder(DummyBase.class).typedArg(Integer.class).build(); assertThatThrownBy(() -> factory.construct(StaticConflict.class)) + .rootCause() .isInstanceOf(IllegalStateException.class); } @@ -104,6 +108,7 @@ class TweedConstructFactoryImplTest { void constructConflictingMixed() { val factory = TweedConstructFactoryImpl.builder(DummyBase.class).typedArg(Integer.class).build(); assertThatThrownBy(() -> factory.construct(MixedConflict.class)) + .rootCause() .isInstanceOf(IllegalStateException.class); } @@ -214,6 +219,7 @@ class TweedConstructFactoryImplTest { .namedArg("number", int.class) .build(); assertThatThrownBy(() -> factory.construct(DuplicateParams.class)) + .rootCause() .isInstanceOf(IllegalStateException.class) .message() .contains("java.lang.String", "number") @@ -229,6 +235,7 @@ class TweedConstructFactoryImplTest { .namedArg("user", String.class) .build(); assertThatThrownBy(() -> factory.construct(Static.class)) + .rootCause() .isInstanceOf(IllegalStateException.class) .message() .contains("java.lang.Integer") @@ -243,6 +250,7 @@ class TweedConstructFactoryImplTest { .namedArg("other", String.class) .build(); assertThatThrownBy(() -> factory.construct(Static.class)) + .rootCause() .isInstanceOf(IllegalStateException.class) .message() .contains("user", "java.lang.String") @@ -257,6 +265,7 @@ class TweedConstructFactoryImplTest { .namedArg("user", Long.class) .build(); assertThatThrownBy(() -> factory.construct(Static.class)) + .rootCause() .isInstanceOf(IllegalStateException.class) .message() .contains("user", "java.lang.String", "java.lang.Long")