Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-knize-sonarsource committed Nov 29, 2024
1 parent f484423 commit 66d6373
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ public String findMainBranch(String connectionId, String projectKey, SonarLintCa
var storedBranches = branchesStorage.read();
return storedBranches.getMainBranchName();
} else {
var serverApi = serverApiProvider.getServerApiOrThrow(connectionId);
var branches = getProjectBranches(serverApi, projectKey, cancelMonitor);
var branches = getProjectBranches(connectionId, projectKey, cancelMonitor);
return branches.getMainBranchName();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,21 @@ void setup() {
issueApi = mock(IssueApi.class);
var serverApi = mock(ServerApi.class);
when(serverApi.issue()).thenReturn(issueApi);
var serverApiProvider = mock(ServerApiProvider.class);
when(serverApiProvider.getServerApiOrThrow(any())).thenReturn(serverApi);
when(serverApiProvider.getServerApi(any())).thenReturn(Optional.of(serverApi));
var serverApiWrapper = new ServerApiErrorHandlingWrapper(serverApi, () -> {});
var connectionManager = mock(ConnectionManager.class);
when(connectionManager.getServerApiWrapperOrThrow(any())).thenReturn(serverApiWrapper);
branchesStorage = mock(ProjectBranchesStorage.class);
var storageService = mock(StorageService.class);
var sonarStorage = mock(SonarProjectStorage.class);
var eventPublisher = mock(ApplicationEventPublisher.class);
var sonarProjectBranchesSynchronizationService = spy(new SonarProjectBranchesSynchronizationService(storageService, serverApiProvider
var sonarProjectBranchesSynchronizationService = spy(new SonarProjectBranchesSynchronizationService(storageService, connectionManager
, eventPublisher));
doReturn(new ProjectBranches(Set.of(), "main")).when(sonarProjectBranchesSynchronizationService).getProjectBranches(any(), any(),
any());
when(storageService.binding(any())).thenReturn(sonarStorage);
when(sonarStorage.branches()).thenReturn(branchesStorage);

showIssueRequestHandler = spy(new ShowIssueRequestHandler(sonarLintRpcClient, serverApiProvider, telemetryService,
showIssueRequestHandler = spy(new ShowIssueRequestHandler(sonarLintRpcClient, connectionManager, telemetryService,
new RequestHandlerBindingAssistant(bindingSuggestionProvider, bindingCandidatesFinder, sonarLintRpcClient,
connectionConfigurationRepository, configurationRepository, userTokenService,
sonarCloudActiveEnvironment), pathTranslationService, sonarCloudActiveEnvironment, sonarProjectBranchesSynchronizationService));
Expand Down Expand Up @@ -393,9 +393,11 @@ private static ShowIssueRequestHandler getShowIssueRequestHandler(TelemetryServi
var sonarLintClient = mock(SonarLintRpcClient.class);
var pathTranslationService = mock(PathTranslationService.class);
var userTokenService = mock(UserTokenService.class);
var sonarProjectBranchesSynchronizationService = mock(SonarProjectBranchesSynchronizationService.class);
SonarCloudActiveEnvironment sonarCloudActiveEnvironment = SonarCloudActiveEnvironment.prod();
return new ShowIssueRequestHandler(sonarLintClient, connectionManager, telemetryService,
new RequestHandlerBindingAssistant(bindingSuggestionProvider, bindingCandidatesFinder, sonarLintClient, repository, configurationRepository, userTokenService, sonarCloudActiveEnvironment), pathTranslationService, sonarCloudActiveEnvironment);
new RequestHandlerBindingAssistant(bindingSuggestionProvider, bindingCandidatesFinder, sonarLintClient, repository, configurationRepository, userTokenService, sonarCloudActiveEnvironment),
pathTranslationService, sonarCloudActiveEnvironment, sonarProjectBranchesSynchronizationService);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void test_download_one_issue_pull_ws_with_user_impacts() {

mockServer.addProtobufResponseDelimited("/api/issues/pull?projectKey=" + DUMMY_KEY + "&branchName=myBranch&languages=java", timestamp, issue);

var result = underTest.downloadFromPull(serverApi, DUMMY_KEY, "myBranch", Optional.empty(), new SonarLintCancelMonitor());
var result = underTest.downloadFromPull(serverApiWrapper, DUMMY_KEY, "myBranch", Optional.empty(), new SonarLintCancelMonitor());
assertThat(result.getChangedIssues()).hasSize(1);
assertThat(result.getClosedIssueKeys()).isEmpty();

Expand Down

0 comments on commit 66d6373

Please sign in to comment.