use of org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest method testSingleArtifactNoParentBadFormat.
/*
* A pom without a parent and a valid exclusion, but with inconsistent whitespace formatting
*/
@Test
public void testSingleArtifactNoParentBadFormat() throws Exception {
IProject project = importProjects(EXCLUDE_PATH, new String[] { "noParentBadFormat/pom.xml" }, new ResolverConfiguration())[0];
waitForJobsToComplete();
new FindEditorRunnable(project.getFile("pom.xml")).open();
ExcludeArtifactRefactoring refactoring = createRefactoring(project.getFile("pom.xml"), new ArtifactKey[] { VALID });
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));
}
use of org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest method testSingleArtifactMissing.
/*
* A pom with no parent, told to exclude an artifact that does not exist
*/
@Test
public void testSingleArtifactMissing() 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[] { MISSING });
RefactoringStatus status = refactoring.checkInitialConditions(monitor);
assertEquals("Expected OK status from checkInitialConditions: ", RefactoringStatus.OK, status.getSeverity());
status = refactoring.checkFinalConditions(monitor);
assertEquals("Expected FATAL status from checkFinalConditions: ", RefactoringStatus.FATAL, status.getSeverity());
assertTrue("Refactoring Message", hasMessage("Unable to locate source for dependency.", status));
}
use of org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest method testPullUp.
@Test
public void testPullUp() throws Exception {
IProject[] projects = importProjects(EXCLUDE_PATH + "/workspaceParent", new String[] { "workspaceParentProject/pom.xml", "workspaceParentModule/pom.xml" }, new ResolverConfiguration());
waitForJobsToComplete();
IProject module = getProject(projects, "workspaceParentModule");
IProject project = getProject(projects, "workspaceParentProject");
new FindEditorRunnable(module.getFile("pom.xml")).open();
ExcludeArtifactRefactoring refactoring = createRefactoring(module.getFile("pom.xml"), new ArtifactKey[] { VALID }, project.getFile("pom.xml"));
RefactoringStatus status = refactoring.checkFinalConditions(monitor);
assertTrue("Expected OK status from checkFinalConditions: " + status.toString(), status.isOK());
Change change = refactoring.createChange(monitor);
assertTrue(change.isEnabled());
assertTrue("Expected module to be changed", isAffected(module.getFile("pom.xml"), change));
assertTrue("Expected module to be changed", isAffected(project.getFile("pom.xml"), change));
Change undo = change.perform(monitor);
assertNotNull("Undo Operation", undo);
assertTrue("project has exclusion set", hasExclusionSet(project, ROOT, VALID));
}
use of org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest method testSingleArtifactKeyRemoteParent.
/*
* A pom with a remote parent and a valid exclude
*/
@Test
public void testSingleArtifactKeyRemoteParent() throws Exception {
IProject project = importProjects(EXCLUDE_PATH, new String[] { "hasRemoteParent/pom.xml" }, new ResolverConfiguration())[0];
waitForJobsToComplete();
new FindEditorRunnable(project.getFile("pom.xml")).open();
ExcludeArtifactRefactoring refactoring = createRefactoring(project.getFile("pom.xml"), new ArtifactKey[] { VALID });
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 local 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));
}
use of org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest method testSingleArtifactKeyInWorkspaceParent.
/*
* A pom with a workspace parent and an exclude which takes place on the
* parent.
*/
@Test
public void testSingleArtifactKeyInWorkspaceParent() throws Exception {
IProject[] projects = importProjects(EXCLUDE_PATH + "/workspaceParentWithDependency", new String[] { "workspaceParentWithDependencyProject/pom.xml", "workspaceParentWithDependencyModule/pom.xml" }, new ResolverConfiguration());
waitForJobsToComplete();
IProject project = getProject(projects, "workspaceParentWithDependencyModule");
new FindEditorRunnable(project.getFile("pom.xml")).open();
ExcludeArtifactRefactoring refactoring = createRefactoring(project.getFile("pom.xml"), new ArtifactKey[] { VALID });
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 parent to be changed", isAffected(getProject(projects, "workspaceParentWithDependencyModule").getFile("pom.xml"), change));
Change undo = change.perform(monitor);
assertNotNull("Undo Operation", undo);
assertTrue("pom has exclusion set", hasExclusionSet(getProject(projects, "workspaceParentWithDependencyModule"), ROOT, VALID));
}
Aggregations