summaryrefslogtreecommitdiff
path: root/src/test/java/org/javacs/ParserFixImportsTest.java
blob: 8eb1fcb35c8c449e89d09e9078a53349668e1ce1 (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
package org.javacs;

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

import java.io.IOException;
import java.nio.file.Files;
import java.util.stream.Collectors;
import org.junit.Test;

public class ParserFixImportsTest {
    @Test
    public void findExistingImports() throws IOException {
        var allJavaFiles =
                Files.walk(JavaCompilerServiceTest.simpleProjectSrc())
                        .filter(f -> f.getFileName().toString().endsWith(".java"))
                        .collect(Collectors.toSet());
        assertThat(allJavaFiles, not(empty()));

        var find = Parser.existingImports(allJavaFiles);
        assertThat(find.classes, hasItem("java.util.List"));
        assertThat(find.packages, hasItem("java.util"));
    }
}