2525
2626import static io .microsphere .annotation .processor .util .EnumUtils .matches ;
2727import static io .microsphere .annotation .processor .util .EnumUtils .toElementKind ;
28+ import static java .lang .annotation .ElementType .FIELD ;
29+ import static java .lang .annotation .ElementType .TYPE ;
2830import static java .lang .annotation .ElementType .values ;
31+ import static org .junit .jupiter .api .Assertions .assertFalse ;
2932import static org .junit .jupiter .api .Assertions .assertNotNull ;
3033import static org .junit .jupiter .api .Assertions .assertTrue ;
3134
@@ -52,12 +55,34 @@ public void testMatches() {
5255 }
5356 }
5457
58+ @ Test
59+ public void testMatchesOnNull () {
60+ assertFalse (matches (null , (ElementType ) null ));
61+ assertFalse (matches (null , TYPE ));
62+ assertFalse (matches (toElementKind (TYPE ), (ElementType ) null ));
63+ }
64+
65+ @ Test
66+ public void testMatchesWithArray () {
67+ for (ElementType elementType : values ()) {
68+ assertTrue (matches (toElementKind (elementType ), values ()));
69+ }
70+ }
71+
72+ @ Test
73+ public void testMatchesWithArrayOnNull () {
74+ assertFalse (matches (null ));
75+ assertFalse (matches (null , (ElementType []) null ));
76+ assertFalse (matches (null , TYPE , FIELD ));
77+ assertFalse (matches (toElementKind (TYPE ), (ElementType []) null ));
78+ }
79+
5580 void assertElementKind (ElementType elementType ) {
5681 ElementKind elementKind = toElementKind (elementType );
5782 assertNotNull (elementKind );
5883 }
5984
6085 void assertMatches (ElementType elementType ) {
61- assertTrue (matches (elementType , toElementKind (elementType )));
86+ assertTrue (matches (toElementKind (elementType ), elementType ));
6287 }
6388}
0 commit comments