1
2
3
4
5 package com.qulice.pmd;
6
7 import org.hamcrest.Matchers;
8 import org.hamcrest.core.IsEqual;
9 import org.junit.jupiter.api.Test;
10
11
12
13
14
15
16
17 final class ImplicitFunctionalInterfaceRuleTest {
18
19
20
21
22 private static final String RULE = "(ImplicitFunctionalInterface)";
23
24 @Test
25 void flagsInterfaceWithSingleAbstractMethod() throws Exception {
26 new PmdAssert(
27 "ImplicitFunctionalInterfaceSingle.java",
28 new IsEqual<>(false),
29 Matchers.containsString(
30 ImplicitFunctionalInterfaceRuleTest.RULE
31 )
32 ).assertOk();
33 }
34
35 @Test
36 void flagsInterfaceExtendingResolvedMarker() throws Exception {
37 new PmdAssert(
38 "ImplicitFunctionalInterfaceMarkerParent.java",
39 new IsEqual<>(false),
40 Matchers.containsString(
41 ImplicitFunctionalInterfaceRuleTest.RULE
42 )
43 ).assertOk();
44 }
45
46 @Test
47 void ignoresInterfaceExtendingUnresolvedParents() throws Exception {
48 new PmdAssert(
49 "ImplicitFunctionalInterfaceUnresolvedParent.java",
50 Matchers.any(Boolean.class),
51 Matchers.not(
52 Matchers.containsString(
53 ImplicitFunctionalInterfaceRuleTest.RULE
54 )
55 )
56 ).assertOk();
57 }
58
59 @Test
60 void ignoresInterfaceExtendingResolvedParentWithMoreMethods()
61 throws Exception {
62 new PmdAssert(
63 "ImplicitFunctionalInterfaceJdkParent.java",
64 Matchers.any(Boolean.class),
65 Matchers.not(
66 Matchers.containsString(
67 ImplicitFunctionalInterfaceRuleTest.RULE
68 )
69 )
70 ).assertOk();
71 }
72 }