use of org.sonarsource.sonarlint.core.client.api.connected.ServerIssue in project sonarlint-core by SonarSource.
the class ConnectedCommunityIssueDownloadTest method download_all_issues_not_limited_to_10k.
@Test
public void download_all_issues_not_limited_to_10k() throws IOException {
engine.update(endpointParams(ORCHESTRATOR), sqHttpClient(), null);
engine.updateProject(endpointParams(ORCHESTRATOR), sqHttpClient(), PROJECT_KEY, false, null, null);
engine.downloadServerIssues(endpointParams(ORCHESTRATOR), sqHttpClient(), PROJECT_KEY, false, null, null);
var file1Issues = engine.getServerIssues(new ProjectBinding(PROJECT_KEY, "", ""), "src/500lines.xoo");
var file2Issues = engine.getServerIssues(new ProjectBinding(PROJECT_KEY, "", ""), "src/10000lines.xoo");
// Number of issues is not limited to 10k
assertThat(file1Issues.size() + file2Issues.size()).isEqualTo(10_500);
Map<String, ServerIssue> allIssues = new HashMap<>();
engine.getServerIssues(new ProjectBinding(PROJECT_KEY, "", ""), "src/500lines.xoo").forEach(i -> allIssues.put(i.key(), i));
engine.getServerIssues(new ProjectBinding(PROJECT_KEY, "", ""), "src/10000lines.xoo").forEach(i -> allIssues.put(i.key(), i));
assertThat(allIssues).hasSize(10_500);
assertThat(allIssues.get(wfIssue.getKey()).resolution()).isEqualTo("WONTFIX");
assertThat(allIssues.get(fpIssue.getKey()).resolution()).isEqualTo("FALSE-POSITIVE");
assertThat(allIssues.get(overridenSeverityIssue.getKey()).severity()).isEqualTo("BLOCKER");
assertThat(allIssues.get(overridenTypeIssue.getKey()).type()).isEqualTo("BUG");
// No hotspots
assertThat(allIssues.values()).allSatisfy(i -> assertThat(i.type()).isIn("CODE_SMELL", "BUG", "VULNERABILITY"));
}
use of org.sonarsource.sonarlint.core.client.api.connected.ServerIssue in project sonarlint-intellij by SonarSource.
the class ServerIssueUpdaterTest method testDownloadAllServerIssues.
@Test
public void testDownloadAllServerIssues() throws InvalidBindingException {
List<VirtualFile> files = new LinkedList<>();
for (int i = 0; i < 10; i++) {
VirtualFile file = mock(VirtualFile.class);
String filename = "MyFile" + i + ".txt";
when(file.getPath()).thenReturn(FileUtil.toSystemIndependentName(projectBaseDir.resolve(filename).toString()));
files.add(file);
}
ServerIssue serverIssue = mock(ServerIssue.class);
// mock creation of engine / server
ConnectedSonarLintEngine engine = mock(ConnectedSonarLintEngine.class);
when(bindingManager.getConnectedEngine()).thenReturn(engine);
SonarQubeServer server = mock(SonarQubeServer.class);
when(server.getHostUrl()).thenReturn("http://dummyserver:9000");
when(bindingManager.getSonarQubeServer()).thenReturn(server);
// mock issues fetched
when(engine.getServerIssues(eq(PROJECT_KEY), anyString())).thenReturn(Collections.singletonList(serverIssue));
// run
settings.setBindingEnabled(true);
updater.initComponent();
updater.fetchAndMatchServerIssues(files, indicator, false);
verify(issueManager, timeout(3000).times(10)).matchWithServerIssues(any(VirtualFile.class), argThat(issues -> issues.size() == 1));
verify(engine).downloadServerIssues(any(ServerConfiguration.class), eq(PROJECT_KEY));
verify(bindingManager).getConnectedEngine();
verify(console, never()).error(anyString());
verify(console, never()).error(anyString(), any(Throwable.class));
}
use of org.sonarsource.sonarlint.core.client.api.connected.ServerIssue in project sonarlint-intellij by SonarSource.
the class ServerIssueUpdaterTest method testServerIssueTracking.
@Test
public void testServerIssueTracking() throws InvalidBindingException {
VirtualFile file = mock(VirtualFile.class);
ServerIssue serverIssue = mock(ServerIssue.class);
String filename = "MyFile.txt";
when(file.getPath()).thenReturn(FileUtil.toSystemIndependentName(projectBaseDir.resolve(filename).toString()));
// mock creation of engine / server
ConnectedSonarLintEngine engine = mock(ConnectedSonarLintEngine.class);
when(bindingManager.getConnectedEngine()).thenReturn(engine);
SonarQubeServer server = mock(SonarQubeServer.class);
when(server.getHostUrl()).thenReturn("http://dummyserver:9000");
when(bindingManager.getSonarQubeServer()).thenReturn(server);
// mock issues downloaded
when(engine.downloadServerIssues(any(ServerConfiguration.class), eq(PROJECT_KEY), eq(filename))).thenReturn(Collections.singletonList(serverIssue));
// run
settings.setBindingEnabled(true);
updater.initComponent();
updater.fetchAndMatchServerIssues(Collections.singletonList(file), indicator, false);
verify(issueManager, timeout(3000).times(1)).matchWithServerIssues(eq(file), argThat(issues -> issues.size() == 1));
verify(bindingManager).getConnectedEngine();
verify(console, never()).error(anyString());
verify(console, never()).error(anyString(), any(Throwable.class));
}
Aggregations