1
2
3
4
5 package com.qulice.pmd;
6
7 import com.qulice.spi.Environment;
8 import com.qulice.spi.Violation;
9 import java.io.File;
10 import java.util.Collections;
11 import org.cactoos.text.TextOf;
12 import org.hamcrest.MatcherAssert;
13 import org.hamcrest.Matchers;
14 import org.junit.jupiter.api.Test;
15
16
17
18
19
20
21
22
23 final class PmdInnerClassConstantsTest {
24
25 @Test
26 void doesNotComplainAboutConstantsInInnerClasses() throws Exception {
27 final String file = "src/main/java/foo/Foo.java";
28 final Environment env = new Environment.Mock().withFile(
29 file,
30 new TextOf(
31 this.getClass().getResourceAsStream("InnerClassConstants.java")
32 ).asString()
33 );
34 MatcherAssert.assertThat(
35 "Private constant in inner class is not a violation",
36 new PmdValidator(env).validate(
37 Collections.singletonList(new File(env.basedir(), file))
38 ),
39 Matchers.<Violation>empty()
40 );
41 }
42 }