use of org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.ModuleUpdateReq in project sonarlint-core by SonarSource.
the class ConnectedDaemonTest method testNormal.
@Test
public void testNormal() throws InterruptedException, IOException {
daemon.run();
daemon.waitReady();
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 8050).usePlaintext(true).build();
LogCollector logs = new LogCollector();
ConnectedSonarLintBlockingStub sonarlint = ConnectedSonarLintGrpc.newBlockingStub(channel);
// REGISTER
sonarlint.start(createConnectedConfig());
// STATE
assertThat(sonarlint.getState(Void.newBuilder().build()).getState()).isEqualTo(StorageState.State.NEVER_UPDATED);
// UPDATE GLOBAL
ServerConfig serverConfig = ServerConfig.newBuilder().setHostUrl(ORCHESTRATOR.getServer().getUrl()).setCredentials(Credentials.newBuilder().setLogin(SONARLINT_USER).setPassword(SONARLINT_PWD).build()).build();
sonarlint.update(serverConfig);
// STATE
assertThat(sonarlint.getState(Void.newBuilder().build()).getState()).isEqualTo(StorageState.State.UPDATED);
// UPDATE MODULE
ModuleUpdateReq moduleUpdate = ModuleUpdateReq.newBuilder().setModuleKey(PROJECT_KEY_JAVA).setServerConfig(serverConfig).build();
sonarlint.updateModule(moduleUpdate);
// ANALYSIS
ClientCall<Void, LogEvent> call = getLogs(logs, channel);
Iterator<Issue> issues = sonarlint.analyze(createAnalysisConfig(PROJECT_KEY_JAVA));
assertThat(issues).hasSize(3);
// assertThat(logs.getLogsAndClear()).contains("2 files indexed");
call.cancel(null, null);
channel.shutdownNow();
channel.awaitTermination(2, TimeUnit.SECONDS);
}
Aggregations