Skip to content

Commit 5bcfcdd

Browse files
committed
Polishing
1 parent 38a56b3 commit 5bcfcdd

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java

+32-32
Original file line numberDiff line numberDiff line change
@@ -65,50 +65,50 @@ void resetStaticFields() {
6565
@Test
6666
void setFieldWithNullTargetObject() {
6767
assertThatIllegalArgumentException()
68-
.isThrownBy(() -> setField((Object) null, "id", 99L))
69-
.withMessageStartingWith("Either targetObject or targetClass");
68+
.isThrownBy(() -> setField((Object) null, "id", 99L))
69+
.withMessageStartingWith("Either targetObject or targetClass");
7070
}
7171

7272
@Test
7373
void getFieldWithNullTargetObject() {
7474
assertThatIllegalArgumentException()
75-
.isThrownBy(() -> getField((Object) null, "id"))
76-
.withMessageStartingWith("Either targetObject or targetClass");
75+
.isThrownBy(() -> getField((Object) null, "id"))
76+
.withMessageStartingWith("Either targetObject or targetClass");
7777
}
7878

7979
@Test
8080
void setFieldWithNullTargetClass() {
8181
assertThatIllegalArgumentException()
82-
.isThrownBy(() -> setField(null, "id", 99L))
83-
.withMessageStartingWith("Either targetObject or targetClass");
82+
.isThrownBy(() -> setField(null, "id", 99L))
83+
.withMessageStartingWith("Either targetObject or targetClass");
8484
}
8585

8686
@Test
8787
void getFieldWithNullTargetClass() {
8888
assertThatIllegalArgumentException()
89-
.isThrownBy(() -> getField(null, "id"))
90-
.withMessageStartingWith("Either targetObject or targetClass");
89+
.isThrownBy(() -> getField(null, "id"))
90+
.withMessageStartingWith("Either targetObject or targetClass");
9191
}
9292

9393
@Test
9494
void setFieldWithNullNameAndNullType() {
9595
assertThatIllegalArgumentException()
96-
.isThrownBy(() -> setField(person, null, 99L, null))
97-
.withMessageStartingWith("Either name or type");
96+
.isThrownBy(() -> setField(person, null, 99L, null))
97+
.withMessageStartingWith("Either name or type");
9898
}
9999

100100
@Test
101101
void setFieldWithBogusName() {
102102
assertThatIllegalArgumentException()
103-
.isThrownBy(() -> setField(person, "bogus", 99L, long.class))
104-
.withMessageStartingWith("Could not find field 'bogus'");
103+
.isThrownBy(() -> setField(person, "bogus", 99L, long.class))
104+
.withMessageStartingWith("Could not find field 'bogus'");
105105
}
106106

107107
@Test
108108
void setFieldWithWrongType() {
109109
assertThatIllegalArgumentException()
110-
.isThrownBy(() -> setField(person, "id", 99L, String.class))
111-
.withMessageStartingWith("Could not find field");
110+
.isThrownBy(() -> setField(person, "id", 99L, String.class))
111+
.withMessageStartingWith("Could not find field");
112112
}
113113

114114
@Test
@@ -434,29 +434,29 @@ void invokingPrivateMethodViaCglibProxyInvokesMethodOnUltimateTarget() {
434434
@Test
435435
void invokeInitMethodBeforeAutowiring() {
436436
assertThatIllegalStateException()
437-
.isThrownBy(() -> invokeMethod(component, "init"))
438-
.withMessageStartingWith("number must not be null");
437+
.isThrownBy(() -> invokeMethod(component, "init"))
438+
.withMessageStartingWith("number must not be null");
439439
}
440440

441441
@Test
442442
void invokeMethodWithIncompatibleArgumentTypes() {
443443
assertThatIllegalStateException()
444-
.isThrownBy(() -> invokeMethod(component, "subtract", "foo", 2.0))
445-
.withMessageStartingWith("Method not found");
444+
.isThrownBy(() -> invokeMethod(component, "subtract", "foo", 2.0))
445+
.withMessageStartingWith("Method not found");
446446
}
447447

448448
@Test
449449
void invokeMethodWithTooFewArguments() {
450450
assertThatIllegalStateException()
451-
.isThrownBy(() -> invokeMethod(component, "configure", 42))
452-
.withMessageStartingWith("Method not found");
451+
.isThrownBy(() -> invokeMethod(component, "configure", 42))
452+
.withMessageStartingWith("Method not found");
453453
}
454454

455455
@Test
456456
void invokeMethodWithTooManyArguments() {
457457
assertThatIllegalStateException()
458-
.isThrownBy(() -> invokeMethod(component, "configure", 42, "enigma", "baz", "quux"))
459-
.withMessageStartingWith("Method not found");
458+
.isThrownBy(() -> invokeMethod(component, "configure", 42, "enigma", "baz", "quux"))
459+
.withMessageStartingWith("Method not found");
460460
}
461461

462462
@Test // SPR-14363
@@ -469,7 +469,7 @@ void getFieldOnLegacyEntityWithSideEffectsInToString() {
469469
void setFieldOnLegacyEntityWithSideEffectsInToString() {
470470
String testCollaborator = "test collaborator";
471471
setField(entity, "collaborator", testCollaborator, Object.class);
472-
assertThat(entity.toString()).contains(testCollaborator);
472+
assertThat(entity).asString().contains(testCollaborator);
473473
}
474474

475475
@Test // SPR-14363
@@ -489,28 +489,28 @@ void invokeGetterMethodOnLegacyEntityWithSideEffectsInToString() {
489489
void invokeSetterMethodOnLegacyEntityWithSideEffectsInToString() {
490490
String testCollaborator = "test collaborator";
491491
invokeSetterMethod(entity, "collaborator", testCollaborator);
492-
assertThat(entity.toString()).contains(testCollaborator);
492+
assertThat(entity).asString().contains(testCollaborator);
493493
}
494494

495495
@Test
496496
void invokeStaticMethodWithNullTargetClass() {
497497
assertThatIllegalArgumentException()
498-
.isThrownBy(() -> invokeMethod(null, null))
499-
.withMessage("Target class must not be null");
498+
.isThrownBy(() -> invokeMethod(null, null))
499+
.withMessage("Target class must not be null");
500500
}
501501

502502
@Test
503503
void invokeStaticMethodWithNullMethodName() {
504504
assertThatIllegalArgumentException()
505-
.isThrownBy(() -> invokeMethod(getClass(), null))
506-
.withMessage("Method name must not be empty");
505+
.isThrownBy(() -> invokeMethod(getClass(), null))
506+
.withMessage("Method name must not be empty");
507507
}
508508

509509
@Test
510510
void invokeStaticMethodWithEmptyMethodName() {
511511
assertThatIllegalArgumentException()
512-
.isThrownBy(() -> invokeMethod(getClass(), " "))
513-
.withMessage("Method name must not be empty");
512+
.isThrownBy(() -> invokeMethod(getClass(), " "))
513+
.withMessage("Method name must not be empty");
514514
}
515515

516516
@Test
@@ -550,8 +550,8 @@ void invokePrivateStaticMethodWithoutArguments() {
550550
@Test
551551
void invokeStaticMethodWithNullTargetObjectAndNullTargetClass() {
552552
assertThatIllegalArgumentException()
553-
.isThrownBy(() -> invokeMethod(null, (Class<?>) null, "id"))
554-
.withMessage("Either 'targetObject' or 'targetClass' for the method must be specified");
553+
.isThrownBy(() -> invokeMethod(null, (Class<?>) null, "id"))
554+
.withMessage("Either 'targetObject' or 'targetClass' for the method must be specified");
555555
}
556556

557557
}

0 commit comments

Comments
 (0)