private Path executeWindupAgainstAppUntilRule( final String inputDir, final GraphContext grCtx, final Class<MavenizeRuleProvider> ruleToRunUpTo) throws IOException, IllegalAccessException, InstantiationException { Assume.assumeTrue("Exists: " + inputDir, new File(inputDir).exists()); final Path outputPath = Paths.get(FileUtils.getTempDirectory().toString(), "Windup-Mavenization-output"); FileUtils.deleteDirectory(outputPath.toFile()); Files.createDirectories(outputPath); grCtx.getGraph().getBaseGraph().commit(); // Configure Windup core final WindupConfiguration processorConfig = new WindupConfiguration(); processorConfig.setRuleProviderFilter(new RuleProviderWithDependenciesPredicate(ruleToRunUpTo)); processorConfig.setGraphContext(grCtx); processorConfig.addInputPath(Paths.get(inputDir)); processorConfig.setOutputDirectory(outputPath); processorConfig.setOptionValue(ScanPackagesOption.NAME, Collections.singletonList("")); processorConfig.setOptionValue(SourceModeOption.NAME, false); processorConfig.setOptionValue(MavenizeOption.NAME, true); processor.execute(processorConfig); return outputPath; }
@Test public void testMetadataFound() throws Exception { String inputPath = "src/test/resources/NonNamespacedMavenDiscoveryTest"; final Path outputPath = getDefaultPath(); FileUtils.deleteDirectory(outputPath.toFile()); Files.createDirectories(outputPath); try (GraphContext context = factory.create(outputPath)) { final WindupConfiguration processorConfig = new WindupConfiguration(); processorConfig.setOptionValue(SourceModeOption.NAME, true); Predicate<RuleProvider> ruleFilter = new AndPredicate(new RuleProviderWithDependenciesPredicate(MigrationRulesPhase.class)); processorConfig.setRuleProviderFilter(ruleFilter); processorConfig.setGraphContext(context); processorConfig.addInputPath(Paths.get(inputPath)); processorConfig.setOutputDirectory(outputPath); processorConfig.setOptionValue(ScanPackagesOption.NAME, Collections.singletonList("")); processor.execute(processorConfig); ProjectModel project = WindupConfigurationService.getConfigurationModel(context) .getInputPaths() .iterator() .next() .getProjectModel(); Assert.assertTrue("Maven Project Expected", project instanceof MavenProjectModel); MavenProjectModel mavenProject = (MavenProjectModel) project; Assert.assertEquals("testgroupid", mavenProject.getGroupId()); Assert.assertEquals("testartifactid", mavenProject.getArtifactId()); Assert.assertEquals("testname", mavenProject.getName()); Assert.assertEquals("1.0.0.testversion", mavenProject.getVersion()); Assert.assertEquals("testdescription", mavenProject.getDescription()); Assert.assertEquals(1, Iterables.size(mavenProject.getDependencies())); ProjectDependencyModel dependency = mavenProject.getDependencies().iterator().next(); Assert.assertEquals( "testdependency-groupid", ((MavenProjectModel) dependency.getProjectModel()).getGroupId()); Assert.assertEquals( "testdependency-artifactid", ((MavenProjectModel) dependency.getProjectModel()).getArtifactId()); Assert.assertEquals("1.4", dependency.getProjectModel().getVersion()); } }