summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2018-06-24 21:41:30 -0700
committerGeorge Fraser <george@fivetran.com>2018-06-24 21:41:30 -0700
commit7ffa86096407093b2cee11ee200529f98ffa4112 (patch)
tree1981f2ccd403c6ac5053f0e47c4ef398c90fe3a6 /src/test
parent2b1145e1a05d7936124fa587942f8ceb806414c0 (diff)
downloadjava-language-server-7ffa86096407093b2cee11ee200529f98ffa4112.zip
fixImports
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/javacs/JavaCompilerServiceTest.java11
-rw-r--r--src/test/resources/MissingImport.java5
2 files changed, 14 insertions, 2 deletions
diff --git a/src/test/java/org/javacs/JavaCompilerServiceTest.java b/src/test/java/org/javacs/JavaCompilerServiceTest.java
index 8320d0c..a067323 100644
--- a/src/test/java/org/javacs/JavaCompilerServiceTest.java
+++ b/src/test/java/org/javacs/JavaCompilerServiceTest.java
@@ -259,8 +259,8 @@ public class JavaCompilerServiceTest {
MethodInvocation found =
compiler.methodInvocation(URI.create("/Overloads.java"), contents("/Overloads.java"), 3, 15).get();
- assertThat(
- found.overloads, containsInAnyOrder(hasToString("print(int)"), hasToString("print(java.lang.String)")));
+ assertThat(found.overloads, hasItem(hasToString("print(int)")));
+ assertThat(found.overloads, hasToString("print(java.lang.String)"));
}
@Test
@@ -281,4 +281,11 @@ public class JavaCompilerServiceTest {
assertTrue(doc.isPresent());
assertThat(Javadocs.commentText(doc.get()).orElse("<empty>"), containsString("A great method"));
}
+
+ @Test
+ public void fixImports() {
+ Set<String> qualifiedNames =
+ compiler.fixImports(resourceUri("/MissingImport.java"), contents("/MissingImport.java"));
+ assertThat(qualifiedNames, hasItem("java.util.List"));
+ }
}
diff --git a/src/test/resources/MissingImport.java b/src/test/resources/MissingImport.java
new file mode 100644
index 0000000..79f0d92
--- /dev/null
+++ b/src/test/resources/MissingImport.java
@@ -0,0 +1,5 @@
+class MissingImport {
+ void test() {
+ List<String> x = null;
+ }
+} \ No newline at end of file