blob: eb764beb10a601cbd95859497d97e496c9e7e195 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package org.javacs;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
public class DocsTest {
@Before
public void setWorkspaceRoot() {
FileStore.setWorkspaceRoots(Set.of(LanguageServerFixture.SIMPLE_WORKSPACE_ROOT));
}
@Test
public void classDoc() {
var sourcePath = Set.of(JavaCompilerServiceTest.simpleProjectSrc());
var docs = new Docs(sourcePath);
var ptr = new Ptr("ClassDoc");
var file = docs.find(ptr).get();
var parse = docs.parse(file);
var path = parse.fuzzyFind(ptr).get();
var tree = parse.doc(path);
assertThat(tree.getFirstSentence(), hasToString("A great class"));
}
@Test
public void memberDoc() {
var sourcePath = Set.of(JavaCompilerServiceTest.simpleProjectSrc());
var docs = new Docs(sourcePath);
var ptr = new Ptr("LocalMethodDoc#targetMethod(int)");
var file = docs.find(ptr).get();
var parse = docs.parse(file);
var path = parse.fuzzyFind(ptr).get();
var tree = parse.doc(path);
assertThat(tree.getFirstSentence(), hasToString("A great method"));
}
@Test
public void platformDoc() {
var docs = new Docs(Set.of());
var ptr = new Ptr("java.util/List");
var file = docs.find(ptr).get();
var parse = docs.parse(file);
var path = parse.fuzzyFind(ptr).get();
var tree = parse.doc(path);
assertThat(tree.getFirstSentence(), not(empty()));
}
}
|