/** * Attach all project models within the application to the index. This will make it easy to * navigate from the projectModel to the application index. */ private void addAllProjectModels(ApplicationReportIndexModel navIdx, ProjectModel projectModel) { navIdx.addProjectModel(projectModel); for (ProjectModel childProject : projectModel.getChildProjects()) { if (!Iterators.asSet(navIdx.getProjectModels()).contains(childProject)) addAllProjectModels(navIdx, childProject); } }
@Test public void testNestedCondition() throws IOException { try (GraphContext context = factory.create()) { ProjectModel pm = context.getFramed().addVertex(null, ProjectModel.class); pm.setName("Main Project"); FileModel inputPath = context.getFramed().addVertex(null, FileModel.class); inputPath.setFilePath("src/test/resources/"); Path outputPath = Paths.get( FileUtils.getTempDirectory().toString(), "windup_" + UUID.randomUUID().toString()); FileUtils.deleteDirectory(outputPath.toFile()); Files.createDirectories(outputPath); inputPath.setProjectModel(pm); pm.setRootFileModel(inputPath); WindupConfiguration windupConfiguration = new WindupConfiguration() .setRuleProviderFilter( new NotPredicate( new RuleProviderPhasePredicate( MigrationRulesPhase.class, ReportGenerationPhase.class))) .setGraphContext(context); windupConfiguration.setInputPath(Paths.get(inputPath.getFilePath())); windupConfiguration.setOutputDirectory(outputPath); processor.execute(windupConfiguration); GraphService<ClassificationModel> classificationService = new GraphService<>(context, ClassificationModel.class); Assert.assertEquals(1, provider.getXmlFileMatches().size()); List<ClassificationModel> classifications = Iterators.asList(classificationService.findAll()); for (ClassificationModel model : classifications) { String classification = model.getClassification(); String classificationString = classification.toString(); Assert.assertEquals("Spring File", classificationString); } Assert.assertEquals(1, classifications.size()); Iterator<FileModel> iterator = classifications.get(0).getFileModels().iterator(); Assert.assertNotNull(iterator.next()); Assert.assertNotNull(iterator.next()); Assert.assertFalse(iterator.hasNext()); } }