use of org.eclipse.m2e.model.edit.pom.Dependency in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest method hasExclusionSet.
/*
* The editor has the given exclusion set
*/
protected static boolean hasExclusionSet(MavenPomEditor editor, final ArtifactKey dependencyKey, final ArtifactKey excluded) throws Exception {
final boolean[] found = new boolean[1];
found[0] = false;
performOnDOMDocument(new OperationTuple(editor.getDocument(), document -> {
Element dep = findChild(findChild(document.getDocumentElement(), DEPENDENCIES), DEPENDENCY, childEquals(GROUP_ID, dependencyKey.getGroupId()), childEquals(ARTIFACT_ID, dependencyKey.getArtifactId()), childEquals(VERSION, dependencyKey.getVersion()));
if (dep != null) {
Element exclusion = findChild(findChild(dep, EXCLUSIONS), EXCLUSION, childEquals(GROUP_ID, excluded.getGroupId()), childEquals(ARTIFACT_ID, excluded.getArtifactId()));
found[0] = exclusion != null;
}
}, true));
return found[0];
}
use of org.eclipse.m2e.model.edit.pom.Dependency in project m2e-core-tests by tesla.
the class MavenModelEditTest method testManyChange.
@Test
public void testManyChange() throws Exception {
PomResourceImpl resource = loadModel("many.xml");
Model model = resource.getModel();
// Dependency dependency = model.getDependencies().getDependencyArray(0);
Dependency dependency = model.getDependencies().get(0);
dependency.setArtifactId("changed-maven-lifecycle");
assertEquals(loadFile("many_change.xml"), MavenModelUtil.toString(resource));
resource.unload();
}
use of org.eclipse.m2e.model.edit.pom.Dependency in project m2e-core-tests by tesla.
the class MavenModelEditTest method testManyAdd.
@Test
public void testManyAdd() throws Exception {
PomResourceImpl resource = loadModel("many.xml");
Model model = resource.getModel();
Dependency dependency = PomFactory.eINSTANCE.createDependency();
dependency.setGroupId("added-groupId");
dependency.setArtifactId("added-artifactId");
EList<Dependency> dependencies = model.getDependencies();
dependencies.add(dependency);
assertEquals(loadFile("many_add.xml"), MavenModelUtil.toString(resource));
resource.unload();
}
use of org.eclipse.m2e.model.edit.pom.Dependency in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest method hasExclusionSet.
/*
* The editor has the given exclusion set
*/
protected static boolean hasExclusionSet(IProject project, ArtifactKey dependencyKey, ArtifactKey excluded) throws Exception {
Model model = loadResource(project.getFile("pom.xml")).getModel();
Dependency d = null;
for (Dependency dep : model.getDependencies()) {
if (dep.getArtifactId().equals(dependencyKey.getArtifactId()) && dep.getGroupId().equals(dependencyKey.getGroupId()) && dep.getVersion().equals(dependencyKey.getVersion())) {
d = dep;
break;
}
}
if (d == null) {
return false;
}
for (Exclusion ex : d.getExclusions()) {
if (ex.getArtifactId().equals(excluded.getArtifactId()) && ex.getGroupId().equals(excluded.getGroupId())) {
return true;
}
}
return false;
}
Aggregations