use of org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest method testCopyDown.
@Test
public void testCopyDown() throws Exception {
IProject[] projects = importProjects(EXCLUDE_PATH + "/workspaceParentWithDependency", new String[] { "workspaceParentWithDependencyProject/pom.xml", "workspaceParentWithDependencyModule/pom.xml" }, new ResolverConfiguration());
waitForJobsToComplete();
IProject module = getProject(projects, "workspaceParentWithDependencyModule");
new FindEditorRunnable(module.getFile("pom.xml")).open();
ExcludeArtifactRefactoring refactoring = createRefactoring(module.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 module to be changed", isAffected(module.getFile("pom.xml"), change));
Change undo = change.perform(monitor);
assertNotNull("Undo Operation", undo);
assertTrue("project has exclusion set", hasExclusionSet(module, ROOT, VALID));
}
use of org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest method testSingleArtifactKeyWorkspaceParent.
/*
* A pom with a workspace parent and a single valid exclude
*/
@Test
public void testSingleArtifactKeyWorkspaceParent() throws Exception {
IProject[] projects = importProjects(EXCLUDE_PATH + "/workspaceParent", new String[] { "workspaceParentProject/pom.xml", "workspaceParentModule/pom.xml" }, new ResolverConfiguration());
waitForJobsToComplete();
IProject project = getProject(projects, "workspaceParentModule");
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 module's 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 testSingleArtifactNoParent.
/*
* A pom without a parent and a valid exclusion
*/
@Test
public void testSingleArtifactNoParent() 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 });
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 testMultipleArtifactWithMissing.
/*
* A pom without a parent, a missing dependency and a valid dependency
*/
@Test
public void testMultipleArtifactWithMissing() 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, 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.ERROR, status.getSeverity());
assertTrue("Missing Dependency Expected", hasMessage("Unable to locate source for dependency a-fake-artifact:that-should-never-exist:1.2.3 in the workspace.", status));
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 testStrangePomName.
/*
* A pom with strange name
*/
@Test
public void testStrangePomName() throws Exception {
IProject project = importProjects(EXCLUDE_PATH, new String[] { "noParent/test-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 test-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));
}
Aggregations