Search in sources :

Example 1 with InMemoryIssueStore

use of org.sonarsource.sonarlint.core.container.connected.InMemoryIssueStore in project sonarlint-core by SonarSource.

the class ModuleStorageUpdateExecutorTest method setUp.

@Before
public void setUp() throws IOException {
    wsClient = WsClientTestUtils.createMockWithStreamResponse(getQualityProfileUrl(), "/update/qualityprofiles_project.pb");
    when(wsClient.getOrganizationKey()).thenReturn(organizationKey);
    WsClientTestUtils.addResponse(wsClient, "/api/properties?format=json&resource=" + MODULE_KEY_WITH_BRANCH_URLENCODED, "[{\"key\":\"sonar.qualitygate\",\"value\":\"1\",\"values\": []}," + "{\"key\":\"sonar.core.version\",\"value\":\"5.5-SNAPSHOT\"}," + "{\"key\":\"sonar.java.someProp\",\"value\":\"foo\"}]");
    WsClientTestUtils.addResponse(wsClient, "/batch/issues?key=" + MODULE_KEY_WITH_BRANCH_URLENCODED, newEmptyStream());
    File tempDir = temp.newFolder();
    tempFolder = mock(TempFolder.class);
    when(tempFolder.newDir()).thenReturn(tempDir);
    storagePaths = mock(StoragePaths.class);
    storageReader = mock(StorageReader.class);
    org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties.Builder propBuilder = GlobalProperties.newBuilder();
    propBuilder.getMutableProperties().put("sonar.qualitygate", "2");
    propBuilder.getMutableProperties().put("sonar.core.version", "5.5-SNAPSHOT");
    when(storageReader.readGlobalProperties()).thenReturn(propBuilder.build());
    when(storageReader.readServerInfos()).thenReturn(ServerInfos.newBuilder().build());
    moduleHierarchy = mock(ModuleHierarchyDownloader.class);
    Map<String, String> modulesPath = new HashMap<>();
    modulesPath.put(MODULE_KEY_WITH_BRANCH, "");
    modulesPath.put(MODULE_KEY_WITH_BRANCH + "child1", "child 1");
    when(moduleHierarchy.fetchModuleHierarchy(eq(MODULE_KEY_WITH_BRANCH), any(ProgressWrapper.class))).thenReturn(modulesPath);
    issueStoreFactory = mock(IssueStoreFactory.class);
    issueStore = new InMemoryIssueStore();
    when(issueStoreFactory.apply(any(Path.class))).thenReturn(issueStore);
    moduleConfigurationDownloader = new ModuleConfigurationDownloader(moduleHierarchy, new ModuleQualityProfilesDownloader(wsClient), mock(SettingsDownloader.class));
}
Also used : StorageReader(org.sonarsource.sonarlint.core.container.storage.StorageReader) ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) Path(java.nio.file.Path) HashMap(java.util.HashMap) InMemoryIssueStore(org.sonarsource.sonarlint.core.container.connected.InMemoryIssueStore) ModuleQualityProfilesDownloader(org.sonarsource.sonarlint.core.container.connected.update.ModuleQualityProfilesDownloader) GlobalProperties(org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties) TempFolder(org.sonar.api.utils.TempFolder) ModuleConfigurationDownloader(org.sonarsource.sonarlint.core.container.connected.update.ModuleConfigurationDownloader) File(java.io.File) StoragePaths(org.sonarsource.sonarlint.core.container.storage.StoragePaths) ModuleHierarchyDownloader(org.sonarsource.sonarlint.core.container.connected.update.ModuleHierarchyDownloader) IssueStoreFactory(org.sonarsource.sonarlint.core.container.connected.IssueStoreFactory) Before(org.junit.Before)

Example 2 with InMemoryIssueStore

use of org.sonarsource.sonarlint.core.container.connected.InMemoryIssueStore in project sonarlint-core by SonarSource.

the class IssueStoreReaderTest method setUp.

@Before
public void setUp() {
    IssueStoreFactory issueStoreFactory = mock(IssueStoreFactory.class);
    issueStore = new InMemoryIssueStore();
    storage = mock(StorageReader.class);
    storagePaths = mock(StoragePaths.class);
    Path storagePath = mock(Path.class);
    when(storagePaths.getServerIssuesPath(MODULE_KEY)).thenReturn(storagePath);
    when(issueStoreFactory.apply(storagePath)).thenReturn(issueStore);
    issueStoreReader = new IssueStoreReader(issueStoreFactory, storage, storagePaths);
}
Also used : Path(java.nio.file.Path) InMemoryIssueStore(org.sonarsource.sonarlint.core.container.connected.InMemoryIssueStore) IssueStoreFactory(org.sonarsource.sonarlint.core.container.connected.IssueStoreFactory) Before(org.junit.Before)

Aggregations

Path (java.nio.file.Path)2 Before (org.junit.Before)2 InMemoryIssueStore (org.sonarsource.sonarlint.core.container.connected.InMemoryIssueStore)2 IssueStoreFactory (org.sonarsource.sonarlint.core.container.connected.IssueStoreFactory)2 File (java.io.File)1 HashMap (java.util.HashMap)1 TempFolder (org.sonar.api.utils.TempFolder)1 ModuleConfigurationDownloader (org.sonarsource.sonarlint.core.container.connected.update.ModuleConfigurationDownloader)1 ModuleHierarchyDownloader (org.sonarsource.sonarlint.core.container.connected.update.ModuleHierarchyDownloader)1 ModuleQualityProfilesDownloader (org.sonarsource.sonarlint.core.container.connected.update.ModuleQualityProfilesDownloader)1 StoragePaths (org.sonarsource.sonarlint.core.container.storage.StoragePaths)1 StorageReader (org.sonarsource.sonarlint.core.container.storage.StorageReader)1 GlobalProperties (org.sonarsource.sonarlint.core.proto.Sonarlint.GlobalProperties)1 ProgressWrapper (org.sonarsource.sonarlint.core.util.ProgressWrapper)1