use of org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest method createRefactoring.
private static ExcludeArtifactRefactoring createRefactoring(IFile pomFile, ArtifactKey[] keys, IFile exclusionPoint) throws CoreException {
ExcludeArtifactRefactoring refactoring = new ExcludeArtifactRefactoring(keys);
IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().create(pomFile, true, monitor);
ParentGatherer g = new ParentGatherer(facade);
List<ParentHierarchyEntry> hierarchy = g.getParentHierarchy(monitor);
refactoring.setHierarchy(hierarchy);
ParentHierarchyEntry exclusionModel = null;
for (ParentHierarchyEntry model : hierarchy) {
if (exclusionPoint.equals(model.getResource())) {
exclusionModel = model;
break;
}
}
if (exclusionModel == null) {
fail("Exclusion point is not present in project parent hierarchy");
}
refactoring.setExclusionPoint(exclusionModel);
return refactoring;
}
use of org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest method testMultipleArtifactKeySinglePom.
/*
* A single pom with multiple exclusions
*/
@Test
public void testMultipleArtifactKeySinglePom() throws Exception {
IProject project = importProjects(EXCLUDE_PATH, new String[] { "noParent/pom.xml" }, new ResolverConfiguration())[0];
waitForJobsToComplete();
new FindEditorRunnable(project.getFile("pom.xml")).open();
ExcludeArtifactRefactoring refactoring = createRefactoring(project.getFile("pom.xml"), new ArtifactKey[] { VALID, VALID2 });
RefactoringStatus status = refactoring.checkInitialConditions(monitor);
assertTrue("Expected OK status from checkInitialConditions: " + status.toString(), status.isOK());
status = refactoring.checkFinalConditions(monitor);
assertTrue("Expected OK status from checkFinalConditions: " + status.toString(), status.isOK());
Change change = refactoring.createChange(monitor);
assertTrue(change.isEnabled());
assertTrue("Expected change to affect pom.xml", isAffected(project.getFile("pom.xml"), change));
Change undo = change.perform(monitor);
assertNotNull("Undo Operation", undo);
assertTrue("pom has exclusion set", hasExclusionSet(editor, ROOT, VALID));
assertTrue("pom has exclusion set", hasExclusionSet(editor, ROOT, VALID2));
}
use of org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest method testArtifactsInMultiplePom.
/*
* A pom with a workspace parent with exclusions in both
*/
@Test
public void testArtifactsInMultiplePom() throws Exception {
IProject[] projects = importProjects(EXCLUDE_PATH + "/workspaceParent2", new String[] { "workspaceParent2Module/pom.xml", "workspaceParent2Project/pom.xml" }, new ResolverConfiguration());
waitForJobsToComplete();
IProject module = getProject(projects, "workspaceParent2Module");
new FindEditorRunnable(module.getFile("pom.xml")).open();
ExcludeArtifactRefactoring refactoring = createRefactoring(module.getFile("pom.xml"), new ArtifactKey[] { VALID, VALID3 });
RefactoringStatus status = refactoring.checkInitialConditions(monitor);
assertTrue("Expected OK status from checkInitialConditions: " + status.toString(), status.isOK());
status = refactoring.checkFinalConditions(monitor);
assertTrue("Expected OK status from checkFinalConditions: " + status.toString(), status.isOK());
Change change = refactoring.createChange(monitor);
assertTrue(change.isEnabled());
assertTrue("Expected change to affect pom.xml", isAffected(module.getFile("pom.xml"), change));
Change undo = change.perform(monitor);
assertNotNull("Undo Operation", undo);
assertTrue("pom has exclusion set", hasExclusionSet(editor, ROOT, VALID));
assertTrue("pom has exclusion set", hasExclusionSet(editor, ROOT2, VALID3));
}
Aggregations