Skip to content

Commit d89f7f1

Browse files
Fix archetype it test
1 parent 267a662 commit d89f7f1

File tree

1 file changed

+26
-10
lines changed
  • maven-plugins/helidon-archetype-maven-plugin/src/test/java/io/helidon/build/maven/archetype

1 file changed

+26
-10
lines changed

maven-plugins/helidon-archetype-maven-plugin/src/test/java/io/helidon/build/maven/archetype/ProjectsTestIT.java

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.nio.file.DirectoryStream;
2121
import java.nio.file.Files;
2222
import java.nio.file.Path;
23+
import java.util.ArrayList;
2324
import java.util.List;
2425

2526
import io.helidon.build.common.test.utils.BuildLog;
@@ -29,10 +30,12 @@
2930
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
3031
import org.junit.jupiter.params.ParameterizedTest;
3132

33+
import static io.helidon.build.common.FileUtils.fileName;
3234
import static io.helidon.build.common.test.utils.BuildLog.assertDiffs;
3335
import static org.hamcrest.MatcherAssert.assertThat;
34-
import static org.hamcrest.Matchers.endsWith;
3536
import static org.hamcrest.Matchers.is;
37+
import static org.hamcrest.Matchers.not;
38+
import static org.hamcrest.Matchers.nullValue;
3639

3740
/**
3841
* Integration test that verifies the projects under {@code src/it/projects}.
@@ -135,31 +138,44 @@ private static Path projectsDir(String baseDir, String prefix) {
135138
return projectsDir;
136139
}
137140

138-
private static void assertProjectCount(Path projectsDir, int expectedCount) throws IOException {
139-
int projectCount = 0;
141+
private static List<Path> testProjects(Path projectsDir) throws IOException {
142+
List<Path> projects = new ArrayList<>();
140143
try (DirectoryStream<Path> paths = Files.newDirectoryStream(projectsDir)) {
141144
for (Path path : paths) {
142-
if (path.getFileName().toString().endsWith("-project")) {
143-
assertThat(Files.isDirectory(path), is(true));
144-
projectCount++;
145+
if (fileName(path).matches(".*-project(-[0-9]+)?$")) {
146+
projects.add(path);
145147
}
146148
}
147-
assertThat(projectCount, is(expectedCount));
148149
}
150+
return projects;
151+
}
152+
153+
private static void assertProjectCount(Path projectsDir, int expectedCount) throws IOException {
154+
int projectCount = 0;
155+
for (Path path : testProjects(projectsDir)) {
156+
assertThat(Files.isDirectory(path), is(true));
157+
projectCount++;
158+
}
159+
assertThat(projectCount, is(expectedCount));
149160
}
150161

151162
private static void assertProjectShape(Path projectsDir, String shape) throws IOException {
152163
// Check project directory
153-
Path outputDir = projectsDir.resolve(shape + "-project");
164+
Path outputDir = testProjects(projectsDir).stream()
165+
.filter(p -> fileName(p).contains(shape + "-project"))
166+
.findFirst()
167+
.orElse(null);
168+
assertThat(outputDir, is(not(nullValue())));
154169
assertThat(Files.exists(outputDir), is(true));
155170

156171
// Check pom file
157172
Path pomFile = outputDir.resolve("pom.xml");
173+
String fileName = fileName(outputDir);
158174
assertContains(pomFile, List.of(
159175
"<groupId>io.helidon.build.maven.archetype.tests</groupId>",
160-
"<artifactId>" + shape + "-project</artifactId>",
176+
"<artifactId>" + fileName + "</artifactId>",
161177
"<version>0.1-SNAPSHOT</version>",
162-
"<name>" + shape + "-project</name>"
178+
"<name>" + fileName + "</name>"
163179
));
164180

165181
// Check source file

0 commit comments

Comments
 (0)