From d4360db497f1210ca83cf56e1e2d2e2cba010cba Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 23 Aug 2019 15:03:41 +0200 Subject: [PATCH] Polish ReflectionTestUtilsTests --- .../test/util/ReflectionTestUtilsTests.java | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java b/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java index bd000db1ef..8261183dbf 100644 --- a/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java +++ b/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java @@ -61,50 +61,50 @@ class ReflectionTestUtilsTests { @Test void setFieldWithNullTargetObject() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - setField((Object) null, "id", Long.valueOf(99))) + assertThatIllegalArgumentException() + .isThrownBy(() -> setField((Object) null, "id", Long.valueOf(99))) .withMessageStartingWith("Either targetObject or targetClass"); } @Test void getFieldWithNullTargetObject() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - getField((Object) null, "id")) + assertThatIllegalArgumentException() + .isThrownBy(() -> getField((Object) null, "id")) .withMessageStartingWith("Either targetObject or targetClass"); } @Test void setFieldWithNullTargetClass() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - setField((Class) null, "id", Long.valueOf(99))) + assertThatIllegalArgumentException() + .isThrownBy(() -> setField((Class) null, "id", Long.valueOf(99))) .withMessageStartingWith("Either targetObject or targetClass"); } @Test void getFieldWithNullTargetClass() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - getField((Class) null, "id")) + assertThatIllegalArgumentException() + .isThrownBy(() -> getField((Class) null, "id")) .withMessageStartingWith("Either targetObject or targetClass"); } @Test void setFieldWithNullNameAndNullType() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - setField(person, null, Long.valueOf(99), null)) + assertThatIllegalArgumentException() + .isThrownBy(() -> setField(person, null, Long.valueOf(99), null)) .withMessageStartingWith("Either name or type"); } @Test void setFieldWithBogusName() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - setField(person, "bogus", Long.valueOf(99), long.class)) + assertThatIllegalArgumentException() + .isThrownBy(() -> setField(person, "bogus", Long.valueOf(99), long.class)) .withMessageStartingWith("Could not find field 'bogus'"); } @Test void setFieldWithWrongType() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - setField(person, "id", Long.valueOf(99), String.class)) + assertThatIllegalArgumentException() + .isThrownBy(() -> setField(person, "id", Long.valueOf(99), String.class)) .withMessageStartingWith("Could not find field"); } @@ -316,8 +316,7 @@ class ReflectionTestUtilsTests { @Test void invokeSetterMethodWithNullValueForPrimitiveBoolean() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - invokeSetterMethod(person, "likesPets", null, boolean.class)); + assertThatIllegalArgumentException().isThrownBy(() -> invokeSetterMethod(person, "likesPets", null, boolean.class)); } @Test @@ -364,29 +363,29 @@ class ReflectionTestUtilsTests { @Test void invokeInitMethodBeforeAutowiring() { - assertThatIllegalStateException().isThrownBy(() -> - invokeMethod(component, "init")) + assertThatIllegalStateException() + .isThrownBy(() -> invokeMethod(component, "init")) .withMessageStartingWith("number must not be null"); } @Test void invokeMethodWithIncompatibleArgumentTypes() { - assertThatIllegalStateException().isThrownBy(() -> - invokeMethod(component, "subtract", "foo", 2.0)) - .withMessageStartingWith("Method not found"); + assertThatIllegalStateException() + .isThrownBy(() -> invokeMethod(component, "subtract", "foo", 2.0)) + .withMessageStartingWith("Method not found"); } @Test void invokeMethodWithTooFewArguments() { - assertThatIllegalStateException().isThrownBy(() -> - invokeMethod(component, "configure", Integer.valueOf(42))) + assertThatIllegalStateException() + .isThrownBy(() -> invokeMethod(component, "configure", Integer.valueOf(42))) .withMessageStartingWith("Method not found"); } @Test void invokeMethodWithTooManyArguments() { - assertThatIllegalStateException().isThrownBy(() -> - invokeMethod(component, "configure", Integer.valueOf(42), "enigma", "baz", "quux")) + assertThatIllegalStateException() + .isThrownBy(() -> invokeMethod(component, "configure", Integer.valueOf(42), "enigma", "baz", "quux")) .withMessageStartingWith("Method not found"); }