aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheckTest.java
blob: eab6ec9cc2f6ae95ae9787411f0d1e7eb8a513be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code for adherence to a set of rules.
// Copyright (C) 2001-2017 the original author or authors.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
////////////////////////////////////////////////////////////////////////////////

package com.puppycrawl.tools.checkstyle.checks.design;

import static com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck.MSG_KEY;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.File;
import java.lang.reflect.Method;

import org.junit.Test;
import org.powermock.reflect.Whitebox;

import antlr.CommonHiddenStreamToken;
import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil;
import com.puppycrawl.tools.checkstyle.utils.CommonUtils;

public class VisibilityModifierCheckTest
    extends AbstractModuleTestSupport {
    @Override
    protected String getPackageLocation() {
        return "com/puppycrawl/tools/checkstyle/checks/design/visibilitymodifier";
    }

    @Test
    public void testGetRequiredTokens() {
        final VisibilityModifierCheck checkObj = new VisibilityModifierCheck();
        final int[] expected = {
            TokenTypes.VARIABLE_DEF,
            TokenTypes.IMPORT,
        };
        assertArrayEquals("Default required tokens are invalid",
            expected, checkObj.getRequiredTokens());
    }

    @Test
    public void testInner()
            throws Exception {
        final DefaultConfiguration checkConfig =
                createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("publicMemberPattern", "^f[A-Z][a-zA-Z0-9]*$");
        final String[] expected = {
            "30:24: " + getCheckMessage(MSG_KEY, "rData"),
            "33:27: " + getCheckMessage(MSG_KEY, "protectedVariable"),
            "36:17: " + getCheckMessage(MSG_KEY, "packageVariable"),
            "41:29: " + getCheckMessage(MSG_KEY, "sWeird"),
            "43:19: " + getCheckMessage(MSG_KEY, "sWeird2"),
            "77:20: " + getCheckMessage(MSG_KEY, "someValue"),
        };
        verify(checkConfig, getPath("InputVisibilityModifierInner.java"), expected);
    }

    @Test
    public void testIgnoreAccess()
            throws Exception {
        final DefaultConfiguration checkConfig =
            createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("publicMemberPattern", "^r[A-Z]");
        checkConfig.addAttribute("protectedAllowed", "true");
        checkConfig.addAttribute("packageAllowed", "true");
        final String[] expected = {
            "17:20: " + getCheckMessage(MSG_KEY, "fData"),
            "77:20: " + getCheckMessage(MSG_KEY, "someValue"),
        };
        verify(checkConfig, getPath("InputVisibilityModifierInner.java"), expected);
    }

    @Test
    public void testSimple() throws Exception {
        final DefaultConfiguration checkConfig =
                createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("publicMemberPattern", "^f[A-Z][a-zA-Z0-9]*$");
        final String[] expected = {
            "33:19: " + getCheckMessage(MSG_KEY, "mNumCreated2"),
            "43:23: " + getCheckMessage(MSG_KEY, "sTest1"),
            "45:26: " + getCheckMessage(MSG_KEY, "sTest3"),
            "47:16: " + getCheckMessage(MSG_KEY, "sTest2"),
            "50:9: " + getCheckMessage(MSG_KEY, "mTest1"),
            "52:16: " + getCheckMessage(MSG_KEY, "mTest2"),
        };
        verify(checkConfig, getPath("InputVisibilityModifierSimple.java"), expected);
    }

    @Test
    public void testStrictJavadoc() throws Exception {
        final DefaultConfiguration checkConfig =
                createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("publicMemberPattern", "^f[A-Z][a-zA-Z0-9]*$");
        final String[] expected = {
            "32:9: " + getCheckMessage(MSG_KEY, "mLen"),
            "33:19: " + getCheckMessage(MSG_KEY, "mDeer"),
            "34:16: " + getCheckMessage(MSG_KEY, "aFreddo"),
        };
        verify(checkConfig, getPath("InputVisibilityModifierPublicOnly.java"), expected);
    }

    @Test
    public void testAllowPublicFinalFieldsInImmutableClass() throws Exception {
        final DefaultConfiguration checkConfig =
                createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("allowPublicImmutableFields", "true");
        final String[] expected = {
            "12:39: " + getCheckMessage(MSG_KEY, "includes"),
            "13:39: " + getCheckMessage(MSG_KEY, "excludes"),
            "16:23: " + getCheckMessage(MSG_KEY, "list"),
            "34:20: " + getCheckMessage(MSG_KEY, "value"),
            "36:24: " + getCheckMessage(MSG_KEY, "bValue"),
            "37:31: " + getCheckMessage(MSG_KEY, "longValue"),
        };
        verify(checkConfig, getPath("InputVisibilityModifierImmutable.java"), expected);
    }

    @Test
    public void testDisAllowPublicFinalAndImmutableFieldsInImmutableClass() throws Exception {
        final DefaultConfiguration checkConfig =
            createModuleConfig(VisibilityModifierCheck.class);
        final String[] expected = {
            "11:22: " + getCheckMessage(MSG_KEY, "someIntValue"),
            "12:39: " + getCheckMessage(MSG_KEY, "includes"),
            "13:39: " + getCheckMessage(MSG_KEY, "excludes"),
            "14:35: " + getCheckMessage(MSG_KEY, "notes"),
            "15:29: " + getCheckMessage(MSG_KEY, "money"),
            "16:23: " + getCheckMessage(MSG_KEY, "list"),
            "30:28: " + getCheckMessage(MSG_KEY, "f"),
            "31:30: " + getCheckMessage(MSG_KEY, "bool"),
            "32:35: " + getCheckMessage(MSG_KEY, "uri"),
            "33:35: " + getCheckMessage(MSG_KEY, "file"),
            "34:20: " + getCheckMessage(MSG_KEY, "value"),
            "35:35: " + getCheckMessage(MSG_KEY, "url"),
            "36:24: " + getCheckMessage(MSG_KEY, "bValue"),
            "37:31: " + getCheckMessage(MSG_KEY, "longValue"),
            };
        verify(checkConfig, getPath("InputVisibilityModifierImmutable.java"), expected);
    }

    @Test
    public void testAllowPublicFinalFieldsInNonFinalClass() throws Exception {
        final DefaultConfiguration checkConfig =
                createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("allowPublicFinalFields", "true");
        final String[] expected = {
            "34:20: " + getCheckMessage(MSG_KEY, "value"),
            "36:24: " + getCheckMessage(MSG_KEY, "bValue"),
            "37:31: " + getCheckMessage(MSG_KEY, "longValue"),
        };
        verify(checkConfig, getPath("InputVisibilityModifierImmutable.java"), expected);
    }

    @Test
    public void testUserSpecifiedImmutableClassesList() throws Exception {
        final DefaultConfiguration checkConfig =
                createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("allowPublicImmutableFields", "true");
        checkConfig.addAttribute("immutableClassCanonicalNames", "java.util.List,"
                + "com.google.common.collect.ImmutableSet, java.lang.String");
        final String[] expected = {
            "15:29: " + getCheckMessage(MSG_KEY, "money"),
            "32:35: " + getCheckMessage(MSG_KEY, "uri"),
            "33:35: " + getCheckMessage(MSG_KEY, "file"),
            "34:20: " + getCheckMessage(MSG_KEY, "value"),
            "35:35: " + getCheckMessage(MSG_KEY, "url"),
            "36:24: " + getCheckMessage(MSG_KEY, "bValue"),
            "37:31: " + getCheckMessage(MSG_KEY, "longValue"),
        };
        verify(checkConfig, getPath("InputVisibilityModifierImmutable.java"), expected);
    }

    @Test
    public void testImmutableSpecifiedSameTypeName() throws Exception {
        final DefaultConfiguration checkConfig =
                createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("allowPublicImmutableFields", "true");
        checkConfig.addAttribute("immutableClassCanonicalNames",
                 "com.puppycrawl.tools.checkstyle.checks.design."
                         + "visibilitymodifier.InputVisibilityModifierGregorianCalendar,"
                 + "com.puppycrawl.tools.checkstyle.checks.design."
                         + "visibilitymodifier.inputs.InetSocketAddress");
        final String[] expected = {
            "7:46: " + getCheckMessage(MSG_KEY, "calendar"),
            "12:45: " + getCheckMessage(MSG_KEY, "adr"),
        };
        verify(checkConfig, getPath("InputVisibilityModifierImmutableSameTypeName.java"),
                expected);
    }

    @Test
    public void testImmutableValueSameTypeName() throws Exception {
        final DefaultConfiguration checkConfig =
                createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("allowPublicImmutableFields", "true");
        final String[] expected = {
            "7:46: " + getCheckMessage(MSG_KEY, "calendar"),
            "8:59: " + getCheckMessage(MSG_KEY, "calendar2"),
            "10:73: " + getCheckMessage(MSG_KEY, "calendar3"),
            "11:36: " + getCheckMessage(MSG_KEY, "address"),
        };
        verify(checkConfig, getPath("InputVisibilityModifierImmutableSameTypeName.java"),
                expected);
    }

    @Test
    public void testImmutableStarImportFalseNegative() throws Exception {
        final DefaultConfiguration checkConfig =
                createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("allowPublicImmutableFields", "true");
        checkConfig.addAttribute("immutableClassCanonicalNames", "java.util.Arrays");
        final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
        verify(checkConfig, getPath("InputVisibilityModifierImmutableStarImport.java"), expected);
    }

    @Test
    public void testImmutableStarImportNoWarn() throws Exception {
        final DefaultConfiguration checkConfig =
                createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("allowPublicImmutableFields", "true");
        checkConfig.addAttribute("immutableClassCanonicalNames",
            "java.lang.String, com.google.common.collect.ImmutableSet");
        final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
        verify(checkConfig, getPath("InputVisibilityModifierImmutableStarImport2.java"),
                expected);
    }

    @Test
    public void testDefaultAnnotationPatterns() throws Exception {
        final DefaultConfiguration checkConfig =
            createModuleConfig(VisibilityModifierCheck.class);
        final String[] expected = {
            "40:19: " + getCheckMessage(MSG_KEY, "customAnnotatedPublic"),
            "43:12: " + getCheckMessage(MSG_KEY, "customAnnotatedPackage"),
            "46:22: " + getCheckMessage(MSG_KEY, "customAnnotatedProtected"),
            "48:19: " + getCheckMessage(MSG_KEY, "unannotatedPublic"),
            "49:12: " + getCheckMessage(MSG_KEY, "unannotatedPackage"),
            "50:22: " + getCheckMessage(MSG_KEY, "unannotatedProtected"),
        };
        verify(checkConfig, getPath("InputVisibilityModifierAnnotated.java"), expected);
    }

    @Test
    public void testCustomAnnotationPatterns() throws Exception {
        final DefaultConfiguration checkConfig =
            createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("ignoreAnnotationCanonicalNames",
                "com.puppycrawl.tools.checkstyle.checks.design."
                    + "InputVisibilityModifierAnnotated.CustomAnnotation");
        final String[] expected = {
            "16:28: " + getCheckMessage(MSG_KEY, "publicJUnitRule"),
            "19:28: " + getCheckMessage(MSG_KEY, "fqPublicJUnitRule"),
            "22:19: " + getCheckMessage(MSG_KEY, "googleCommonsAnnotatedPublic"),
            "25:12: " + getCheckMessage(MSG_KEY, "googleCommonsAnnotatedPackage"),
            "28:22: " + getCheckMessage(MSG_KEY, "googleCommonsAnnotatedProtected"),
            "31:19: " + getCheckMessage(MSG_KEY, "fqGoogleCommonsAnnotatedPublic"),
            "34:12: " + getCheckMessage(MSG_KEY, "fqGoogleCommonsAnnotatedPackage"),
            "37:22: " + getCheckMessage(MSG_KEY, "fqGoogleCommonsAnnotatedProtected"),
            "48:19: " + getCheckMessage(MSG_KEY, "unannotatedPublic"),
            "49:12: " + getCheckMessage(MSG_KEY, "unannotatedPackage"),
            "50:22: " + getCheckMessage(MSG_KEY, "unannotatedProtected"),
            "59:35: " + getCheckMessage(MSG_KEY, "publicJUnitClassRule"),
            "62:35: " + getCheckMessage(MSG_KEY, "fqPublicJUnitClassRule"),
        };
        verify(checkConfig, getPath("InputVisibilityModifierAnnotated.java"), expected);
    }

    @Test
    public void testIgnoreAnnotationNoPattern() throws Exception {
        final DefaultConfiguration checkConfig =
            createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("ignoreAnnotationCanonicalNames", "");
        final String[] expected = {
            "16:28: " + getCheckMessage(MSG_KEY, "publicJUnitRule"),
            "19:28: " + getCheckMessage(MSG_KEY, "fqPublicJUnitRule"),
            "22:19: " + getCheckMessage(MSG_KEY, "googleCommonsAnnotatedPublic"),
            "25:12: " + getCheckMessage(MSG_KEY, "googleCommonsAnnotatedPackage"),
            "28:22: " + getCheckMessage(MSG_KEY, "googleCommonsAnnotatedProtected"),
            "31:19: " + getCheckMessage(MSG_KEY, "fqGoogleCommonsAnnotatedPublic"),
            "34:12: " + getCheckMessage(MSG_KEY, "fqGoogleCommonsAnnotatedPackage"),
            "37:22: " + getCheckMessage(MSG_KEY, "fqGoogleCommonsAnnotatedProtected"),
            "40:19: " + getCheckMessage(MSG_KEY, "customAnnotatedPublic"),
            "43:12: " + getCheckMessage(MSG_KEY, "customAnnotatedPackage"),
            "46:22: " + getCheckMessage(MSG_KEY, "customAnnotatedProtected"),
            "48:19: " + getCheckMessage(MSG_KEY, "unannotatedPublic"),
            "49:12: " + getCheckMessage(MSG_KEY, "unannotatedPackage"),
            "50:22: " + getCheckMessage(MSG_KEY, "unannotatedProtected"),
            "59:35: " + getCheckMessage(MSG_KEY, "publicJUnitClassRule"),
            "62:35: " + getCheckMessage(MSG_KEY, "fqPublicJUnitClassRule"),
        };
        verify(checkConfig, getPath("InputVisibilityModifierAnnotated.java"), expected);
    }

    @Test
    public void testIgnoreAnnotationSameName() throws Exception {
        final DefaultConfiguration checkConfig =
            createModuleConfig(VisibilityModifierCheck.class);
        final String[] expected = {
            "11:28: " + getCheckMessage(MSG_KEY, "publicJUnitRule"),
            "14:28: " + getCheckMessage(MSG_KEY, "publicJUnitClassRule"),
        };
        verify(checkConfig, getPath("InputVisibilityModifierAnnotatedSameTypeName.java"),
                expected);
    }

    @Test
    public void testGetAcceptableTokens() {
        final VisibilityModifierCheck obj = new VisibilityModifierCheck();
        final int[] expected = {
            TokenTypes.VARIABLE_DEF,
            TokenTypes.IMPORT,
        };
        assertArrayEquals("Default acceptable tokens are invalid",
            expected, obj.getAcceptableTokens());
    }

    @Test
    public void testPublicImmutableFieldsNotAllowed() throws Exception {
        final DefaultConfiguration checkConfig =
            createModuleConfig(VisibilityModifierCheck.class);
        final String[] expected = {
            "10:22: " + getCheckMessage(MSG_KEY, "someIntValue"),
            "11:39: " + getCheckMessage(MSG_KEY, "includes"),
            "12:35: " + getCheckMessage(MSG_KEY, "notes"),
            "13:29: " + getCheckMessage(MSG_KEY, "value"),
            "14:23: " + getCheckMessage(MSG_KEY, "list"),
        };
        verify(checkConfig, getPath("InputVisibilityModifiersPublicImmutable.java"), expected);
    }

    @Test
    public void testPublicFinalFieldsNotAllowed() throws Exception {
        final DefaultConfiguration checkConfig =
            createModuleConfig(VisibilityModifierCheck.class);
        final String[] expected = {
            "10:22: " + getCheckMessage(MSG_KEY, "someIntValue"),
            "11:39: " + getCheckMessage(MSG_KEY, "includes"),
            "12:35: " + getCheckMessage(MSG_KEY, "notes"),
            "13:29: " + getCheckMessage(MSG_KEY, "value"),
            "14:23: " + getCheckMessage(MSG_KEY, "list"),
        };
        verify(checkConfig, getPath("InputVisibilityModifiersPublicImmutable.java"), expected);
    }

    @Test
    public void testPublicFinalFieldsAllowed() throws Exception {
        final DefaultConfiguration checkConfig =
            createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("allowPublicFinalFields", "true");
        checkConfig.addAttribute("immutableClassCanonicalNames",
            "com.google.common.collect.ImmutableSet");
        final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;
        verify(checkConfig, getPath("InputVisibilityModifiersPublicImmutable.java"), expected);
    }

    @Test
    public void testPublicFinalFieldInEnum() throws Exception {
        final DefaultConfiguration checkConfig =
            createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("allowPublicImmutableFields", "true");
        final String[] expected = {
            "15:23: " + getCheckMessage(MSG_KEY, "hole"),
        };
        verify(checkConfig, getPath("InputVisibilityModifiersEnumIsSealed.java"), expected);
    }

    @Test
    public void testWrongTokenType() {
        final VisibilityModifierCheck obj = new VisibilityModifierCheck();
        final DetailAST ast = new DetailAST();
        ast.initialize(new CommonHiddenStreamToken(TokenTypes.CLASS_DEF, "class"));
        try {
            obj.visitToken(ast);
            fail("exception expected");
        }
        catch (IllegalArgumentException ex) {
            assertEquals("Invalid exception message",
                "Unexpected token type: class", ex.getMessage());
        }
    }

    @Test
    public void testNullModifiers() throws Exception {
        final DefaultConfiguration checkConfig =
            createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("allowPublicImmutableFields", "true");
        final String[] expected = {
            "11:50: " + getCheckMessage(MSG_KEY, "i"),
        };
        verify(checkConfig, getPath("InputVisibilityModifiersNullModifiers.java"), expected);
    }

    @Test
    public void testVisibilityModifiersOfGenericFields() throws Exception {
        final DefaultConfiguration checkConfig =
            createModuleConfig(VisibilityModifierCheck.class);
        checkConfig.addAttribute("allowPublicImmutableFields", "true");
        checkConfig.addAttribute("immutableClassCanonicalNames",
            "com.google.common.collect.ImmutableMap,"
            + "java.lang.String,"
            + "java.util.Optional,"
            + "java.math.BigDecimal");
        final String[] expected = {
            "16:56: " + getCheckMessage(MSG_KEY, "perfSeries"),
            "17:66: " + getCheckMessage(MSG_KEY, "peopleMap"),
            "18:66: " + getCheckMessage(MSG_KEY, "someMap"),
            "19:76: " + getCheckMessage(MSG_KEY, "newMap"),
            "21:45: " + getCheckMessage(MSG_KEY, "optionalOfObject"),
            "22:35: " + getCheckMessage(MSG_KEY, "obj"),
            "24:19: " + getCheckMessage(MSG_KEY, "rqUID"),
            "25:29: " + getCheckMessage(MSG_KEY, "rqTime"),
            "26:45: " + getCheckMessage(MSG_KEY, "rates"),
            "27:50: " + getCheckMessage(MSG_KEY, "loans"),
            "28:60: " + getCheckMessage(MSG_KEY, "cards"),
            "29:60: " + getCheckMessage(MSG_KEY, "values"),
            "30:70: " + getCheckMessage(MSG_KEY, "permissions"),
            "32:38: " + getCheckMessage(MSG_KEY, "mapOfStrings"),
            "33:48: " + getCheckMessage(MSG_KEY, "names"),
            "34:48: " + getCheckMessage(MSG_KEY, "links"),
            "35:38: " + getCheckMessage(MSG_KEY, "presentations"),
            "36:48: " + getCheckMessage(MSG_KEY, "collection"),
            "39:73: " + getCheckMessage(MSG_KEY, "exceptions"),
        };
        verify(checkConfig, getPath("InputVisibilityModifierGenerics.java"), expected);
    }

    /**
     * We can not cover this mutation because it force all imports to be non static,
     * but static imports are ignored, so we will not see any affect on validation.
     * We could remove this method at all, and it will work correctly as we can not use
     * class with name "", but in this case internal collection will have short names
     * as "" that will not make problems, but will be weird in debug.
     *
     * @throws Exception when exception occurred during execution.
     */
    @Test
    public void testIsStarImportNullAst() throws Exception {
        final DetailAST importAst = TestUtil.parseFile(new File(getPath(
            "InputVisibilityModifierIsStarImport.java"))).getNextSibling();
        final VisibilityModifierCheck check = new VisibilityModifierCheck();
        final Method isStarImport = Whitebox.getMethod(VisibilityModifierCheck.class,
            "isStarImport", DetailAST.class);

        assertTrue("Should return true when star import is passed",
            (boolean) isStarImport.invoke(check, importAst));
    }
}