JaroslavTulach commented on a change in pull request #2601:
URL: https://github.com/apache/netbeans/pull/2601#discussion_r544439344



##########
File path: 
java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java
##########
@@ -888,6 +891,73 @@ public void logMessage(MessageParams arg0) {
                          "<none>:1:26-1:29", "<none>:2:12-2:15", 
"<none>:3:17-3:20");
     }
 
+    public void testHover() throws Exception {
+        File src = new File(getWorkDir(), "Test.java");
+        src.getParentFile().mkdirs();
+        String code = "public class Test {\n" +
+                      "    public static void main(String[] args) {\n" +
+                      "        System.out.println(\"Hello World!\");\n" +
+                      "    }\n" +
+                      "}\n";
+        try (Writer w = new FileWriter(src)) {
+            w.write(code);
+        }
+        FileUtil.refreshFor(getWorkDir());
+        Launcher<LanguageServer> serverLauncher = 
LSPLauncher.createClientLauncher(new LanguageClient() {
+            @Override
+            public void telemetryEvent(Object arg0) {
+                throw new UnsupportedOperationException("Not supported yet.");
+            }
+
+            @Override
+            public void publishDiagnostics(PublishDiagnosticsParams params) {
+            }
+
+            @Override
+            public void showMessage(MessageParams arg0) {
+            }
+
+            @Override
+            public CompletableFuture<MessageActionItem> 
showMessageRequest(ShowMessageRequestParams arg0) {
+                throw new UnsupportedOperationException("Not supported yet.");
+            }
+
+            @Override
+            public void logMessage(MessageParams arg0) {
+                throw new UnsupportedOperationException("Not supported yet.");
+            }
+        }, client.getInputStream(), client.getOutputStream());
+        serverLauncher.startListening();
+        LanguageServer server = serverLauncher.getRemoteProxy();
+        InitializeResult result = server.initialize(new 
InitializeParams()).get();
+        assertTrue(result.getCapabilities().getHoverProvider());
+        Hover hover = server.getTextDocumentService().hover(new 
HoverParams(new TextDocumentIdentifier(toURI(src)), new Position(2, 10))).get();
+        assertNotNull(hover);
+        assertTrue(hover.getContents().isRight());
+        MarkupContent content = hover.getContents().getRight();
+        assertNotNull(content);
+        assertEquals(content.getKind(), "markdown");
+        assertEquals(content.getValue(), "**[java.​lang](*0)**\n" +
+                "\n" +
+                "```\n" +
+                "public final class System\n" +

Review comment:
       Isn't this test too JDK specific? What if the wording of the Javadoc 
changes between the various JDKs? Then the test would fail.
   
   It might be safer to create own class with Javadoc and test against it. That 
one would be stable.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to