Search in sources :

Example 1 with AnalysisReq

use of org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.AnalysisReq in project sonarlint-core by SonarSource.

the class StandaloneDaemonTest method test.

@Test
public void test() throws InterruptedException, IOException {
    LogCollector logs = new LogCollector();
    StandaloneSonarLintBlockingStub sonarlint = StandaloneSonarLintGrpc.newBlockingStub(channel);
    AnalysisReq analysisConfig = createAnalysisConfig("sample-javascript");
    long start = System.currentTimeMillis();
    ClientCall<Void, LogEvent> call = getLogs(logs, channel);
    try {
        for (int i = 0; i < 10; i++) {
            System.out.println("ITERATION: " + i);
            Iterator<Issue> issues = sonarlint.analyze(analysisConfig);
            assertThat(issues).hasSize(1);
            // Give some time for logs to come
            Thread.sleep(500);
            List<String> logsLines = logs.getLogsAndClear();
            // To be sure logs are not flooded by low level logs
            assertThat(logsLines.size()).isLessThan(100);
            assertThat(logsLines).contains("1 files indexed");
        }
    } finally {
        call.cancel("no more logs needed", null);
    }
    System.out.println("TIME " + (System.currentTimeMillis() - start));
}
Also used : Issue(org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Issue) LogEvent(org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.LogEvent) AnalysisReq(org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.AnalysisReq) StandaloneSonarLintBlockingStub(org.sonarsource.sonarlint.daemon.proto.StandaloneSonarLintGrpc.StandaloneSonarLintBlockingStub) Void(org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Void) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 AnalysisReq (org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.AnalysisReq)1 Issue (org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Issue)1 LogEvent (org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.LogEvent)1 Void (org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Void)1 StandaloneSonarLintBlockingStub (org.sonarsource.sonarlint.daemon.proto.StandaloneSonarLintGrpc.StandaloneSonarLintBlockingStub)1