11package org .bbottema .javareflection ;
22
3- import lombok .AllArgsConstructor ;
43import org .bbottema .javareflection .model .InvokableObject ;
54import org .bbottema .javareflection .model .LookupMode ;
65import org .bbottema .javareflection .model .MethodModifier ;
76import org .bbottema .javareflection .model .MethodParameter ;
87import org .bbottema .javareflection .testmodel .*;
98import org .bbottema .javareflection .util .MetaAnnotationExtractor ;
109import org .bbottema .javareflection .valueconverter .ValueConversionHelper ;
11- import org .jetbrains .annotations .NonNls ;
12- import org .jetbrains .annotations .NotNull ;
1310import org .junit .Before ;
1411import org .junit .Test ;
1512import sun .reflect .generics .reflectiveObjects .ParameterizedTypeImpl ;
3027import static org .assertj .core .api .Assertions .fail ;
3128import static org .assertj .core .util .Lists .newArrayList ;
3229import static org .bbottema .javareflection .ClassUtils .collectMethodsByName ;
30+ import static org .bbottema .javareflection .MethodUtils .onlyMethod ;
3331import static org .bbottema .javareflection .model .MethodModifier .MATCH_ANY ;
3432
3533public class MethodUtilsTest {
@@ -47,19 +45,19 @@ public void testFindCompatibleMethod()
4745 allButSmartLookup .remove (LookupMode .SMART_CONVERT );
4846
4947 Set <InvokableObject <Method >> m = MethodUtils .findCompatibleMethod (B .class , "foo" , allButSmartLookup , double .class , Pear .class , String .class );
50- assertThat (m ).isNotEmpty ( );
51- assertThat (m . iterator (). next (). getMethod ( )).isEqualTo (Foo .class .getMethod ("foo" , Double .class , Fruit .class , char .class ));
48+ assertThat (m ).hasSize ( 1 );
49+ assertThat (onlyMethod ( m )).isEqualTo (Foo .class .getMethod ("foo" , Double .class , Fruit .class , char .class ));
5250 Set <InvokableObject <Method >> m2 = MethodUtils .findCompatibleMethod (B .class , "foo" , allButSmartLookup , double .class , Pear .class , String .class );
53- assertThat (m2 ).isNotEmpty ( );
51+ assertThat (m2 ).hasSize ( 1 );
5452 assertThat (m2 ).isEqualTo (m );
5553 // find the same method, but now the first implementation on C should be returned
5654 m = MethodUtils .findCompatibleMethod (C .class , "foo" , allButSmartLookup , double .class , Pear .class , String .class );
57- assertThat (m ).isNotEmpty ( );
58- assertThat (m . iterator (). next (). getMethod ( )).isEqualTo (C .class .getMethod ("foo" , Double .class , Fruit .class , char .class ));
55+ assertThat (m ).hasSize ( 1 );
56+ assertThat (onlyMethod ( m )).isEqualTo (C .class .getMethod ("foo" , Double .class , Fruit .class , char .class ));
5957 // find a String method
6058 m = MethodUtils .findCompatibleMethod (String .class , "concat" , EnumSet .noneOf (LookupMode .class ), String .class );
61- assertThat (m ).isNotEmpty ( );
62- assertThat (m . iterator (). next (). getMethod ( )).isEqualTo (String .class .getMethod ("concat" , String .class ));
59+ assertThat (m ).hasSize ( 1 );
60+ assertThat (onlyMethod ( m )).isEqualTo (String .class .getMethod ("concat" , String .class ));
6361 // shouldn't be able to find the following methods
6462 try {
6563 MethodUtils .findCompatibleMethod (B .class , "foos" , allButSmartLookup , double .class , Pear .class , String .class );
@@ -80,7 +78,7 @@ public void testFindCompatibleMethod()
8078 // OK
8179 }
8280 Set <InvokableObject <Method >> result = MethodUtils .findCompatibleMethod (B .class , "foo" , LookupMode .FULL , double .class , Fruit .class , Math .class );
83- assertThat (result ).isNotEmpty ( );
81+ assertThat (result ).hasSize ( 1 );
8482 }
8583
8684 @ Test
0 commit comments