|
20 | 20 | import java.nio.file.DirectoryStream; |
21 | 21 | import java.nio.file.Files; |
22 | 22 | import java.nio.file.Path; |
| 23 | +import java.util.ArrayList; |
23 | 24 | import java.util.List; |
24 | 25 |
|
25 | 26 | import io.helidon.build.common.test.utils.BuildLog; |
|
29 | 30 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; |
30 | 31 | import org.junit.jupiter.params.ParameterizedTest; |
31 | 32 |
|
| 33 | +import static io.helidon.build.common.FileUtils.fileName; |
32 | 34 | import static io.helidon.build.common.test.utils.BuildLog.assertDiffs; |
33 | 35 | import static org.hamcrest.MatcherAssert.assertThat; |
34 | | -import static org.hamcrest.Matchers.endsWith; |
35 | 36 | import static org.hamcrest.Matchers.is; |
| 37 | +import static org.hamcrest.Matchers.not; |
| 38 | +import static org.hamcrest.Matchers.nullValue; |
36 | 39 |
|
37 | 40 | /** |
38 | 41 | * Integration test that verifies the projects under {@code src/it/projects}. |
@@ -135,31 +138,44 @@ private static Path projectsDir(String baseDir, String prefix) { |
135 | 138 | return projectsDir; |
136 | 139 | } |
137 | 140 |
|
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<>(); |
140 | 143 | try (DirectoryStream<Path> paths = Files.newDirectoryStream(projectsDir)) { |
141 | 144 | 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); |
145 | 147 | } |
146 | 148 | } |
147 | | - assertThat(projectCount, is(expectedCount)); |
148 | 149 | } |
| 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)); |
149 | 160 | } |
150 | 161 |
|
151 | 162 | private static void assertProjectShape(Path projectsDir, String shape) throws IOException { |
152 | 163 | // 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()))); |
154 | 169 | assertThat(Files.exists(outputDir), is(true)); |
155 | 170 |
|
156 | 171 | // Check pom file |
157 | 172 | Path pomFile = outputDir.resolve("pom.xml"); |
| 173 | + String fileName = fileName(outputDir); |
158 | 174 | assertContains(pomFile, List.of( |
159 | 175 | "<groupId>io.helidon.build.maven.archetype.tests</groupId>", |
160 | | - "<artifactId>" + shape + "-project</artifactId>", |
| 176 | + "<artifactId>" + fileName + "</artifactId>", |
161 | 177 | "<version>0.1-SNAPSHOT</version>", |
162 | | - "<name>" + shape + "-project</name>" |
| 178 | + "<name>" + fileName + "</name>" |
163 | 179 | )); |
164 | 180 |
|
165 | 181 | // Check source file |
|
0 commit comments