Search in sources :

Example 6 with AddExclusionOperation

use of org.eclipse.m2e.core.ui.internal.editing.AddExclusionOperation 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 7 with AddExclusionOperation

use of org.eclipse.m2e.core.ui.internal.editing.AddExclusionOperation 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)

Aggregations

AddExclusionOperation (org.eclipse.m2e.core.ui.internal.editing.AddExclusionOperation)7 OperationTuple (org.eclipse.m2e.core.ui.internal.editing.PomEdits.OperationTuple)6 Test (org.junit.Test)6 ArtifactKey (org.eclipse.m2e.core.embedder.ArtifactKey)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Dependency (org.apache.maven.model.Dependency)1 IFile (org.eclipse.core.resources.IFile)1 IStatus (org.eclipse.core.runtime.IStatus)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 Status (org.eclipse.core.runtime.Status)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)1 AddDependencyOperation (org.eclipse.m2e.core.ui.internal.editing.AddDependencyOperation)1 CompoundOperation (org.eclipse.m2e.core.ui.internal.editing.PomEdits.CompoundOperation)1 Operation (org.eclipse.m2e.core.ui.internal.editing.PomEdits.Operation)1 RemoveDependencyOperation (org.eclipse.m2e.core.ui.internal.editing.RemoveDependencyOperation)1 ParentHierarchyEntry (org.eclipse.m2e.core.ui.internal.util.ParentHierarchyEntry)1