|
36 | 36 | import com.qulice.spi.Environment; |
37 | 37 | import com.qulice.spi.Violation; |
38 | 38 | import java.io.File; |
39 | | -import java.util.Collection; |
40 | 39 | import java.util.Collections; |
41 | 40 | import org.hamcrest.MatcherAssert; |
42 | 41 | import org.hamcrest.Matchers; |
@@ -127,34 +126,18 @@ public void findsProblemsInJavaFiles() throws Exception { |
127 | 126 |
|
128 | 127 | /** |
129 | 128 | * PmdValidator can understand method references. |
130 | | - * @todo #1129 Replace not+empty() with more precise containsInAnyOrder |
131 | 129 | * @throws Exception If something wrong happens inside. |
132 | 130 | */ |
133 | 131 | @Test |
134 | | - @SuppressWarnings("PMD.AvoidDuplicateLiterals") |
135 | 132 | public void understandsMethodReferences() throws Exception { |
136 | | - final String file = "src/main/java/Other.java"; |
137 | | - final Environment env = new Environment.Mock().withFile( |
| 133 | + final String file = "UnderstandsMethodReferences.java"; |
| 134 | + new PmdAssert( |
138 | 135 | file, |
139 | | - Joiner.on('\n').join( |
140 | | - "import java.util.ArrayList;", |
141 | | - "class Other {", |
142 | | - " public static void test() {", |
143 | | - " new ArrayList<String>().forEach(Other::other);", |
144 | | - " }", |
145 | | - " private static void other(String some) {", |
146 | | - " // body", |
147 | | - " }", |
148 | | - "}" |
| 136 | + Matchers.is(true), |
| 137 | + Matchers.not( |
| 138 | + Matchers.containsString("(UnusedPrivateMethod)") |
149 | 139 | ) |
150 | | - ); |
151 | | - final Collection<Violation> violations = new PmdValidator(env).validate( |
152 | | - Collections.singletonList(new File(env.basedir(), file)) |
153 | | - ); |
154 | | - MatcherAssert.assertThat( |
155 | | - violations, |
156 | | - Matchers.not(Matchers.<Violation>empty()) |
157 | | - ); |
| 140 | + ).validate(); |
158 | 141 | } |
159 | 142 |
|
160 | 143 | /** |
|
0 commit comments