ProjectService { public List<Module> getModules() { List<Module> modules = new ArrayList<>(); Collection<String> allModules = new SpringBeanNamespacePrefixMapper().getNamespaceMappings().values(); if (project.isMavenProject()) { try { String pomXml = FileUtils.readToString(new FileSystemResource(project.getMavenPomFile())); SimpleNamespaceContext nsContext = new SimpleNamespaceContext(); nsContext.bindNamespaceUri("mvn", "http: Document pomDoc = XMLUtils.parseMessagePayload(pomXml); NodeList dependencies = XPathUtils.evaluateAsNodeList(pomDoc, "/mvn:project/mvn:dependencies/mvn:dependency/mvn:artifactId[starts-with(., 'citrus-')]", nsContext); for (int i = 0; i < dependencies.getLength(); i++) { String moduleName = DomUtils.getTextValue((Element) dependencies.item(i)); if (moduleName.equals("citrus-core")) { allModules.remove("citrus"); } else { allModules.remove(moduleName); } modules.add(new Module(moduleName.substring("citrus-".length()), project.getVersion(), true)); } } catch (IOException e) { throw new ApplicationRuntimeException("Unable to open Maven pom.xml file", e); } } allModules.stream() .filter(name -> !name.equals("citrus-test")) .map(name -> name.equals("citrus") ? "citrus-core" : name) .map(name -> new Module(name.substring("citrus-".length()), project.getVersion(), false)) .forEach(modules::add); return modules; }  @PostConstruct void loadDefaultProject(); Project load(String projectHomeDir); Project create(Repository repository); Project create(MavenArchetype archetype); File getSpringXmlApplicationContextFile(); File getSpringJavaConfigFile(); boolean hasSpringXmlApplicationContext(); boolean hasSpringJavaConfig(); void update(Project project); void saveProjectInfo(Project project); Properties getProjectProperties(); boolean validateProject(Project project); Project getActiveProject(); void closeActiveProject(); void setActiveProject(Project project); void addConnector(); void removeConnector(); List<Module> getModules(); void add(Module module); void remove(Module module); String getCloneDownloadUrl(Repository repository); void setFileBrowserService(FileBrowserService fileBrowserService); void setSpringBeanService(SpringBeanService springBeanService); void setSpringJavaConfigService(SpringJavaConfigService springJavaConfigService); void setEnvironment(Environment environment); String[] getRecentProjects(); void setProject(Project project);  }
@Test public void testGetModules() throws Exception { Project testProject = new Project(new ClassPathResource("projects/maven").getFile().getCanonicalPath()); projectService.setActiveProject(testProject); List<Module> modules = projectService.getModules(); Assert.assertEquals(modules.size(), new SpringBeanNamespacePrefixMapper().getNamespaceMappings().size()); Assert.assertTrue(modules.stream().anyMatch(module -> module.isActive() && module.getName().equals("core"))); Assert.assertTrue(modules.stream().anyMatch(module -> module.isActive() && module.getName().equals("java-dsl"))); Assert.assertTrue(modules.stream().anyMatch(module -> module.isActive() && module.getName().equals("http"))); Assert.assertTrue(modules.stream().anyMatch(module -> module.isActive() && module.getName().equals("jms"))); Assert.assertTrue(modules.stream().anyMatch(module -> module.isActive() && module.getName().equals("ws"))); }