|
19 | 19 |
|
20 | 20 | package org.checkstyle.plugins.sonar; |
21 | 21 |
|
22 | | -import static org.junit.Assert.assertTrue; |
| 22 | +import static org.junit.Assert.assertFalse; |
23 | 23 |
|
24 | | -import java.io.File; |
| 24 | +import java.io.IOException; |
| 25 | +import java.nio.file.Files; |
| 26 | +import java.nio.file.Path; |
| 27 | +import java.nio.file.Paths; |
| 28 | +import java.nio.file.attribute.BasicFileAttributes; |
| 29 | +import java.util.List; |
| 30 | +import java.util.function.BiPredicate; |
| 31 | +import java.util.stream.Collectors; |
25 | 32 |
|
26 | 33 | import org.junit.Test; |
27 | 34 |
|
28 | 35 | public class CheckJarTest { |
29 | | - private static final String VERSION = "4.30"; |
| 36 | + private static final String MATCHER = ".*checkstyle-sonar-plugin-\\d+\\.\\d+(-SNAPSHOT)?\\.jar"; |
30 | 37 |
|
31 | 38 | @Test |
32 | | - public void testJarPresence() { |
33 | | - final boolean snapshotExists = new File("target/checkstyle-sonar-plugin-" |
34 | | - + VERSION + "-SNAPSHOT.jar").exists(); |
35 | | - final boolean releaseExists = new File("target/checkstyle-sonar-plugin-" |
36 | | - + VERSION + ".jar").exists(); |
37 | | - assertTrue("Jar should exists", |
38 | | - snapshotExists || releaseExists); |
| 39 | + public void testJarPresence() throws IOException { |
| 40 | + final BiPredicate<Path, BasicFileAttributes> matcher = (path, basicFileAttributes) -> { |
| 41 | + return path.toString() |
| 42 | + .matches(MATCHER); |
| 43 | + }; |
| 44 | + final List<Path> files = Files.find(Paths.get("target"), 1, matcher) |
| 45 | + .collect(Collectors.toList()); |
| 46 | + assertFalse("Jar should exists", files.isEmpty()); |
39 | 47 | } |
40 | 48 | } |
0 commit comments