/** Validate that the expected Properties Models were found */ private void validatePropertiesModels(GraphContext context) throws Exception { GraphService<PropertiesModel> service = new GraphService<>(context, PropertiesModel.class); int numberFound = 0; for (PropertiesModel model : service.findAll()) { numberFound++; Properties props = model.getProperties(); Assert.assertEquals("value1", props.getProperty("example1")); Assert.assertEquals("anothervalue", props.getProperty("anotherproperty")); Assert.assertEquals("1234", props.getProperty("timetaken")); } Assert.assertEquals(1, numberFound); }
@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()); } }