summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2018-12-23 17:19:09 -0800
committerGeorge Fraser <george@fivetran.com>2018-12-23 17:19:09 -0800
commit888fe5075feedaf427c66a06a68089b62672beed (patch)
treeac79a0ed51131cc82f4176d93abc11d88b34ad85 /src/test/java
parentb6ad35a751145fb1e4b820d5ea11fc596a2d156d (diff)
downloadjava-language-server-888fe5075feedaf427c66a06a68089b62672beed.zip
Find references code lens, room for optimization
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/javacs/CodeLensTest.java2
-rw-r--r--src/test/java/org/javacs/JavaCompilerServiceTest.java12
2 files changed, 8 insertions, 6 deletions
diff --git a/src/test/java/org/javacs/CodeLensTest.java b/src/test/java/org/javacs/CodeLensTest.java
index 6f0c802..ec7bd04 100644
--- a/src/test/java/org/javacs/CodeLensTest.java
+++ b/src/test/java/org/javacs/CodeLensTest.java
@@ -6,6 +6,7 @@ import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
+import java.util.Optional;
import java.util.StringJoiner;
import java.util.concurrent.ExecutionException;
import org.eclipse.lsp4j.CodeLens;
@@ -32,6 +33,7 @@ public class CodeLensTest {
for (var lens : lenses) {
var command = new StringJoiner(", ");
for (var arg : lens.getCommand().getArguments()) {
+ if (arg instanceof Optional) arg = ((Optional) arg).orElse(null);
command.add(Objects.toString(arg));
}
commands.add(command.toString());
diff --git a/src/test/java/org/javacs/JavaCompilerServiceTest.java b/src/test/java/org/javacs/JavaCompilerServiceTest.java
index b5a7f9b..6023337 100644
--- a/src/test/java/org/javacs/JavaCompilerServiceTest.java
+++ b/src/test/java/org/javacs/JavaCompilerServiceTest.java
@@ -227,16 +227,16 @@ public class JavaCompilerServiceTest {
var stringify = new ArrayList<String>();
for (var t : refs) {
var unit = t.getCompilationUnit();
- var name = unit.getSourceFile().getName();
+ var name = Paths.get(unit.getSourceFile().toUri()).getFileName();
var trees = compiler.trees();
var pos = trees.getSourcePositions();
var lines = unit.getLineMap();
var start = pos.getStartPosition(unit, t.getLeaf());
var line = lines.getLineNumber(start);
- if (name.endsWith("GotoDefinition.java") && line == 3) return;
stringify.add(String.format("%s:%d", name, line));
}
- fail(String.format("No GotoDefinition.java:3 in %s", stringify));
+ assertThat(stringify, hasItem("GotoDefinition.java:3"));
+ assertThat(stringify, not(hasItem("GotoDefinition.java:6")));
}
@Test
@@ -245,10 +245,10 @@ public class JavaCompilerServiceTest {
var refs = compiler.referencesFile(resourceUri(file), contents(file), rrp);
var stringify = new ArrayList<String>();
for (var r : refs) {
- if (r.fromFile.toString().endsWith("GotoDefinition.java")) return;
- stringify.add(String.format("%s:%d", r.fromFile, r.startLine));
+ var fileName = Paths.get(r.fromFile).getFileName();
+ stringify.add(String.format("%s:%d", fileName, r.startLine));
}
- fail(String.format("No GotoDefinition.java in %s", stringify));
+ assertThat(stringify, hasItem("GotoDefinition.java:3"));
}
@Test