Skip to content

Commit

Permalink
Enhanced tests to support '/*' syntax for 'testDataPath' tag (#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrizzi authored May 5, 2023
1 parent b31a217 commit 6e80a0c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
import java.nio.file.Paths;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Stream;

import static org.jboss.windup.rules.tests.WindupRulesTest.MULTIPLE_STANDALONE_TEST_APPLICATIONS_MARKER;

@RunWith(ParameterizedArquillianRunner.class)
public class WindupRulesMultipleTests {
Expand Down Expand Up @@ -371,18 +374,19 @@ private Path getDefaultPath()

private void runWindup(GraphContext context, File baseRuleDirectory, final List<Path> rulePaths, File input, File output, boolean sourceMode, String source, String target) throws IOException
{
ProjectModel pm = context.getFramed().addFramedVertex(ProjectModel.class);
pm.setName("Project: " + input.getAbsolutePath());
FileModel inputPath = context.getFramed().addFramedVertex(FileModel.class);
inputPath.setFilePath(input.getCanonicalPath());

FileUtils.deleteDirectory(output);
Files.createDirectories(output.toPath());

pm.setRootFileModel(inputPath);
WindupConfiguration windupConfiguration = new WindupConfiguration()
final WindupConfiguration windupConfiguration = new WindupConfiguration()
.setGraphContext(context);
windupConfiguration.addInputPath(Paths.get(inputPath.getFilePath()));
final String inputAbsolutePath = input.getAbsolutePath();
if (inputAbsolutePath.endsWith(MULTIPLE_STANDALONE_TEST_APPLICATIONS_MARKER)) {
try (Stream<Path> stream = Files.list(Paths.get(inputAbsolutePath.substring(0, inputAbsolutePath.indexOf(MULTIPLE_STANDALONE_TEST_APPLICATIONS_MARKER))))) {
stream.forEach(windupConfiguration::addInputPath);
}
} else {
windupConfiguration.addInputPath(Paths.get(inputAbsolutePath));
}
windupConfiguration.setOutputDirectory(output.toPath());
windupConfiguration.addDefaultUserRulesDirectory(baseRuleDirectory.toPath());
windupConfiguration.setOptionValue(SourceModeOption.NAME, sourceMode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;

import javax.inject.Inject;

Expand Down Expand Up @@ -78,6 +79,7 @@ public class WindupRulesTest

private static final String RUN_TEST_MATCHING = "runTestsMatching";
private static final String RUN_TEST_ID_MATCHING = "runTestIdMatching";
public static final String MULTIPLE_STANDALONE_TEST_APPLICATIONS_MARKER = "/*";

@Deployment
@AddonDependencies({
Expand Down Expand Up @@ -317,18 +319,19 @@ private Path getDefaultPath()

private void runWindup(GraphContext context, File baseRuleDirectory, final List<Path> rulePaths, File input, File output, boolean sourceMode, String source, String target) throws IOException
{
ProjectModel pm = context.getFramed().addFramedVertex(ProjectModel.class);
pm.setName("Project: " + input.getAbsolutePath());
FileModel inputPath = context.getFramed().addFramedVertex(FileModel.class);
inputPath.setFilePath(input.getCanonicalPath());

FileUtils.deleteDirectory(output);
Files.createDirectories(output.toPath());

pm.setRootFileModel(inputPath);
WindupConfiguration windupConfiguration = new WindupConfiguration()
final WindupConfiguration windupConfiguration = new WindupConfiguration()
.setGraphContext(context);
windupConfiguration.addInputPath(Paths.get(inputPath.getFilePath()));
final String inputAbsolutePath = input.getAbsolutePath();
if (inputAbsolutePath.endsWith(MULTIPLE_STANDALONE_TEST_APPLICATIONS_MARKER)) {
try (Stream<Path> stream = Files.list(Paths.get(inputAbsolutePath.substring(0, inputAbsolutePath.indexOf(MULTIPLE_STANDALONE_TEST_APPLICATIONS_MARKER))))) {
stream.forEach(windupConfiguration::addInputPath);
}
} else {
windupConfiguration.addInputPath(Paths.get(inputAbsolutePath));
}
windupConfiguration.setOutputDirectory(output.toPath());
windupConfiguration.addDefaultUserRulesDirectory(baseRuleDirectory.toPath());
windupConfiguration.setOptionValue(SourceModeOption.NAME, sourceMode);
Expand Down

0 comments on commit 6e80a0c

Please # to comment.