/**
  * 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);
   }
 }
Ejemplo n.º 2
0
  @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());
    }
  }
  private void createReportIndex(GraphContext context, ProjectModel projectModel) {
    ApplicationReportService service = new ApplicationReportService(context);
    ApplicationReportModel applicationReportModel = service.create();
    applicationReportModel.setReportPriority(100);
    applicationReportModel.setDisplayInApplicationReportIndex(true);
    applicationReportModel.setReportName(REPORT_INDEX);
    applicationReportModel.setReportIconClass("glyphicon glyphicon-th-list");
    applicationReportModel.setMainApplicationReport(true);
    applicationReportModel.setTemplatePath(TEMPLATE);
    applicationReportModel.setTemplateType(TemplateType.FREEMARKER);
    applicationReportModel.setProjectModel(projectModel);
    applicationReportModel.setDescription(
        "This report provides summary information about findings from the migration analysis, as well as links to additional reports with detailed information.");

    // Set the filename for the report
    ReportService reportService = new ReportService(context);
    reportService.setUniqueFilename(
        applicationReportModel, "report_index_" + projectModel.getName(), "html");
  }