Skip to content

Commit 69eb02c

Browse files
author
Daniel Muehlbachler
committed
Issue #288: match jar file name for CheckJarTest
1 parent 7d70dbb commit 69eb02c

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/it/java/org/checkstyle/plugins/sonar/CheckJarTest.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,30 @@
1919

2020
package org.checkstyle.plugins.sonar;
2121

22-
import static org.junit.Assert.assertTrue;
22+
import static org.junit.Assert.assertFalse;
2323

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;
2532

2633
import org.junit.Test;
2734

2835
public class CheckJarTest {
29-
private static final String VERSION = "4.30";
36+
private static final String MATCHER = ".*checkstyle-sonar-plugin-\\d+\\.\\d+(-SNAPSHOT)?\\.jar";
3037

3138
@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());
3947
}
4048
}

0 commit comments

Comments
 (0)