Search in sources :

Example 1 with ModuleList

use of org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList in project sonarlint-core by SonarSource.

the class ModuleListDownloaderTest method update_modules_before_6_dot_3.

@Test
public void update_modules_before_6_dot_3() throws Exception {
    SonarLintWsClient wsClient = WsClientTestUtils.createMock();
    WsClientTestUtils.addReaderResponse(wsClient, "api/projects/index?format=json&subprojects=true", "/update/all_projects.json");
    File tempDir = temp.newFolder();
    ModuleListDownloader moduleListUpdate = new ModuleListDownloader(wsClient);
    moduleListUpdate.fetchModulesListTo(tempDir.toPath(), "6.2", new ProgressWrapper(null));
    ModuleList moduleList = ProtobufUtil.readFile(tempDir.toPath().resolve(StoragePaths.MODULE_LIST_PB), ModuleList.parser());
    assertThat(moduleList.getModulesByKeyMap()).hasSize(1559);
    assertThat(moduleList.getModulesByKeyMap().values()).extracting("qu").contains("TRK", "BRC");
}
Also used : ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) ModuleList(org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList) File(java.io.File) SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient) Test(org.junit.Test)

Example 2 with ModuleList

use of org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList in project sonarlint-core by SonarSource.

the class AllModulesReader method get.

@Override
public Map<String, RemoteModule> get() {
    Map<String, RemoteModule> results = new HashMap<>();
    ModuleList readModuleListFromStorage = storageReader.readModuleList();
    Map<String, Module> modulesByKey = readModuleListFromStorage.getModulesByKeyMap();
    for (Map.Entry<String, Module> entry : modulesByKey.entrySet()) {
        results.put(entry.getKey(), new DefaultRemoteModule(entry.getValue()));
    }
    return results;
}
Also used : RemoteModule(org.sonarsource.sonarlint.core.client.api.connected.RemoteModule) DefaultRemoteModule(org.sonarsource.sonarlint.core.container.model.DefaultRemoteModule) HashMap(java.util.HashMap) ModuleList(org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList) Module(org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList.Module) RemoteModule(org.sonarsource.sonarlint.core.client.api.connected.RemoteModule) DefaultRemoteModule(org.sonarsource.sonarlint.core.container.model.DefaultRemoteModule) Map(java.util.Map) HashMap(java.util.HashMap) DefaultRemoteModule(org.sonarsource.sonarlint.core.container.model.DefaultRemoteModule)

Example 3 with ModuleList

use of org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList in project sonarlint-core by SonarSource.

the class ModuleListDownloaderTest method update_modules_after_6_dot_3.

@Test
public void update_modules_after_6_dot_3() throws Exception {
    SonarLintWsClient wsClient = WsClientTestUtils.createMock();
    WsClientTestUtils.addStreamResponse(wsClient, "api/components/search.protobuf?qualifiers=TRK,BRC&ps=500&p=1", "/update/searchmodulesp1.pb");
    File tempDir = temp.newFolder();
    ModuleListDownloader moduleListUpdate = new ModuleListDownloader(wsClient);
    moduleListUpdate.fetchModulesListTo(tempDir.toPath(), "6.3", new ProgressWrapper(null));
    ModuleList moduleList = ProtobufUtil.readFile(tempDir.toPath().resolve(StoragePaths.MODULE_LIST_PB), ModuleList.parser());
    assertThat(moduleList.getModulesByKeyMap()).hasSize(282);
    assertThat(moduleList.getModulesByKeyMap().values()).extracting("qu").contains("TRK", "BRC");
}
Also used : ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) ModuleList(org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList) File(java.io.File) SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient) Test(org.junit.Test)

Example 4 with ModuleList

use of org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList in project sonarlint-core by SonarSource.

the class ModuleListDownloaderTest method update_modules_after_6_dot_3_with_org.

@Test
public void update_modules_after_6_dot_3_with_org() throws Exception {
    SonarLintWsClient wsClient = WsClientTestUtils.createMock();
    when(wsClient.getOrganizationKey()).thenReturn("myOrg");
    WsClientTestUtils.addStreamResponse(wsClient, "api/components/search.protobuf?qualifiers=TRK,BRC&organization=myOrg&ps=500&p=1", "/update/searchmodulesp1.pb");
    File tempDir = temp.newFolder();
    ModuleListDownloader moduleListUpdate = new ModuleListDownloader(wsClient);
    moduleListUpdate.fetchModulesListTo(tempDir.toPath(), "6.3", new ProgressWrapper(null));
    ModuleList moduleList = ProtobufUtil.readFile(tempDir.toPath().resolve(StoragePaths.MODULE_LIST_PB), ModuleList.parser());
    assertThat(moduleList.getModulesByKeyMap()).hasSize(282);
    assertThat(moduleList.getModulesByKeyMap().values()).extracting("qu").contains("TRK", "BRC");
}
Also used : ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) ModuleList(org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList) File(java.io.File) SonarLintWsClient(org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient) Test(org.junit.Test)

Aggregations

ModuleList (org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList)4 File (java.io.File)3 Test (org.junit.Test)3 SonarLintWsClient (org.sonarsource.sonarlint.core.container.connected.SonarLintWsClient)3 ProgressWrapper (org.sonarsource.sonarlint.core.util.ProgressWrapper)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 RemoteModule (org.sonarsource.sonarlint.core.client.api.connected.RemoteModule)1 DefaultRemoteModule (org.sonarsource.sonarlint.core.container.model.DefaultRemoteModule)1 Module (org.sonarsource.sonarlint.core.proto.Sonarlint.ModuleList.Module)1