Search in sources :

Example 26 with OperationTuple

use of org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple in project m2e-core-tests by tesla.

the class AddExclusionOperationTest method testAddExclusion_existingExclusion.

@Test
public void testAddExclusion_existingExclusion() throws Exception {
    document.setText(// 
    StructuredModelManager.getModelManager(), "<project><dependencies>" + // 
    "<dependency><groupId>AAA</groupId><artifactId>BBB</artifactId><version>1.0</version></dependency>" + // 
    "<dependency><groupId>AAAB</groupId><artifactId>BBB</artifactId><version>1.0</version></dependency>" + // 
    "<dependency><groupId>AAA</groupId><artifactId>BBBB</artifactId><version>1.0</version>" + // 
    "<exclusions><exclusion><groupId>g</groupId><artifactId>b</artifactId><version>1.0</version></exclusion></exclusions></dependency>" + // 
    "</dependencies></project>");
    PomEdits.performOnDOMDocument(new OperationTuple(tempModel, new AddExclusionOperation(d, e)));
    assertEquals("Expected no dependency: " + d.toString() + "\n" + document.getText(), 1, dependencyCount(tempModel, d));
    assertTrue("Has exclusion " + e.toString() + "\n" + document.getText(), hasExclusion(tempModel, d, e));
    ArtifactKey key = new ArtifactKey("g", "b", "1.0", null);
    assertTrue("Existing Exclusion Present " + key.toString() + "\n" + document.getText(), hasExclusion(tempModel, d, key));
    assertEquals("Exclusions", 2, getExclusionCount(tempModel, d));
    assertEquals("Dependency Count: \n" + document.getText(), 3, getDependencyCount(tempModel));
}
Also used : OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) ArtifactKey(org.eclipse.m2e.core.embedder.ArtifactKey) AddExclusionOperation(org.eclipse.m2e.core.ui.internal.editing.AddExclusionOperation) Test(org.junit.Test)

Example 27 with OperationTuple

use of org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple in project m2e-core-tests by tesla.

the class AddExclusionOperationTest method testMissingDependency_noDependenciesElement.

@Test
public void testMissingDependency_noDependenciesElement() throws Exception {
    // 
    document.setText(// 
    StructuredModelManager.getModelManager(), "<project></project>");
    PomEdits.performOnDOMDocument(new OperationTuple(tempModel, new AddExclusionOperation(d, e)));
    assertEquals("Expected no dependency: " + d.toString() + "\n" + document.getText(), 0, dependencyCount(tempModel, d));
}
Also used : OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) AddExclusionOperation(org.eclipse.m2e.core.ui.internal.editing.AddExclusionOperation) Test(org.junit.Test)

Example 28 with OperationTuple

use of org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple in project m2e-core-tests by tesla.

the class AddExclusionOperationTest method testAddExclusion_duplicateExclusion.

@Test
public void testAddExclusion_duplicateExclusion() throws Exception {
    document.setText(// 
    StructuredModelManager.getModelManager(), "<project><dependencies>" + // 
    "<dependency><groupId>AAA</groupId><artifactId>BBB</artifactId><version>1.0</version></dependency>" + // 
    "<dependency><groupId>AAAB</groupId><artifactId>BBB</artifactId><version>1.0</version></dependency>" + // 
    "<dependency><groupId>AAA</groupId><artifactId>BBBB</artifactId><version>1.0</version>" + // 
    "<exclusions><exclusion><groupId>g</groupId><artifactId>a</artifactId><version>1.0</version></exclusion></exclusions></dependency>" + // 
    "</dependencies></project>");
    PomEdits.performOnDOMDocument(new OperationTuple(tempModel, new AddExclusionOperation(d, e)));
    assertEquals("Expected no dependency: " + d.toString() + "\n" + document.getText(), 1, dependencyCount(tempModel, d));
    assertTrue("Has exclusion " + e.toString() + "\n" + document.getText(), hasExclusion(tempModel, d, e));
    assertEquals("Exclusions", 1, getExclusionCount(tempModel, d));
    assertEquals("Dependency Count: \n" + document.getText(), 3, getDependencyCount(tempModel));
}
Also used : OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) AddExclusionOperation(org.eclipse.m2e.core.ui.internal.editing.AddExclusionOperation) Test(org.junit.Test)

Example 29 with OperationTuple

use of org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple in project m2e-core-tests by tesla.

the class RemoveDependencyOperationTest method testRemoveDependency.

@Test
public void testRemoveDependency() throws Exception {
    // 
    document.setText(// 
    StructuredModelManager.getModelManager(), // 
    "<project><dependencies>" + // 
    "<dependency><groupId>AAA</groupId><artifactId>BBB</artifactId><version>1.0</version></dependency>" + // 
    "<dependency><groupId>AAAB</groupId><artifactId>BBB</artifactId><version>1.0</version></dependency>" + // 
    "<dependency><groupId>AAA</groupId><artifactId>BBBB</artifactId><version>1.0</version></dependency>" + "</dependencies></project>");
    PomEdits.performOnDOMDocument(new OperationTuple(tempModel, new RemoveDependencyOperation(d)));
    assertEquals("Expected dependency removed: " + d.toString() + "\n" + document.getText(), 0, dependencyCount(tempModel, d));
    assertEquals("Dependency Count: \n" + document.getText(), 2, getDependencyCount(tempModel));
}
Also used : OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) RemoveDependencyOperation(org.eclipse.m2e.core.ui.internal.editing.RemoveDependencyOperation) Test(org.junit.Test)

Example 30 with OperationTuple

use of org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple in project m2e-core-tests by tesla.

the class RemoveDependencyOperationTest method testMissingDependency_noDependenciesElement.

@Test
public void testMissingDependency_noDependenciesElement() throws Exception {
    // 
    document.setText(// 
    StructuredModelManager.getModelManager(), "<project></project>");
    PomEdits.performOnDOMDocument(new OperationTuple(tempModel, new RemoveDependencyOperation(d)));
    assertEquals("Expected dependency removed: " + d.toString() + "\n" + document.getText(), 0, dependencyCount(tempModel, d));
    assertEquals("Dependency Count: \n" + document.getText(), 0, getDependencyCount(tempModel));
}
Also used : OperationTuple(org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple) RemoveDependencyOperation(org.eclipse.m2e.core.ui.internal.editing.RemoveDependencyOperation) Test(org.junit.Test)

Aggregations

OperationTuple (org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple)30 Test (org.junit.Test)16 IFile (org.eclipse.core.resources.IFile)11 Element (org.w3c.dom.Element)11 CoreException (org.eclipse.core.runtime.CoreException)9 IStatus (org.eclipse.core.runtime.IStatus)8 IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)8 Operation (org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)7 Status (org.eclipse.core.runtime.Status)7 Job (org.eclipse.core.runtime.jobs.Job)7 IProject (org.eclipse.core.resources.IProject)6 AddExclusionOperation (org.eclipse.m2e.core.ui.internal.editing.AddExclusionOperation)6 PomEdits.findChild (org.eclipse.m2e.core.ui.internal.editing.PomEdits.findChild)6 PomEdits.performOnDOMDocument (org.eclipse.m2e.core.ui.internal.editing.PomEdits.performOnDOMDocument)6 NLS (org.eclipse.osgi.util.NLS)6 List (java.util.List)5 ArtifactKey (org.eclipse.m2e.core.embedder.ArtifactKey)5 ARTIFACT_ID (org.eclipse.m2e.core.ui.internal.editing.PomEdits.ARTIFACT_ID)5 GROUP_ID (org.eclipse.m2e.core.ui.internal.editing.PomEdits.GROUP_ID)5