1
2
3
4
5 package com.qulice.spi;
6
7 import org.hamcrest.MatcherAssert;
8 import org.hamcrest.Matchers;
9 import org.junit.jupiter.api.Test;
10 import org.junit.jupiter.params.ParameterizedTest;
11 import org.junit.jupiter.params.provider.ValueSource;
12
13
14
15
16
17
18 final class IgnoredTest {
19
20 @ParameterizedTest
21 @ValueSource(
22 strings = {
23 "/src/test/resources/com/qulice/Bad.java",
24 "/src/test/resources/foo/bar/baz/Broken.java",
25 "/src/site/apt/Sample.java",
26 "/src/site/resources/js/script.js",
27 "/src/it/violations/pom.xml",
28 "/src/it/violations/src/main/java/foo/Bad.java",
29 "/home/me/prj/src/test/resources/Bad.java",
30 "/home/me/prj/src/it/foo/Bad.java"
31 }
32 )
33 void ignoresFilesInIgnoredDirectories(final String path) {
34 MatcherAssert.assertThat(
35 String.format("%s must be ignored", path),
36 new Ignored(path).yes(),
37 Matchers.is(true)
38 );
39 }
40
41 @ParameterizedTest
42 @ValueSource(
43 strings = {
44 "/src/main/java/com/qulice/Good.java",
45 "/src/test/java/com/qulice/GoodTest.java",
46 "/src/main/resources/checks.xml",
47 "/src/test/groovy/com/qulice/GoodTest.groovy",
48 "/src/itest/java/foo/Bad.java",
49 "/src/integration/java/foo/Bad.java",
50 "/src/sitemap/java/foo/Bad.java"
51 }
52 )
53 void keepsFilesOutsideIgnoredDirectories(final String path) {
54 MatcherAssert.assertThat(
55 String.format("%s cannot be ignored", path),
56 new Ignored(path).yes(),
57 Matchers.is(false)
58 );
59 }
60
61 @Test
62 void ignoresDirectoryOfNestedModule() {
63 MatcherAssert.assertThat(
64 "Ignored directory of a nested module must be recognized",
65 new Ignored("/modules/core/src/site/apt/Sample.java").yes(),
66 Matchers.is(true)
67 );
68 }
69 }