@@ -65,50 +65,50 @@ void resetStaticFields() {
65
65
@ Test
66
66
void setFieldWithNullTargetObject () {
67
67
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" );
70
70
}
71
71
72
72
@ Test
73
73
void getFieldWithNullTargetObject () {
74
74
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" );
77
77
}
78
78
79
79
@ Test
80
80
void setFieldWithNullTargetClass () {
81
81
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" );
84
84
}
85
85
86
86
@ Test
87
87
void getFieldWithNullTargetClass () {
88
88
assertThatIllegalArgumentException ()
89
- .isThrownBy (() -> getField (null , "id" ))
90
- .withMessageStartingWith ("Either targetObject or targetClass" );
89
+ .isThrownBy (() -> getField (null , "id" ))
90
+ .withMessageStartingWith ("Either targetObject or targetClass" );
91
91
}
92
92
93
93
@ Test
94
94
void setFieldWithNullNameAndNullType () {
95
95
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" );
98
98
}
99
99
100
100
@ Test
101
101
void setFieldWithBogusName () {
102
102
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'" );
105
105
}
106
106
107
107
@ Test
108
108
void setFieldWithWrongType () {
109
109
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" );
112
112
}
113
113
114
114
@ Test
@@ -434,29 +434,29 @@ void invokingPrivateMethodViaCglibProxyInvokesMethodOnUltimateTarget() {
434
434
@ Test
435
435
void invokeInitMethodBeforeAutowiring () {
436
436
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" );
439
439
}
440
440
441
441
@ Test
442
442
void invokeMethodWithIncompatibleArgumentTypes () {
443
443
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" );
446
446
}
447
447
448
448
@ Test
449
449
void invokeMethodWithTooFewArguments () {
450
450
assertThatIllegalStateException ()
451
- .isThrownBy (() -> invokeMethod (component , "configure" , 42 ))
452
- .withMessageStartingWith ("Method not found" );
451
+ .isThrownBy (() -> invokeMethod (component , "configure" , 42 ))
452
+ .withMessageStartingWith ("Method not found" );
453
453
}
454
454
455
455
@ Test
456
456
void invokeMethodWithTooManyArguments () {
457
457
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" );
460
460
}
461
461
462
462
@ Test // SPR-14363
@@ -469,7 +469,7 @@ void getFieldOnLegacyEntityWithSideEffectsInToString() {
469
469
void setFieldOnLegacyEntityWithSideEffectsInToString () {
470
470
String testCollaborator = "test collaborator" ;
471
471
setField (entity , "collaborator" , testCollaborator , Object .class );
472
- assertThat (entity . toString () ).contains (testCollaborator );
472
+ assertThat (entity ). asString ( ).contains (testCollaborator );
473
473
}
474
474
475
475
@ Test // SPR-14363
@@ -489,28 +489,28 @@ void invokeGetterMethodOnLegacyEntityWithSideEffectsInToString() {
489
489
void invokeSetterMethodOnLegacyEntityWithSideEffectsInToString () {
490
490
String testCollaborator = "test collaborator" ;
491
491
invokeSetterMethod (entity , "collaborator" , testCollaborator );
492
- assertThat (entity . toString () ).contains (testCollaborator );
492
+ assertThat (entity ). asString ( ).contains (testCollaborator );
493
493
}
494
494
495
495
@ Test
496
496
void invokeStaticMethodWithNullTargetClass () {
497
497
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" );
500
500
}
501
501
502
502
@ Test
503
503
void invokeStaticMethodWithNullMethodName () {
504
504
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" );
507
507
}
508
508
509
509
@ Test
510
510
void invokeStaticMethodWithEmptyMethodName () {
511
511
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" );
514
514
}
515
515
516
516
@ Test
@@ -550,8 +550,8 @@ void invokePrivateStaticMethodWithoutArguments() {
550
550
@ Test
551
551
void invokeStaticMethodWithNullTargetObjectAndNullTargetClass () {
552
552
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" );
555
555
}
556
556
557
557
}
0 commit comments