Search in sources :

Example 6 with ExcludeArtifactRefactoring

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));
}
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 7 with ExcludeArtifactRefactoring

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));
}
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 8 with ExcludeArtifactRefactoring

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));
}
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 9 with ExcludeArtifactRefactoring

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));
}
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 10 with ExcludeArtifactRefactoring

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));
}
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