Search in sources :

Example 1 with ExcludeArtifactRefactoring

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));
}
Also used : ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) Change(org.eclipse.ltk.core.refactoring.Change) DocumentChange(org.eclipse.ltk.core.refactoring.DocumentChange) TextFileChange(org.eclipse.ltk.core.refactoring.TextFileChange) IProject(org.eclipse.core.resources.IProject) ExcludeArtifactRefactoring(org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring) Test(org.junit.Test)

Example 2 with ExcludeArtifactRefactoring

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));
}
Also used : ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IProject(org.eclipse.core.resources.IProject) ExcludeArtifactRefactoring(org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring) Test(org.junit.Test)

Example 3 with ExcludeArtifactRefactoring

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));
}
Also used : ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) Change(org.eclipse.ltk.core.refactoring.Change) DocumentChange(org.eclipse.ltk.core.refactoring.DocumentChange) TextFileChange(org.eclipse.ltk.core.refactoring.TextFileChange) IProject(org.eclipse.core.resources.IProject) ExcludeArtifactRefactoring(org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring) Test(org.junit.Test)

Example 4 with ExcludeArtifactRefactoring

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));
}
Also used : ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) Change(org.eclipse.ltk.core.refactoring.Change) DocumentChange(org.eclipse.ltk.core.refactoring.DocumentChange) TextFileChange(org.eclipse.ltk.core.refactoring.TextFileChange) IProject(org.eclipse.core.resources.IProject) ExcludeArtifactRefactoring(org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring) Test(org.junit.Test)

Example 5 with ExcludeArtifactRefactoring

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));
}
Also used : ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) Change(org.eclipse.ltk.core.refactoring.Change) DocumentChange(org.eclipse.ltk.core.refactoring.DocumentChange) TextFileChange(org.eclipse.ltk.core.refactoring.TextFileChange) IProject(org.eclipse.core.resources.IProject) ExcludeArtifactRefactoring(org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring) Test(org.junit.Test)

Aggregations

ExcludeArtifactRefactoring (org.eclipse.m2e.refactoring.exclude.ExcludeArtifactRefactoring)13 IProject (org.eclipse.core.resources.IProject)12 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)12 ResolverConfiguration (org.eclipse.m2e.core.project.ResolverConfiguration)12 Test (org.junit.Test)12 Change (org.eclipse.ltk.core.refactoring.Change)11 CompositeChange (org.eclipse.ltk.core.refactoring.CompositeChange)11 DocumentChange (org.eclipse.ltk.core.refactoring.DocumentChange)11 TextFileChange (org.eclipse.ltk.core.refactoring.TextFileChange)11 IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)1 ParentGatherer (org.eclipse.m2e.core.ui.internal.util.ParentGatherer)1 ParentHierarchyEntry (org.eclipse.m2e.core.ui.internal.util.ParentHierarchyEntry)1