View Javadoc
1   ////////////////////////////////////////////////////////////////////////////////
2   // checkstyle: Checks Java source code for adherence to a set of rules.
3   // Copyright (C) 2001-2017 the original author or authors.
4   //
5   // This library is free software; you can redistribute it and/or
6   // modify it under the terms of the GNU Lesser General Public
7   // License as published by the Free Software Foundation; either
8   // version 2.1 of the License, or (at your option) any later version.
9   //
10  // This library is distributed in the hope that it will be useful,
11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  // Lesser General Public License for more details.
14  //
15  // You should have received a copy of the GNU Lesser General Public
16  // License along with this library; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  ////////////////////////////////////////////////////////////////////////////////
19  
20  package com.puppycrawl.tools.checkstyle.checks.design;
21  
22  import static com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck.MSG_KEY;
23  import static org.junit.Assert.assertArrayEquals;
24  import static org.junit.Assert.assertEquals;
25  import static org.junit.Assert.assertTrue;
26  import static org.junit.Assert.fail;
27  
28  import java.io.File;
29  import java.lang.reflect.Method;
30  
31  import org.junit.Test;
32  import org.powermock.reflect.Whitebox;
33  
34  import antlr.CommonHiddenStreamToken;
35  import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
36  import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
37  import com.puppycrawl.tools.checkstyle.api.DetailAST;
38  import com.puppycrawl.tools.checkstyle.api.TokenTypes;
39  import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil;
40  import com.puppycrawl.tools.checkstyle.utils.CommonUtils;
41  
42  public class VisibilityModifierCheckTest
43      extends AbstractModuleTestSupport {
44      @Override
45      protected String getPackageLocation() {
46          return "com/puppycrawl/tools/checkstyle/checks/design/visibilitymodifier";
47      }
48  
49      @Test
50      public void testGetRequiredTokens() {
51          final VisibilityModifierCheck checkObj = new VisibilityModifierCheck();
52          final int[] expected = {
53              TokenTypes.VARIABLE_DEF,
54              TokenTypes.IMPORT,
55          };
56          assertArrayEquals("Default required tokens are invalid",
57              expected, checkObj.getRequiredTokens());
58      }
59  
60      @Test
61      public void testInner()
62              throws Exception {
63          final DefaultConfiguration checkConfig =
64                  createModuleConfig(VisibilityModifierCheck.class);
65          checkConfig.addAttribute("publicMemberPattern", "^f[A-Z][a-zA-Z0-9]*$");
66          final String[] expected = {
67              "30:24: " + getCheckMessage(MSG_KEY, "rData"),
68              "33:27: " + getCheckMessage(MSG_KEY, "protectedVariable"),
69              "36:17: " + getCheckMessage(MSG_KEY, "packageVariable"),
70              "41:29: " + getCheckMessage(MSG_KEY, "sWeird"),
71              "43:19: " + getCheckMessage(MSG_KEY, "sWeird2"),
72              "77:20: " + getCheckMessage(MSG_KEY, "someValue"),
73          };
74          verify(checkConfig, getPath("InputVisibilityModifierInner.java"), expected);
75      }
76  
77      @Test
78      public void testIgnoreAccess()
79              throws Exception {
80          final DefaultConfiguration checkConfig =
81              createModuleConfig(VisibilityModifierCheck.class);
82          checkConfig.addAttribute("publicMemberPattern", "^r[A-Z]");
83          checkConfig.addAttribute("protectedAllowed", "true");
84          checkConfig.addAttribute("packageAllowed", "true");
85          final String[] expected = {
86              "17:20: " + getCheckMessage(MSG_KEY, "fData"),
87              "77:20: " + getCheckMessage(MSG_KEY, "someValue"),
88          };
89          verify(checkConfig, getPath("InputVisibilityModifierInner.java"), expected);
90      }
91  
92      @Test
93      public void testSimple() throws Exception {
94          final DefaultConfiguration checkConfig =
95                  createModuleConfig(VisibilityModifierCheck.class);
96          checkConfig.addAttribute("publicMemberPattern", "^f[A-Z][a-zA-Z0-9]*$");
97          final String[] expected = {
98              "33:19: " + getCheckMessage(MSG_KEY, "mNumCreated2"),
99              "43:23: " + getCheckMessage(MSG_KEY, "sTest1"),
100             "45:26: " + getCheckMessage(MSG_KEY, "sTest3"),
101             "47:16: " + getCheckMessage(MSG_KEY, "sTest2"),
102             "50:9: " + getCheckMessage(MSG_KEY, "mTest1"),
103             "52:16: " + getCheckMessage(MSG_KEY, "mTest2"),
104         };
105         verify(checkConfig, getPath("InputVisibilityModifierSimple.java"), expected);
106     }
107 
108     @Test
109     public void testStrictJavadoc() throws Exception {
110         final DefaultConfiguration checkConfig =
111                 createModuleConfig(VisibilityModifierCheck.class);
112         checkConfig.addAttribute("publicMemberPattern", "^f[A-Z][a-zA-Z0-9]*$");
113         final String[] expected = {
114             "32:9: " + getCheckMessage(MSG_KEY, "mLen"),
115             "33:19: " + getCheckMessage(MSG_KEY, "mDeer"),
116             "34:16: " + getCheckMessage(MSG_KEY, "aFreddo"),
117         };
118         verify(checkConfig, getPath("InputVisibilityModifierPublicOnly.java"), expected);
119     }
120 
121     @Test
122     public void testAllowPublicFinalFieldsInImmutableClass() throws Exception {
123         final DefaultConfiguration checkConfig =
124                 createModuleConfig(VisibilityModifierCheck.class);
125         checkConfig.addAttribute("allowPublicImmutableFields", "true");
126         final String[] expected = {
127             "12:39: " + getCheckMessage(MSG_KEY, "includes"),
128             "13:39: " + getCheckMessage(MSG_KEY, "excludes"),
129             "16:23: " + getCheckMessage(MSG_KEY, "list"),
130             "34:20: " + getCheckMessage(MSG_KEY, "value"),
131             "36:24: " + getCheckMessage(MSG_KEY, "bValue"),
132             "37:31: " + getCheckMessage(MSG_KEY, "longValue"),
133         };
134         verify(checkConfig, getPath("InputVisibilityModifierImmutable.java"), expected);
135     }
136 
137     @Test
138     public void testDisAllowPublicFinalAndImmutableFieldsInImmutableClass() throws Exception {
139         final DefaultConfiguration checkConfig =
140             createModuleConfig(VisibilityModifierCheck.class);
141         final String[] expected = {
142             "11:22: " + getCheckMessage(MSG_KEY, "someIntValue"),
143             "12:39: " + getCheckMessage(MSG_KEY, "includes"),
144             "13:39: " + getCheckMessage(MSG_KEY, "excludes"),
145             "14:35: " + getCheckMessage(MSG_KEY, "notes"),
146             "15:29: " + getCheckMessage(MSG_KEY, "money"),
147             "16:23: " + getCheckMessage(MSG_KEY, "list"),
148             "30:28: " + getCheckMessage(MSG_KEY, "f"),
149             "31:30: " + getCheckMessage(MSG_KEY, "bool"),
150             "32:35: " + getCheckMessage(MSG_KEY, "uri"),
151             "33:35: " + getCheckMessage(MSG_KEY, "file"),
152             "34:20: " + getCheckMessage(MSG_KEY, "value"),
153             "35:35: " + getCheckMessage(MSG_KEY, "url"),
154             "36:24: " + getCheckMessage(MSG_KEY, "bValue"),
155             "37:31: " + getCheckMessage(MSG_KEY, "longValue"),
156             };
157         verify(checkConfig, getPath("InputVisibilityModifierImmutable.java"), expected);
158     }
159 
160     @Test
161     public void testAllowPublicFinalFieldsInNonFinalClass() throws Exception {
162         final DefaultConfiguration checkConfig =
163                 createModuleConfig(VisibilityModifierCheck.class);
164         checkConfig.addAttribute("allowPublicFinalFields", "true");
165         final String[] expected = {
166             "34:20: " + getCheckMessage(MSG_KEY, "value"),
167             "36:24: " + getCheckMessage(MSG_KEY, "bValue"),
168             "37:31: " + getCheckMessage(MSG_KEY, "longValue"),
169         };
170         verify(checkConfig, getPath("InputVisibilityModifierImmutable.java"), expected);
171     }
172 
173     @Test
174     public void testUserSpecifiedImmutableClassesList() throws Exception {
175         final DefaultConfiguration checkConfig =
176                 createModuleConfig(VisibilityModifierCheck.class);
177         checkConfig.addAttribute("allowPublicImmutableFields", "true");
178         checkConfig.addAttribute("immutableClassCanonicalNames", "java.util.List,"
179                 + "com.google.common.collect.ImmutableSet, java.lang.String");
180         final String[] expected = {
181             "15:29: " + getCheckMessage(MSG_KEY, "money"),
182             "32:35: " + getCheckMessage(MSG_KEY, "uri"),
183             "33:35: " + getCheckMessage(MSG_KEY, "file"),
184             "34:20: " + getCheckMessage(MSG_KEY, "value"),
185             "35:35: " + getCheckMessage(MSG_KEY, "url"),
186             "36:24: " + getCheckMessage(MSG_KEY, "bValue"),
187             "37:31: " + getCheckMessage(MSG_KEY, "longValue"),
188         };
189         verify(checkConfig, getPath("InputVisibilityModifierImmutable.java"), expected);
190     }
191 
192     @Test
193     public void testImmutableSpecifiedSameTypeName() throws Exception {
194         final DefaultConfiguration checkConfig =
195                 createModuleConfig(VisibilityModifierCheck.class);
196         checkConfig.addAttribute("allowPublicImmutableFields", "true");
197         checkConfig.addAttribute("immutableClassCanonicalNames",
198                  "com.puppycrawl.tools.checkstyle.checks.design."
199                          + "visibilitymodifier.InputVisibilityModifierGregorianCalendar,"
200                  + "com.puppycrawl.tools.checkstyle.checks.design."
201                          + "visibilitymodifier.inputs.InetSocketAddress");
202         final String[] expected = {
203             "7:46: " + getCheckMessage(MSG_KEY, "calendar"),
204             "12:45: " + getCheckMessage(MSG_KEY, "adr"),
205         };
206         verify(checkConfig, getPath("InputVisibilityModifierImmutableSameTypeName.java"),
207                 expected);
208     }
209 
210     @Test
211     public void testImmutableValueSameTypeName() throws Exception {
212         final DefaultConfiguration checkConfig =
213                 createModuleConfig(VisibilityModifierCheck.class);
214         checkConfig.addAttribute("allowPublicImmutableFields", "true");
215         final String[] expected = {
216             "7:46: " + getCheckMessage(MSG_KEY, "calendar"),
217             "8:59: " + getCheckMessage(MSG_KEY, "calendar2"),
218             "10:73: " + getCheckMessage(MSG_KEY, "calendar3"),
219             "11:36: " + getCheckMessage(MSG_KEY, "address"),
220         };
221         verify(checkConfig, getPath("InputVisibilityModifierImmutableSameTypeName.java"),
222                 expected);
223     }
224 
225     @Test
226     public void testImmutableStarImportFalseNegative() throws Exception {
227         final DefaultConfiguration checkConfig =
228                 createModuleConfig(VisibilityModifierCheck.class);
229         checkConfig.addAttribute("allowPublicImmutableFields", "true");
230         checkConfig.addAttribute("immutableClassCanonicalNames", "java.util.Arrays");
231         final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
232         verify(checkConfig, getPath("InputVisibilityModifierImmutableStarImport.java"), expected);
233     }
234 
235     @Test
236     public void testImmutableStarImportNoWarn() throws Exception {
237         final DefaultConfiguration checkConfig =
238                 createModuleConfig(VisibilityModifierCheck.class);
239         checkConfig.addAttribute("allowPublicImmutableFields", "true");
240         checkConfig.addAttribute("immutableClassCanonicalNames",
241             "java.lang.String, com.google.common.collect.ImmutableSet");
242         final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
243         verify(checkConfig, getPath("InputVisibilityModifierImmutableStarImport2.java"),
244                 expected);
245     }
246 
247     @Test
248     public void testDefaultAnnotationPatterns() throws Exception {
249         final DefaultConfiguration checkConfig =
250             createModuleConfig(VisibilityModifierCheck.class);
251         final String[] expected = {
252             "40:19: " + getCheckMessage(MSG_KEY, "customAnnotatedPublic"),
253             "43:12: " + getCheckMessage(MSG_KEY, "customAnnotatedPackage"),
254             "46:22: " + getCheckMessage(MSG_KEY, "customAnnotatedProtected"),
255             "48:19: " + getCheckMessage(MSG_KEY, "unannotatedPublic"),
256             "49:12: " + getCheckMessage(MSG_KEY, "unannotatedPackage"),
257             "50:22: " + getCheckMessage(MSG_KEY, "unannotatedProtected"),
258         };
259         verify(checkConfig, getPath("InputVisibilityModifierAnnotated.java"), expected);
260     }
261 
262     @Test
263     public void testCustomAnnotationPatterns() throws Exception {
264         final DefaultConfiguration checkConfig =
265             createModuleConfig(VisibilityModifierCheck.class);
266         checkConfig.addAttribute("ignoreAnnotationCanonicalNames",
267                 "com.puppycrawl.tools.checkstyle.checks.design."
268                     + "InputVisibilityModifierAnnotated.CustomAnnotation");
269         final String[] expected = {
270             "16:28: " + getCheckMessage(MSG_KEY, "publicJUnitRule"),
271             "19:28: " + getCheckMessage(MSG_KEY, "fqPublicJUnitRule"),
272             "22:19: " + getCheckMessage(MSG_KEY, "googleCommonsAnnotatedPublic"),
273             "25:12: " + getCheckMessage(MSG_KEY, "googleCommonsAnnotatedPackage"),
274             "28:22: " + getCheckMessage(MSG_KEY, "googleCommonsAnnotatedProtected"),
275             "31:19: " + getCheckMessage(MSG_KEY, "fqGoogleCommonsAnnotatedPublic"),
276             "34:12: " + getCheckMessage(MSG_KEY, "fqGoogleCommonsAnnotatedPackage"),
277             "37:22: " + getCheckMessage(MSG_KEY, "fqGoogleCommonsAnnotatedProtected"),
278             "48:19: " + getCheckMessage(MSG_KEY, "unannotatedPublic"),
279             "49:12: " + getCheckMessage(MSG_KEY, "unannotatedPackage"),
280             "50:22: " + getCheckMessage(MSG_KEY, "unannotatedProtected"),
281             "59:35: " + getCheckMessage(MSG_KEY, "publicJUnitClassRule"),
282             "62:35: " + getCheckMessage(MSG_KEY, "fqPublicJUnitClassRule"),
283         };
284         verify(checkConfig, getPath("InputVisibilityModifierAnnotated.java"), expected);
285     }
286 
287     @Test
288     public void testIgnoreAnnotationNoPattern() throws Exception {
289         final DefaultConfiguration checkConfig =
290             createModuleConfig(VisibilityModifierCheck.class);
291         checkConfig.addAttribute("ignoreAnnotationCanonicalNames", "");
292         final String[] expected = {
293             "16:28: " + getCheckMessage(MSG_KEY, "publicJUnitRule"),
294             "19:28: " + getCheckMessage(MSG_KEY, "fqPublicJUnitRule"),
295             "22:19: " + getCheckMessage(MSG_KEY, "googleCommonsAnnotatedPublic"),
296             "25:12: " + getCheckMessage(MSG_KEY, "googleCommonsAnnotatedPackage"),
297             "28:22: " + getCheckMessage(MSG_KEY, "googleCommonsAnnotatedProtected"),
298             "31:19: " + getCheckMessage(MSG_KEY, "fqGoogleCommonsAnnotatedPublic"),
299             "34:12: " + getCheckMessage(MSG_KEY, "fqGoogleCommonsAnnotatedPackage"),
300             "37:22: " + getCheckMessage(MSG_KEY, "fqGoogleCommonsAnnotatedProtected"),
301             "40:19: " + getCheckMessage(MSG_KEY, "customAnnotatedPublic"),
302             "43:12: " + getCheckMessage(MSG_KEY, "customAnnotatedPackage"),
303             "46:22: " + getCheckMessage(MSG_KEY, "customAnnotatedProtected"),
304             "48:19: " + getCheckMessage(MSG_KEY, "unannotatedPublic"),
305             "49:12: " + getCheckMessage(MSG_KEY, "unannotatedPackage"),
306             "50:22: " + getCheckMessage(MSG_KEY, "unannotatedProtected"),
307             "59:35: " + getCheckMessage(MSG_KEY, "publicJUnitClassRule"),
308             "62:35: " + getCheckMessage(MSG_KEY, "fqPublicJUnitClassRule"),
309         };
310         verify(checkConfig, getPath("InputVisibilityModifierAnnotated.java"), expected);
311     }
312 
313     @Test
314     public void testIgnoreAnnotationSameName() throws Exception {
315         final DefaultConfiguration checkConfig =
316             createModuleConfig(VisibilityModifierCheck.class);
317         final String[] expected = {
318             "11:28: " + getCheckMessage(MSG_KEY, "publicJUnitRule"),
319             "14:28: " + getCheckMessage(MSG_KEY, "publicJUnitClassRule"),
320         };
321         verify(checkConfig, getPath("InputVisibilityModifierAnnotatedSameTypeName.java"),
322                 expected);
323     }
324 
325     @Test
326     public void testGetAcceptableTokens() {
327         final VisibilityModifierCheck obj = new VisibilityModifierCheck();
328         final int[] expected = {
329             TokenTypes.VARIABLE_DEF,
330             TokenTypes.IMPORT,
331         };
332         assertArrayEquals("Default acceptable tokens are invalid",
333             expected, obj.getAcceptableTokens());
334     }
335 
336     @Test
337     public void testPublicImmutableFieldsNotAllowed() throws Exception {
338         final DefaultConfiguration checkConfig =
339             createModuleConfig(VisibilityModifierCheck.class);
340         final String[] expected = {
341             "10:22: " + getCheckMessage(MSG_KEY, "someIntValue"),
342             "11:39: " + getCheckMessage(MSG_KEY, "includes"),
343             "12:35: " + getCheckMessage(MSG_KEY, "notes"),
344             "13:29: " + getCheckMessage(MSG_KEY, "value"),
345             "14:23: " + getCheckMessage(MSG_KEY, "list"),
346         };
347         verify(checkConfig, getPath("InputVisibilityModifiersPublicImmutable.java"), expected);
348     }
349 
350     @Test
351     public void testPublicFinalFieldsNotAllowed() throws Exception {
352         final DefaultConfiguration checkConfig =
353             createModuleConfig(VisibilityModifierCheck.class);
354         final String[] expected = {
355             "10:22: " + getCheckMessage(MSG_KEY, "someIntValue"),
356             "11:39: " + getCheckMessage(MSG_KEY, "includes"),
357             "12:35: " + getCheckMessage(MSG_KEY, "notes"),
358             "13:29: " + getCheckMessage(MSG_KEY, "value"),
359             "14:23: " + getCheckMessage(MSG_KEY, "list"),
360         };
361         verify(checkConfig, getPath("InputVisibilityModifiersPublicImmutable.java"), expected);
362     }
363 
364     @Test
365     public void testPublicFinalFieldsAllowed() throws Exception {
366         final DefaultConfiguration checkConfig =
367             createModuleConfig(VisibilityModifierCheck.class);
368         checkConfig.addAttribute("allowPublicFinalFields", "true");
369         checkConfig.addAttribute("immutableClassCanonicalNames",
370             "com.google.common.collect.ImmutableSet");
371         final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
372         verify(checkConfig, getPath("InputVisibilityModifiersPublicImmutable.java"), expected);
373     }
374 
375     @Test
376     public void testPublicFinalFieldInEnum() throws Exception {
377         final DefaultConfiguration checkConfig =
378             createModuleConfig(VisibilityModifierCheck.class);
379         checkConfig.addAttribute("allowPublicImmutableFields", "true");
380         final String[] expected = {
381             "15:23: " + getCheckMessage(MSG_KEY, "hole"),
382         };
383         verify(checkConfig, getPath("InputVisibilityModifiersEnumIsSealed.java"), expected);
384     }
385 
386     @Test
387     public void testWrongTokenType() {
388         final VisibilityModifierCheck obj = new VisibilityModifierCheck();
389         final DetailAST ast = new DetailAST();
390         ast.initialize(new CommonHiddenStreamToken(TokenTypes.CLASS_DEF, "class"));
391         try {
392             obj.visitToken(ast);
393             fail("exception expected");
394         }
395         catch (IllegalArgumentException ex) {
396             assertEquals("Invalid exception message",
397                 "Unexpected token type: class", ex.getMessage());
398         }
399     }
400 
401     @Test
402     public void testNullModifiers() throws Exception {
403         final DefaultConfiguration checkConfig =
404             createModuleConfig(VisibilityModifierCheck.class);
405         checkConfig.addAttribute("allowPublicImmutableFields", "true");
406         final String[] expected = {
407             "11:50: " + getCheckMessage(MSG_KEY, "i"),
408         };
409         verify(checkConfig, getPath("InputVisibilityModifiersNullModifiers.java"), expected);
410     }
411 
412     @Test
413     public void testVisibilityModifiersOfGenericFields() throws Exception {
414         final DefaultConfiguration checkConfig =
415             createModuleConfig(VisibilityModifierCheck.class);
416         checkConfig.addAttribute("allowPublicImmutableFields", "true");
417         checkConfig.addAttribute("immutableClassCanonicalNames",
418             "com.google.common.collect.ImmutableMap,"
419             + "java.lang.String,"
420             + "java.util.Optional,"
421             + "java.math.BigDecimal");
422         final String[] expected = {
423             "16:56: " + getCheckMessage(MSG_KEY, "perfSeries"),
424             "17:66: " + getCheckMessage(MSG_KEY, "peopleMap"),
425             "18:66: " + getCheckMessage(MSG_KEY, "someMap"),
426             "19:76: " + getCheckMessage(MSG_KEY, "newMap"),
427             "21:45: " + getCheckMessage(MSG_KEY, "optionalOfObject"),
428             "22:35: " + getCheckMessage(MSG_KEY, "obj"),
429             "24:19: " + getCheckMessage(MSG_KEY, "rqUID"),
430             "25:29: " + getCheckMessage(MSG_KEY, "rqTime"),
431             "26:45: " + getCheckMessage(MSG_KEY, "rates"),
432             "27:50: " + getCheckMessage(MSG_KEY, "loans"),
433             "28:60: " + getCheckMessage(MSG_KEY, "cards"),
434             "29:60: " + getCheckMessage(MSG_KEY, "values"),
435             "30:70: " + getCheckMessage(MSG_KEY, "permissions"),
436             "32:38: " + getCheckMessage(MSG_KEY, "mapOfStrings"),
437             "33:48: " + getCheckMessage(MSG_KEY, "names"),
438             "34:48: " + getCheckMessage(MSG_KEY, "links"),
439             "35:38: " + getCheckMessage(MSG_KEY, "presentations"),
440             "36:48: " + getCheckMessage(MSG_KEY, "collection"),
441             "39:73: " + getCheckMessage(MSG_KEY, "exceptions"),
442         };
443         verify(checkConfig, getPath("InputVisibilityModifierGenerics.java"), expected);
444     }
445 
446     /**
447      * We can not cover this mutation because it force all imports to be non static,
448      * but static imports are ignored, so we will not see any affect on validation.
449      * We could remove this method at all, and it will work correctly as we can not use
450      * class with name "", but in this case internal collection will have short names
451      * as "" that will not make problems, but will be weird in debug.
452      *
453      * @throws Exception when exception occurred during execution.
454      */
455     @Test
456     public void testIsStarImportNullAst() throws Exception {
457         final DetailAST importAst = TestUtil.parseFile(new File(getPath(
458             "InputVisibilityModifierIsStarImport.java"))).getNextSibling();
459         final VisibilityModifierCheck check = new VisibilityModifierCheck();
460         final Method isStarImport = Whitebox.getMethod(VisibilityModifierCheck.class,
461             "isStarImport", DetailAST.class);
462 
463         assertTrue("Should return true when star import is passed",
464             (boolean) isStarImport.invoke(check, importAst));
465     }
466 }