Add test for inserting maven dependency by smart completion
authorSergey Evdokimov <sergey.evdokimov@jetbrains.com>
Thu, 5 Sep 2013 18:03:01 +0000 (22:03 +0400)
committerSergey Evdokimov <sergey.evdokimov@jetbrains.com>
Thu, 5 Sep 2013 18:04:05 +0000 (22:04 +0400)
plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionTest.java

index d9b194b723071eb1303d58be7f6fc08839f34d76..93fb0f2943474141970982c5c8dde76dc877f31b 100644 (file)
@@ -1,5 +1,8 @@
 package org.jetbrains.idea.maven.dom;
 
+import com.intellij.codeInsight.completion.CompletionType;
+import com.intellij.codeInsight.lookup.LookupElement;
+
 import java.io.IOException;
 
 /**
@@ -14,11 +17,37 @@ public class MavenDependencyCompletionTest extends MavenDomWithIndicesTestCase {
 
                      "<dependencies>" +
                      "  <dependency>" +
-                     "    jun<caret>" +
+                     "    <caret>" +
                      "  </dependency>" +
                      "</dependencies>");
 
     assertCompletionVariantsInclude(myProjectPom, "junit:junit");
   }
 
+  public void testInsertDependency() throws IOException {
+    createProjectPom("<groupId>test</groupId>\n" +
+                     "<artifactId>project</artifactId>\n" +
+                     "<version>1</version>\n" +
+
+                     "<dependencies>\n" +
+                     "  <dependency>ju<caret></dependency>\n" +
+                     "</dependencies>\n");
+
+    configTest(myProjectPom);
+    myFixture.complete(CompletionType.SMART);
+    assertContain(myFixture.getLookupElementStrings(), "4.0", "3.8.2");
+
+    myFixture.checkResult(createPomXml("<groupId>test</groupId>\n" +
+                                       "<artifactId>project</artifactId>\n" +
+                                       "<version>1</version>\n" +
+
+                                       "<dependencies>\n" +
+                                       "    <dependency>\n" +
+                                       "        <groupId>junit</groupId>\n" +
+                                       "        <artifactId>junit</artifactId>\n" +
+                                       "        <version><caret></version>\n" +
+                                       "    </dependency>\n" +
+                                       "</dependencies>\n"));
+  }
+
 }