@Test public void testUpdatePomArtifactId() { PomXmlWriter.updatePomArtifactId(document, "koala-commons-codechecker-2"); DocumentUtil.document2Xml(xmlPath, document); Document document2 = DocumentUtil.readDocument(xmlPath); String artifactId = PomXmlReader.queryText("/xmlns:project/xmlns:artifactId", document2); Assert.assertEquals(artifactId, "koala-commons-codechecker-2"); }
@Test public void testUpdateModules() { List<String> modules = new ArrayList<String>(); modules.add("bbb"); PomXmlWriter.updateModules(document, modules); List<String> newModules = PomXmlReader.queryModules(document); Assert.assertTrue(modules.equals(newModules)); }
@Test public void testUpdateDependency() { Dependency dependency = new Dependency("com.puppycrawl.tools", "checkstyle", "5.6"); Dependency newdependency = new Dependency("com.puppycrawl.tools", "checkstyle-core", "5.7"); PomXmlWriter.updateDependency(document, dependency, newdependency); List<String> artifactIds = PomXmlReader.queryListText( "/xmlns:project/xmlns:dependencies/xmlns:dependency/xmlns:artifactId", document); boolean artifactIdChanged = false; for (String artifactId : artifactIds) { if (artifactId.equals("checkstyle-core")) { artifactIdChanged = true; break; } } Assert.assertTrue(artifactIdChanged); }