From cbf5d3a72f2e08b79de4b7c887aaa15bc7cbefe3 Mon Sep 17 00:00:00 2001 From: Damien Urruty Date: Wed, 22 Jan 2025 08:42:49 +0100 Subject: [PATCH 1/2] Rename method in backend builder Start better reflects that the backend will be started --- .../BindingSuggestionsMediumTests.java | 14 +-- .../ConnectedHotspotMediumTests.java | 2 +- .../ConnectedIssueExclusionsMediumTests.java | 2 +- .../mediumtest/ConnectedIssueMediumTests.java | 6 +- .../ConnectedStorageProblemsMediumTests.java | 2 +- .../ConnectionSetupMediumTests.java | 22 ++-- .../ConnectionSuggestionMediumTests.java | 24 ++-- .../mediumtest/EffectiveRulesMediumTests.java | 28 ++--- .../mediumtest/EmbeddedServerMediumTests.java | 10 +- .../mediumtest/InitializationMediumTests.java | 2 +- .../NotebookLanguageMediumTests.java | 2 +- ...haredConnectedModeSettingsMediumTests.java | 6 +- .../StandaloneIssueMediumTests.java | 60 +++++----- .../StandaloneNoPluginMediumTests.java | 2 +- .../StandaloneRulesMediumTests.java | 10 +- .../java/mediumtest/TelemetryMediumTests.java | 22 ++-- .../java/mediumtest/UserTokenMediumTests.java | 4 +- .../analysis/AnalysisMediumTests.java | 58 +++++----- .../AnalysisReadinessMediumTests.java | 4 +- .../AnalysisTriggeringMediumTests.java | 16 +-- .../AnalysysForcedByClientMediumTests.java | 12 +- .../analysis/NodeJsMediumTests.java | 6 +- .../RulesInConnectedModeMediumTests.java | 8 +- .../SupportedFilePatternsMediumTests.java | 6 +- .../branch/SonarProjectBranchMediumTests.java | 20 ++-- .../ConnectionGetAllProjectsMediumTests.java | 12 +- ...nectionGetProjectNameByKeyMediumTests.java | 10 +- .../ConnectionValidatorMediumTests.java | 14 +-- .../connection/OrganizationMediumTests.java | 8 +- .../DogfoodingRpcServiceMediumTests.java | 6 +- .../file/ClientFileExclusionsMediumTests.java | 12 +- .../ConnectedFileExclusionsMediumTests.java | 6 +- ...CheckStatusChangePermittedMediumTests.java | 8 +- .../hotspots/HotspotEventsMediumTests.java | 12 +- ...tspotLocalDetectionSupportMediumTests.java | 10 +- .../HotspotStatusChangeMediumTests.java | 14 +-- .../OpenHotspotInBrowserMediumTests.java | 4 +- .../hotspots/OpenHotspotInIdeMediumTests.java | 18 +-- .../http/AuthenticationMediumTests.java | 6 +- .../mediumtest/http/ProxyMediumTests.java | 12 +- .../java/mediumtest/http/SslMediumTests.java | 8 +- .../mediumtest/http/TimeoutMediumTests.java | 2 +- ...patedStatusChangeSupportedMediumTests.java | 8 +- ...utionStatusChangePermittedMediumTests.java | 26 ++--- .../issues/IssueEventsMediumTests.java | 20 ++-- .../issues/IssuesStatusChangeMediumTests.java | 38 +++---- ...lOnlyResolvedIssuesStorageMediumTests.java | 2 +- .../OpenFixSuggestionInIdeMediumTests.java | 24 ++-- .../issues/OpenIssueInIdeMediumTests.java | 24 ++-- .../newcode/NewCodeTelemetryMediumTests.java | 8 +- ...esInConnectedModePromotionMediumTests.java | 8 +- .../rules/RuleDetailsMediumTests.java | 6 +- .../rules/RuleEventsMediumTests.java | 18 +-- .../events/ServerSentEventsMediumTests.java | 50 ++++----- .../SmartNotificationsMediumTests.java | 16 +-- ...nchSpecificSynchronizationMediumTests.java | 11 +- .../ConnectionSyncMediumTests.java | 8 +- .../PluginSynchronizationMediumTests.java | 22 ++-- .../RuleSetSynchronizationMediumTests.java | 4 +- .../ServerInfoSynchronizationMediumTests.java | 12 +- ...lnerabilitySynchronizationMediumTests.java | 2 +- .../TaintVulnerabilitiesMediumTests.java | 10 +- .../TaintVulnerabilityEventsMediumTests.java | 20 ++-- .../tracking/IssueTrackingMediumTests.java | 40 +++---- .../SecurityHotspotTrackingMediumTests.java | 6 +- .../websockets/WebSocketMediumTests.java | 106 +++++++++--------- .../test/utils/SonarLintBackendFixture.java | 20 ++-- 67 files changed, 509 insertions(+), 510 deletions(-) diff --git a/medium-tests/src/test/java/mediumtest/BindingSuggestionsMediumTests.java b/medium-tests/src/test/java/mediumtest/BindingSuggestionsMediumTests.java index 6fb38c7685..dbe3d4bc70 100644 --- a/medium-tests/src/test/java/mediumtest/BindingSuggestionsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/BindingSuggestionsMediumTests.java @@ -82,7 +82,7 @@ void test_connection_added_should_suggest_binding_with_no_matches(SonarLintTestH var fakeClient = harness.newFakeClient().build(); var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID, "My Project 1") - .build(fakeClient); + .start(fakeClient); await().untilAsserted(() -> assertThat(fakeClient.getLogMessages()).contains("No connections configured, skipping binding suggestions.")); backend.getConnectionService() @@ -101,7 +101,7 @@ void test_connection_added_should_suggest_binding_with_matches(SonarLintTestHarn var fakeClient = harness.newFakeClient().build(); var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID, "sonarlint-core") - .build(fakeClient); + .start(fakeClient); await().untilAsserted(() -> assertThat(fakeClient.getLogMessages()).contains("No connections configured, skipping binding suggestions.")); sonarqubeMock.stubFor(get("/api/components/search.protobuf?qualifiers=TRK&ps=500&p=1") @@ -131,7 +131,7 @@ void test_project_added_should_suggest_binding_with_matches(SonarLintTestHarness var fakeClient = harness.newFakeClient().build(); var backend = harness.newBackend() .withSonarQubeConnection(MYSONAR, sonarqubeMock.baseUrl()) - .build(fakeClient); + .start(fakeClient); sonarqubeMock.stubFor(get("/api/components/search.protobuf?qualifiers=TRK&ps=500&p=1") .willReturn(aResponse().withResponseBody(protobufBody(Components.SearchWsResponse.newBuilder() @@ -170,7 +170,7 @@ void test_uses_binding_clues_when_initializing_fs(SonarLintTestHarness harness, var backend = harness.newBackend() .withSonarQubeConnection(MYSONAR, sonarqubeMock.baseUrl()) .withSonarQubeConnection("another") - .build(fakeClient); + .start(fakeClient); sonarqubeMock.stubFor(get("/api/components/show.protobuf?component=org.sonarsource.sonarlint%3Asonarlint-core-parent") .willReturn(aResponse().withResponseBody(protobufBody(Components.ShowWsResponse.newBuilder() @@ -204,7 +204,7 @@ void test_uses_binding_clues_when_updating_fs(SonarLintTestHarness harness, @Tem var backend = harness.newBackend() .withSonarQubeConnection(MYSONAR, sonarqubeMock.baseUrl()) .withSonarQubeConnection("another") - .build(fakeClient); + .start(fakeClient); sonarqubeMock.stubFor(get("/api/components/show.protobuf?component=org.sonarsource.sonarlint%3Asonarlint-core-parent") .willReturn(aResponse().withResponseBody(protobufBody(Components.ShowWsResponse.newBuilder() @@ -249,7 +249,7 @@ void test_binding_suggestion_via_service(SonarLintTestHarness harness) throws Ex var fakeClient = harness.newFakeClient().build(); var backend = harness.newBackend() .withSonarQubeConnection(MYSONAR, sonarqubeMock.baseUrl()) - .build(fakeClient); + .start(fakeClient); sonarqubeMock.stubFor(get("/api/components/search.protobuf?qualifiers=TRK&ps=500&p=1") .willReturn(aResponse().withResponseBody(protobufBody(Components.SearchWsResponse.newBuilder() @@ -285,7 +285,7 @@ void test_uses_binding_clues_from_shared_configuration_when_updating_fs(SonarLin var backend = harness.newBackend() .withSonarQubeConnection(MYSONAR, sonarqubeMock.baseUrl()) .withSonarQubeConnection("another") - .build(fakeClient); + .start(fakeClient); sonarqubeMock.stubFor(get("/api/components/show.protobuf?component=org.sonarsource.sonarlint%3Asonarlint-core-parent") .willReturn(aResponse().withResponseBody(protobufBody(Components.ShowWsResponse.newBuilder() diff --git a/medium-tests/src/test/java/mediumtest/ConnectedHotspotMediumTests.java b/medium-tests/src/test/java/mediumtest/ConnectedHotspotMediumTests.java index c0e8330fc3..b3f7be2c48 100644 --- a/medium-tests/src/test/java/mediumtest/ConnectedHotspotMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/ConnectedHotspotMediumTests.java @@ -70,7 +70,7 @@ void should_locally_detect_hotspots_when_connected_to_sonarqube(SonarLintTestHar .withSonarQubeConnection(CONNECTION_ID, server) .withBoundConfigScope(CONFIG_SCOPE_ID, CONNECTION_ID, projectKey) .withExtraEnabledLanguagesInConnectedMode(JAVA) - .build(client); + .start(client); client.waitForSynchronization(); var analysisId = UUID.randomUUID(); diff --git a/medium-tests/src/test/java/mediumtest/ConnectedIssueExclusionsMediumTests.java b/medium-tests/src/test/java/mediumtest/ConnectedIssueExclusionsMediumTests.java index 491c3922db..c9f5468af0 100644 --- a/medium-tests/src/test/java/mediumtest/ConnectedIssueExclusionsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/ConnectedIssueExclusionsMediumTests.java @@ -85,7 +85,7 @@ static void prepare(@TempDir Path baseDir) { .withActiveRule("java:S1481", "BLOCKER")))) .withBoundConfigScope(JAVA_MODULE_KEY, CONNECTION_ID, JAVA_MODULE_KEY) .withEnabledLanguageInStandaloneMode(Language.JAVA) - .build(client); + .start(client); } @BeforeEach diff --git a/medium-tests/src/test/java/mediumtest/ConnectedIssueMediumTests.java b/medium-tests/src/test/java/mediumtest/ConnectedIssueMediumTests.java index b93e97d09d..daa172f447 100644 --- a/medium-tests/src/test/java/mediumtest/ConnectedIssueMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/ConnectedIssueMediumTests.java @@ -88,7 +88,7 @@ void simpleJavaBound(SonarLintTestHarness harness, @TempDir Path baseDir) { .withSonarQubeConnection(CONNECTION_ID, server) .withBoundConfigScope(CONFIG_SCOPE_ID, CONNECTION_ID, projectKey) .withExtraEnabledLanguagesInConnectedMode(JAVA) - .build(client); + .start(client); client.waitForSynchronization(); var analysisId = UUID.randomUUID(); @@ -137,7 +137,7 @@ void emptyQPJava(SonarLintTestHarness harness, @TempDir Path baseDir) { .withSonarQubeConnection(CONNECTION_ID, server) .withBoundConfigScope(CONFIG_SCOPE_ID, CONNECTION_ID, projectKey) .withExtraEnabledLanguagesInConnectedMode(JAVA) - .build(client); + .start(client); client.waitForSynchronization(); var analysisId = UUID.randomUUID(); @@ -181,7 +181,7 @@ void it_should_get_hotspot_details(SonarLintTestHarness harness, @TempDir Path b project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule("java:S2068", "BLOCKER")))) .withBoundConfigScope(CONFIG_SCOPE_ID, connectionId, projectKey) .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> Assertions.assertThat(client.getSynchronizedConfigScopeIds()).contains(CONFIG_SCOPE_ID)); var analysisId = UUID.randomUUID(); diff --git a/medium-tests/src/test/java/mediumtest/ConnectedStorageProblemsMediumTests.java b/medium-tests/src/test/java/mediumtest/ConnectedStorageProblemsMediumTests.java index 448264dad1..0a176e475c 100644 --- a/medium-tests/src/test/java/mediumtest/ConnectedStorageProblemsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/ConnectedStorageProblemsMediumTests.java @@ -67,7 +67,7 @@ void corrupted_plugin_should_not_prevent_startup(SonarLintTestHarness harness, @ ruleSet -> ruleSet.withActiveRule("java:S106", "BLOCKER")))) .withBoundConfigScope(CONFIG_SCOPE_ID, CONNECTION_ID, CONFIG_SCOPE_ID) .withEnabledLanguageInStandaloneMode(org.sonarsource.sonarlint.core.rpc.protocol.common.Language.JAVA) - .withEnabledLanguageInStandaloneMode(org.sonarsource.sonarlint.core.rpc.protocol.common.Language.JS).build(client); + .withEnabledLanguageInStandaloneMode(org.sonarsource.sonarlint.core.rpc.protocol.common.Language.JS).start(client); backend.getAnalysisService().analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams(CONFIG_SCOPE_ID, UUID.randomUUID(), List.of(inputFile.toUri()), Map.of(), false, Instant.now().toEpochMilli())).get(); diff --git a/medium-tests/src/test/java/mediumtest/ConnectionSetupMediumTests.java b/medium-tests/src/test/java/mediumtest/ConnectionSetupMediumTests.java index 6721196142..345421dfc5 100644 --- a/medium-tests/src/test/java/mediumtest/ConnectionSetupMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/ConnectionSetupMediumTests.java @@ -52,7 +52,7 @@ void it_should_open_the_sonarlint_auth_url_for_sonarcloud(SonarLintTestHarness h ServerFixture.Server scServer = harness.newFakeSonarCloudServer() .start(); - var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarCloudConnection("connectionId").build(fakeClient); + var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarCloudConnection("connectionId").start(fakeClient); var futureResponse = backend.getConnectionService().helpGenerateUserToken(new HelpGenerateUserTokenParams(scServer.baseUrl())); @@ -76,7 +76,7 @@ void it_should_open_the_sonarlint_auth_url_for_sonarcloud(SonarLintTestHarness h void it_should_open_the_sonarlint_auth_url_for_sonarqube_9_7_plus(SonarLintTestHarness harness) throws IOException, InterruptedException { var fakeClient = harness.newFakeClient().build(); var server = harness.newFakeSonarQubeServer("9.9").start(); - var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarQubeConnection("connectionId", server).build(fakeClient); + var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarQubeConnection("connectionId", server).start(fakeClient); var futureResponse = backend.getConnectionService().helpGenerateUserToken(new HelpGenerateUserTokenParams(server.baseUrl())); @@ -100,7 +100,7 @@ void it_should_open_the_sonarlint_auth_url_for_sonarqube_9_7_plus(SonarLintTestH void it_should_reject_tokens_from_missing_origin(SonarLintTestHarness harness) throws IOException, InterruptedException { var fakeClient = harness.newFakeClient().build(); var server = harness.newFakeSonarQubeServer("9.9").start(); - var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarQubeConnection("connectionId", server).build(fakeClient); + var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarQubeConnection("connectionId", server).start(fakeClient); backend.getConnectionService().helpGenerateUserToken(new HelpGenerateUserTokenParams(server.baseUrl())); @@ -118,7 +118,7 @@ void it_should_reject_tokens_from_missing_origin(SonarLintTestHarness harness) t void it_should_reject_tokens_from_unexpected_origin(SonarLintTestHarness harness) throws IOException, InterruptedException { var fakeClient = harness.newFakeClient().build(); var server = harness.newFakeSonarQubeServer("9.9").start(); - var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarQubeConnection("connectionId", server).build(fakeClient); + var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarQubeConnection("connectionId", server).start(fakeClient); backend.getConnectionService().helpGenerateUserToken(new HelpGenerateUserTokenParams(server.baseUrl())); @@ -136,7 +136,7 @@ void it_should_reject_tokens_from_unexpected_origin(SonarLintTestHarness harness @SonarLintTest void it_should_open_the_sonarlint_auth_url_without_port_for_sonarqube_9_7_plus_when_server_is_not_started(SonarLintTestHarness harness) throws MalformedURLException { var fakeClient = harness.newFakeClient().build(); - var backend = harness.newBackend().withClientName("ClientName").build(fakeClient); + var backend = harness.newBackend().withClientName("ClientName").start(fakeClient); var server = harness.newFakeSonarQubeServer("9.9").start(); var futureResponse = backend.getConnectionService().helpGenerateUserToken(new HelpGenerateUserTokenParams(server.baseUrl())); @@ -151,7 +151,7 @@ void it_should_open_the_sonarlint_auth_url_without_port_for_sonarqube_9_7_plus_w @SonarLintTest void it_should_reject_incoming_user_token_with_wrong_http_method(SonarLintTestHarness harness) throws IOException, InterruptedException { var fakeClient = harness.newFakeClient().build(); - var backend = harness.newBackend().withEmbeddedServer().build(fakeClient); + var backend = harness.newBackend().withEmbeddedServer().start(fakeClient); var request = HttpRequest.newBuilder() .uri(URI.create("http://localhost:" + backend.getEmbeddedServerPort() + "/sonarlint/api/token")) @@ -164,7 +164,7 @@ void it_should_reject_incoming_user_token_with_wrong_http_method(SonarLintTestHa @SonarLintTest void it_should_reject_incoming_user_token_with_wrong_body(SonarLintTestHarness harness) throws IOException, InterruptedException { var fakeClient = harness.newFakeClient().build(); - var backend = harness.newBackend().withEmbeddedServer().build(fakeClient); + var backend = harness.newBackend().withEmbeddedServer().start(fakeClient); var request = HttpRequest.newBuilder() .uri(URI.create("http://localhost:" + backend.getEmbeddedServerPort() + "/sonarlint/api/token")) @@ -178,7 +178,7 @@ void it_should_reject_incoming_user_token_with_wrong_body(SonarLintTestHarness h @SonarLintTest void it_should_fail_to_validate_connection_if_host_not_found(SonarLintTestHarness harness) throws InterruptedException, ExecutionException { var fakeClient = harness.newFakeClient().build(); - var backend = harness.newBackend().build(fakeClient); + var backend = harness.newBackend().start(fakeClient); var connectionResponse = backend.getConnectionService() .validateConnection(new ValidateConnectionParams(new TransientSonarQubeConnectionDto("http://notexists", Either.forRight(new UsernamePasswordDto("foo", "bar"))))).get(); @@ -190,7 +190,7 @@ void it_should_fail_to_validate_connection_if_host_not_found(SonarLintTestHarnes @SonarLintTest void it_should_support_notifications_if_sonarcloud(SonarLintTestHarness harness) throws ExecutionException, InterruptedException { var fakeClient = harness.newFakeClient().build(); - var backend = harness.newBackend().build(fakeClient); + var backend = harness.newBackend().start(fakeClient); var connectionResponse = backend.getConnectionService() .checkSmartNotificationsSupported(new CheckSmartNotificationsSupportedParams( @@ -204,7 +204,7 @@ void it_should_support_notifications_if_sonarcloud(SonarLintTestHarness harness) void it_should_support_notifications_if_sonarqube_supports(SonarLintTestHarness harness) throws ExecutionException, InterruptedException { var fakeClient = harness.newFakeClient().build(); var server = harness.newFakeSonarQubeServer().withSmartNotificationsSupported(true).start(); - var backend = harness.newBackend().withEmbeddedServer().withSonarQubeConnection("connectionId", server).build(fakeClient); + var backend = harness.newBackend().withEmbeddedServer().withSonarQubeConnection("connectionId", server).start(fakeClient); var connectionResponse = backend.getConnectionService() .checkSmartNotificationsSupported(new CheckSmartNotificationsSupportedParams( @@ -218,7 +218,7 @@ void it_should_support_notifications_if_sonarqube_supports(SonarLintTestHarness void it_should_not_support_notifications_if_sonarqube_does_not_support(SonarLintTestHarness harness) throws ExecutionException, InterruptedException { var fakeClient = harness.newFakeClient().build(); var server = harness.newFakeSonarQubeServer().withSmartNotificationsSupported(false).start(); - var backend = harness.newBackend().withEmbeddedServer().withSonarQubeConnection("connectionId", server).build(fakeClient); + var backend = harness.newBackend().withEmbeddedServer().withSonarQubeConnection("connectionId", server).start(fakeClient); var connectionResponse = backend.getConnectionService() .checkSmartNotificationsSupported(new CheckSmartNotificationsSupportedParams( diff --git a/medium-tests/src/test/java/mediumtest/ConnectionSuggestionMediumTests.java b/medium-tests/src/test/java/mediumtest/ConnectionSuggestionMediumTests.java index 895cb73f1c..f79cdd66e9 100644 --- a/medium-tests/src/test/java/mediumtest/ConnectionSuggestionMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/ConnectionSuggestionMediumTests.java @@ -76,7 +76,7 @@ void should_suggest_sonarqube_connection_when_initializing_fs(SonarLintTestHarne .build(); var backend = harness.newBackend() - .build(fakeClient); + .start(fakeClient); backend.getFileService().didUpdateFileSystem(new DidUpdateFileSystemParams(List.of(fileDto), Collections.emptyList(), Collections.emptyList())); @@ -109,7 +109,7 @@ void should_not_suggest_connection_for_empty_values(String projectKey, String se .withInitialFs(CONFIG_SCOPE_ID, List.of(fileDto)) .build(); - var backend = harness.newBackend().build(fakeClient); + var backend = harness.newBackend().start(fakeClient); backend.getFileService().didUpdateFileSystem(new DidUpdateFileSystemParams(List.of(fileDto), Collections.emptyList(), Collections.emptyList())); @@ -134,7 +134,7 @@ void should_suggest_connection_for_non_empty_values(String projectKey, String se List.of(fileDto)) .build(); - var backend = harness.newBackend().build(fakeClient); + var backend = harness.newBackend().start(fakeClient); backend.getFileService().didUpdateFileSystem(new DidUpdateFileSystemParams(List.of(fileDto), Collections.emptyList(), Collections.emptyList())); @@ -154,7 +154,7 @@ void should_suggest_sonarcloud_connection_when_initializing_fs(SonarLintTestHarn .build(); var backend = harness.newBackend() - .build(fakeClient); + .start(fakeClient); backend.getFileService().didUpdateFileSystem(new DidUpdateFileSystemParams(List.of(fileDto), Collections.emptyList(), Collections.emptyList())); @@ -187,7 +187,7 @@ void should_suggest_connection_when_initializing_fs_for_csharp_project(SonarLint .build(); var backend = harness.newBackend() - .build(fakeClient); + .start(fakeClient); backend.getFileService().didUpdateFileSystem(new DidUpdateFileSystemParams(List.of(fileDto), Collections.emptyList(), Collections.emptyList())); @@ -214,7 +214,7 @@ void should_suggest_connection_when_initializing_fs_with_scanner_file(SonarLintT .build(); var backend = harness.newBackend() - .build(fakeClient); + .start(fakeClient); backend.getFileService().didUpdateFileSystem(new DidUpdateFileSystemParams(List.of(fileDto), Collections.emptyList(), Collections.emptyList())); @@ -241,7 +241,7 @@ void should_suggest_sonarcloud_connection_when_initializing_fs_with_scanner_file .build(); var backend = harness.newBackend() - .build(fakeClient); + .start(fakeClient); backend.getFileService().didUpdateFileSystem(new DidUpdateFileSystemParams(List.of(fileDto), Collections.emptyList(), Collections.emptyList())); @@ -270,7 +270,7 @@ void should_suggest_connection_when_config_scope_added(SonarLintTestHarness harn .build(); var backend = harness.newBackend() - .build(fakeClient); + .start(fakeClient); backend.getConfigurationService() .didAddConfigurationScopes( @@ -306,7 +306,7 @@ void should_suggest_connection_with_multiple_bindings_when_config_scope_added(So .build(); var backend = harness.newBackend() - .build(fakeClient); + .start(fakeClient); backend.getConfigurationService() .didAddConfigurationScopes( @@ -348,7 +348,7 @@ void should_suggest_sonarlint_configuration_in_priority(SonarLintTestHarness har .build(); var backend = harness.newBackend() - .build(fakeClient); + .start(fakeClient); backend.getConfigurationService() .didAddConfigurationScopes( @@ -381,7 +381,7 @@ void should_suggest_sonarqube_connection_when_pascal_case(SonarLintTestHarness h .build(); var backend = harness.newBackend() - .build(fakeClient); + .start(fakeClient); backend.getFileService().didUpdateFileSystem(new DidUpdateFileSystemParams(List.of(fileDto), Collections.emptyList(), Collections.emptyList())); @@ -410,7 +410,7 @@ void should_suggest_sonarcloud_connection_when_pascal_case(SonarLintTestHarness .build(); var backend = harness.newBackend() - .build(fakeClient); + .start(fakeClient); backend.getFileService().didUpdateFileSystem(new DidUpdateFileSystemParams(List.of(fileDto), Collections.emptyList(), Collections.emptyList())); diff --git a/medium-tests/src/test/java/mediumtest/EffectiveRulesMediumTests.java b/medium-tests/src/test/java/mediumtest/EffectiveRulesMediumTests.java index a09f074638..69713360cd 100644 --- a/medium-tests/src/test/java/mediumtest/EffectiveRulesMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/EffectiveRulesMediumTests.java @@ -66,7 +66,7 @@ void it_should_return_embedded_rule_when_project_is_not_bound(SonarLintTestHarne var backend = harness.newBackend() .withUnboundConfigScope("scopeId") .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(); + .start(); var details = getEffectiveRuleDetails(backend, "scopeId", "python:S139"); @@ -89,7 +89,7 @@ void it_should_consider_standalone_rule_config_for_effective_parameter_values(So .withUnboundConfigScope("scopeId") .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) .withStandaloneRuleConfig("python:S139", true, Map.of("legalTrailingCommentPattern", "initialValue")) - .build(); + .start(); var detailsAfterInit = getEffectiveRuleDetails(backend, "scopeId", "python:S139"); @@ -118,7 +118,7 @@ void it_should_fail_when_rule_key_unknown_and_project_is_not_bound(SonarLintTest var backend = harness.newBackend() .withUnboundConfigScope("scopeId") .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(); + .start(); var futureResponse = backend.getRulesService().getEffectiveRuleDetails(new GetEffectiveRuleDetailsParams("scopeId", "python:SXXXX")); @@ -134,7 +134,7 @@ void it_should_return_rule_loaded_from_server_plugin_when_project_is_bound_and_p .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withSonarQubeConnection("connectionId", mockWebServerExtension.endpointParams().getBaseUrl(), storage -> storage.withPlugin(TestPlugin.JAVA)) .withEnabledLanguageInStandaloneMode(JAVA) - .build(); + .start(); var details = getEffectiveRuleDetails(backend, "scopeId", "java:S106"); @@ -154,7 +154,7 @@ void it_should_merge_rule_from_storage_and_server_when_project_is_bound(SonarLin ruleSet -> ruleSet.withActiveRule("python:S139", "INFO", Map.of("legalTrailingCommentPattern", "blah"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(); + .start(); mockWebServerExtension.addProtobufResponse("/api/rules/show.protobuf?key=python:S139", Rules.ShowResponse.newBuilder() .setRule(Rules.Rule.newBuilder().setName("newName").setSeverity("INFO").setType(Common.RuleType.BUG).setLang("py").setHtmlNote("extendedDesc").build()) .build()); @@ -178,7 +178,7 @@ void it_should_merge_rule_from_storage_and_server_when_parent_project_is_bound(S .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withChildConfigScope("childScopeId", "scopeId") .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(); + .start(); mockWebServerExtension.addProtobufResponse("/api/rules/show.protobuf?key=python:S139", Rules.ShowResponse.newBuilder() .setRule(Rules.Rule.newBuilder().setName("newName").setSeverity("INFO").setType(Common.RuleType.BUG).setLang("py").setHtmlNote("extendedDesc").build()) .build()); @@ -202,7 +202,7 @@ void it_return_single_section_from_server_when_project_is_bound(SonarLintTestHar projectStorage -> projectStorage.withRuleSet("js", ruleSet -> ruleSet.withActiveRule("jssecurity:S5696", "BLOCKER")))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") - .build(); + .start(); mockWebServerExtension.addProtobufResponse("/api/rules/show.protobuf?key=jssecurity:S5696", Rules.ShowResponse.newBuilder() .setRule(Rules.Rule.newBuilder().setName(name).setSeverity("BLOCKER").setType(Common.RuleType.VULNERABILITY).setLang("js") .setDescriptionSections(Rules.Rule.DescriptionSections.newBuilder() @@ -230,7 +230,7 @@ void it_should_fail_to_merge_rule_from_storage_and_server_when_connection_is_unk projectStorage -> projectStorage.withRuleSet("python", ruleSet -> ruleSet.withActiveRule("python:S139", "INFO", Map.of("legalTrailingCommentPattern", "blah"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") - .build(); + .start(); var futureResponse = backend.getRulesService().getEffectiveRuleDetails(new GetEffectiveRuleDetailsParams("scopeId", "python:S139")); @@ -247,7 +247,7 @@ void it_should_fail_to_merge_rule_from_storage_and_server_when_rule_does_not_exi projectStorage -> projectStorage.withRuleSet("python", ruleSet -> ruleSet.withActiveRule("python:S139", "INFO", Map.of("legalTrailingCommentPattern", "blah"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") - .build(); + .start(); var futureResponse = backend.getRulesService().getEffectiveRuleDetails(new GetEffectiveRuleDetailsParams("scopeId", "python:S139")); @@ -267,7 +267,7 @@ void it_should_merge_template_rule_from_storage_and_server_when_project_is_bound ruleSet -> ruleSet.withCustomActiveRule("python:custom", "python:CommentRegularExpression", "INFO", Map.of("message", "msg", "regularExpression", "regExp"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(); + .start(); mockWebServerExtension.addProtobufResponse("/api/rules/show.protobuf?key=python:custom", Rules.ShowResponse.newBuilder() .setRule(Rules.Rule.newBuilder().setName("newName").setSeverity("INFO").setType(Common.RuleType.BUG).setLang("py").setHtmlNote("extendedDesc") .setDescriptionSections(Rules.Rule.DescriptionSections.newBuilder() @@ -296,7 +296,7 @@ void it_should_merge_rule_from_storage_and_server_rule_when_rule_is_unknown_in_l ruleSet -> ruleSet.withActiveRule("python:S139", "INFO", Map.of("legalTrailingCommentPattern", "blah"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withEnabledLanguageInStandaloneMode(PYTHON) - .build(); + .start(); mockWebServerExtension.addProtobufResponse("/api/rules/show.protobuf?key=python:S139", Rules.ShowResponse.newBuilder() .setRule(Rules.Rule.newBuilder().setName("newName").setSeverity("INFO").setType(Common.RuleType.BUG).setLang("py").setHtmlNote("extendedDesc") .setDescriptionSections(Rules.Rule.DescriptionSections.newBuilder() @@ -413,7 +413,7 @@ void it_should_add_a_more_info_tab_if_no_resource_section_exists_and_extended_de ruleSet -> ruleSet.withActiveRule("python:S139", "INFO", Map.of("legalTrailingCommentPattern", "blah"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withEnabledLanguageInStandaloneMode(PYTHON) - .build(); + .start(); mockWebServerExtension.addProtobufResponse("/api/rules/show.protobuf?key=python:S139", Rules.ShowResponse.newBuilder() .setRule(Rules.Rule.newBuilder().setName("newName").setSeverity("INFO").setType(Common.RuleType.BUG).setLang("py").setHtmlNote("extendedDesc") .setEducationPrinciples(Rules.Rule.EducationPrinciples.newBuilder().addEducationPrinciples("never_trust_user_input").build()) @@ -471,7 +471,7 @@ void it_should_split_security_hotspots_rule_description_and_adapt_title(SonarLin .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) .withSecurityHotspotsEnabled() - .build(); + .start(); var details = getEffectiveRuleDetails(backend, "scopeId", "python:S4784"); @@ -489,7 +489,7 @@ private SonarLintTestRpcServer prepareForRuleDescriptionSectionsAndContext(Sonar ruleSet -> ruleSet.withActiveRule("python:S139", "INFO", Map.of("legalTrailingCommentPattern", "blah"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withEnabledLanguageInStandaloneMode(PYTHON) - .build(); + .start(); mockWebServerExtension.addProtobufResponse("/api/rules/show.protobuf?key=python:S139", Rules.ShowResponse.newBuilder() .setRule(Rules.Rule.newBuilder().setName("newName").setSeverity("INFO").setType(Common.RuleType.BUG).setLang("py").setHtmlNote("extendedDesc") .setEducationPrinciples(Rules.Rule.EducationPrinciples.newBuilder().addEducationPrinciples("never_trust_user_input").build()) diff --git a/medium-tests/src/test/java/mediumtest/EmbeddedServerMediumTests.java b/medium-tests/src/test/java/mediumtest/EmbeddedServerMediumTests.java index c046489cae..23626db1d9 100644 --- a/medium-tests/src/test/java/mediumtest/EmbeddedServerMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/EmbeddedServerMediumTests.java @@ -36,7 +36,7 @@ class EmbeddedServerMediumTests { @SonarLintTest void it_should_return_the_ide_name_and_empty_description_if_the_origin_is_not_trusted(SonarLintTestHarness harness) throws IOException, InterruptedException { var fakeClient = harness.newFakeClient().build(); - var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").build(fakeClient); + var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").start(fakeClient); var embeddedServerPort = backend.getEmbeddedServerPort(); var request = HttpRequest.newBuilder() @@ -55,7 +55,7 @@ void it_should_not_trust_origin_having_known_connection_prefix(SonarLintTestHarn var fakeClient = harness.newFakeClient().build(); when(fakeClient.getClientLiveDescription()).thenReturn("WorkspaceTitle"); - var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarQubeConnection("connectionId", "https://sonar.my").build(fakeClient); + var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarQubeConnection("connectionId", "https://sonar.my").start(fakeClient); var embeddedServerPort = backend.getEmbeddedServerPort(); var request = HttpRequest.newBuilder() @@ -75,7 +75,7 @@ void it_should_return_the_ide_name_and_full_description_if_the_origin_is_trusted var fakeClient = harness.newFakeClient().build(); when(fakeClient.getClientLiveDescription()).thenReturn("WorkspaceTitle"); - var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarQubeConnection("connectionId", "https://sonar.my").build(fakeClient); + var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarQubeConnection("connectionId", "https://sonar.my").start(fakeClient); var embeddedServerPort = backend.getEmbeddedServerPort(); var request = HttpRequest.newBuilder() @@ -101,7 +101,7 @@ void it_should_set_preflight_response_accordingly_when_receiving_preflight_reque var fakeClient = harness.newFakeClient().build(); when(fakeClient.getClientLiveDescription()).thenReturn("WorkspaceTitle"); - var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarQubeConnection("connectionId", "http://sonar.my").build(fakeClient); + var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarQubeConnection("connectionId", "http://sonar.my").start(fakeClient); var request = HttpRequest.newBuilder() .method("OPTIONS", HttpRequest.BodyPublishers.noBody()) @@ -122,7 +122,7 @@ void it_should_receive_bad_request_response_if_not_right_method(SonarLintTestHar var fakeClient = harness.newFakeClient().build(); when(fakeClient.getClientLiveDescription()).thenReturn("WorkspaceTitle"); - var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarQubeConnection("connectionId", "https://sonar.my").build(fakeClient); + var backend = harness.newBackend().withEmbeddedServer().withClientName("ClientName").withSonarQubeConnection("connectionId", "https://sonar.my").start(fakeClient); var embeddedServerPort = backend.getEmbeddedServerPort(); var requestToken = HttpRequest.newBuilder() diff --git a/medium-tests/src/test/java/mediumtest/InitializationMediumTests.java b/medium-tests/src/test/java/mediumtest/InitializationMediumTests.java index a5d4889b07..75989bfa73 100644 --- a/medium-tests/src/test/java/mediumtest/InitializationMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/InitializationMediumTests.java @@ -41,7 +41,7 @@ class InitializationMediumTests { @SonarLintTest void it_should_fail_to_initialize_the_backend_twice(SonarLintTestHarness harness) { var backend = harness.newBackend() - .build(); + .start(); var telemetryInitDto = new TelemetryClientConstantAttributesDto("mediumTests", "mediumTests", "1.2.3", "4.5.6", emptyMap()); var featureFlags = new FeatureFlagsDto(false, false, false, false, false, false, false, false, false, false, false); var future = backend diff --git a/medium-tests/src/test/java/mediumtest/NotebookLanguageMediumTests.java b/medium-tests/src/test/java/mediumtest/NotebookLanguageMediumTests.java index bcf976230e..7ef0a48294 100644 --- a/medium-tests/src/test/java/mediumtest/NotebookLanguageMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/NotebookLanguageMediumTests.java @@ -54,7 +54,7 @@ void should_not_enable_sync_for_notebook_python_language(SonarLintTestHarness ha .withEnabledLanguageInStandaloneMode(Language.JS) .withEnabledLanguageInStandaloneMode(Language.IPYTHON) .withFullSynchronization() - .build(fakeClient); + .start(fakeClient); backend.getConnectionService().didChangeCredentials(new DidChangeCredentialsParams(CONNECTION_ID)); diff --git a/medium-tests/src/test/java/mediumtest/SharedConnectedModeSettingsMediumTests.java b/medium-tests/src/test/java/mediumtest/SharedConnectedModeSettingsMediumTests.java index 5f7c2cf515..4375615c6d 100644 --- a/medium-tests/src/test/java/mediumtest/SharedConnectedModeSettingsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/SharedConnectedModeSettingsMediumTests.java @@ -37,7 +37,7 @@ class SharedConnectedModeSettingsMediumTests { void should_throw_when_not_bound(SonarLintTestHarness harness) { var configScopeId = "file:///my/folder"; var backend = harness.newBackend() - .build(); + .start(); var fileContents = getFileContents(backend, configScopeId); @@ -63,7 +63,7 @@ void should_return_sc_config_when_bound_to_sonarcloud(SonarLintTestHarness harne .withSonarCloudConnection(connectionId, organizationKey) .withBoundConfigScope(configScopeId, connectionId, projectKey) .withTelemetryEnabled() - .build(); + .start(); var result = getFileContents(backend, configScopeId); @@ -91,7 +91,7 @@ void should_return_sq_config_when_bound_to_sonarqube(SonarLintTestHarness harnes .withSonarQubeConnection(connectionId, server) .withBoundConfigScope(configScopeId, connectionId, projectKey) .withTelemetryEnabled() - .build(); + .start(); var result = getFileContents(backend, configScopeId); diff --git a/medium-tests/src/test/java/mediumtest/StandaloneIssueMediumTests.java b/medium-tests/src/test/java/mediumtest/StandaloneIssueMediumTests.java index 8b16799143..7b0a988eb6 100644 --- a/medium-tests/src/test/java/mediumtest/StandaloneIssueMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/StandaloneIssueMediumTests.java @@ -99,7 +99,7 @@ void simpleJavaScript(SonarLintTestHarness harness, @TempDir Path baseDir) throw var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVASCRIPT) - .build(client); + .start(client); var issues = analyzeFileAndGetIssues(inputFile.toUri(), client, backend, CONFIGURATION_SCOPE_ID); @@ -134,7 +134,7 @@ void sonarjs_should_honor_global_and_analysis_level_properties(SonarLintTestHarn .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVASCRIPT) - .build(client); + .start(client); backend.getRulesService() .updateStandaloneRulesConfiguration(new UpdateStandaloneRulesConfigurationParams(Map.of("javascript:S3827", new StandaloneRuleConfigDto(true, emptyMap())))); @@ -170,7 +170,7 @@ void simpleTypeScript(SonarLintTestHarness harness, @TempDir Path baseDir) throw var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVASCRIPT) - .build(client); + .start(client); var issues = analyzeFileAndGetIssues(inputFile.toUri(), client, backend, CONFIGURATION_SCOPE_ID); @@ -202,7 +202,7 @@ void simpleJavaScriptInYamlFile(SonarLintTestHarness harness, @TempDir Path base var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVASCRIPT) - .build(client); + .start(client); var issues = analyzeFileAndGetIssues(inputFile.toUri(), client, backend, CONFIGURATION_SCOPE_ID); assertThat(issues).extracting(RaisedIssueDto::getRuleKey, i -> i.getTextRange().getStartLine()).containsOnly( @@ -237,7 +237,7 @@ void simpleC(SonarLintTestHarness harness, @TempDir Path baseDir) { var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.CFAMILY) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var analysisResult = backend.getAnalysisService().analyzeFilesAndTrack( @@ -271,7 +271,7 @@ void simplePhp(SonarLintTestHarness harness, @TempDir Path baseDir) { var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PHP) - .build(client); + .start(client); var issues = analyzeFileAndGetIssues(inputFile.toUri(), client, backend, CONFIGURATION_SCOPE_ID); @@ -301,7 +301,7 @@ void fileEncoding(SonarLintTestHarness harness, @TempDir Path baseDir) throws IO var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PHP) - .build(client); + .start(client); var issues = analyzeFileAndGetIssues(inputFile.toUri(), client, backend, CONFIGURATION_SCOPE_ID); @@ -325,7 +325,7 @@ void analysisErrors(SonarLintTestHarness harness, @TempDir Path baseDir) { var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PHP) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var analysisResult = backend.getAnalysisService().analyzeFilesAndTrack( @@ -348,7 +348,7 @@ void simplePython(SonarLintTestHarness harness, @TempDir Path baseDir) { var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(client); + .start(client); var issues = analyzeFileAndGetIssues(inputFile.toUri(), client, backend, CONFIGURATION_SCOPE_ID); @@ -367,7 +367,7 @@ void simpleKotlinKts(SonarLintTestHarness harness, @TempDir Path baseDir) { var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.KOTLIN) - .build(client); + .start(client); var issues = analyzeFileAndGetIssues(inputFile.toUri(), client, backend, CONFIGURATION_SCOPE_ID); @@ -389,7 +389,7 @@ void useRelativePathToEvaluatePathPatterns(SonarLintTestHarness harness, @TempDi var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(client); + .start(client); var issues = analyzeFileAndGetIssues(inputFile.toUri(), client, backend, CONFIGURATION_SCOPE_ID); @@ -416,7 +416,7 @@ void simpleJava(SonarLintTestHarness harness, @TempDir Path baseDir) { var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); var issues = analyzeFileAndGetIssues(inputFile.toUri(), client, backend, CONFIGURATION_SCOPE_ID); @@ -444,7 +444,7 @@ void simpleJavaWithQuickFix(SonarLintTestHarness harness, @TempDir Path baseDir) var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); var issues = analyzeFileAndGetIssues(inputFile.toUri(), client, backend, CONFIGURATION_SCOPE_ID); @@ -487,7 +487,7 @@ void simpleJavaWithCommaInClasspath(SonarLintTestHarness harness, @TempDir Path var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var analysisResult = backend.getAnalysisService().analyzeFilesAndTrack( @@ -517,7 +517,7 @@ void it_should_get_issue_details_for_standalone_issue(SonarLintTestHarness harne var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.TEXT) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); backend.getAnalysisService() @@ -551,7 +551,7 @@ void it_should_not_get_issue_details_for_non_existent_issue(SonarLintTestHarness var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.TEXT) - .build(client); + .start(client); var issueId = UUID.randomUUID(); var params = new GetEffectiveIssueDetailsParams(CONFIGURATION_SCOPE_ID, issueId); @@ -567,7 +567,7 @@ void noRuleTemplates(SonarLintTestHarness harness) throws ExecutionException, In var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(client); + .start(client); var response = backend.getRulesService().listAllStandaloneRulesDefinitions().get(); assertThat(response.getRulesByKey()).doesNotContainKey("python:XPath"); @@ -587,7 +587,7 @@ void onlyLoadRulesOfEnabledLanguages(SonarLintTestHarness harness) throws Execut if (COMMERCIAL_ENABLED) { backendBuilder = backendBuilder.withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.CFAMILY); } - var backend = backendBuilder.build(client); + var backend = backendBuilder.start(client); var enabledLanguages = EnumSet.of(JAVA, JS, PHP, PYTHON, TS, XML, KOTLIN); @@ -616,7 +616,7 @@ void simpleJavaNoHotspots(SonarLintTestHarness harness, @TempDir Path baseDir) t var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getRulesService() .updateStandaloneRulesConfiguration(new UpdateStandaloneRulesConfigurationParams(Map.of("java:S1313", new StandaloneRuleConfigDto(true, emptyMap())))); @@ -640,7 +640,7 @@ void simpleJavaPomXml(SonarLintTestHarness harness, @TempDir Path baseDir) { var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); var issues = analyzeFileAndGetIssues(inputFile.toUri(), client, backend, CONFIGURATION_SCOPE_ID); @@ -666,7 +666,7 @@ void supportJavaSuppressWarning(SonarLintTestHarness harness, @TempDir Path base var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); var issues = analyzeFileAndGetIssues(inputFile.toUri(), client, backend, CONFIGURATION_SCOPE_ID); @@ -691,7 +691,7 @@ void simpleJavaWithBytecode(SonarLintTestHarness harness) { var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var analysisResult = backend.getAnalysisService().analyzeFilesAndTrack( new AnalyzeFilesAndTrackParams(CONFIGURATION_SCOPE_ID, analysisId, List.of(inputFile.toUri()), Map.of("sonar.java.binaries", projectWithByteCode.resolve("bin").toString()), @@ -727,7 +727,7 @@ void simpleJavaWithExcludedRules(SonarLintTestHarness harness, @TempDir Path bas var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getRulesService() .updateStandaloneRulesConfiguration(new UpdateStandaloneRulesConfigurationParams(Map.of("java:S106", new StandaloneRuleConfigDto(false, emptyMap())))); @@ -757,7 +757,7 @@ void simpleJavaWithExcludedRulesUsingDeprecatedKey(SonarLintTestHarness harness, var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getRulesService() .updateStandaloneRulesConfiguration(new UpdateStandaloneRulesConfigurationParams(Map.of("squid:S106", new StandaloneRuleConfigDto(false, emptyMap())))); @@ -789,7 +789,7 @@ void simpleJavaWithIncludedRules(SonarLintTestHarness harness, @TempDir Path bas var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getRulesService() .updateStandaloneRulesConfiguration(new UpdateStandaloneRulesConfigurationParams(Map.of("java:S3553", new StandaloneRuleConfigDto(true, emptyMap())))); @@ -821,7 +821,7 @@ void simpleJavaWithIncludedRulesUsingDeprecatedKey(SonarLintTestHarness harness, var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getRulesService() .updateStandaloneRulesConfiguration(new UpdateStandaloneRulesConfigurationParams(Map.of("squid:S3553", new StandaloneRuleConfigDto(true, emptyMap())))); @@ -853,7 +853,7 @@ void simpleJavaWithIssueOnDir(SonarLintTestHarness harness, @TempDir Path baseDi var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getRulesService() .updateStandaloneRulesConfiguration(new UpdateStandaloneRulesConfigurationParams(Map.of("java:S1228", new StandaloneRuleConfigDto(true, emptyMap())))); @@ -886,7 +886,7 @@ void simpleJavaWithSecondaryLocations(SonarLintTestHarness harness, @TempDir Pat var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); var issues = analyzeFileAndGetIssues(inputFile.toUri(), client, backend, CONFIGURATION_SCOPE_ID); @@ -931,7 +931,7 @@ void testJavaSurefireDontCrashAnalysis(SonarLintTestHarness harness, @TempDir Pa var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var analysisResult = backend.getAnalysisService().analyzeFilesAndTrack( @@ -973,7 +973,7 @@ void lazy_init_file_metadata(SonarLintTestHarness harness, @TempDir Path baseDir var backend = harness.newBackend() .withUnboundConfigScope(CONFIGURATION_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var analysisResult = backend.getAnalysisService().analyzeFilesAndTrack( diff --git a/medium-tests/src/test/java/mediumtest/StandaloneNoPluginMediumTests.java b/medium-tests/src/test/java/mediumtest/StandaloneNoPluginMediumTests.java index 47d6e1fec1..f02c7ea23d 100644 --- a/medium-tests/src/test/java/mediumtest/StandaloneNoPluginMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/StandaloneNoPluginMediumTests.java @@ -54,7 +54,7 @@ void dont_fail_and_detect_language_even_if_no_plugin(SonarLintTestHarness harnes var backend = harness.newBackend() .withSecurityHotspotsEnabled() .withUnboundConfigScope(CONFIG_SCOPE_ID) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var analysisResult = backend.getAnalysisService().analyzeFilesAndTrack( diff --git a/medium-tests/src/test/java/mediumtest/StandaloneRulesMediumTests.java b/medium-tests/src/test/java/mediumtest/StandaloneRulesMediumTests.java index 6db765c743..9c92507df8 100644 --- a/medium-tests/src/test/java/mediumtest/StandaloneRulesMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/StandaloneRulesMediumTests.java @@ -47,7 +47,7 @@ void it_should_return_only_embedded_rules_of_enabled_languages(SonarLintTestHarn var backend = harness.newBackend() .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) .withStandaloneEmbeddedPlugin(TestPlugin.PHP) - .build(); + .start(); var allRules = listAllStandaloneRulesDefinitions(backend).getRulesByKey().values(); @@ -58,7 +58,7 @@ void it_should_return_only_embedded_rules_of_enabled_languages(SonarLintTestHarn void it_should_return_param_definition(SonarLintTestHarness harness) { var backend = harness.newBackend() .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(); + .start(); var javaS1176 = listAllStandaloneRulesDefinitions(backend).getRulesByKey().get("java:S1176"); @@ -79,7 +79,7 @@ void it_should_return_param_definition(SonarLintTestHarness harness) { void it_should_return_rule_details_with_definition_and_description(SonarLintTestHarness harness) throws ExecutionException, InterruptedException { var backend = harness.newBackend() .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(); + .start(); var ruleDetails = backend.getRulesService().getStandaloneRuleDetails(new GetStandaloneRuleDescriptionParams("java:S1176")).get(); @@ -97,7 +97,7 @@ void it_should_return_rule_details_with_definition_and_description(SonarLintTest void it_should_not_contain_rule_templates(SonarLintTestHarness harness) { var backend = harness.newBackend() .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(); + .start(); var allRules = listAllStandaloneRulesDefinitions(backend).getRulesByKey().values(); @@ -109,7 +109,7 @@ void it_should_not_contain_rule_templates(SonarLintTestHarness harness) { void it_should_not_contain_hotspots_by_default(SonarLintTestHarness harness) { var backend = harness.newBackend() .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(); + .start(); var allRules = listAllStandaloneRulesDefinitions(backend).getRulesByKey().values(); diff --git a/medium-tests/src/test/java/mediumtest/TelemetryMediumTests.java b/medium-tests/src/test/java/mediumtest/TelemetryMediumTests.java index 175a5ba757..e950b1c198 100644 --- a/medium-tests/src/test/java/mediumtest/TelemetryMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/TelemetryMediumTests.java @@ -101,7 +101,7 @@ void it_should_not_create_telemetry_file_if_telemetry_disabled_by_system_propert var backend = harness.newBackend() .withSonarQubeConnection("connectionId", "http://localhost:12345", storage -> storage.withProject("projectKey", project -> project.withMainBranch("master"))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") - .build(); + .start(); assertThat(backend.getTelemetryService().getStatus().get().isEnabled()).isFalse(); @@ -119,7 +119,7 @@ void it_should_not_enable_telemetry_if_disabled_by_system_property(SonarLintTest .withSonarQubeConnection("connectionId", "http://localhost:12345", storage -> storage.withProject("projectKey", project -> project.withMainBranch("master"))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") - .build(fakeClient); + .start(fakeClient); assertThat(backend.getTelemetryService().getStatus().get().isEnabled()).isFalse(); backend.getTelemetryService().enableTelemetry(); @@ -140,7 +140,7 @@ void it_should_create_telemetry_file_if_telemetry_enabled(SonarLintTestHarness h .withSonarQubeConnection("connectionId", "http://localhost:12345", storage -> storage.withProject("projectKey", project -> project.withMainBranch("master"))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withTelemetryEnabled(telemetryEndpointMock.baseUrl() + "/sonarlint-telemetry") - .build(fakeClient); + .start(fakeClient); backend.getHotspotService().openHotspotInBrowser(new OpenHotspotInBrowserParams("scopeId", "ab12ef45")); await().untilAsserted(() -> assertThat(backend.telemetryFilePath()).isNotEmptyFile()); @@ -166,7 +166,7 @@ void it_should_consider_telemetry_status_in_file(SonarLintTestHarness harness) t .withSonarQubeConnection("connectionId") .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withTelemetryEnabled() - .build(); + .start(); assertThat(backend.getTelemetryService().getStatus().get().isEnabled()).isTrue(); assertThat(backend.telemetryFilePath()).isNotEmptyFile(); @@ -186,7 +186,7 @@ void it_should_ping_telemetry_endpoint(SonarLintTestHarness harness) throws Exec var backend = harness.newBackend() .withTelemetryEnabled(telemetryEndpointMock.baseUrl() + "/sonarlint-telemetry") - .build(fakeClient); + .start(fakeClient); assertThat(backend.getTelemetryService().getStatus().get().isEnabled()).isTrue(); @@ -213,7 +213,7 @@ void it_should_disable_telemetry(SonarLintTestHarness harness) throws ExecutionE var backend = harness.newBackend() .withTelemetryEnabled(telemetryEndpointMock.baseUrl() + "/sonarlint-telemetry") - .build(fakeClient); + .start(fakeClient); assertThat(backend.getTelemetryService().getStatus().get().isEnabled()).isTrue(); @@ -246,7 +246,7 @@ void it_should_enable_disabled_telemetry(SonarLintTestHarness harness) throws Ex .withSonarQubeConnection("connectionId") .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withTelemetryEnabled() - .build(fakeClient); + .start(fakeClient); backend.getTelemetryService().disableTelemetry(); assertThat(backend.getTelemetryService().getStatus().get().isEnabled()).isFalse(); @@ -263,7 +263,7 @@ void it_should_not_crash_when_cannot_build_payload(SonarLintTestHarness harness) harness.newBackend() .withSonarQubeConnection("connectionId") .withBoundConfigScope("scopeId", "connectionId", "projectKey") - .build(fakeClient); + .start(fakeClient); assertThat(telemetryEndpointMock.getAllServeEvents()).isEmpty(); } @@ -279,7 +279,7 @@ void failed_upload_payload_should_log_if_debug(SonarLintTestHarness harness) { .withSonarQubeConnection("connectionId") .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withTelemetryEnabled() - .build(fakeClient); + .start(fakeClient); assertThat(telemetryEndpointMock.getAllServeEvents()).isEmpty(); await().untilAsserted(() -> assertThat(fakeClient.getLogs()).extracting(LogParams::getMessage).contains(("Failed to fetch telemetry payload"))); @@ -425,7 +425,7 @@ void it_should_apply_telemetry_migration(SonarLintTestHarness harness) throws Ex var backend = harness.newBackend() .withTelemetryMigration(new TelemetryMigrationDto(OffsetDateTime.now(), 42, false)) .withTelemetryEnabled() - .build(); + .start(); assertThat(backend.getTelemetryService().getStatus().get().isEnabled()).isFalse(); } @@ -435,7 +435,7 @@ private SonarLintTestRpcServer setupClientAndBackend(SonarLintTestHarness harnes .withSonarQubeConnection("connectionId") .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withTelemetryEnabled() - .build(); + .start(); } } diff --git a/medium-tests/src/test/java/mediumtest/UserTokenMediumTests.java b/medium-tests/src/test/java/mediumtest/UserTokenMediumTests.java index 96f03e3f11..6b5a7fa348 100644 --- a/medium-tests/src/test/java/mediumtest/UserTokenMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/UserTokenMediumTests.java @@ -30,7 +30,7 @@ class UserTokenMediumTests { @SonarLintTest void test_revoke_user_token(SonarLintTestHarness harness) { - var backend = harness.newBackend().build(); + var backend = harness.newBackend().start(); var tokenName = "tokenNameTest"; var server = harness.newFakeSonarQubeServer().withToken(tokenName).start(); @@ -42,7 +42,7 @@ void test_revoke_user_token(SonarLintTestHarness harness) { @SonarLintTest void test_revoke_unknown_user_token(SonarLintTestHarness harness) { - var backend = harness.newBackend().build(); + var backend = harness.newBackend().start(); var tokenName = "tokenNameTest"; var server = harness.newFakeSonarQubeServer().start(); diff --git a/medium-tests/src/test/java/mediumtest/analysis/AnalysisMediumTests.java b/medium-tests/src/test/java/mediumtest/analysis/AnalysisMediumTests.java index 7cb44ce937..0a580866f2 100644 --- a/medium-tests/src/test/java/mediumtest/analysis/AnalysisMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/analysis/AnalysisMediumTests.java @@ -106,7 +106,7 @@ void it_should_skip_analysis_if_no_file_provided(SonarLintTestHarness harness, @ var client = harness.newFakeClient().build(); var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var result = backend.getAnalysisService() @@ -144,7 +144,7 @@ void should_not_raise_issues_for_previously_analysed_files_if_they_were_not_subm .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) .withDisabledPluginsForAnalysis(SonarLanguage.JAVA.getPluginKey()) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var result = backend.getAnalysisService() @@ -182,7 +182,7 @@ void it_should_analyze_xml_file_in_standalone_mode(SonarLintTestHarness harness, var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var result = backend.getAnalysisService() @@ -223,7 +223,7 @@ void it_should_analyze_xml_file_in_connected_mode(SonarLintTestHarness harness, storage -> storage.withPlugin(TestPlugin.XML).withProject("projectKey", project -> project.withRuleSet("xml", ruleSet -> ruleSet.withActiveRule("xml:S3421", "BLOCKER")))) .withBoundConfigScope(CONFIG_SCOPE_ID, "connectionId", "projectKey") .withExtraEnabledLanguagesInConnectedMode(Language.XML) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var result = backend.getAnalysisService() @@ -251,7 +251,7 @@ void it_should_notify_client_on_plugin_skip(SonarLintTestHarness harness, @TempD var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var result = backend.getAnalysisService() @@ -272,7 +272,7 @@ void it_should_notify_client_on_secret_detection(SonarLintTestHarness harness, @ var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.TEXT) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var result = backend.getAnalysisService() @@ -293,7 +293,7 @@ void it_should_notify_client_on_analysis_progress(SonarLintTestHarness harness, var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.TEXT) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); backend.getAnalysisService() @@ -318,7 +318,7 @@ void analysis_response_should_contain_raw_issues(SonarLintTestHarness harness, @ var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.TEXT) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var result = backend.getAnalysisService() @@ -346,7 +346,7 @@ void it_should_report_issues_for_multi_file_analysis_taking_data_from_module_fil var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var result = backend.getAnalysisService() @@ -373,7 +373,7 @@ void it_should_report_multi_file_issues_for_files_added_after_initialization(Son .build(); var backend = harness.newBackend() .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var result = backend.getAnalysisService().analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams(CONFIG_SCOPE_ID, analysisId, @@ -430,7 +430,7 @@ void it_should_report_issues_for_multi_file_analysis_only_for_leaf_config_scopes .withUnboundConfigScope(parentConfigScope) .withUnboundConfigScope(leafConfigScope, leafConfigScope, parentConfigScope) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var leafConfigScopeResult = backend.getAnalysisService().analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams(leafConfigScope, analysisId, @@ -461,7 +461,7 @@ void it_should_update_module_file_system_on_file_events_creating_file(SonarLintT var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var parentConfigScopeResult = backend.getAnalysisService().analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams(CONFIG_SCOPE_ID, analysisId, @@ -508,7 +508,7 @@ void it_should_update_module_file_system_on_file_events_deleting_file(SonarLintT var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var result = backend.getAnalysisService().analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams(CONFIG_SCOPE_ID, analysisId, @@ -550,7 +550,7 @@ void it_should_update_module_file_system_on_file_events_editing_file(SonarLintTe var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var result = backend.getAnalysisService().analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams(CONFIG_SCOPE_ID, analysisId, @@ -578,7 +578,7 @@ void it_should_update_module_file_system_on_file_events_editing_file(SonarLintTe @SonarLintTest void should_save_and_return_client_analysis_settings(SonarLintTestHarness harness) { - var backend = harness.newBackend().build(); + var backend = harness.newBackend().start(); backend.getAnalysisService().didSetUserAnalysisProperties( new DidChangeAnalysisPropertiesParams(CONFIG_SCOPE_ID, Map.of("key1", "user-value1", "key2", "user-value2"))); @@ -591,7 +591,7 @@ void should_save_and_return_client_analysis_settings(SonarLintTestHarness harnes void should_set_js_internal_bundlePath_if_provided(SonarLintTestHarness harness, @TempDir Path baseDir) { var backend = harness.newBackend() .withEslintBridgeServerBundlePath(baseDir.resolve("eslint-bridge")) - .build(); + .start(); var analysisProperties = backend.getAnalysisService().getAnalysisConfig(new GetAnalysisConfigParams(CONFIG_SCOPE_ID)).join().getAnalysisProperties(); @@ -600,7 +600,7 @@ void should_set_js_internal_bundlePath_if_provided(SonarLintTestHarness harness, @SonarLintTest void should_not_set_js_internal_bundlePath_when_not_provided(SonarLintTestHarness harness) { - var backend = harness.newBackend().build(); + var backend = harness.newBackend().start(); var analysisProperties = backend.getAnalysisService().getAnalysisConfig(new GetAnalysisConfigParams(CONFIG_SCOPE_ID)).join().getAnalysisProperties(); @@ -611,7 +611,7 @@ void should_not_set_js_internal_bundlePath_when_not_provided(SonarLintTestHarnes void should_not_set_js_internal_bundlePath_when_no_language_specific_requirements(SonarLintTestHarness harness) { var backend = harness.newBackend() .withNoLanguageSpecificRequirements() - .build(); + .start(); var analysisProperties = backend.getAnalysisService().getAnalysisConfig(new GetAnalysisConfigParams(CONFIG_SCOPE_ID)).join().getAnalysisProperties(); @@ -636,7 +636,7 @@ void it_should_skip_analysis_and_keep_rules_if_disabled_language_for_analysis(So .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) .withDisabledPluginsForAnalysis(SonarLanguage.XML.getPluginKey()) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var result = backend.getAnalysisService() @@ -679,7 +679,7 @@ void it_should_skip_analysis_only_for_disabled_language(SonarLintTestHarness har .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) .withDisabledPluginsForAnalysis(SonarLanguage.XML.getPluginKey()) - .build(client); + .start(client); var analysisId = UUID.randomUUID(); var result = backend.getAnalysisService() @@ -719,7 +719,7 @@ void should_trigger_analysis_on_path_to_compile_command_change(SonarLintTestHarn var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.CFAMILY) - .build(client); + .start(client); backend.getAnalysisService() .didSetUserAnalysisProperties(new DidChangeAnalysisPropertiesParams(CONFIG_SCOPE_ID, Map.of("sonar.cfamily.build-wrapper-content", buildWrapperContent))); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, cFileUri)); @@ -741,7 +741,7 @@ void should_allow_removing_compile_commands_path(SonarLintTestHarness harness) { var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.CFAMILY) - .build(); + .start(); backend.getAnalysisService().didChangePathToCompileCommands(new DidChangePathToCompileCommandsParams(CONFIG_SCOPE_ID, null)); @@ -790,7 +790,7 @@ void it_should_unload_rules_cache_on_config_scope_closed(SonarLintTestHarness ha .withBoundConfigScope(configScope2, connectionId2, projectKey2) .withExtraEnabledLanguagesInConnectedMode(Language.XML) .withFullSynchronization() - .build(client); + .start(client); backend.getConfigurationService().didAddConfigurationScopes(new DidAddConfigurationScopesParams(List.of( new ConfigurationScopeDto(configScope2, null, true, configScope2, new BindingConfigurationDto(connectionId2, projectKey2, true))))); @@ -862,7 +862,7 @@ void it_should_not_unload_rules_cache_on_config_scope_closed_if_another_config_s .withBoundConfigScope(configScope2, connectionId2, projectKey2) .withExtraEnabledLanguagesInConnectedMode(Language.XML) .withFullSynchronization() - .build(client); + .start(client); backend.getConfigurationService().didAddConfigurationScopes(new DidAddConfigurationScopesParams(List.of( new ConfigurationScopeDto(configScope2, null, true, configScope2, new BindingConfigurationDto(connectionId2, projectKey2, true))))); @@ -900,7 +900,7 @@ void it_should_analyse_file_with_non_file_uri_schema(SonarLintTestHarness harnes var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getAnalysisService() .analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams(CONFIG_SCOPE_ID, UUID.randomUUID(), List.of(fileUri1), Map.of(), false, System.currentTimeMillis())).join(); @@ -932,7 +932,7 @@ void it_should_respect_gitignore_exclusions(SonarLintTestHarness harness, @TempD var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getAnalysisService() .analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams(CONFIG_SCOPE_ID, UUID.randomUUID(), List.of(fileUri), Map.of(), false, System.currentTimeMillis())).join(); @@ -943,7 +943,7 @@ void it_should_respect_gitignore_exclusions(SonarLintTestHarness harness, @TempD void it_should_not_use_enterprise_csharp_analyzer_in_standalone(SonarLintTestHarness harness) { var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) - .build(); + .start(); var response = backend.getAnalysisService().shouldUseEnterpriseCSharpAnalyzer(new ShouldUseEnterpriseCSharpAnalyzerParams(CONFIG_SCOPE_ID)).join(); @@ -960,7 +960,7 @@ void it_should_not_use_enterprise_csharp_analyzer_when_connected_to_community(So .withBoundConfigScope(CONFIG_SCOPE_ID, "connectionId", "projectKey") .withExtraEnabledLanguagesInConnectedMode(Language.XML) .withFullSynchronization() - .build(); + .start(); var result = backend.getAnalysisService().shouldUseEnterpriseCSharpAnalyzer(new ShouldUseEnterpriseCSharpAnalyzerParams(CONFIG_SCOPE_ID)).join(); @@ -980,7 +980,7 @@ void it_should_use_enterprise_csharp_analyzer_when_connected_to_community_non_re .withBoundConfigScope(CONFIG_SCOPE_ID, "connectionId", "projectKey") .withExtraEnabledLanguagesInConnectedMode(Language.XML) .withFullSynchronization() - .build(); + .start(); var result = backend.getAnalysisService().shouldUseEnterpriseCSharpAnalyzer(new ShouldUseEnterpriseCSharpAnalyzerParams(CONFIG_SCOPE_ID)).join(); diff --git a/medium-tests/src/test/java/mediumtest/analysis/AnalysisReadinessMediumTests.java b/medium-tests/src/test/java/mediumtest/analysis/AnalysisReadinessMediumTests.java index 1d723ffd6f..d0d2b98b9c 100644 --- a/medium-tests/src/test/java/mediumtest/analysis/AnalysisReadinessMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/analysis/AnalysisReadinessMediumTests.java @@ -52,7 +52,7 @@ class AnalysisReadinessMediumTests { void it_should_be_immediately_consider_analysis_to_be_ready_when_adding_a_non_bound_configuration_scope(SonarLintTestHarness harness) { var client = harness.newFakeClient().build(); var backend = harness.newBackend() - .build(client); + .start(client); backend.getConfigurationService().didAddConfigurationScopes(new DidAddConfigurationScopesParams(List.of(new ConfigurationScopeDto(CONFIG_SCOPE_ID, null, true, "name", null)))); @@ -82,7 +82,7 @@ void it_should_analyze_xml_file_in_connected_mode(SonarLintTestHarness harness, .withBoundConfigScope(CONFIG_SCOPE_ID, "connectionId", "projectKey") .withFullSynchronization() .withExtraEnabledLanguagesInConnectedMode(Language.XML) - .build(client); + .start(client); verify(client, never()).didChangeAnalysisReadiness(Set.of(CONFIG_SCOPE_ID), true); diff --git a/medium-tests/src/test/java/mediumtest/analysis/AnalysisTriggeringMediumTests.java b/medium-tests/src/test/java/mediumtest/analysis/AnalysisTriggeringMediumTests.java index 59d27b001e..f7853f681c 100644 --- a/medium-tests/src/test/java/mediumtest/analysis/AnalysisTriggeringMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/analysis/AnalysisTriggeringMediumTests.java @@ -76,7 +76,7 @@ void it_should_analyze_file_on_open(SonarLintTestHarness harness, @TempDir Path var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, fileUri)); @@ -106,7 +106,7 @@ void it_should_not_fail_an_analysis_of_windows_shortcut_file_and_skip_the_file_a var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.TEXT) - .build(client); + .start(client); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, windowsShortcut.toUri())); await().during(5, TimeUnit.SECONDS).untilAsserted(() -> { @@ -139,7 +139,7 @@ void it_should_not_fail_an_analysis_of_symlink_file_and_skip_the_file_analysis(S var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, link.toUri())); await().during(5, TimeUnit.SECONDS).untilAsserted(() -> { @@ -161,7 +161,7 @@ void it_should_analyze_open_file_on_content_change(SonarLintTestHarness harness, var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, fileUri)); var publishedIssues = getPublishedIssues(client, CONFIG_SCOPE_ID); assertThat(publishedIssues) @@ -201,7 +201,7 @@ void it_should_analyze_closed_file_on_content_change(SonarLintTestHarness harnes var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, fileUri)); var publishedIssues = getPublishedIssues(client, CONFIG_SCOPE_ID); assertThat(publishedIssues) @@ -244,7 +244,7 @@ void it_should_analyze_open_files_when_re_enabling_automatic_analysis(SonarLintT .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) .withAutomaticAnalysisEnabled(false) - .build(client); + .start(client); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, fileUri)); backend.getAnalysisService().didChangeAutomaticAnalysisSetting(new DidChangeAutomaticAnalysisSettingParams(true)); @@ -273,7 +273,7 @@ void it_should_analyze_open_files_when_enabling_rule(SonarLintTestHarness harnes var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, fileUri)); var publishedIssues = getPublishedIssues(client, CONFIG_SCOPE_ID); assertThat(publishedIssues) @@ -309,7 +309,7 @@ void it_should_not_analyze_open_files_but_should_clear_and_report_issues_when_di var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, fileUri)); var publishedIssues = getPublishedIssues(client, CONFIG_SCOPE_ID); assertThat(publishedIssues) diff --git a/medium-tests/src/test/java/mediumtest/analysis/AnalysysForcedByClientMediumTests.java b/medium-tests/src/test/java/mediumtest/analysis/AnalysysForcedByClientMediumTests.java index 764e1d6718..cb27e7011e 100644 --- a/medium-tests/src/test/java/mediumtest/analysis/AnalysysForcedByClientMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/analysis/AnalysysForcedByClientMediumTests.java @@ -73,7 +73,7 @@ void should_run_forced_analysis_for_list_of_files(SonarLintTestHarness harness, var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getAnalysisService().analyzeFileList( new AnalyzeFileListParams(CONFIG_SCOPE_ID, List.of(fileUri1, fileUri2))); @@ -100,7 +100,7 @@ void should_run_forced_analysis_for_open_files(SonarLintTestHarness harness, @Te var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, fileUri1)); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, fileUri2)); @@ -139,7 +139,7 @@ void should_run_forced_analysis_vcs_changed_files(SonarLintTestHarness harness, var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getAnalysisService().analyzeVCSChangedFiles(new AnalyzeVCSChangedFilesParams(CONFIG_SCOPE_ID)); await().during(500, TimeUnit.MILLISECONDS).untilAsserted(() -> assertThat(client.getRaisedIssuesForScopeId(CONFIG_SCOPE_ID)).hasSize(3)); @@ -184,7 +184,7 @@ void should_run_forced_full_project_analysis_only_for_hotspots(SonarLintTestHarn .withSonarQubeConnection(connectionId, serverWithHotspots) .withBoundConfigScope(CONFIG_SCOPE_ID, connectionId, projectKey) .withExtraEnabledLanguagesInConnectedMode(JAVA) - .build(client); + .start(client); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(client.getSynchronizedConfigScopeIds()).contains(CONFIG_SCOPE_ID)); backend.getAnalysisService().analyzeFullProject(new AnalyzeFullProjectParams(CONFIG_SCOPE_ID, true)); @@ -240,7 +240,7 @@ void should_run_forced_full_project_analysis_for_all_findings(SonarLintTestHarne .withSonarQubeConnection(connectionId, serverWithHotspots) .withBoundConfigScope(CONFIG_SCOPE_ID, connectionId, projectKey) .withExtraEnabledLanguagesInConnectedMode(JAVA) - .build(client); + .start(client); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(client.getSynchronizedConfigScopeIds()).contains(CONFIG_SCOPE_ID)); backend.getAnalysisService().analyzeFullProject(new AnalyzeFullProjectParams(CONFIG_SCOPE_ID, false)); @@ -275,7 +275,7 @@ void should_not_check_file_exclusions_for_forced_analysis(SonarLintTestHarness h var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, fileUri)); diff --git a/medium-tests/src/test/java/mediumtest/analysis/NodeJsMediumTests.java b/medium-tests/src/test/java/mediumtest/analysis/NodeJsMediumTests.java index f9bb680a63..919970679f 100644 --- a/medium-tests/src/test/java/mediumtest/analysis/NodeJsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/analysis/NodeJsMediumTests.java @@ -41,7 +41,7 @@ void wrong_node_path_prevents_loading_sonar_js_rules(SonarLintTestHarness harnes var backend = harness.newBackend() .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVASCRIPT) .withClientNodeJsPath(Paths.get("wrong")) - .build(client); + .start(client); var globalConfig = backend.getAnalysisService().getGlobalStandaloneConfiguration().join(); @@ -62,7 +62,7 @@ void can_retrieve_auto_detected_node_js(SonarLintTestHarness harness) { var client = harness.newFakeClient().build(); var backend = harness.newBackend() .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVASCRIPT) - .build(client); + .start(client); var nodeJsDetails = backend.getAnalysisService().getAutoDetectedNodeJs().join().getDetails(); @@ -76,7 +76,7 @@ void can_retrieve_forced_node_js(SonarLintTestHarness harness) { var client = harness.newFakeClient().build(); var backend = harness.newBackend() .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVASCRIPT) - .build(client); + .start(client); var nodeJsDetails = backend.getAnalysisService().didChangeClientNodeJsPath(new DidChangeClientNodeJsPathParams(null)).join().getDetails(); diff --git a/medium-tests/src/test/java/mediumtest/analysis/RulesInConnectedModeMediumTests.java b/medium-tests/src/test/java/mediumtest/analysis/RulesInConnectedModeMediumTests.java index 7c53edcdd5..7d18f0480a 100644 --- a/medium-tests/src/test/java/mediumtest/analysis/RulesInConnectedModeMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/analysis/RulesInConnectedModeMediumTests.java @@ -54,7 +54,7 @@ void should_ignore_unknown_active_rule_parameters_and_convert_deprecated_keys(So .withActiveRule("java:S3776", "BLOCKER", Map.of("blah", "blah")) // Emulate server returning a deprecated template key .withCustomActiveRule("squid:myCustomRule", "squid:S124", "MAJOR", Map.of("message", "Needs to be reviewed", "regularExpression", ".*REVIEW.*"))))) - .build(); + .start(); backend.getConfigurationService().didAddConfigurationScopes( new DidAddConfigurationScopesParams(List.of(new ConfigurationScopeDto(CONFIG_SCOPE_ID, null, true, "My project", @@ -79,7 +79,7 @@ void hotspot_rules_should_be_active_when_feature_flag_is_enabled(SonarLintTestHa .withSonarQubeConnection(CONNECTION_ID, storage -> storage.withServerVersion("9.7").withProject(JAVA_MODULE_KEY, project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule("java:S4792", "INFO")))) .withBoundConfigScope(CONFIG_SCOPE_ID, CONNECTION_ID, JAVA_MODULE_KEY) - .build(); + .start(); var activeRules = backend.getAnalysisService().getAnalysisConfig(new GetAnalysisConfigParams(CONFIG_SCOPE_ID)).get().getActiveRules(); @@ -95,7 +95,7 @@ void hotspot_rules_should_not_be_active_when_feature_flag_is_disabled(SonarLintT .withSonarQubeConnection(CONNECTION_ID, storage -> storage.withServerVersion("9.7").withProject(JAVA_MODULE_KEY, project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule("java:S4792", "INFO")))) .withBoundConfigScope(CONFIG_SCOPE_ID, CONNECTION_ID, JAVA_MODULE_KEY) - .build(); + .start(); var activeRules = backend.getAnalysisService().getAnalysisConfig(new GetAnalysisConfigParams(CONFIG_SCOPE_ID)).get().getActiveRules(); @@ -110,7 +110,7 @@ void should_use_ipython_standalone_active_rules_in_connected_mode(SonarLintTestH .withSonarQubeConnection(CONNECTION_ID, storage -> storage.withServerVersion("9.9").withProject(JAVA_MODULE_KEY, project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule("java:S4792", "INFO")))) .withBoundConfigScope(CONFIG_SCOPE_ID, CONNECTION_ID, JAVA_MODULE_KEY) - .build(); + .start(); var activeRules = backend.getAnalysisService().getAnalysisConfig(new GetAnalysisConfigParams(CONFIG_SCOPE_ID)).get().getActiveRules(); diff --git a/medium-tests/src/test/java/mediumtest/analysis/SupportedFilePatternsMediumTests.java b/medium-tests/src/test/java/mediumtest/analysis/SupportedFilePatternsMediumTests.java index 976e99087e..7f872b8989 100644 --- a/medium-tests/src/test/java/mediumtest/analysis/SupportedFilePatternsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/analysis/SupportedFilePatternsMediumTests.java @@ -34,7 +34,7 @@ class SupportedFilePatternsMediumTests { void it_should_return_default_supported_file_patterns_in_standalone_mode(SonarLintTestHarness harness) throws ExecutionException, InterruptedException { var backend = harness.newBackend() .withEnabledLanguageInStandaloneMode(JAVA) - .build(); + .start(); var patterns = backend.getAnalysisService().getSupportedFilePatterns(new GetSupportedFilePatternsParams("configScopeId")).get().getPatterns(); assertThat(patterns).containsOnly("**/*.java", "**/*.jav"); @@ -48,7 +48,7 @@ void it_should_return_default_supported_file_patterns_in_connected_mode_when_not .withProject("projectKey")) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withExtraEnabledLanguagesInConnectedMode(JAVA) - .build(client); + .start(client); var patterns = backend.getAnalysisService().getSupportedFilePatterns(new GetSupportedFilePatternsParams("configScopeId")).get().getPatterns(); assertThat(patterns).containsOnly("**/*.java", "**/*.jav"); @@ -62,7 +62,7 @@ void it_should_return_supported_file_patterns_with_server_defined_file_suffixes( .withProject("projectKey", project -> project.withSetting("sonar.java.file.suffixes", ".foo, .bar"))) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withEnabledLanguageInStandaloneMode(JAVA) - .build(client); + .start(client); var patterns = backend.getAnalysisService().getSupportedFilePatterns(new GetSupportedFilePatternsParams("configScopeId")).get().getPatterns(); assertThat(patterns).containsOnly("**/*.foo", "**/*.bar"); diff --git a/medium-tests/src/test/java/mediumtest/branch/SonarProjectBranchMediumTests.java b/medium-tests/src/test/java/mediumtest/branch/SonarProjectBranchMediumTests.java index 1194855c5f..88fd7b6aeb 100644 --- a/medium-tests/src/test/java/mediumtest/branch/SonarProjectBranchMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/branch/SonarProjectBranchMediumTests.java @@ -50,7 +50,7 @@ void it_should_not_request_client_to_match_branch_when_vcs_repo_change_occurs_on var backend = harness.newBackend() .withUnboundConfigScope("configScopeId") - .build(client); + .start(client); notifyVcsRepositoryChanged(backend, "configScopeId"); @@ -69,7 +69,7 @@ void it_should_request_client_to_match_branch_when_vcs_repo_change_occurs_on_bou storage -> storage.withProject("projectKey", project -> project.withMainBranch("main").withNonMainBranch("myBranch"))) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(client); + .start(client); notifyVcsRepositoryChanged(backend, "configScopeId"); @@ -87,7 +87,7 @@ void it_should_not_notify_client_if_matched_branch_did_not_change(SonarLintTestH storage -> storage.withProject("projectKey", project -> project.withMainBranch("main").withNonMainBranch("myBranch"))) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(client); + .start(client); // Wait for the first branch matching verify(client, timeout(5000)).didChangeMatchedSonarProjectBranch(eq("configScopeId"), any()); @@ -110,7 +110,7 @@ void it_should_default_to_the_main_branch_if_client_unable_to_match_branch(Sonar storage -> storage.withProject("projectKey", project -> project.withMainBranch("main").withNonMainBranch("myBranch"))) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(client); + .start(client); notifyVcsRepositoryChanged(backend, "configScopeId"); @@ -123,7 +123,7 @@ void it_should_not_match_any_branch_if_there_is_none_in_the_storage(SonarLintTes var backend = harness.newBackend() .withSonarQubeConnection("connectionId") .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(client); + .start(client); notifyVcsRepositoryChanged(backend, "configScopeId"); @@ -141,7 +141,7 @@ void it_should_not_notify_client_when_error_occurs_during_client_branch_matching storage -> storage.withProject("projectKey", project -> project.withMainBranch("main").withNonMainBranch("myBranch"))) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(client); + .start(client); verify(client, timeout(1000)).didChangeMatchedSonarProjectBranch("configScopeId", "main"); } @@ -157,7 +157,7 @@ void verify_that_multiple_quick_branch_notifications_are_not_running_in_race_con storage -> storage.withProject("projectKey", project -> project.withMainBranch("main").withNonMainBranch("myBranch"))) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(client); + .start(client); // Wait for initial branch matching verify(client, timeout(5000)).didChangeMatchedSonarProjectBranch("configScopeId", "branchA"); @@ -181,7 +181,7 @@ void it_should_return_matched_branch_after_matching(SonarLintTestHarness harness storage -> storage.withProject("projectKey", project -> project.withMainBranch("main").withNonMainBranch("myBranch"))) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(client); + .start(client); // Initial matching verify(client, timeout(1000)).didChangeMatchedSonarProjectBranch("configScopeId", "main"); @@ -213,7 +213,7 @@ void it_should_trigger_branch_specific_synchronization_if_the_branch_changed(Son project -> project.withMainBranch("main").withNonMainBranch("myBranch"))) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withProjectSynchronization() - .build(client); + .start(client); // Wait for first sync verify(client, timeout(5000)).didChangeMatchedSonarProjectBranch(eq("configScopeId"), eq("main")); @@ -241,7 +241,7 @@ void it_should_clear_the_matched_branch_when_the_binding_changes(SonarLintTestHa storage -> storage.withProject("projectKey", project -> project.withMainBranch("main").withNonMainBranch("myBranch"))) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(client); + .start(client); verify(client, timeout(5000)).didChangeMatchedSonarProjectBranch(eq("configScopeId"), eq("myBranch")); diff --git a/medium-tests/src/test/java/mediumtest/connection/ConnectionGetAllProjectsMediumTests.java b/medium-tests/src/test/java/mediumtest/connection/ConnectionGetAllProjectsMediumTests.java index 7da7ea1564..b09cd40870 100644 --- a/medium-tests/src/test/java/mediumtest/connection/ConnectionGetAllProjectsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/connection/ConnectionGetAllProjectsMediumTests.java @@ -44,7 +44,7 @@ class ConnectionGetAllProjectsMediumTests { @SonarLintTest void it_should_return_an_empty_response_if_no_projects_in_sonarqube(SonarLintTestHarness harness) { var server = harness.newFakeSonarQubeServer().start(); - var backend = harness.newBackend().build(); + var backend = harness.newBackend().start(); var response = getAllProjects(backend, new TransientSonarQubeConnectionDto(server.baseUrl(), Either.forLeft(new TokenDto(null)))); @@ -56,7 +56,7 @@ void it_should_return_an_empty_response_if_no_projects_in_sonarcloud_organizatio var server = harness.newFakeSonarCloudServer("myOrg").start(); var backend = harness.newBackend() .withSonarCloudUrl(server.baseUrl()) - .build(); + .start(); var response = getAllProjects(backend, new TransientSonarCloudConnectionDto("myOrg", Either.forLeft(new TokenDto("token")))); @@ -69,7 +69,7 @@ void it_should_return_the_list_of_projects_on_sonarqube(SonarLintTestHarness har .withProject("projectKey1", project -> project.withName("MyProject1")) .withProject("projectKey2", project -> project.withName("MyProject2")) .start(); - var backend = harness.newBackend().build(); + var backend = harness.newBackend().start(); var response = getAllProjects(backend, new TransientSonarQubeConnectionDto(server.baseUrl(), Either.forLeft(new TokenDto("token")))); @@ -87,7 +87,7 @@ void it_should_fuzzy_search_for_projects_on_sonarqube(SonarLintTestHarness harne .start(); var backend = harness.newBackend() .withSonarQubeConnection("connectionId", server.baseUrl()) - .build(); + .start(); var emptySearch = backend.getConnectionService().fuzzySearchProjects(new FuzzySearchProjectsParams("connectionId", "")).join(); assertThat(emptySearch.getTopResults()) @@ -123,7 +123,7 @@ void it_should_return_the_list_of_projects_on_sonarcloud(SonarLintTestHarness ha .start(); var backend = harness.newBackend() .withSonarCloudUrl(server.baseUrl()) - .build(); + .start(); var response = getAllProjects(backend, new TransientSonarCloudConnectionDto("myOrg", Either.forLeft(new TokenDto("token")))); @@ -139,7 +139,7 @@ void it_should_support_cancellation(SonarLintTestHarness harness) { .withStatus(200) .withFixedDelay(2000))); var client = harness.newFakeClient().build(); - var backend = harness.newBackend().build(client); + var backend = harness.newBackend().start(client); var connectionDto = new TransientSonarQubeConnectionDto(server.baseUrl(), Either.forLeft(new TokenDto(null))); diff --git a/medium-tests/src/test/java/mediumtest/connection/ConnectionGetProjectNameByKeyMediumTests.java b/medium-tests/src/test/java/mediumtest/connection/ConnectionGetProjectNameByKeyMediumTests.java index 0684dacd8d..3f233b8810 100644 --- a/medium-tests/src/test/java/mediumtest/connection/ConnectionGetProjectNameByKeyMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/connection/ConnectionGetProjectNameByKeyMediumTests.java @@ -44,7 +44,7 @@ class ConnectionGetProjectNameByKeyMediumTests { @SonarLintTest void it_should_return_null_if_no_projects_in_sonarqube(SonarLintTestHarness harness) { var server = harness.newFakeSonarQubeServer().start(); - var backend = harness.newBackend().build(); + var backend = harness.newBackend().start(); var response = getProjectNamesByKey(backend, new TransientSonarQubeConnectionDto(server.baseUrl(), Either.forLeft(new TokenDto("token"))), List.of("myProject")); @@ -58,7 +58,7 @@ void it_should_return_null_if_no_projects_in_sonarcloud_organization(SonarLintTe var server = harness.newFakeSonarCloudServer("myOrg").start(); var backend = harness.newBackend() .withSonarCloudUrl(server.baseUrl()) - .build(); + .start(); var response = getProjectNamesByKey(backend, new TransientSonarCloudConnectionDto("myOrg", Either.forLeft(new TokenDto("token"))), List.of( "myProject")); @@ -76,7 +76,7 @@ void it_should_find_project_name_if_available_on_sonarqube(SonarLintTestHarness .start(); var backend = harness.newBackend() .withSonarQubeConnection("connectionId", server.baseUrl()) - .build(); + .start(); var response = getProjectNamesByKey(backend, new TransientSonarQubeConnectionDto(server.baseUrl(), Either.forLeft(new TokenDto("token"))), List.of("project-foo2", "project-foo3", "project-foo4")); @@ -95,7 +95,7 @@ void it_should_find_project_names_if_available_on_sonarcloud(SonarLintTestHarnes .start(); var backend = harness.newBackend() .withSonarCloudUrl(server.baseUrl()) - .build(); + .start(); var response = getProjectNamesByKey(backend, new TransientSonarCloudConnectionDto("myOrg", Either.forLeft(new TokenDto("token"))), List.of("projectKey2", "projectKey3", "projectKey4")); @@ -112,7 +112,7 @@ void it_should_support_cancellation(SonarLintTestHarness harness) { .withStatus(200) .withFixedDelay(2000))); var client = harness.newFakeClient().build(); - var backend = harness.newBackend().build(client); + var backend = harness.newBackend().start(client); var connectionDto = new TransientSonarQubeConnectionDto(server.baseUrl(), Either.forLeft(new TokenDto(null))); diff --git a/medium-tests/src/test/java/mediumtest/connection/ConnectionValidatorMediumTests.java b/medium-tests/src/test/java/mediumtest/connection/ConnectionValidatorMediumTests.java index a8f48c9675..aaf67f1a60 100644 --- a/medium-tests/src/test/java/mediumtest/connection/ConnectionValidatorMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/connection/ConnectionValidatorMediumTests.java @@ -48,7 +48,7 @@ class ConnectionValidatorMediumTests { void testConnection_ok(SonarLintTestHarness harness) { var backend = harness.newBackend() .withSonarCloudUrl(serverMock.baseUrl()) - .build(); + .start(); serverMock.stubFor(get("/api/system/status") .willReturn(aResponse().withBody("{\"id\": \"20160308094653\",\"version\": \"9.9\",\"status\": \"UP\"}"))); serverMock.stubFor(get("/api/authentication/validate?format=json") @@ -63,7 +63,7 @@ void testConnection_ok(SonarLintTestHarness harness) { void testConnectionOrganizationNotFound(SonarLintTestHarness harness) { var backend = harness.newBackend() .withSonarCloudUrl(serverMock.baseUrl()) - .build(); + .start(); serverMock.stubFor(get("/api/system/status") .willReturn(aResponse().withBody("{\"id\": \"20160308094653\",\"version\": \"9.9\",\"status\": \"UP\"}"))); serverMock.stubFor(get("/api/authentication/validate?format=json") @@ -81,7 +81,7 @@ void testConnectionOrganizationNotFound(SonarLintTestHarness harness) { void testConnection_ok_with_org(SonarLintTestHarness harness) { var backend = harness.newBackend() .withSonarCloudUrl(serverMock.baseUrl()) - .build(); + .start(); serverMock.stubFor(get("/api/system/status") .willReturn(aResponse().withBody("{\"id\": \"20160308094653\",\"version\": \"9.9\",\"status\": \"UP\"}"))); serverMock.stubFor(get("/api/authentication/validate?format=json") @@ -105,7 +105,7 @@ void testConnection_ok_with_org(SonarLintTestHarness harness) { void testConnection_ok_without_org(SonarLintTestHarness harness) { var backend = harness.newBackend() .withSonarCloudUrl(serverMock.baseUrl()) - .build(); + .start(); serverMock.stubFor(get("/api/system/status") .willReturn(aResponse().withBody("{\"id\": \"20160308094653\",\"version\": \"9.9\",\"status\": \"UP\"}"))); serverMock.stubFor(get("/api/authentication/validate?format=json") @@ -119,7 +119,7 @@ void testConnection_ok_without_org(SonarLintTestHarness harness) { void testUnsupportedServer(SonarLintTestHarness harness) { var backend = harness.newBackend() .withSonarCloudUrl(serverMock.baseUrl()) - .build(); + .start(); serverMock.stubFor(get("/api/system/status") .willReturn(aResponse().withBody("{\"id\": \"20160308094653\",\"version\": \"6.7\",\"status\": \"UP\"}"))); @@ -133,7 +133,7 @@ void testUnsupportedServer(SonarLintTestHarness harness) { void testClientError(SonarLintTestHarness harness) { var backend = harness.newBackend() .withSonarCloudUrl(serverMock.baseUrl()) - .build(); + .start(); serverMock.stubFor(get("/api/system/status") .willReturn(aResponse().withStatus(400))); @@ -148,7 +148,7 @@ void testClientError(SonarLintTestHarness harness) { void testResponseError(SonarLintTestHarness harness) { var backend = harness.newBackend() .withSonarCloudUrl(serverMock.baseUrl()) - .build(); + .start(); serverMock.stubFor(get("/api/system/status") .willReturn(aResponse().withBody("{\"id\": }"))); diff --git a/medium-tests/src/test/java/mediumtest/connection/OrganizationMediumTests.java b/medium-tests/src/test/java/mediumtest/connection/OrganizationMediumTests.java index 76c0d9d263..5f93af3a70 100644 --- a/medium-tests/src/test/java/mediumtest/connection/OrganizationMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/connection/OrganizationMediumTests.java @@ -60,7 +60,7 @@ void it_should_list_empty_user_organizations(SonarLintTestHarness harness) throw .build(); var backend = harness.newBackend() .withSonarCloudUrl(sonarcloudMock.baseUrl()) - .build(fakeClient); + .start(fakeClient); sonarcloudMock.stubFor(get("/api/organizations/search.protobuf?member=true&ps=500&p=1") .willReturn(aResponse().withStatus(200).withResponseBody(protobufBody(Organizations.SearchWsResponse.newBuilder() .build())))); @@ -74,7 +74,7 @@ void it_should_list_empty_user_organizations(SonarLintTestHarness harness) throw void it_should_list_user_organizations(SonarLintTestHarness harness) throws ExecutionException, InterruptedException { var backend = harness.newBackend() .withSonarCloudUrl(sonarcloudMock.baseUrl()) - .build(); + .start(); sonarcloudMock.stubFor(get("/api/organizations/search.protobuf?member=true&ps=500&p=1") .willReturn(aResponse().withStatus(200).withResponseBody(protobufBody(Organizations.SearchWsResponse.newBuilder() .addOrganizations(Organizations.Organization.newBuilder() @@ -109,7 +109,7 @@ void it_should_list_user_organizations(SonarLintTestHarness harness) throws Exec void it_should_get_organizations_by_key(SonarLintTestHarness harness) throws ExecutionException, InterruptedException { var backend = harness.newBackend() .withSonarCloudUrl(sonarcloudMock.baseUrl()) - .build(); + .start(); sonarcloudMock.stubFor(get("/api/organizations/search.protobuf?organizations=myCustomOrg&ps=500&p=1") .willReturn(aResponse().withStatus(200).withResponseBody(protobufBody(Organizations.SearchWsResponse.newBuilder() .addOrganizations(Organizations.Organization.newBuilder() @@ -136,7 +136,7 @@ void it_should_get_organizations_by_key(SonarLintTestHarness harness) throws Exe void it_should_fuzzy_search_and_cache_organizations_on_sonarcloud(SonarLintTestHarness harness) { var backend = harness.newBackend() .withSonarCloudUrl(sonarcloudMock.baseUrl()) - .build(); + .start(); sonarcloudMock.stubFor(get("/api/organizations/search.protobuf?member=true&ps=500&p=1") .willReturn(aResponse().withStatus(200).withResponseBody(protobufBody(Organizations.SearchWsResponse.newBuilder() .addOrganizations(Organizations.Organization.newBuilder() diff --git a/medium-tests/src/test/java/mediumtest/dogfooding/DogfoodingRpcServiceMediumTests.java b/medium-tests/src/test/java/mediumtest/dogfooding/DogfoodingRpcServiceMediumTests.java index a77d0f7d40..41e384f6a0 100644 --- a/medium-tests/src/test/java/mediumtest/dogfooding/DogfoodingRpcServiceMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/dogfooding/DogfoodingRpcServiceMediumTests.java @@ -48,7 +48,7 @@ void setUp() { @SonarLintTest void should_return_true_when_env_variable_is_set(SonarLintTestHarness harness) { environmentVariables.set(SONARSOURCE_DOGFOODING_ENV_VAR_KEY, "1"); - var backend = harness.newBackend().build(); + var backend = harness.newBackend().start(); var result = backend.getDogfoodingService().isDogfoodingEnvironment().join(); @@ -57,7 +57,7 @@ void should_return_true_when_env_variable_is_set(SonarLintTestHarness harness) { @SonarLintTest void should_return_false_when_env_var_is_absent(SonarLintTestHarness harness) { - var backend = harness.newBackend().build(); + var backend = harness.newBackend().start(); var result = backend.getDogfoodingService().isDogfoodingEnvironment().join(); @@ -66,7 +66,7 @@ void should_return_false_when_env_var_is_absent(SonarLintTestHarness harness) { @SonarLintTest void should_return_false_when_env_var_is_false(SonarLintTestHarness harness) { - var backend = harness.newBackend().build(); + var backend = harness.newBackend().start(); environmentVariables.set(SONARSOURCE_DOGFOODING_ENV_VAR_KEY, "0"); var result = backend.getDogfoodingService().isDogfoodingEnvironment().join(); diff --git a/medium-tests/src/test/java/mediumtest/file/ClientFileExclusionsMediumTests.java b/medium-tests/src/test/java/mediumtest/file/ClientFileExclusionsMediumTests.java index 00497da1e9..ede9620367 100644 --- a/medium-tests/src/test/java/mediumtest/file/ClientFileExclusionsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/file/ClientFileExclusionsMediumTests.java @@ -61,7 +61,7 @@ void it_should_not_analyze_excluded_file_on_open(SonarLintTestHarness harness, @ var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, fileUri)); @@ -80,7 +80,7 @@ void it_should_analyze_not_excluded_file_on_open(SonarLintTestHarness harness, @ var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, fileUri)); @@ -102,7 +102,7 @@ void it_should_not_analyze_non_user_defined_file_on_open(SonarLintTestHarness ha var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, fileUri)); @@ -120,7 +120,7 @@ void it_should_analyze_user_defined_file_on_open(SonarLintTestHarness harness, @ var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, fileUri)); @@ -164,7 +164,7 @@ void it_should_not_exclude_client_defined_file_exclusion_in_connected_mode(Sonar project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule(ruleKey, "MINOR")) .withMainBranch(branchName))) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getConfigurationService() .didAddConfigurationScopes(new DidAddConfigurationScopesParams(List.of( @@ -208,7 +208,7 @@ void it_should_exclude_non_user_defined_files_in_connected_mode(SonarLintTestHar project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule(ruleKey, "MINOR")) .withMainBranch(branchName))) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getConfigurationService() .didAddConfigurationScopes(new DidAddConfigurationScopesParams(List.of( diff --git a/medium-tests/src/test/java/mediumtest/file/ConnectedFileExclusionsMediumTests.java b/medium-tests/src/test/java/mediumtest/file/ConnectedFileExclusionsMediumTests.java index 669771cbb3..c3a99305f7 100644 --- a/medium-tests/src/test/java/mediumtest/file/ConnectedFileExclusionsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/file/ConnectedFileExclusionsMediumTests.java @@ -99,7 +99,7 @@ void fileInclusionsExclusions(SonarLintTestHarness harness, @TempDir Path tmp) t .withBoundConfigScope(CONFIG_SCOPE_ID, MYSONAR, PROJECT_KEY) .withFullSynchronization() .withProjectSynchronization() - .build(fakeClient); + .start(fakeClient); verify(fakeClient, timeout(5000).times(1)).didSynchronizeConfigurationScopes(Set.of(CONFIG_SCOPE_ID)); @@ -213,7 +213,7 @@ void it_should_not_try_to_compute_exclusions_when_storage_is_empty(SonarLintTest .withUnboundConfigScope(CONFIG_SCOPE_ID) .withFullSynchronization() .withProjectSynchronization() - .build(fakeClient); + .start(fakeClient); backend.getConfigurationService().didUpdateBinding(new DidUpdateBindingParams(CONFIG_SCOPE_ID, new BindingConfigurationDto(MYSONAR, PROJECT_KEY, true))); // get statuses while synchronization happens in background @@ -244,7 +244,7 @@ void it_should_fallback_to_default_charset_if_encoding_is_unknown(SonarLintTestH .withUnboundConfigScope(CONFIG_SCOPE_ID) .withFullSynchronization() .withProjectSynchronization() - .build(fakeClient); + .start(fakeClient); mockSonarProjectSettings(server, Map.of("sonar.exclusions", "src/**")); forceSyncOfConfigScope(backend, fakeClient); diff --git a/medium-tests/src/test/java/mediumtest/hotspots/HotspotCheckStatusChangePermittedMediumTests.java b/medium-tests/src/test/java/mediumtest/hotspots/HotspotCheckStatusChangePermittedMediumTests.java index dc9754c068..4242a3f607 100644 --- a/medium-tests/src/test/java/mediumtest/hotspots/HotspotCheckStatusChangePermittedMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/hotspots/HotspotCheckStatusChangePermittedMediumTests.java @@ -37,7 +37,7 @@ class HotspotCheckStatusChangePermittedMediumTests { @SonarLintTest void it_should_fail_when_the_connection_is_unknown(SonarLintTestHarness harness) { - var backend = harness.newBackend().build(); + var backend = harness.newBackend().start(); var response = checkStatusChangePermitted(backend, "connectionId"); @@ -55,7 +55,7 @@ void it_should_return_3_statuses_for_sonarcloud(SonarLintTestHarness harness) { var backend = harness.newBackend() .withSonarCloudUrl(server.baseUrl()) .withSonarCloudConnection("connectionId", "orgKey") - .build(); + .start(); var response = checkStatusChangePermitted(backend, "connectionId"); @@ -71,7 +71,7 @@ void it_should_return_4_statuses_for_sonarqube(SonarLintTestHarness harness) { var server = harness.newFakeSonarQubeServer().withProject("projectKey", project -> project.withDefaultBranch(branch -> branch.withHotspot("hotspotKey"))).start(); var backend = harness.newBackend() .withSonarQubeConnection("connectionId", server) - .build(); + .start(); var response = checkStatusChangePermitted(backend, "connectionId"); @@ -91,7 +91,7 @@ void it_should_not_be_changeable_when_permission_missing(SonarLintTestHarness ha .start(); var backend = harness.newBackend() .withSonarQubeConnection("connectionId", server) - .build(); + .start(); var response = checkStatusChangePermitted(backend, "connectionId"); diff --git a/medium-tests/src/test/java/mediumtest/hotspots/HotspotEventsMediumTests.java b/medium-tests/src/test/java/mediumtest/hotspots/HotspotEventsMediumTests.java index 66cbb1e16a..ef802d74f5 100644 --- a/medium-tests/src/test/java/mediumtest/hotspots/HotspotEventsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/hotspots/HotspotEventsMediumTests.java @@ -109,7 +109,7 @@ void it_should_add_hotspot_in_storage(SonarLintTestHarness harness) { .withSonarQubeConnection("connectionId", server, storage -> storage.withProject("projectKey", project -> project.withMainBranch("branchName"))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(20)).untilAsserted(() -> assertThat(readHotspots(backend, "connectionId", "projectKey", "branchName", "file/path")) @@ -138,7 +138,7 @@ void it_should_remove_hotspot_from_storage(SonarLintTestHarness harness) { .withSonarQubeConnection("connectionId", server, storage -> storage.withProject("projectKey", project -> project.withMainBranch("branchName", branch -> branch.withHotspot(aServerHotspot("hotspotKey"))))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(4)).untilAsserted(() -> assertThat(readHotspots(backend, "connectionId", "projectKey", "branchName", "file/path")) @@ -214,7 +214,7 @@ void should_republish_hotspots_without_closed_one(SonarLintTestHarness harness, .withFullSynchronization() .withSonarQubeConnection(connectionId, serverWithHotspots) .withBoundConfigScope(CONFIG_SCOPE_ID, connectionId, projectKey) - .build(client); + .start(client); await().atMost(Duration.ofSeconds(20)).untilAsserted(() -> assertThat(client.getSynchronizedConfigScopeIds()).contains(CONFIG_SCOPE_ID)); analyzeFileAndGetHotspots(fileUri, client, backend, CONFIG_SCOPE_ID); @@ -258,7 +258,7 @@ void it_should_update_hotspot_in_storage_when_changing_status(SonarLintTestHarne storage -> storage.withProject("projectKey", project -> project.withMainBranch("branchName", branch -> branch.withHotspot(aServerHotspot("AYhSN6mVrRF_krvNbHl1").withStatus(HotspotReviewStatus.TO_REVIEW))))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readHotspots(backend, "connectionId", "projectKey", "branchName", "file/path")) @@ -289,7 +289,7 @@ void it_should_update_hotspot_in_storage_when_changing_assignee(SonarLintTestHar storage -> storage.withProject("projectKey", project -> project.withMainBranch("branchName", branch -> branch.withHotspot(aServerHotspot("AYhSN6mVrRF_krvNbHl1").withAssignee("previousAssignee"))))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readHotspots(backend, "connectionId", "projectKey", "branchName", "file/path")) @@ -358,7 +358,7 @@ void should_raise_hotspot_with_changed_data(SonarLintTestHarness harness, @TempD .withFullSynchronization() .withSonarQubeConnection(connectionId, serverWithHotspots) .withBoundConfigScope(CONFIG_SCOPE_ID, connectionId, projectKey) - .build(client); + .start(client); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(client.getSynchronizedConfigScopeIds()).contains(CONFIG_SCOPE_ID)); analyzeFileAndGetHotspots(fileUri, client, backend, CONFIG_SCOPE_ID); diff --git a/medium-tests/src/test/java/mediumtest/hotspots/HotspotLocalDetectionSupportMediumTests.java b/medium-tests/src/test/java/mediumtest/hotspots/HotspotLocalDetectionSupportMediumTests.java index 623144b3b9..202d39ef13 100644 --- a/medium-tests/src/test/java/mediumtest/hotspots/HotspotLocalDetectionSupportMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/hotspots/HotspotLocalDetectionSupportMediumTests.java @@ -37,7 +37,7 @@ class HotspotLocalDetectionSupportMediumTests { @SonarLintTest void it_should_fail_when_the_configuration_scope_id_is_unknown(SonarLintTestHarness harness) { - var backend = harness.newBackend().build(); + var backend = harness.newBackend().start(); var future = backend.getHotspotService().checkLocalDetectionSupported(new CheckLocalDetectionSupportedParams("configScopeId")); @@ -53,7 +53,7 @@ void it_should_fail_when_the_configuration_scope_id_is_unknown(SonarLintTestHarn void it_should_fail_when_the_configuration_scope_is_bound_to_an_unknown_connection(SonarLintTestHarness harness) { var backend = harness.newBackend() .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(); + .start(); var future = backend.getHotspotService().checkLocalDetectionSupported(new CheckLocalDetectionSupportedParams("configScopeId")); @@ -69,7 +69,7 @@ void it_should_fail_when_the_configuration_scope_is_bound_to_an_unknown_connecti void it_should_not_support_local_detection_in_standalone_mode(SonarLintTestHarness harness) { var backend = harness.newBackend() .withUnboundConfigScope("configScopeId") - .build(); + .start(); var checkResponse = checkLocalDetectionSupported(backend, "configScopeId"); @@ -83,7 +83,7 @@ void it_should_support_local_detection_when_connected_to_sonarcloud(SonarLintTes var backend = harness.newBackend() .withSonarCloudConnection("connectionId", "orgKey") .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(); + .start(); var checkResponse = checkLocalDetectionSupported(backend, "configScopeId"); @@ -99,7 +99,7 @@ void it_should_support_local_detection_when_connected_to_sonarqube(SonarLintTest .withSonarQubeConnection("connectionId", storage -> storage.withServerVersion("9.9") .withProject("projectKey")) .withBoundConfigScope(configScopeId, "connectionId", "projectKey") - .build(); + .start(); var checkResponse = checkLocalDetectionSupported(backend, configScopeId); diff --git a/medium-tests/src/test/java/mediumtest/hotspots/HotspotStatusChangeMediumTests.java b/medium-tests/src/test/java/mediumtest/hotspots/HotspotStatusChangeMediumTests.java index 1208d71ec2..1901f30f96 100644 --- a/medium-tests/src/test/java/mediumtest/hotspots/HotspotStatusChangeMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/hotspots/HotspotStatusChangeMediumTests.java @@ -46,7 +46,7 @@ void it_should_fail_the_future_when_the_server_returns_an_error(SonarLintTestHar var backend = harness.newBackend() .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(); + .start(); var response = setStatusToSafe(backend, "configScopeId", "hotspotKey"); @@ -59,7 +59,7 @@ void it_should_fail_the_future_when_the_server_returns_an_error(SonarLintTestHar @SonarLintTest void it_should_do_nothing_when_the_configuration_scope_is_unknown(SonarLintTestHarness harness) { - var backend = harness.newBackend().build(); + var backend = harness.newBackend().start(); var response = setStatusToSafe(backend, "configScopeId", "hotspotKey"); @@ -70,7 +70,7 @@ void it_should_do_nothing_when_the_configuration_scope_is_unknown(SonarLintTestH void it_should_do_nothing_when_the_configuration_scope_bound_connection_is_unknown(SonarLintTestHarness harness) { var backend = harness.newBackend() .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(); + .start(); var response = setStatusToSafe(backend, "configScopeId", "hotspotKey"); @@ -85,7 +85,7 @@ void it_should_update_the_status_on_sonarcloud_through_the_web_api(SonarLintTest .withSonarCloudUrl(server.baseUrl()) .withSonarCloudConnection("connectionId", "orgKey") .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(); + .start(); var response = setStatusToSafe(backend, "configScopeId", "hotspotKey"); @@ -102,7 +102,7 @@ void it_should_update_the_status_on_sonarqube_through_the_web_api(SonarLintTestH var backend = harness.newBackend() .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(); + .start(); var response = setStatusToSafe(backend, "configScopeId", "hotspotKey"); @@ -120,7 +120,7 @@ void it_should_update_the_hotspot_status_in_the_storage(SonarLintTestHarness har var backend = harness.newBackend() .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(); + .start(); var response = setStatusToSafe(backend, "configScopeId", "hotspotKey"); @@ -138,7 +138,7 @@ void it_should_count_status_change_in_telemetry(SonarLintTestHarness harness) { .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withTelemetryEnabled() - .build(); + .start(); var response = setStatusToSafe(backend, "configScopeId", "hotspotKey"); diff --git a/medium-tests/src/test/java/mediumtest/hotspots/OpenHotspotInBrowserMediumTests.java b/medium-tests/src/test/java/mediumtest/hotspots/OpenHotspotInBrowserMediumTests.java index 25e67f8a9c..ce4218695a 100644 --- a/medium-tests/src/test/java/mediumtest/hotspots/OpenHotspotInBrowserMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/hotspots/OpenHotspotInBrowserMediumTests.java @@ -41,7 +41,7 @@ void it_should_open_hotspot_in_sonarqube(SonarLintTestHarness harness) throws Ma .withSonarQubeConnection("connectionId", "http://localhost:12345", storage -> storage.withProject("projectKey", project -> project.withMainBranch("master"))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withTelemetryEnabled() - .build(fakeClient); + .start(fakeClient); backend.getHotspotService().openHotspotInBrowser(new OpenHotspotInBrowserParams("scopeId", "ab12ef45")); @@ -55,7 +55,7 @@ void it_should_not_open_hotspot_if_unbound(SonarLintTestHarness harness) throws var fakeClient = harness.newFakeClient().build(); var backend = harness.newBackend() .withUnboundConfigScope("scopeId") - .build(fakeClient); + .start(fakeClient); backend.getHotspotService().openHotspotInBrowser(new OpenHotspotInBrowserParams("scopeId", "ab12ef45")); diff --git a/medium-tests/src/test/java/mediumtest/hotspots/OpenHotspotInIdeMediumTests.java b/medium-tests/src/test/java/mediumtest/hotspots/OpenHotspotInIdeMediumTests.java index c3dc57d6c8..42a8684755 100644 --- a/medium-tests/src/test/java/mediumtest/hotspots/OpenHotspotInIdeMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/hotspots/OpenHotspotInIdeMediumTests.java @@ -73,7 +73,7 @@ void it_should_fail_request_when_server_parameter_missing(SonarLintTestHarness h var serverWithoutHotspot = harness.newFakeSonarQubeServer("1.2.3").start(); var backend = harness.newBackend() .withEmbeddedServer() - .build(); + .start(); var statusCode = requestGetOpenHotspotWithParams(backend, serverWithoutHotspot, "project=projectKey&hotspot=key"); @@ -85,7 +85,7 @@ void it_should_fail_request_when_project_parameter_missing(SonarLintTestHarness var serverWithoutHotspot = harness.newFakeSonarQubeServer("1.2.3").start(); var backend = harness.newBackend() .withEmbeddedServer() - .build(); + .start(); var statusCode = requestGetOpenHotspotWithParams(backend, serverWithoutHotspot, "server=URL&hotspot=key"); @@ -97,7 +97,7 @@ void it_should_fail_request_when_hotspot_parameter_missing(SonarLintTestHarness var serverWithoutHotspot = harness.newFakeSonarQubeServer("1.2.3").start(); var backend = harness.newBackend() .withEmbeddedServer() - .build(); + .start(); var statusCode = requestGetOpenHotspotWithParams(backend, serverWithoutHotspot, "server=URL&project=projectKey"); @@ -112,7 +112,7 @@ void it_should_open_hotspot_in_ide_when_project_bound(SonarLintTestHarness harne .withSonarQubeConnection(CONNECTION_ID, serverWithHotspot) .withBoundConfigScope(SCOPE_ID, CONNECTION_ID, PROJECT_KEY) .withEmbeddedServer() - .build(fakeClient); + .start(fakeClient); var statusCode = requestGetOpenHotspotWithParams(backend, serverWithHotspot, "server=" + urlEncode(serverWithHotspot.baseUrl()) + "&project=projectKey&hotspot=key"); assertThat(statusCode).isEqualTo(200); @@ -135,7 +135,7 @@ void it_should_update_telemetry_data_when_opening_hotspot_in_ide(SonarLintTestHa .withBoundConfigScope(SCOPE_ID, CONNECTION_ID, PROJECT_KEY) .withEmbeddedServer() .withTelemetryEnabled() - .build(); + .start(); requestGetOpenHotspotWithParams(backend, serverWithHotspot, "server=" + urlEncode(serverWithHotspot.baseUrl()) + "&project=projectKey&hotspot=key"); @@ -153,7 +153,7 @@ void it_should_assist_creating_the_connection_when_server_url_unknown(SonarLintT var backend = harness.newBackend() .withUnboundConfigScope(SCOPE_ID, SONAR_PROJECT_NAME) .withEmbeddedServer() - .build(fakeClient); + .start(fakeClient); mockAssistCreatingConnection(backend, fakeClient, serverWithHotspot, CONNECTION_ID); mockAssistBinding(backend, fakeClient, SCOPE_ID, CONNECTION_ID, PROJECT_KEY); @@ -178,7 +178,7 @@ void it_should_assist_creating_the_binding_if_scope_not_bound(SonarLintTestHarne .withSonarQubeConnection(CONNECTION_ID, serverWithHotspot) .withUnboundConfigScope(SCOPE_ID, SONAR_PROJECT_NAME) .withEmbeddedServer() - .build(fakeClient); + .start(fakeClient); mockAssistCreatingConnection(backend, fakeClient, serverWithHotspot, CONNECTION_ID); mockAssistBinding(backend, fakeClient, SCOPE_ID, CONNECTION_ID, PROJECT_KEY); @@ -202,7 +202,7 @@ void it_should_display_a_message_when_failing_to_fetch_the_hotspot(SonarLintTest .withSonarQubeConnection(CONNECTION_ID, serverWithoutHotspot) .withBoundConfigScope(SCOPE_ID, CONNECTION_ID, PROJECT_KEY) .withEmbeddedServer() - .build(fakeClient); + .start(fakeClient); var statusCode = requestGetOpenHotspotWithParams(backend, "server=" + urlEncode(serverWithoutHotspot.baseUrl()) + "&project=projectKey&hotspot=key", serverWithoutHotspot.baseUrl()); @@ -219,7 +219,7 @@ void it_should_not_accept_post_method(SonarLintTestHarness harness) { .withSonarQubeConnection(CONNECTION_ID, serverWithoutHotspot) .withBoundConfigScope(SCOPE_ID, CONNECTION_ID, PROJECT_KEY) .withEmbeddedServer() - .build(); + .start(); var statusCode = requestPostOpenHotspotWithParams(backend, serverWithoutHotspot, "server=" + urlEncode(serverWithoutHotspot.baseUrl()) + "&project=projectKey&hotspot=key"); diff --git a/medium-tests/src/test/java/mediumtest/http/AuthenticationMediumTests.java b/medium-tests/src/test/java/mediumtest/http/AuthenticationMediumTests.java index 140f2dad67..f4359cce11 100644 --- a/medium-tests/src/test/java/mediumtest/http/AuthenticationMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/http/AuthenticationMediumTests.java @@ -62,7 +62,7 @@ void it_should_authenticate_preemptively_on_sonarqube_with_login_password(SonarL ruleSet -> ruleSet.withActiveRule("python:S139", "INFO", Map.of("legalTrailingCommentPattern", "blah"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(fakeClient); + .start(fakeClient); sonarqubeMock.stubFor(get("/api/system/status") .willReturn(aResponse().withStatus(200).withBody("{\"id\": \"20160308094653\",\"version\": \"10.8\",\"status\": " + "\"UP\"}"))); @@ -90,7 +90,7 @@ void it_should_authenticate_preemptively_on_sonarqube_9_9_with_token_and_basic_s ruleSet -> ruleSet.withActiveRule("python:S139", "INFO", Map.of("legalTrailingCommentPattern", "blah"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(fakeClient); + .start(fakeClient); sonarqubeMock.stubFor(get("/api/rules/show.protobuf?key=python:S139") .willReturn(aResponse().withStatus(200).withResponseBody(protobufBody(Rules.ShowResponse.newBuilder() .setRule(Rules.Rule.newBuilder().setName("newName").setSeverity("INFO").setType(Common.RuleType.BUG).setLang("py").setHtmlNote("extendedDesc from server").build()) @@ -118,7 +118,7 @@ void it_should_authenticate_preemptively_on_sonarqube_10_4_with_token_and_bearer ruleSet -> ruleSet.withActiveRule("python:S139", "INFO", Map.of("legalTrailingCommentPattern", "blah"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(fakeClient); + .start(fakeClient); sonarqubeMock.stubFor(get("/api/rules/show.protobuf?key=python:S139") .willReturn(aResponse().withStatus(200).withResponseBody(protobufBody(Rules.ShowResponse.newBuilder() .setRule(Rules.Rule.newBuilder().setName("newName").setSeverity("INFO").setType(Common.RuleType.BUG).setLang("py").setHtmlNote("extendedDesc from server").build()) diff --git a/medium-tests/src/test/java/mediumtest/http/ProxyMediumTests.java b/medium-tests/src/test/java/mediumtest/http/ProxyMediumTests.java index da9c2a8960..3391db44fb 100644 --- a/medium-tests/src/test/java/mediumtest/http/ProxyMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/http/ProxyMediumTests.java @@ -110,7 +110,7 @@ void it_should_honor_http_proxy_settings(SonarLintTestHarness harness) { ruleSet -> ruleSet.withActiveRule("python:S139", "INFO", Map.of("legalTrailingCommentPattern", "blah"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(fakeClient); + .start(fakeClient); sonarqubeMock.stubFor(get("/api/rules/show.protobuf?key=python:S139") .willReturn(aResponse().withStatus(200).withResponseBody(protobufBody(Rules.ShowResponse.newBuilder() .setRule(Rules.Rule.newBuilder().setName("newName").setSeverity("INFO").setType(Common.RuleType.BUG).setLang("py").setHtmlNote("extendedDesc from server").build()) @@ -136,7 +136,7 @@ void it_should_honor_http_direct_proxy_settings(SonarLintTestHarness harness) { ruleSet -> ruleSet.withActiveRule("python:S139", "INFO", Map.of("legalTrailingCommentPattern", "blah"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(fakeClient); + .start(fakeClient); sonarqubeMock.stubFor(get("/api/rules/show.protobuf?key=python:S139") .willReturn(aResponse().withStatus(200).withResponseBody(protobufBody(Rules.ShowResponse.newBuilder() .setRule(Rules.Rule.newBuilder().setName("newName").setSeverity("INFO").setType(Common.RuleType.BUG).setLang("py").setHtmlNote("extendedDesc from server").build()) @@ -167,7 +167,7 @@ void it_should_honor_http_proxy_authentication(SonarLintTestHarness harness) { ruleSet -> ruleSet.withActiveRule("python:S139", "INFO", Map.of("legalTrailingCommentPattern", "blah"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(fakeClient); + .start(fakeClient); sonarqubeMock.stubFor(get("/api/rules/show.protobuf?key=python:S139") .willReturn(aResponse().withStatus(200).withResponseBody(protobufBody(Rules.ShowResponse.newBuilder() .setRule(Rules.Rule.newBuilder().setName("newName").setSeverity("INFO").setType(Common.RuleType.BUG).setLang("py").setHtmlNote("extendedDesc from server").build()) @@ -197,7 +197,7 @@ void it_should_honor_http_proxy_authentication_with_null_password(SonarLintTestH ruleSet -> ruleSet.withActiveRule("python:S139", "INFO", Map.of("legalTrailingCommentPattern", "blah"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(fakeClient); + .start(fakeClient); sonarqubeMock.stubFor(get("/api/rules/show.protobuf?key=python:S139") .willReturn(aResponse().withStatus(200).withResponseBody(protobufBody(Rules.ShowResponse.newBuilder() .setRule(Rules.Rule.newBuilder().setName("newName").setSeverity("INFO").setType(Common.RuleType.BUG).setLang("py").setHtmlNote("extendedDesc from server").build()) @@ -227,7 +227,7 @@ void it_should_fail_if_proxy_port_is_smaller_than_valid_range(SonarLintTestHarne ruleSet -> ruleSet.withActiveRule("python:S139", "INFO", Map.of("legalTrailingCommentPattern", "blah"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(fakeClient); + .start(fakeClient); sonarqubeMock.stubFor(get("/api/rules/show.protobuf?key=python:S139") .willReturn(aResponse().withStatus(200).withResponseBody(protobufBody(Rules.ShowResponse.newBuilder() .setRule(Rules.Rule.newBuilder().setName("newName").setSeverity("INFO").setType(Common.RuleType.BUG).setLang("py").setHtmlNote("extendedDesc from server").build()) @@ -262,7 +262,7 @@ void it_should_fail_if_proxy_port_is_higher_than_valid_range(SonarLintTestHarnes ruleSet -> ruleSet.withActiveRule("python:S139", "INFO", Map.of("legalTrailingCommentPattern", "blah"))))) .withBoundConfigScope("scopeId", "connectionId", "projectKey") .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.PYTHON) - .build(fakeClient); + .start(fakeClient); sonarqubeMock.stubFor(get("/api/rules/show.protobuf?key=python:S139") .willReturn(aResponse().withStatus(200).withResponseBody(protobufBody(Rules.ShowResponse.newBuilder() .setRule(Rules.Rule.newBuilder().setName("newName").setSeverity("INFO").setType(Common.RuleType.BUG).setLang("py").setHtmlNote("extendedDesc from server").build()) diff --git a/medium-tests/src/test/java/mediumtest/http/SslMediumTests.java b/medium-tests/src/test/java/mediumtest/http/SslMediumTests.java index e3109ae1f9..40f854b4d0 100644 --- a/medium-tests/src/test/java/mediumtest/http/SslMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/http/SslMediumTests.java @@ -109,7 +109,7 @@ void it_should_not_trust_server_self_signed_certificate_by_default(SonarLintTest var fakeClient = harness.newFakeClient().build(); var backend = harness.newBackend() .withSonarCloudUrl(sonarcloudMock.baseUrl()) - .build(fakeClient); + .start(fakeClient); var future = backend.getConnectionService().getOrganization(new GetOrganizationParams(Either.forLeft(new TokenDto("token")), "myOrg")); var thrown = assertThrows(CompletionException.class, future::join); @@ -123,7 +123,7 @@ void it_should_ask_user_only_once_if_server_certificate_is_trusted(SonarLintTest var backend = harness.newBackend() .withSonarCloudUrl(sonarcloudMock.baseUrl()) - .build(fakeClient); + .start(fakeClient); when(fakeClient.checkServerTrusted(any(), any())) .thenReturn(true); @@ -195,7 +195,7 @@ void it_should_fail_if_client_certificate_not_provided(SonarLintTestHarness harn var fakeClient = harness.newFakeClient().build(); var backend = harness.newBackend() .withSonarCloudUrl(sonarcloudMock.baseUrl()) - .build(fakeClient); + .start(fakeClient); when(fakeClient.checkServerTrusted(any(), any())) .thenReturn(true); @@ -214,7 +214,7 @@ void it_should_succeed_if_client_certificate_provided(SonarLintTestHarness harne var backend = harness.newBackend() .withKeyStore(toPath(Objects.requireNonNull(SslMediumTests.class.getResource("/ssl/client.p12"))), "pwdClientCertP12", null) .withSonarCloudUrl(sonarcloudMock.baseUrl()) - .build(fakeClient); + .start(fakeClient); when(fakeClient.checkServerTrusted(any(), any())) .thenReturn(true); diff --git a/medium-tests/src/test/java/mediumtest/http/TimeoutMediumTests.java b/medium-tests/src/test/java/mediumtest/http/TimeoutMediumTests.java index 24b25aec68..ce7ca46ccd 100644 --- a/medium-tests/src/test/java/mediumtest/http/TimeoutMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/http/TimeoutMediumTests.java @@ -58,7 +58,7 @@ void it_should_timeout_on_long_response(SonarLintTestHarness harness) { var backend = harness.newBackend() .withHttpResponseTimeout(Duration.ofSeconds(1)) .withSonarCloudUrl(sonarcloudMock.baseUrl()) - .build(fakeClient); + .start(fakeClient); sonarcloudMock.stubFor(get("/api/organizations/search.protobuf?organizations=myOrg&ps=500&p=1") .willReturn(aResponse().withStatus(200) .withFixedDelay(2000) diff --git a/medium-tests/src/test/java/mediumtest/issues/CheckAnticipatedStatusChangeSupportedMediumTests.java b/medium-tests/src/test/java/mediumtest/issues/CheckAnticipatedStatusChangeSupportedMediumTests.java index ce7b3e0aa9..d1d7045204 100644 --- a/medium-tests/src/test/java/mediumtest/issues/CheckAnticipatedStatusChangeSupportedMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/issues/CheckAnticipatedStatusChangeSupportedMediumTests.java @@ -46,7 +46,7 @@ void tearDown() { @SonarLintTest void it_should_fail_when_the_connection_is_unknown(SonarLintTestHarness harness) { - var backend = harness.newBackend().build(); + var backend = harness.newBackend().start(); assertThat(checkAnticipatedStatusChangeSupported(backend, "configScopeId")) .failsWithin(Duration.ofSeconds(2)) @@ -62,7 +62,7 @@ void it_should_not_be_available_for_sonarcloud(SonarLintTestHarness harness) { .withSonarCloudUrl(mockWebServerExtension.endpointParams().getBaseUrl()) .withSonarCloudConnection("connectionId", "orgKey") .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(); + .start(); assertThat(checkAnticipatedStatusChangeSupported(backend, "configScopeId")) .succeedsWithin(Duration.ofSeconds(2)) @@ -75,7 +75,7 @@ void it_should_not_be_available_for_sonarqube_prior_to_10_2(SonarLintTestHarness var backend = harness.newBackend() .withSonarQubeConnection("connectionId", mockWebServerExtension.endpointParams().getBaseUrl(), storage -> storage.withServerVersion("10.1")) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(); + .start(); assertThat(checkAnticipatedStatusChangeSupported(backend, "configScopeId")) .succeedsWithin(Duration.ofSeconds(2)) @@ -88,7 +88,7 @@ void it_should_be_available_for_sonarqube_10_2_plus(SonarLintTestHarness harness var backend = harness.newBackend() .withSonarQubeConnection("connectionId", mockWebServerExtension.endpointParams().getBaseUrl(), storage -> storage.withServerVersion("10.2")) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(); + .start(); assertThat(checkAnticipatedStatusChangeSupported(backend, "configScopeId")) .succeedsWithin(Duration.ofSeconds(2)) diff --git a/medium-tests/src/test/java/mediumtest/issues/CheckResolutionStatusChangePermittedMediumTests.java b/medium-tests/src/test/java/mediumtest/issues/CheckResolutionStatusChangePermittedMediumTests.java index 5a8e250962..a816665ccf 100644 --- a/medium-tests/src/test/java/mediumtest/issues/CheckResolutionStatusChangePermittedMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/issues/CheckResolutionStatusChangePermittedMediumTests.java @@ -80,7 +80,7 @@ void tearDown() { @SonarLintTest void it_should_fail_when_the_connection_is_unknown(SonarLintTestHarness harness) { - var backend = harness.newBackend().build(); + var backend = harness.newBackend().start(); var response = checkStatusChangePermitted(backend, CONNECTION_ID, "issueKey"); @@ -97,7 +97,7 @@ void it_should_allow_2_statuses_when_user_has_permission_for_sonarqube_103(Sonar fakeServerWithIssue("issueKey", List.of("wontfix", "falsepositive")); var backend = harness.newBackend() .withSonarQubeConnection(CONNECTION_ID, mockWebServerExtension.endpointParams().getBaseUrl(), storage -> storage.withServerVersion("10.3")) - .build(); + .start(); var response = checkStatusChangePermitted(backend, CONNECTION_ID, "issueKey"); @@ -113,7 +113,7 @@ void it_should_allow_2_statuses_when_user_has_permission_for_sonarqube_104(Sonar fakeServerWithIssue("issueKey", List.of("accept", "falsepositive")); var backend = harness.newBackend() .withSonarQubeConnection(CONNECTION_ID, mockWebServerExtension.endpointParams().getBaseUrl(), storage -> storage.withServerVersion("10.4")) - .build(); + .start(); var response = checkStatusChangePermitted(backend, CONNECTION_ID, "issueKey"); @@ -130,7 +130,7 @@ void it_should_allow_2_statuses_when_user_has_permission_for_sonarcloud(SonarLin var backend = harness.newBackend() .withSonarCloudUrl(mockWebServerExtension.endpointParams().getBaseUrl()) .withSonarCloudConnection(CONNECTION_ID, "orgKey") - .build(); + .start(); var response = checkStatusChangePermitted(backend, CONNECTION_ID, "issueKey"); @@ -147,7 +147,7 @@ void it_should_fallback_to_server_check_if_the_issue_uuid_is_not_found_in_local_ fakeServerWithIssue(issueKey, List.of("accept", "falsepositive")); var backend = harness.newBackend() .withSonarQubeConnection(CONNECTION_ID, mockWebServerExtension.endpointParams().getBaseUrl(), storage -> storage.withServerVersion("10.4")) - .build(); + .start(); var response = checkStatusChangePermitted(backend, CONNECTION_ID, issueKey); @@ -163,7 +163,7 @@ void it_should_not_permit_status_change_when_issue_misses_required_transitions(S fakeServerWithIssue("issueKey", List.of("confirm")); var backend = harness.newBackend() .withSonarQubeConnection(CONNECTION_ID, mockWebServerExtension.endpointParams().getBaseUrl(), storage -> storage.withServerVersion("10.3")) - .build(); + .start(); var response = checkStatusChangePermitted(backend, CONNECTION_ID, "issueKey"); @@ -179,7 +179,7 @@ void it_should_fail_if_no_issue_is_returned_by_web_api(SonarLintTestHarness harn fakeServerWithResponse("issueKey", null, Issues.SearchWsResponse.newBuilder().build()); var backend = harness.newBackend() .withSonarQubeConnection(CONNECTION_ID, mockWebServerExtension.endpointParams().getBaseUrl(), storage -> storage.withServerVersion("10.3")) - .build(); + .start(); var response = checkStatusChangePermitted(backend, CONNECTION_ID, "issueKey"); @@ -196,7 +196,7 @@ void it_should_fail_if_no_issue_is_returned_by_web_api(SonarLintTestHarness harn void it_should_fail_if_web_api_returns_an_error(SonarLintTestHarness harness) { var backend = harness.newBackend() .withSonarQubeConnection(CONNECTION_ID, mockWebServerExtension.endpointParams().getBaseUrl(), storage -> storage.withServerVersion("10.3")) - .build(); + .start(); var response = checkStatusChangePermitted(backend, CONNECTION_ID, "issueKey"); @@ -212,7 +212,7 @@ void it_should_fail_if_web_api_returns_unexpected_body(SonarLintTestHarness harn fakeServerWithWrongBody("issueKey"); var backend = harness.newBackend() .withSonarQubeConnection(CONNECTION_ID, mockWebServerExtension.endpointParams().getBaseUrl(), storage -> storage.withServerVersion("10.3")) - .build(); + .start(); var response = checkStatusChangePermitted(backend, CONNECTION_ID, "issueKey"); @@ -258,7 +258,7 @@ void it_should_not_permit_status_change_on_local_only_issues_for_sonarcloud(Sona .withBoundConfigScope(CONFIG_SCOPE_ID, CONNECTION_ID, projectKey) .withExtraEnabledLanguagesInConnectedMode(Language.XML) .withFullSynchronization() - .build(client); + .start(client); client.waitForSynchronization(); waitForAnalysisReady(client, CONFIG_SCOPE_ID); @@ -311,7 +311,7 @@ void it_should_not_permit_status_change_on_local_only_issues_for_sonarqube_prior .withBoundConfigScope(CONFIG_SCOPE_ID, CONNECTION_ID, projectKey) .withExtraEnabledLanguagesInConnectedMode(Language.XML) .withFullSynchronization() - .build(client); + .start(client); client.waitForSynchronization(); waitForAnalysisReady(client, CONFIG_SCOPE_ID); @@ -374,7 +374,7 @@ void it_should_permit_status_change_on_local_only_issues_for_sonarqube_10_2_plus .withBoundConfigScope(CONFIG_SCOPE_ID, CONNECTION_ID, projectKey) .withExtraEnabledLanguagesInConnectedMode(Language.XML) .withFullSynchronization() - .build(client); + .start(client); client.waitForSynchronization(); backend.getAnalysisService().analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams(CONFIG_SCOPE_ID, UUID.randomUUID(), @@ -427,7 +427,7 @@ void it_should_permit_status_change_on_local_only_issues_for_sonarqube_10_4_plus .withBoundConfigScope(CONFIG_SCOPE_ID, CONNECTION_ID, projectKey) .withExtraEnabledLanguagesInConnectedMode(Language.XML) .withFullSynchronization() - .build(client); + .start(client); client.waitForSynchronization(); waitForAnalysisReady(client, CONFIG_SCOPE_ID); diff --git a/medium-tests/src/test/java/mediumtest/issues/IssueEventsMediumTests.java b/medium-tests/src/test/java/mediumtest/issues/IssueEventsMediumTests.java index ec58f91617..b46773692e 100644 --- a/medium-tests/src/test/java/mediumtest/issues/IssueEventsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/issues/IssueEventsMediumTests.java @@ -103,7 +103,7 @@ void it_should_update_issue_in_storage_with_new_resolution(SonarLintTestHarness .withSonarQubeConnection("connectionId", server, storage -> storage.withProject(projectKey, project -> project.withMainBranch("branchName", branch -> branch.withIssue(aServerIssue("key1").open())))) .withBoundConfigScope("configScope", "connectionId", projectKey) - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readIssues(backend, "connectionId", projectKey, "branchName", "file/path")) @@ -137,7 +137,7 @@ void it_should_update_issue_in_storage_with_new_impacts(SonarLintTestHarness har project -> project.withMainBranch("branchName", branch -> branch.withIssue(aServerIssue("key1").withImpacts(Map.of(SoftwareQuality.MAINTAINABILITY, ImpactSeverity.HIGH)))))) .withBoundConfigScope("configScope", "connectionId", projectKey) - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readIssues(backend, "connectionId", projectKey, "branchName", "file/path")) @@ -169,7 +169,7 @@ void it_should_update_issue_in_storage_with_new_impacts_when_it_does_not_exist_i .withSonarQubeConnection("connectionId", server, storage -> storage.withProject(projectKey, project -> project.withMainBranch("branchName", branch -> branch.withIssue(aServerIssue("key1"))))) .withBoundConfigScope("configScope", "connectionId", projectKey) - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readIssues(backend, "connectionId", projectKey, "branchName", "file/path")) @@ -203,7 +203,7 @@ void it_should_update_issue_in_storage_with_new_impacts_on_different_software_qu project -> project.withMainBranch("branchName", branch -> branch.withIssue(aServerIssue("key1").withImpacts(Map.of(SoftwareQuality.SECURITY, ImpactSeverity.BLOCKER)))))) .withBoundConfigScope("configScope", "connectionId", projectKey) - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readIssues(backend, "connectionId", projectKey, "branchName", "file/path")) @@ -234,7 +234,7 @@ void it_should_update_issue_in_storage_with_new_severity(SonarLintTestHarness ha storage -> storage.withProject("projectKey", project -> project.withMainBranch("branchName", branch -> branch.withIssue(aServerIssue("key1").withSeverity(IssueSeverity.INFO))))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readIssues(backend, "connectionId", "projectKey", "branchName", "file/path")) @@ -265,7 +265,7 @@ void it_should_update_issue_in_storage_with_new_type(SonarLintTestHarness harnes storage -> storage.withProject("projectKey", project -> project.withMainBranch("branchName", branch -> branch.withIssue(aServerIssue("key1").withType(RuleType.VULNERABILITY))))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readIssues(backend, "connectionId", "projectKey", "branchName", "file/path")) @@ -319,7 +319,7 @@ void should_raise_issue_with_changed_rule_type(SonarLintTestHarness harness, @Te .withFullSynchronization() .withSonarQubeConnection(connectionId, serverWithIssues) .withBoundConfigScope(CONFIG_SCOPE_ID, connectionId, projectKey) - .build(client); + .start(client); await().atMost(Duration.ofMinutes(2)).untilAsserted(() -> assertThat(client.getSynchronizedConfigScopeIds()).contains(CONFIG_SCOPE_ID)); analyzeFileAndGetIssue(fileUri, client, backend, CONFIG_SCOPE_ID); @@ -384,7 +384,7 @@ void should_raise_issue_with_changed_resolution(SonarLintTestHarness harness, @T .withFullSynchronization() .withSonarQubeConnection(connectionId, serverWithIssues) .withBoundConfigScope(CONFIG_SCOPE_ID, connectionId, projectKey) - .build(client); + .start(client); await().atMost(Duration.ofMinutes(2)).untilAsserted(() -> assertThat(client.getSynchronizedConfigScopeIds()).contains(CONFIG_SCOPE_ID)); analyzeFileAndGetIssue(fileUri, client, backend, CONFIG_SCOPE_ID); @@ -446,7 +446,7 @@ void should_raise_issue_with_changed_impacts(SonarLintTestHarness harness, @Temp .withFullSynchronization() .withSonarQubeConnection(connectionId, serverWithIssues) .withBoundConfigScope(CONFIG_SCOPE_ID, connectionId, projectKey) - .build(client); + .start(client); await().atMost(Duration.ofMinutes(2)).untilAsserted(() -> assertThat(client.getSynchronizedConfigScopeIds()).contains(CONFIG_SCOPE_ID)); analyzeFileAndGetIssue(fileUri, client, backend, CONFIG_SCOPE_ID); @@ -512,7 +512,7 @@ void should_raise_issue_with_changed_severity(SonarLintTestHarness harness, @Tem .withFullSynchronization() .withSonarQubeConnection(connectionId, serverWithIssues) .withBoundConfigScope(CONFIG_SCOPE_ID, connectionId, projectKey) - .build(client); + .start(client); await().atMost(Duration.ofMinutes(2)).untilAsserted(() -> assertThat(client.getSynchronizedConfigScopeIds()).contains(CONFIG_SCOPE_ID)); analyzeFileAndGetIssue(fileUri, client, backend, CONFIG_SCOPE_ID); diff --git a/medium-tests/src/test/java/mediumtest/issues/IssuesStatusChangeMediumTests.java b/medium-tests/src/test/java/mediumtest/issues/IssuesStatusChangeMediumTests.java index aea92d061a..1a48f7231e 100644 --- a/medium-tests/src/test/java/mediumtest/issues/IssuesStatusChangeMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/issues/IssuesStatusChangeMediumTests.java @@ -74,7 +74,7 @@ void it_should_update_the_status_on_sonarqube_when_changing_the_status_on_a_serv .withProject("projectKey", project -> project.withMainBranch("main", branch -> branch.withIssue(serverIssue))) .withServerVersion("9.8")) .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey") - .build(); + .start(); var response = backend.getIssueService().changeStatus(new ChangeIssueStatusParams(CONFIGURATION_SCOPE_ID, "myIssueKey", ResolutionStatus.WONT_FIX, false)); @@ -104,7 +104,7 @@ void it_should_update_the_telemetry_when_changing_the_status_on_a_server_matched .withServerVersion("9.8")) .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey") .withTelemetryEnabled() - .build(); + .start(); var response = backend.getIssueService().changeStatus(new ChangeIssueStatusParams(CONFIGURATION_SCOPE_ID, "myIssueKey", ResolutionStatus.WONT_FIX, false)); @@ -124,7 +124,7 @@ void it_should_fail_the_future_when_the_server_returns_an_error(SonarLintTestHar .withProject("projectKey", project -> project.withMainBranch("main", branch -> branch.withIssue(serverIssue))) .withServerVersion("9.8")) .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey") - .build(); + .start(); var response = backend.getIssueService().changeStatus(new ChangeIssueStatusParams(CONFIGURATION_SCOPE_ID, "myIssueKey", ResolutionStatus.WONT_FIX, false)); @@ -163,7 +163,7 @@ void it_should_update_local_only_storage_when_the_issue_exists_locally(SonarLint .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey") .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) .withFullSynchronization() - .build(client); + .start(client); client.waitForSynchronization(); backend.getAnalysisService().analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams(CONFIGURATION_SCOPE_ID, UUID.randomUUID(), @@ -207,7 +207,7 @@ void it_should_sync_anticipated_transitions_with_sonarqube_when_the_issue_exists .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey") .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) .withFullSynchronization() - .build(client); + .start(client); client.waitForSynchronization(); backend.getAnalysisService().analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams(CONFIGURATION_SCOPE_ID, UUID.randomUUID(), @@ -256,7 +256,7 @@ void it_should_update_telemetry_when_changing_status_of_a_local_only_issue(Sonar .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) .withFullSynchronization() .withTelemetryEnabled() - .build(client); + .start(client); client.waitForSynchronization(); backend.getAnalysisService().analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams(CONFIGURATION_SCOPE_ID, UUID.randomUUID(), @@ -280,7 +280,7 @@ void it_should_fail_when_the_issue_does_not_exists(SonarLintTestHarness harness) var backend = harness.newBackend() .withSonarQubeConnection(CONNECTION_ID, server) .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey") - .build(); + .start(); var params = new ChangeIssueStatusParams(CONFIGURATION_SCOPE_ID, "myIssueKey", ResolutionStatus.WONT_FIX, false); var issueService = backend.getIssueService(); @@ -299,7 +299,7 @@ void it_should_add_new_comment_to_server_issue(SonarLintTestHarness harness) { .withSonarQubeConnection(CONNECTION_ID, server, storage -> storage.withProject("projectKey", project -> project.withMainBranch("main", branch -> branch.withIssue(aServerIssue("myIssueKey"))))) .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey") - .build(); + .start(); var response = backend.getIssueService().addComment(new AddIssueCommentParams(CONFIGURATION_SCOPE_ID, "myIssueKey", "That's " + "serious issue")); @@ -321,7 +321,7 @@ void it_should_add_new_comment_to_server_issue_with_uuid_key(SonarLintTestHarnes .withSonarQubeConnection(CONNECTION_ID, server, storage -> storage.withProject("projectKey", project -> project.withMainBranch("main", branch -> branch.withIssue(aServerIssue(issueKey))))) .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey") - .build(); + .start(); var response = backend.getIssueService().addComment(new AddIssueCommentParams(CONFIGURATION_SCOPE_ID, issueKey, "That's " + "serious issue")); @@ -342,7 +342,7 @@ void it_should_add_new_comment_to_resolved_local_only_issue(SonarLintTestHarness var backend = harness.newBackend() .withSonarQubeConnection(CONNECTION_ID, server) .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey", storage -> storage.withLocalOnlyIssue(aLocalOnlyIssueResolved(issueId))) - .build(); + .start(); var response = backend.getIssueService().addComment(new AddIssueCommentParams(CONFIGURATION_SCOPE_ID, issueId.toString(), "That's " + "serious issue")); @@ -362,7 +362,7 @@ void it_should_throw_if_server_response_is_not_OK_during_add_new_comment_to_issu .withSonarQubeConnection(CONNECTION_ID, server, storage -> storage.withProject("projectKey", project -> project.withMainBranch("main", branch -> branch.withIssue(aServerIssue("myIssueKey"))))) .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey") - .build(); + .start(); var response = backend.getIssueService().addComment(new AddIssueCommentParams(CONFIGURATION_SCOPE_ID, "myIssueKey", "That's " + "serious issue")); @@ -382,7 +382,7 @@ void it_should_throw_if_issue_is_unknown_when_adding_a_comment(SonarLintTestHarn var backend = harness.newBackend() .withSonarQubeConnection(CONNECTION_ID, server) .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey") - .build(); + .start(); var response = backend.getIssueService().addComment(new AddIssueCommentParams(CONFIGURATION_SCOPE_ID, "myIssueKey", "That's " + "serious issue")); @@ -402,7 +402,7 @@ void it_should_throw_if_issue_with_uuid_key_is_unknown_when_adding_a_comment(Son var backend = harness.newBackend() .withSonarQubeConnection(CONNECTION_ID, server) .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey") - .build(); + .start(); var issueKey = UUID.randomUUID().toString(); var response = backend.getIssueService().addComment(new AddIssueCommentParams(CONFIGURATION_SCOPE_ID, issueKey, "That's " + @@ -424,7 +424,7 @@ void it_should_reopen_issue_by_id(SonarLintTestHarness harness) throws Execution var backend = harness.newBackend() .withSonarQubeConnection(CONNECTION_ID, server) .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey", storage -> storage.withLocalOnlyIssue(aLocalOnlyIssueResolved(issueId))) - .build(); + .start(); var storedIssues = backend.getLocalOnlyIssueStorageService().get().loadAll(CONFIGURATION_SCOPE_ID); assertThat(storedIssues).extracting(LocalOnlyIssue::getId).containsOnly(issueId); @@ -456,7 +456,7 @@ void it_should_load_issues(SonarLintTestHarness harness) { new LocalOnlyIssueResolution(org.sonarsource.sonarlint.core.commons.IssueStatus.WONT_FIX, Instant.now().truncatedTo(ChronoUnit.MILLIS), "comment"))) .withLocalOnlyIssue(aLocalOnlyIssueResolved(issueId1)) .withLocalOnlyIssue(aLocalOnlyIssueResolved(issueId2))) - .build(); + .start(); var issuesForFile = backend.getLocalOnlyIssueStorageService().get().loadForFile(CONFIGURATION_SCOPE_ID, Path.of("file/path")); var issuesForOtherFile = backend.getLocalOnlyIssueStorageService().get().loadForFile(CONFIGURATION_SCOPE_ID, Path.of("file/path1")); @@ -486,7 +486,7 @@ void it_should_reopen_all_issues_for_file(SonarLintTestHarness harness) throws E "ruleKey", "message", new LocalOnlyIssueResolution(org.sonarsource.sonarlint.core.commons.IssueStatus.WONT_FIX, Instant.now().truncatedTo(ChronoUnit.MILLIS), "comment")))) - .build(); + .start(); var storedIssues = backend.getLocalOnlyIssueStorageService().get().loadAll(CONFIGURATION_SCOPE_ID); assertThat(storedIssues).extracting(LocalOnlyIssue::getId).containsOnly(issueId1, issueId2, otherFileIssueId); @@ -507,7 +507,7 @@ void it_should_return_false_on_reopen_issue_with_invalid_id(SonarLintTestHarness var backend = harness.newBackend() .withSonarQubeConnection(CONNECTION_ID, server) .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey", storage -> storage.withLocalOnlyIssue(aLocalOnlyIssueResolved(issueId))) - .build(); + .start(); var response = backend.getIssueService().reopenIssue(new ReopenIssueParams(CONFIGURATION_SCOPE_ID, invalidIssueId, false)); @@ -525,7 +525,7 @@ void it_should_return_false_on_reopen_non_existing_issue(SonarLintTestHarness ha var backend = harness.newBackend() .withSonarQubeConnection(CONNECTION_ID, server) .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey", storage -> storage.withLocalOnlyIssue(aLocalOnlyIssueResolved(issueId))) - .build(); + .start(); var response = backend.getIssueService().reopenIssue(new ReopenIssueParams(CONFIGURATION_SCOPE_ID, nonExistingIssueId.toString(), false)); @@ -547,7 +547,7 @@ void it_should_return_true_on_reopening_server_issue(SonarLintTestHarness harnes .withProject("projectKey", project -> project.withMainBranch("main", branch -> branch.withIssue(serverIssue))) .withServerVersion("9.8")) .withBoundConfigScope(CONFIGURATION_SCOPE_ID, CONNECTION_ID, "projectKey") - .build(); + .start(); var reopenResponse = backend.getIssueService().reopenIssue(new ReopenIssueParams(CONFIGURATION_SCOPE_ID, "myIssueKey", false)); diff --git a/medium-tests/src/test/java/mediumtest/issues/LocalOnlyResolvedIssuesStorageMediumTests.java b/medium-tests/src/test/java/mediumtest/issues/LocalOnlyResolvedIssuesStorageMediumTests.java index c961a98b9f..0f3b000b51 100644 --- a/medium-tests/src/test/java/mediumtest/issues/LocalOnlyResolvedIssuesStorageMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/issues/LocalOnlyResolvedIssuesStorageMediumTests.java @@ -42,7 +42,7 @@ void it_should_purge_local_only_stored_issues_resolved_more_than_one_week_ago_at .withServerVersion("9.8")) .withBoundConfigScope("configScopeId", "connectionId", "projectKey", storage -> storage.withLocalOnlyIssue(aLocalOnlyIssueResolved(Instant.now().minus(1, ChronoUnit.MINUTES).minus(7, ChronoUnit.DAYS)))) - .build(); + .start(); var storedIssues = backend.getLocalOnlyIssueStorageService().get().loadAll("configScopeId"); diff --git a/medium-tests/src/test/java/mediumtest/issues/OpenFixSuggestionInIdeMediumTests.java b/medium-tests/src/test/java/mediumtest/issues/OpenFixSuggestionInIdeMediumTests.java index be2d23c292..52a3d3c1eb 100644 --- a/medium-tests/src/test/java/mediumtest/issues/OpenFixSuggestionInIdeMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/issues/OpenFixSuggestionInIdeMediumTests.java @@ -103,7 +103,7 @@ void it_should_update_the_telemetry_on_show_issue(SonarLintTestHarness harness, .withEmbeddedServer() .withTelemetryEnabled() .withOpenFixSuggestion() - .build(fakeClient); + .start(fakeClient); assertThat(backend.telemetryFilePath()) .content().asBase64Decoded().asString() @@ -131,7 +131,7 @@ void it_should_open_a_fix_suggestion_in_ide(SonarLintTestHarness harness, @TempD .withBoundConfigScope(CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY) .withEmbeddedServer() .withOpenFixSuggestion() - .build(fakeClient); + .start(fakeClient); var statusCode = executeOpenFixSuggestionRequestWithoutToken(backend, scServer, FIX_PAYLOAD, ISSUE_KEY, PROJECT_KEY, BRANCH_NAME, ORG_KEY); assertThat(statusCode).isEqualTo(200); @@ -167,7 +167,7 @@ void it_should_assist_creating_the_binding_if_scope_not_bound(SonarLintTestHarne .withUnboundConfigScope(CONFIG_SCOPE_ID, PROJECT_KEY) .withEmbeddedServer() .withOpenFixSuggestion() - .build(fakeClient); + .start(fakeClient); mockAssistCreatingConnection(backend, fakeClient, CONNECTION_ID); mockAssistBinding(backend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); @@ -191,7 +191,7 @@ void it_should_not_assist_binding_if_multiple_suggestions(SonarLintTestHarness h .withUnboundConfigScope("configScopeB", PROJECT_KEY + " 2") .withEmbeddedServer() .withOpenFixSuggestion() - .build(fakeClient); + .start(fakeClient); mockAssistCreatingConnection(backend, fakeClient, CONNECTION_ID); mockAssistBinding(backend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); @@ -217,7 +217,7 @@ void it_should_assist_binding_if_multiple_suggestions_but_scopes_are_parent_and_ .withUnboundConfigScope("configScopeChild", PROJECT_KEY, "configScopeParent") .withEmbeddedServer() .withOpenFixSuggestion() - .build(fakeClient); + .start(fakeClient); mockAssistCreatingConnection(backend, fakeClient, CONNECTION_ID); mockAssistBinding(backend, fakeClient, "configScopeParent", CONNECTION_ID, PROJECT_KEY); @@ -241,7 +241,7 @@ void it_should_assist_creating_the_connection_when_no_sc_connection(SonarLintTes .withUnboundConfigScope(CONFIG_SCOPE_ID, PROJECT_KEY) .withEmbeddedServer() .withOpenFixSuggestion() - .build(fakeClient); + .start(fakeClient); mockAssistCreatingConnection(backend, fakeClient, CONNECTION_ID); mockAssistBinding(backend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); @@ -271,7 +271,7 @@ void it_should_revoke_token_when_exception_thrown_while_assist_creating_the_conn .withUnboundConfigScope(CONFIG_SCOPE_ID, PROJECT_KEY) .withEmbeddedServer() .withOpenFixSuggestion() - .build(fakeClient); + .start(fakeClient); var statusCode = executeOpenFixSuggestionRequestWithToken(backend, scServer, FIX_PAYLOAD, ISSUE_KEY, PROJECT_KEY, BRANCH_NAME, "orgKey", "token-name", "token-value"); assertThat(statusCode).isEqualTo(200); @@ -288,7 +288,7 @@ void it_should_fail_request_when_issue_parameter_missing(SonarLintTestHarness ha var backend = harness.newBackend() .withEmbeddedServer() .withOpenFixSuggestion() - .build(); + .start(); var scServer = buildSonarCloudServer(harness).start(); var statusCode = executeOpenFixSuggestionRequestWithoutToken(backend, scServer, FIX_PAYLOAD, "", PROJECT_KEY, BRANCH_NAME, ORG_KEY); @@ -300,7 +300,7 @@ void it_should_fail_request_when_issue_parameter_missing(SonarLintTestHarness ha void it_should_fail_request_when_feature_not_enabled(SonarLintTestHarness harness) throws Exception { var backend = harness.newBackend() .withEmbeddedServer() - .build(); + .start(); var scServer = buildSonarCloudServer(harness).start(); var statusCode = executeOpenFixSuggestionRequestWithoutToken(backend, scServer, FIX_PAYLOAD, ISSUE_KEY, PROJECT_KEY, BRANCH_NAME, ORG_KEY); @@ -312,7 +312,7 @@ void it_should_fail_request_when_feature_not_enabled(SonarLintTestHarness harnes void it_should_fail_request_when_project_parameter_missing(SonarLintTestHarness harness) throws IOException, InterruptedException { var backend = harness.newBackend() .withEmbeddedServer() - .build(); + .start(); var scServer = buildSonarCloudServer(harness).start(); var statusCode = executeOpenFixSuggestionRequestWithoutToken(backend, scServer, ISSUE_KEY, "", "", "", ""); @@ -330,7 +330,7 @@ void it_should_fail_when_origin_is_missing(SonarLintTestHarness harness) throws .withBoundConfigScope(CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY) .withEmbeddedServer() .withOpenFixSuggestion() - .build(fakeClient); + .start(fakeClient); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create( "http://localhost:" + backend.getEmbeddedServerPort() + "/sonarlint/api/fix/show?server=" + scServer.baseUrl() + "&issue=" + ISSUE_KEY + @@ -357,7 +357,7 @@ void it_should_fail_when_origin_does_not_match(SonarLintTestHarness harness, @Te .withBoundConfigScope(CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY) .withEmbeddedServer() .withOpenFixSuggestion() - .build(fakeClient); + .start(fakeClient); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create( "http://localhost:" + backend.getEmbeddedServerPort() + "/sonarlint/api/fix/show?server=" + scServer.baseUrl() + "&issue=" + ISSUE_KEY + diff --git a/medium-tests/src/test/java/mediumtest/issues/OpenIssueInIdeMediumTests.java b/medium-tests/src/test/java/mediumtest/issues/OpenIssueInIdeMediumTests.java index 718b65a818..8da4ae6d9f 100644 --- a/medium-tests/src/test/java/mediumtest/issues/OpenIssueInIdeMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/issues/OpenIssueInIdeMediumTests.java @@ -87,7 +87,7 @@ void it_should_update_the_telemetry_on_show_issue(SonarLintTestHarness harness) .withBoundConfigScope(CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY) .withEmbeddedServer() .withTelemetryEnabled() - .build(fakeClient); + .start(fakeClient); assertThat(backend.telemetryFilePath()) .content().asBase64Decoded().asString() @@ -115,7 +115,7 @@ void it_should_open_an_issue_in_ide(SonarLintTestHarness harness) throws Excepti .withSonarQubeConnection(connectionId, fakeServerWithIssue) .withBoundConfigScope(configScopeId, connectionId, projectKey) .withEmbeddedServer() - .build(fakeClient); + .start(fakeClient); var statusCode = executeOpenIssueRequest(backend, fakeServerWithIssue, ISSUE_KEY, PROJECT_KEY, BRANCH_NAME); assertThat(statusCode).isEqualTo(200); @@ -149,7 +149,7 @@ void it_should_open_pr_issue_in_ide(SonarLintTestHarness harness) throws IOExcep .withSonarQubeConnection(connectionId, fakeServerWithIssue) .withBoundConfigScope(configScopeId, connectionId, projectKey) .withEmbeddedServer() - .build(fakeClient); + .start(fakeClient); var statusCode = executeOpenIssueRequest(backend, fakeServerWithIssue, PR_ISSUE_KEY, PROJECT_KEY, BRANCH_NAME, "1234"); assertThat(statusCode).isEqualTo(200); @@ -184,7 +184,7 @@ void it_should_open_a_file_level_issue_in_ide(SonarLintTestHarness harness) thro .withSonarQubeConnection(connectionId, fakeServerWithIssue) .withBoundConfigScope(configScopeId, connectionId, projectKey) .withEmbeddedServer() - .build(fakeClient); + .start(fakeClient); var statusCode = executeOpenIssueRequest(backend, fakeServerWithIssue, FILE_LEVEL_ISSUE_KEY, PROJECT_KEY, BRANCH_NAME); assertThat(statusCode).isEqualTo(200); @@ -215,7 +215,7 @@ void it_should_assist_creating_the_binding_if_scope_not_bound(SonarLintTestHarne .withSonarQubeConnection(CONNECTION_ID, fakeServerWithIssue) .withUnboundConfigScope(CONFIG_SCOPE_ID, SONAR_PROJECT_NAME) .withEmbeddedServer() - .build(fakeClient); + .start(fakeClient); mockAssistCreatingConnection(backend, fakeClient, fakeServerWithIssue, CONNECTION_ID); mockAssistBinding(backend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); @@ -236,7 +236,7 @@ void it_should_not_assist_binding_if_multiple_suggestions(SonarLintTestHarness h .withUnboundConfigScope("configScopeA", SONAR_PROJECT_NAME + " 1") .withUnboundConfigScope("configScopeB", SONAR_PROJECT_NAME + " 2") .withEmbeddedServer() - .build(fakeClient); + .start(fakeClient); mockAssistCreatingConnection(backend, fakeClient, fakeServerWithIssue, CONNECTION_ID); mockAssistBinding(backend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); @@ -258,7 +258,7 @@ void it_should_assist_binding_if_multiple_suggestions_but_scopes_are_parent_and_ .withUnboundConfigScope("configScopeParent", SONAR_PROJECT_NAME) .withUnboundConfigScope("configScopeChild", SONAR_PROJECT_NAME, "configScopeParent") .withEmbeddedServer() - .build(fakeClient); + .start(fakeClient); mockAssistCreatingConnection(backend, fakeClient, fakeServerWithIssue, CONNECTION_ID); mockAssistBinding(backend, fakeClient, "configScopeParent", CONNECTION_ID, PROJECT_KEY); @@ -276,7 +276,7 @@ void it_should_assist_creating_the_connection_when_server_url_unknown(SonarLintT var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID, SONAR_PROJECT_NAME) .withEmbeddedServer() - .build(fakeClient); + .start(fakeClient); mockAssistCreatingConnection(backend, fakeClient, fakeServerWithIssue, CONNECTION_ID); mockAssistBinding(backend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); @@ -304,7 +304,7 @@ void it_should_assist_creating_the_connection_when_no_sc_connection(SonarLintTes .withSonarCloudUrl("https://sonar.my") .withUnboundConfigScope(CONFIG_SCOPE_ID, SONAR_PROJECT_NAME) .withEmbeddedServer() - .build(fakeClient); + .start(fakeClient); mockAssistCreatingConnection(backend, fakeClient, fakeServerWithIssue, CONNECTION_ID); mockAssistBinding(backend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); @@ -332,7 +332,7 @@ void it_should_revoke_token_when_exception_thrown_while_assist_creating_the_conn .withSonarCloudUrl("https://sonar.my") .withUnboundConfigScope(CONFIG_SCOPE_ID, SONAR_PROJECT_NAME) .withEmbeddedServer() - .build(fakeClient); + .start(fakeClient); var statusCode = executeOpenSCIssueRequest(backend, ISSUE_KEY, PROJECT_KEY, BRANCH_NAME, "orgKey", "token-name", "token-value"); assertThat(statusCode).isEqualTo(200); @@ -348,7 +348,7 @@ void it_should_revoke_token_when_exception_thrown_while_assist_creating_the_conn void it_should_fail_request_when_issue_parameter_missing(SonarLintTestHarness harness) throws Exception { var backend = harness.newBackend() .withEmbeddedServer() - .build(); + .start(); var fakeServerWithIssue = fakeServerWithIssue(harness).start(); var statusCode = executeOpenIssueRequest(backend, fakeServerWithIssue, "", PROJECT_KEY, BRANCH_NAME); @@ -360,7 +360,7 @@ void it_should_fail_request_when_issue_parameter_missing(SonarLintTestHarness ha void it_should_fail_request_when_project_parameter_missing(SonarLintTestHarness harness) throws Exception { var backend = harness.newBackend() .withEmbeddedServer() - .build(); + .start(); var fakeServerWithIssue = fakeServerWithIssue(harness).start(); var statusCode = executeOpenIssueRequest(backend, fakeServerWithIssue, ISSUE_KEY, "", "", ""); diff --git a/medium-tests/src/test/java/mediumtest/newcode/NewCodeTelemetryMediumTests.java b/medium-tests/src/test/java/mediumtest/newcode/NewCodeTelemetryMediumTests.java index c862e47222..bb01c18674 100644 --- a/medium-tests/src/test/java/mediumtest/newcode/NewCodeTelemetryMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/newcode/NewCodeTelemetryMediumTests.java @@ -29,21 +29,21 @@ class NewCodeTelemetryMediumTests { @SonarLintTest void it_should_save_initial_value_when_focus_on_overall_code(SonarLintTestHarness harness) { - var backend = harness.newBackend().withTelemetryEnabled().build(); + var backend = harness.newBackend().withTelemetryEnabled().start(); assertThat(backend.telemetryFilePath()).content().asBase64Decoded().asString().contains("\"isFocusOnNewCode\":false,\"codeFocusChangedCount\":0"); } @SonarLintTest void it_should_save_initial_value_when_focus_on_new_code(SonarLintTestHarness harness) { - var backend = harness.newBackend().withTelemetryEnabled().withFocusOnNewCode().build(); + var backend = harness.newBackend().withTelemetryEnabled().withFocusOnNewCode().start(); assertThat(backend.telemetryFilePath()).content().asBase64Decoded().asString().contains("\"isFocusOnNewCode\":true,\"codeFocusChangedCount\":0"); } @SonarLintTest void it_should_save_new_focus_and_increment_count_when_focusing_on_new_code(SonarLintTestHarness harness) { - var backend = harness.newBackend().withTelemetryEnabled().build(); + var backend = harness.newBackend().withTelemetryEnabled().start(); backend.getNewCodeService().didToggleFocus(); @@ -52,7 +52,7 @@ void it_should_save_new_focus_and_increment_count_when_focusing_on_new_code(Sona @SonarLintTest void it_should_save_new_focus_and_increment_count_when_focusing_on_overall_code(SonarLintTestHarness harness) { - var backend = harness.newBackend().withTelemetryEnabled().withFocusOnNewCode().build(); + var backend = harness.newBackend().withTelemetryEnabled().withFocusOnNewCode().start(); backend.getNewCodeService().didToggleFocus(); diff --git a/medium-tests/src/test/java/mediumtest/promotion/ExtraEnabledLanguagesInConnectedModePromotionMediumTests.java b/medium-tests/src/test/java/mediumtest/promotion/ExtraEnabledLanguagesInConnectedModePromotionMediumTests.java index 144422d962..2663c85f79 100644 --- a/medium-tests/src/test/java/mediumtest/promotion/ExtraEnabledLanguagesInConnectedModePromotionMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/promotion/ExtraEnabledLanguagesInConnectedModePromotionMediumTests.java @@ -59,7 +59,7 @@ void it_should_notify_clients_for_a_detected_language_that_is_enabled_only_in_co .withUnboundConfigScope("configScopeId") .withEmbeddedServer() .withTelemetryEnabled() - .build(fakeClient); + .start(fakeClient); backend.getAnalysisService() .analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams("configScopeId", UUID.randomUUID(), @@ -82,7 +82,7 @@ void it_should_not_notify_clients_when_already_in_connected_mode(SonarLintTestHa .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withEmbeddedServer() .withTelemetryEnabled() - .build(fakeClient); + .start(fakeClient); backend.getAnalysisService() .analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams("configScopeId", UUID.randomUUID(), @@ -103,7 +103,7 @@ void it_should_not_notify_clients_when_detected_language_is_not_an_extra_languag .withUnboundConfigScope("configScopeId") .withEmbeddedServer() .withTelemetryEnabled() - .build(fakeClient); + .start(fakeClient); backend.getAnalysisService() .analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams("configScopeId", UUID.randomUUID(), @@ -124,7 +124,7 @@ void it_should_not_notify_clients_when_no_language_was_detected_during_analysis( .withUnboundConfigScope("configScopeId") .withEmbeddedServer() .withTelemetryEnabled() - .build(fakeClient); + .start(fakeClient); backend.getAnalysisService() .analyzeFilesAndTrack(new AnalyzeFilesAndTrackParams("configScopeId", UUID.randomUUID(), diff --git a/medium-tests/src/test/java/mediumtest/rules/RuleDetailsMediumTests.java b/medium-tests/src/test/java/mediumtest/rules/RuleDetailsMediumTests.java index de9bdd3d1b..697b9b24b6 100644 --- a/medium-tests/src/test/java/mediumtest/rules/RuleDetailsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/rules/RuleDetailsMediumTests.java @@ -44,7 +44,7 @@ void it_should_return_details_from_server_when_sonarqube(SonarLintTestHarness ha storage -> storage.withServerVersion("9.9").withProject("projectKey", project -> project.withRuleSet("secrets", ruleSet -> ruleSet.withActiveRule("secrets:S6290", "MAJOR")))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); var ruleDetails = backend.getAnalysisService().getRuleDetails(new GetRuleDetailsParams("configScope", "secrets:S6290")).join(); @@ -66,7 +66,7 @@ void it_should_return_details_from_server_when_sonarcloud(SonarLintTestHarness h storage -> storage.withPlugin(TestPlugin.TEXT).withProject("projectKey", project -> project.withRuleSet("secrets", ruleSet -> ruleSet.withActiveRule("secrets:S6290", "MAJOR")))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); var ruleDetails = backend.getAnalysisService().getRuleDetails(new GetRuleDetailsParams("configScope", "secrets:S6290")).join(); @@ -87,7 +87,7 @@ void it_should_return_details_from_the_embedded_ipython_rules_when_connected(Son storage -> storage.withPlugin(TestPlugin.TEXT).withProject("projectKey", project -> project.withRuleSet("secrets", ruleSet -> ruleSet.withActiveRule("secrets:S6290", "MAJOR")))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); var ruleDetails = backend.getAnalysisService().getRuleDetails(new GetRuleDetailsParams("configScope", "ipython:PrintStatementUsage")).join(); diff --git a/medium-tests/src/test/java/mediumtest/rules/RuleEventsMediumTests.java b/medium-tests/src/test/java/mediumtest/rules/RuleEventsMediumTests.java index dee20e09dd..1c523dc234 100644 --- a/medium-tests/src/test/java/mediumtest/rules/RuleEventsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/rules/RuleEventsMediumTests.java @@ -97,7 +97,7 @@ void it_should_create_the_ruleset_storage_if_does_not_exist_without_impacts(Sona .withServerSentEventsEnabled() .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readRuleSets(backend, "connectionId", "projectKey")) @@ -137,7 +137,7 @@ void it_should_create_the_ruleset_storage_if_does_not_exist(SonarLintTestHarness .withServerSentEventsEnabled() .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readRuleSets(backend, "connectionId", "projectKey")) @@ -184,7 +184,7 @@ void it_should_update_existing_rule_in_storage(SonarLintTestHarness harness) { project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule("java:S0000", "INFO")))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readRuleSets(backend, "connectionId", "projectKey")) @@ -222,7 +222,7 @@ void it_should_add_rule_to_existing_ruleset_in_storage(SonarLintTestHarness harn project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule("java:S0000", "INFO")))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readRuleSets(backend, "connectionId", "projectKey")) @@ -276,7 +276,7 @@ void it_should_reanalyze_open_files_on_new_rules_enabled(SonarLintTestHarness ha .withFullSynchronization() .withSonarQubeConnection(connectionId, server) .withBoundConfigScope(CONFIG_SCOPE_ID, connectionId, projectKey) - .build(client); + .start(client); backend.getFileService().didOpenFile(new DidOpenFileParams(CONFIG_SCOPE_ID, fileUri)); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(client.getSynchronizedConfigScopeIds()).contains(CONFIG_SCOPE_ID)); @@ -322,7 +322,7 @@ void it_should_add_rule_to_new_ruleset_in_existing_storage(SonarLintTestHarness project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule("java:S0000", "INFO")))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readRuleSets(backend, "connectionId", "projectKey")) @@ -352,7 +352,7 @@ void it_should_remove_deactivated_rule_from_existing_storage(SonarLintTestHarnes project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule("java:S0000", "INFO").withActiveRule("java:S0001", "INFO")))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readRuleSets(backend, "connectionId", "projectKey")) @@ -381,7 +381,7 @@ void it_should_remove_ruleset_from_storage_when_deactivating_last_rule(SonarLint project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule("java:S0000", "INFO")))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readRuleSets(backend, "connectionId", "projectKey")) @@ -434,7 +434,7 @@ void it_should_re_raise_issues_without_deactivated_rules(SonarLintTestHarness ha .withFullSynchronization() .withSonarQubeConnection(connectionId, server) .withBoundConfigScope(CONFIG_SCOPE_ID, connectionId, projectKey) - .build(client); + .start(client); await().atMost(Duration.ofSeconds(20)).untilAsserted(() -> assertThat(client.getSynchronizedConfigScopeIds()).contains(CONFIG_SCOPE_ID)); var raisedIssues = analyzeFileAndGetIssues(fileUri, client, backend, CONFIG_SCOPE_ID); diff --git a/medium-tests/src/test/java/mediumtest/server/events/ServerSentEventsMediumTests.java b/medium-tests/src/test/java/mediumtest/server/events/ServerSentEventsMediumTests.java index 2673595129..81ced06a1b 100644 --- a/medium-tests/src/test/java/mediumtest/server/events/ServerSentEventsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/server/events/ServerSentEventsMediumTests.java @@ -107,7 +107,7 @@ void should_subscribe_for_events_if_connected_to_sonarqube(SonarLintTestHarness .withServerSentEventsEnabled() .withSonarQubeConnection("connectionId", sonarServerMock.baseUrl()) .withUnboundConfigScope("configScope") - .build(); + .start(); bind(backend, "configScope", "connectionId", "projectKey"); @@ -124,7 +124,7 @@ void should_not_subscribe_for_events_if_sonarcloud_connection(SonarLintTestHarne .withServerSentEventsEnabled() .withSonarCloudConnection("connectionId") .withUnboundConfigScope("configScope") - .build(); + .start(); bind(backend, "configScope", "connectionId", "projectKey"); @@ -139,7 +139,7 @@ void should_not_resubscribe_for_events_if_sonarqube_connection_and_binding_is_th .withServerSentEventsEnabled() .withSonarQubeConnection("connectionId", sonarServerMock.baseUrl()) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(requestedPaths()).hasSize(1)); bind(backend, "configScope", "connectionId", "projectKey"); @@ -162,7 +162,7 @@ void should_not_resubscribe_for_events_if_sonarqube_connection(SonarLintTestHarn .withServerSentEventsEnabled() .withSonarQubeConnection("connectionId", sonarServerMock.baseUrl()) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(requestedPaths()).hasSize(1)); unbind(backend, "configScope"); @@ -179,7 +179,7 @@ void should_unsubscribe_for_events_if_sonarqube_connection_and_other_projects_bo .withSonarQubeConnection("connectionId", sonarServerMock.baseUrl()) .withBoundConfigScope("configScope1", "connectionId", "projectKey1") .withBoundConfigScope("configScope2", "connectionId", "projectKey2") - .build(); + .start(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(requestedPaths()).hasSize(1)); unbind(backend, "configScope1"); @@ -204,7 +204,7 @@ void should_subscribe_if_bound_to_sonarqube(SonarLintTestHarness harness) { .withExtraEnabledLanguagesInConnectedMode(JAVA) .withServerSentEventsEnabled() .withSonarQubeConnection("connectionId", sonarServerMock.baseUrl()) - .build(); + .start(); addConfigurationScope(backend, "configScope", "connectionId", "projectKey"); @@ -220,7 +220,7 @@ void should_log_subscription_errors(SonarLintTestHarness harness) { .withExtraEnabledLanguagesInConnectedMode(JAVA) .withServerSentEventsEnabled() .withSonarQubeConnection("connectionId", sonarServerMock.baseUrl()) - .build(client); + .start(client); var projectKey = "projectKey"; sonarServerMock.stubFor(get("/api/push/sonarlint_events?projectKeys=" + projectKey + "&languages=java,js") @@ -245,7 +245,7 @@ void should_not_subscribe_if_not_bound(SonarLintTestHarness harness) { .withExtraEnabledLanguagesInConnectedMode(JAVA) .withServerSentEventsEnabled() .withSonarQubeConnection("connectionId", sonarServerMock.baseUrl()) - .build(); + .start(); addConfigurationScope(backend, "configScope", null, null); @@ -260,7 +260,7 @@ void should_not_subscribe_if_bound_to_sonarcloud(SonarLintTestHarness harness) { .withExtraEnabledLanguagesInConnectedMode(JAVA) .withServerSentEventsEnabled() .withSonarCloudConnection("connectionId") - .build(); + .start(); addConfigurationScope(backend, "configScope", "connectionId", "projectKey"); @@ -284,7 +284,7 @@ void should_do_nothing_if_scope_was_not_bound(SonarLintTestHarness harness) { .withServerSentEventsEnabled() .withSonarQubeConnection("connectionId", sonarServerMock.baseUrl()) .withUnboundConfigScope("configScope") - .build(); + .start(); removeScope(backend, "configScope"); @@ -300,7 +300,7 @@ void should_do_nothing_if_scope_was_bound_to_sonarcloud(SonarLintTestHarness har .withServerSentEventsEnabled() .withSonarCloudConnection("connectionId") .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); removeScope(backend, "configScope"); @@ -315,7 +315,7 @@ void should_close_connection_when_if_scope_was_bound_to_sonarcloud_and_no_other_ .withServerSentEventsEnabled() .withSonarQubeConnection("connectionId", sonarServerMock.baseUrl()) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(requestedPaths()).hasSize(1)); removeScope(backend, "configScope"); @@ -332,7 +332,7 @@ void should_keep_connection_if_scope_was_bound_to_sonarqube_and_another_scope_is .withSonarQubeConnection("connectionId", sonarServerMock.baseUrl()) .withBoundConfigScope("configScope1", "connectionId", "projectKey") .withBoundConfigScope("configScope2", "connectionId", "projectKey") - .build(); + .start(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(requestedPaths()).hasSize(1)); removeScope(backend, "configScope1"); @@ -351,7 +351,7 @@ void should_reopen_connection_if_scope_was_bound_to_sonarqube_and_another_scope_ .withSonarQubeConnection("connectionId", sonarServerMock.baseUrl()) .withBoundConfigScope("configScope1", "connectionId", "projectKey1") .withBoundConfigScope("configScope2", "connectionId", "projectKey2") - .build(); + .start(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(requestedPaths()).hasSize(1)); removeScope(backend, "configScope1"); @@ -378,7 +378,7 @@ void should_resubscribe_if_sonarqube_connection_was_open(SonarLintTestHarness ha .withServerSentEventsEnabled() .withSonarQubeConnection("connectionId", sonarServerMock.baseUrl()) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(requestedPaths()).hasSize(1)); notifyCredentialsChanged(backend, "connectionId"); @@ -398,7 +398,7 @@ void should_do_nothing_if_sonarcloud(SonarLintTestHarness harness) { .withServerSentEventsEnabled() .withSonarCloudConnection("connectionId") .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); notifyCredentialsChanged(backend, "connectionId"); @@ -412,7 +412,7 @@ void should_do_nothing_if_sonarqube_connection_was_not_open(SonarLintTestHarness .withExtraEnabledLanguagesInConnectedMode(JAVA) .withServerSentEventsEnabled() .withSonarQubeConnection("connectionId", sonarServerMock.baseUrl()) - .build(); + .start(); notifyCredentialsChanged(backend, "connectionId"); @@ -434,7 +434,7 @@ void should_do_nothing_if_no_scope_is_bound(SonarLintTestHarness harness) { .withExtraEnabledLanguagesInConnectedMode(JAVA) .withServerSentEventsEnabled() .withUnboundConfigScope("configScope") - .build(); + .start(); backend.getConnectionService() .didUpdateConnections(new DidUpdateConnectionsParams(List.of(new SonarQubeConnectionConfigurationDto("connectionId", "url", true)), Collections.emptyList())); @@ -449,7 +449,7 @@ void should_do_nothing_if_sonarcloud(SonarLintTestHarness harness) { .withExtraEnabledLanguagesInConnectedMode(JAVA) .withServerSentEventsEnabled() .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); backend.getConnectionService() .didUpdateConnections(new DidUpdateConnectionsParams(Collections.emptyList(), List.of(new SonarCloudConnectionConfigurationDto("connectionId", "orgKey", true)))); @@ -464,7 +464,7 @@ void should_open_connection_when_bound_scope_exists(SonarLintTestHarness harness .withExtraEnabledLanguagesInConnectedMode(JAVA) .withServerSentEventsEnabled() .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); backend.getConnectionService().didUpdateConnections( new DidUpdateConnectionsParams(List.of(new SonarQubeConnectionConfigurationDto("connectionId", sonarServerMock.baseUrl(), true)), Collections.emptyList())); @@ -486,7 +486,7 @@ void should_do_nothing_if_sonarcloud(SonarLintTestHarness harness) { .withServerSentEventsEnabled() .withSonarCloudConnection("connectionId") .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); backend.getConnectionService().didUpdateConnections(new DidUpdateConnectionsParams(Collections.emptyList(), Collections.emptyList())); @@ -501,7 +501,7 @@ void should_close_active_connection_if_sonarqube(SonarLintTestHarness harness) { .withServerSentEventsEnabled() .withSonarQubeConnection("connectionId", sonarServerMock.baseUrl()) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(requestedPaths()).hasSize(1)); backend.getConnectionService().didUpdateConnections(new DidUpdateConnectionsParams(Collections.emptyList(), Collections.emptyList())); @@ -521,7 +521,7 @@ void should_resubscribe_if_sonarqube_connection_active(SonarLintTestHarness harn .withServerSentEventsEnabled() .withSonarQubeConnection("connectionId", sonarServerMock.baseUrl()) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(requestedPaths()).hasSize(1)); backend.getConnectionService().didUpdateConnections( @@ -542,7 +542,7 @@ void should_not_resubscribe_if_sonarcloud(SonarLintTestHarness harness) { .withServerSentEventsEnabled() .withSonarCloudConnection("connectionId") .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(); + .start(); backend.getConnectionService().didUpdateConnections(new DidUpdateConnectionsParams(List.of(), Collections.emptyList())); @@ -597,7 +597,7 @@ void should_forward_taint_events_to_client(SonarLintTestHarness harness) { .withFullSynchronization() .withSonarQubeConnection("connectionId", serverWithTaintIssues) .withBoundConfigScope("configScope", "connectionId", projectKey) - .build(fakeClient); + .start(fakeClient); fakeClient.waitForSynchronization(); ArgumentCaptor> captor = ArgumentCaptor.forClass(List.class); diff --git a/medium-tests/src/test/java/mediumtest/smartnotifications/SmartNotificationsMediumTests.java b/medium-tests/src/test/java/mediumtest/smartnotifications/SmartNotificationsMediumTests.java index a4fa4566b7..7bcf3accac 100644 --- a/medium-tests/src/test/java/mediumtest/smartnotifications/SmartNotificationsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/smartnotifications/SmartNotificationsMediumTests.java @@ -122,7 +122,7 @@ void it_should_send_notification_for_two_config_scope_with_same_binding(SonarLin .withBoundConfigScope("scopeId", CONNECTION_ID, PROJECT_KEY) .withBoundConfigScope("scopeId2", CONNECTION_ID, PROJECT_KEY) .withSmartNotifications() - .build(fakeClient); + .start(fakeClient); await().atMost(3, SECONDS).until(() -> !fakeClient.getSmartNotificationsToShow().isEmpty()); @@ -145,7 +145,7 @@ void it_should_send_notification_for_two_config_scope_with_inherited_binding(Son .withBoundConfigScope("parentScopeId", CONNECTION_ID, PROJECT_KEY) .withChildConfigScope("childScopeId", "parentScopeId") .withSmartNotifications() - .build(fakeClient); + .start(fakeClient); await().atMost(3, SECONDS).until(() -> !fakeClient.getSmartNotificationsToShow().isEmpty()); @@ -183,7 +183,7 @@ void it_should_send_notification_for_different_bindings(SonarLintTestHarness har .withBoundConfigScope("scopeId5", CONNECTION_ID, PROJECT_KEY_4) .withBoundConfigScope("scopeId6", CONNECTION_ID_2, PROJECT_KEY_4) .withSmartNotifications() - .build(fakeClient); + .start(fakeClient); await().atMost(3, SECONDS).untilAsserted(() -> assertThat(fakeClient.getSmartNotificationsToShow()).hasSize(4)); @@ -211,7 +211,7 @@ void it_should_not_send_notification_with_unbound_config_scope(SonarLintTestHarn .withUnboundConfigScope("scopeId") .withBoundConfigScope("scopeId2", CONNECTION_ID, PROJECT_KEY) .withSmartNotifications() - .build(fakeClient); + .start(fakeClient); await().atMost(3, SECONDS).until(() -> !fakeClient.getSmartNotificationsToShow().isEmpty()); @@ -232,7 +232,7 @@ void it_should_send_notification_after_adding_removing_binding(SonarLintTestHarn storage -> storage.withProject(PROJECT_KEY, project -> project.withLastSmartNotificationPoll(STORED_DATE))) .withBoundConfigScope("scopeId", CONNECTION_ID, PROJECT_KEY) .withSmartNotifications() - .build(fakeClient); + .start(fakeClient); backend.getConfigurationService().didRemoveConfigurationScope(new DidRemoveConfigurationScopeParams("scopeId")); @@ -261,7 +261,7 @@ void it_should_send_notification_handled_by_sonarcloud_websocket_as_fallback(Son .withSonarCloudConnectionAndNotifications(CONNECTION_ID, "myOrg", storage -> storage.withProject(PROJECT_KEY, project -> project.withLastSmartNotificationPoll(STORED_DATE))) .withBoundConfigScope("scopeId", CONNECTION_ID, PROJECT_KEY) .withSmartNotifications() - .build(fakeClient); + .start(fakeClient); await().atMost(3, SECONDS).until(() -> !fakeClient.getSmartNotificationsToShow().isEmpty()); @@ -287,7 +287,7 @@ void it_should_skip_polling_notifications_when_sonarcloud_websocket_opened(Sonar .withBoundConfigScope("scopeId", CONNECTION_ID, PROJECT_KEY) .withSmartNotifications() .withServerSentEventsEnabled() - .build(fakeClient); + .start(fakeClient); await().atMost(2, SECONDS).until(() -> webSocketServer.getConnections().size() == 1); @@ -315,7 +315,7 @@ void it_should_send_sonarqube_notification(SonarLintTestHarness harness) { storage -> storage.withProject(PROJECT_KEY, project -> project.withLastSmartNotificationPoll(STORED_DATE))) .withBoundConfigScope("scopeId", CONNECTION_ID, PROJECT_KEY) .withSmartNotifications() - .build(fakeClient); + .start(fakeClient); await().atMost(3, SECONDS).until(() -> !fakeClient.getSmartNotificationsToShow().isEmpty()); diff --git a/medium-tests/src/test/java/mediumtest/synchronization/BranchSpecificSynchronizationMediumTests.java b/medium-tests/src/test/java/mediumtest/synchronization/BranchSpecificSynchronizationMediumTests.java index 7d475d158f..9347abbdfc 100644 --- a/medium-tests/src/test/java/mediumtest/synchronization/BranchSpecificSynchronizationMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/synchronization/BranchSpecificSynchronizationMediumTests.java @@ -38,7 +38,6 @@ import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.SECONDS; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; import static org.awaitility.Awaitility.waitAtMost; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.after; @@ -63,7 +62,7 @@ void it_should_automatically_synchronize_bound_projects_that_have_an_active_bran .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withFullSynchronization() - .build(client); + .start(client); waitAtMost(3, SECONDS).untilAsserted(() -> { assertThat(backend.getWorkDir()).isDirectoryContaining(path -> path.getFileName().toString().contains("xodus-issue-store")); @@ -92,7 +91,7 @@ void it_should_honor_binding_inheritance(SonarLintTestHarness harness) { var backend = harness.newBackend() .withSonarQubeConnection("connectionId", server) .withFullSynchronization() - .build(client); + .start(client); backend.getConfigurationService().didAddConfigurationScopes( new DidAddConfigurationScopesParams(List.of( @@ -130,7 +129,7 @@ void it_should_report_progress_to_the_client_when_synchronizing(SonarLintTestHar .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withBoundConfigScope("configScopeId2", "connectionId", "projectKey2") .withFullSynchronization() - .build(fakeClient); + .start(fakeClient); fakeClient.waitForSynchronization(); @@ -161,7 +160,7 @@ void it_should_not_report_progress_to_the_client_when_synchronizing_if_client_re .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withBoundConfigScope("configScopeId2", "connectionId", "projectKey2") .withFullSynchronization() - .build(fakeClient); + .start(fakeClient); fakeClient.waitForSynchronization(); waitAtMost(3, SECONDS).untilAsserted(() -> { @@ -182,7 +181,7 @@ void it_should_skip_second_consecutive_synchronization_for_the_same_server_proje .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withFullSynchronization() - .build(fakeClient); + .start(fakeClient); fakeClient.waitForSynchronization(); reset(fakeClient); diff --git a/medium-tests/src/test/java/mediumtest/synchronization/ConnectionSyncMediumTests.java b/medium-tests/src/test/java/mediumtest/synchronization/ConnectionSyncMediumTests.java index 926fc5f479..c9ae816ffc 100644 --- a/medium-tests/src/test/java/mediumtest/synchronization/ConnectionSyncMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/synchronization/ConnectionSyncMediumTests.java @@ -60,7 +60,7 @@ void it_should_cache_extracted_rule_metadata_per_connection(SonarLintTestHarness .withSonarQubeConnection(CONNECTION_ID, server, storage -> storage.withPlugin(TestPlugin.JAVA)) .withBoundConfigScope(SCOPE_ID, CONNECTION_ID, "projectKey") .withEnabledLanguageInStandaloneMode(JAVA) - .build(client); + .start(client); await().untilAsserted(() -> assertThat(client.getLogMessages()).contains("Binding suggestion computation queued for config scopes 'scopeId'...")); assertThat(client.getLogMessages()).doesNotContain("Extracting rules metadata for connection 'connectionId'"); @@ -87,7 +87,7 @@ void it_should_evict_cache_when_connection_is_removed(SonarLintTestHarness harne .withSonarQubeConnection(CONNECTION_ID, server, storage -> storage.withPlugin(TestPlugin.JAVA)) .withBoundConfigScope(SCOPE_ID, CONNECTION_ID, "projectKey") .withEnabledLanguageInStandaloneMode(JAVA) - .build(client); + .start(client); await().untilAsserted(() -> assertThat(client.getLogMessages()).contains("Binding suggestion computation queued for config scopes 'scopeId'...")); getEffectiveRuleDetails(backend, SCOPE_ID, "java:S106"); @@ -119,7 +119,7 @@ void it_should_sync_when_credentials_are_updated(SonarLintTestHarness harness) { .withEnabledLanguageInStandaloneMode(JAVA) .withProjectSynchronization() .withFullSynchronization() - .build(client); + .start(client); await().untilAsserted(() -> assertThat(client.getLogMessages()).contains("Error while checking if soon unsupported")); server.registerSystemApiResponses(); @@ -150,7 +150,7 @@ void it_should_notify_client_if_invalid_token() { .withEnabledLanguageInStandaloneMode(JAVA) .withProjectSynchronization() .withFullSynchronization() - .build(client); + .start(client); await().untilAsserted(() -> assertThat(client.getLogMessages()).contains("Error during synchronization")); backend.getConnectionService().didChangeCredentials(new DidChangeCredentialsParams(CONNECTION_ID)); diff --git a/medium-tests/src/test/java/mediumtest/synchronization/PluginSynchronizationMediumTests.java b/medium-tests/src/test/java/mediumtest/synchronization/PluginSynchronizationMediumTests.java index d719f78223..10fa8bc592 100644 --- a/medium-tests/src/test/java/mediumtest/synchronization/PluginSynchronizationMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/synchronization/PluginSynchronizationMediumTests.java @@ -61,7 +61,7 @@ void it_should_pull_plugins_at_startup_from_the_server(SonarLintTestHarness harn .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withFullSynchronization() - .build(); + .start(); waitAtMost(20, SECONDS).untilAsserted(() -> { assertThat(getPluginsStorageFolder(backend)).isDirectoryContaining(path -> path.getFileName().toString().equals("sonar-java-plugin-7.16.0.30901.jar")); @@ -86,7 +86,7 @@ void it_should_not_pull_plugins_if_server_is_down(SonarLintTestHarness harness) .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withFullSynchronization() - .build(client); + .start(client); waitAtMost(3, SECONDS).untilAsserted(() -> { assertThat(getPluginsStorageFolder(backend)).doesNotExist(); @@ -106,7 +106,7 @@ void it_should_not_pull_already_pulled_plugin(SonarLintTestHarness harness) { .withSonarQubeConnection("connectionId", server, storage -> storage.withPlugin(TestPlugin.JAVA)) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withFullSynchronization() - .build(client); + .start(client); waitAtMost(3, SECONDS).untilAsserted(() -> { assertThat(getPluginsStorageFolder(backend)).isDirectoryContaining(path -> path.getFileName().toString().equals("sonar-java-plugin-7.16.0.30901.jar")); @@ -131,7 +131,7 @@ void it_should_pull_a_plugin_if_already_pulled_but_hash_is_different(SonarLintTe .withSonarQubeConnection("connectionId", server, storage -> storage.withPlugin(TestPlugin.JAVA.getPluginKey(), TestPlugin.JAVA.getPath(), "differentHash")) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withFullSynchronization() - .build(client); + .start(client); waitAtMost(3, SECONDS).untilAsserted(() -> assertThat(getPluginReferencesFilePath(backend)) .exists() @@ -152,7 +152,7 @@ void it_should_not_pull_plugins_that_do_not_support_sonarlint(SonarLintTestHarne .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withFullSynchronization() - .build(client); + .start(client); waitAtMost(3, SECONDS).untilAsserted(() -> { File[] files = getPluginsStorageFolder(backend).toFile().listFiles(); @@ -174,7 +174,7 @@ void it_should_not_pull_embedded_plugins(SonarLintTestHarness harness) { .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withFullSynchronization() - .build(client); + .start(client); waitAtMost(3, SECONDS).untilAsserted(() -> { File[] files = getPluginsStorageFolder(backend).toFile().listFiles(); @@ -195,7 +195,7 @@ void it_should_not_pull_plugins_for_not_enabled_languages(SonarLintTestHarness h .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withFullSynchronization() - .build(client); + .start(client); waitAtMost(3, SECONDS).untilAsserted(() -> { File[] files = getPluginsStorageFolder(backend).toFile().listFiles(); @@ -216,7 +216,7 @@ void it_should_pull_third_party_plugins_for_custom_rules(SonarLintTestHarness ha .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withFullSynchronization() - .build(client); + .start(client); waitAtMost(3, SECONDS).untilAsserted(() -> { assertThat(getPluginsStorageFolder(backend)).isDirectoryContaining(path -> path.getFileName().toString().equals("java-custom-plugin-4.3.0.1456.jar")); @@ -241,7 +241,7 @@ void it_should_pull_the_old_typescript_plugin_if_language_enabled(SonarLintTestH .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withFullSynchronization() - .build(client); + .start(client); waitAtMost(3, SECONDS).untilAsserted(() -> { assertThat(getPluginsStorageFolder(backend)).isDirectoryContaining(path -> path.getFileName().toString().equals("sonar-typescript-plugin-1.9.0.3766.jar")); @@ -265,7 +265,7 @@ void it_should_not_pull_the_old_typescript_plugin_if_language_not_enabled(SonarL .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withFullSynchronization() - .build(client); + .start(client); waitAtMost(3, SECONDS).untilAsserted(() -> { File[] files = getPluginsStorageFolder(backend).toFile().listFiles(); @@ -287,7 +287,7 @@ void it_should_clean_up_plugins_that_are_no_longer_relevant(SonarLintTestHarness .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withEnabledLanguageInStandaloneMode(Language.PHP) .withFullSynchronization() - .build(client); + .start(client); waitAtMost(3, SECONDS).untilAsserted(() -> { assertThat(getPluginsStorageFolder(backend).toFile().listFiles()) diff --git a/medium-tests/src/test/java/mediumtest/synchronization/RuleSetSynchronizationMediumTests.java b/medium-tests/src/test/java/mediumtest/synchronization/RuleSetSynchronizationMediumTests.java index 2d7ac0fdf0..fa260da3ac 100644 --- a/medium-tests/src/test/java/mediumtest/synchronization/RuleSetSynchronizationMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/synchronization/RuleSetSynchronizationMediumTests.java @@ -54,7 +54,7 @@ void it_should_pull_active_ruleset_from_server(SonarLintTestHarness harness) { .withEnabledLanguageInStandaloneMode(Language.JAVA) .withSonarQubeConnection("connectionId", server) .withFullSynchronization() - .build(); + .start(); addConfigurationScope(backend, "configScopeId", "connectionId", "projectKey"); @@ -79,7 +79,7 @@ void it_should_not_pull_when_server_is_down(SonarLintTestHarness harness) { .withEnabledLanguageInStandaloneMode(Language.JAVA) .withSonarQubeConnection("connectionId", server) .withFullSynchronization() - .build(client); + .start(client); addConfigurationScope(backend, "configScopeId", "connectionId", "projectKey"); diff --git a/medium-tests/src/test/java/mediumtest/synchronization/ServerInfoSynchronizationMediumTests.java b/medium-tests/src/test/java/mediumtest/synchronization/ServerInfoSynchronizationMediumTests.java index fd46595765..0b57c27842 100644 --- a/medium-tests/src/test/java/mediumtest/synchronization/ServerInfoSynchronizationMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/synchronization/ServerInfoSynchronizationMediumTests.java @@ -49,7 +49,7 @@ void it_should_pull_server_info_when_bound_configuration_scope_is_added(SonarLin .withEnabledLanguageInStandaloneMode(Language.JAVA) .withSonarQubeConnection("connectionId", server) .withFullSynchronization() - .build(); + .start(); addConfigurationScope(backend, "configScopeId", "connectionId", "projectKey"); @@ -68,7 +68,7 @@ void it_should_pull_old_server_info_and_mode_should_be_missing(SonarLintTestHarn .withEnabledLanguageInStandaloneMode(Language.JAVA) .withSonarQubeConnection("connectionId", server) .withFullSynchronization() - .build(); + .start(); addConfigurationScope(backend, "configScopeId", "connectionId", "projectKey"); @@ -84,7 +84,7 @@ void it_should_synchronize_with_sonarcloud_and_mode_should_be_missing(SonarLintT .withEnabledLanguageInStandaloneMode(Language.JAVA) .withSonarCloudConnection("connectionId", "test") .withFullSynchronization() - .build(); + .start(); addConfigurationScope(backend, "configScopeId", "connectionId", "projectKey"); @@ -103,7 +103,7 @@ void it_should_synchronize_with_recent_sonarqube_and_return_mode(SonarLintTestHa .withEnabledLanguageInStandaloneMode(Language.JAVA) .withSonarQubeConnection("connectionId", server) .withFullSynchronization() - .build(); + .start(); addConfigurationScope(backend, "configScopeId", "connectionId", "projectKey"); @@ -124,7 +124,7 @@ void it_should_stop_synchronization_if_server_is_down(SonarLintTestHarness harne .withEnabledLanguageInStandaloneMode(Language.JAVA) .withSonarQubeConnection("connectionId", server) .withFullSynchronization() - .build(client); + .start(client); addConfigurationScope(backend, "configScopeId", "connectionId", "projectKey"); @@ -144,7 +144,7 @@ void it_should_stop_synchronization_if_server_version_is_unsupported(SonarLintTe .withEnabledLanguageInStandaloneMode(Language.JAVA) .withSonarQubeConnection("connectionId", server) .withFullSynchronization() - .build(client); + .start(client); addConfigurationScope(backend, "configScopeId", "connectionId", "projectKey"); diff --git a/medium-tests/src/test/java/mediumtest/synchronization/TaintVulnerabilitySynchronizationMediumTests.java b/medium-tests/src/test/java/mediumtest/synchronization/TaintVulnerabilitySynchronizationMediumTests.java index 794f8d69b5..fd0d29daf8 100644 --- a/medium-tests/src/test/java/mediumtest/synchronization/TaintVulnerabilitySynchronizationMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/synchronization/TaintVulnerabilitySynchronizationMediumTests.java @@ -61,7 +61,7 @@ void it_should_incrementally_pull_taint_vulnerabilities_when_connected_to_sonarq .withEnabledLanguageInStandaloneMode(Language.JAVA) .withSonarQubeConnection("connectionId", server) .withFullSynchronization() - .build(); + .start(); addConfigurationScope(backend, "configScopeId", "connectionId", "projectKey"); diff --git a/medium-tests/src/test/java/mediumtest/taint/vulnerabilities/TaintVulnerabilitiesMediumTests.java b/medium-tests/src/test/java/mediumtest/taint/vulnerabilities/TaintVulnerabilitiesMediumTests.java index a9576c87d4..56ab5a4220 100644 --- a/medium-tests/src/test/java/mediumtest/taint/vulnerabilities/TaintVulnerabilitiesMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/taint/vulnerabilities/TaintVulnerabilitiesMediumTests.java @@ -47,7 +47,7 @@ class TaintVulnerabilitiesMediumTests { @SonarLintTest void it_should_return_no_taint_vulnerabilities_if_the_scope_is_not_bound(SonarLintTestHarness harness) { var backend = harness.newBackend() - .build(); + .start(); var taintVulnerabilities = listAllTaintVulnerabilities(backend, "configScopeId"); @@ -59,7 +59,7 @@ void it_should_return_no_taint_vulnerabilities_if_the_storage_is_empty(SonarLint var backend = harness.newBackend() .withSonarQubeConnection("connectionId") .withBoundConfigScope("configScopeId", "connectionId", "projectKey") - .build(); + .start(); var taintVulnerabilities = listAllTaintVulnerabilities(backend, "configScopeId"); @@ -82,7 +82,7 @@ void it_should_return_the_stored_taint_vulnerabilities(SonarLintTestHarness harn .withIntroductionDate(introductionDate))))) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withFullSynchronization() - .build(); + .start(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(listAllTaintVulnerabilities(backend, "configScopeId")) .extracting(TaintVulnerabilityDto::getIntroductionDate) @@ -114,7 +114,7 @@ void it_should_return_taint_details(SonarLintTestHarness harness) { branch -> branch.withTaintIssue(fakeTaintBuilder)))) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withFullSynchronization() - .build(client); + .start(client); client.waitForSynchronization(); @@ -147,7 +147,7 @@ void it_should_refresh_taint_vulnerabilities_when_requested(SonarLintTestHarness project -> project.withMainBranch("main"))) .withBoundConfigScope("configScopeId", "connectionId", "projectKey") .withFullSynchronization() - .build(); + .start(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(listAllTaintVulnerabilities(backend, "configScopeId")).isNotEmpty()); // switch server to simulate a new dataset. Not ideal, should be handled differently backend.getConnectionService() diff --git a/medium-tests/src/test/java/mediumtest/taint/vulnerabilities/TaintVulnerabilityEventsMediumTests.java b/medium-tests/src/test/java/mediumtest/taint/vulnerabilities/TaintVulnerabilityEventsMediumTests.java index 0c544d2759..c60f3c6a45 100644 --- a/medium-tests/src/test/java/mediumtest/taint/vulnerabilities/TaintVulnerabilityEventsMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/taint/vulnerabilities/TaintVulnerabilityEventsMediumTests.java @@ -143,7 +143,7 @@ void it_should_store_taint_vulnerability_in_storage(SonarLintTestHarness harness .withServerSentEventsEnabled() .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readTaintVulnerabilities(backend, "connectionId", "projectKey", "branchName")) @@ -166,7 +166,7 @@ void it_should_notify_client(SonarLintTestHarness harness) { .withSonarQubeConnection("connectionId", server) .withBoundConfigScope("configScope", "connectionId", "projectKey") .withFullSynchronization() - .build(client); + .start(client); // Wait for synchronization so that the local storage has the correct severity mode client.waitForSynchronization(); sseServer.shouldSendServerEventOnce(); @@ -215,7 +215,7 @@ void it_should_update_taint_vulnerability_in_storage_with_new_resolution(SonarLi .withSonarQubeConnection("connectionId", server, storage -> storage.withProject("projectKey", project -> project.withMainBranch("branchName", branch -> branch.withTaintIssue(aServerTaintIssue("key1").open())))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readTaintVulnerabilities(backend, "connectionId", "projectKey", "branchName")) @@ -247,7 +247,7 @@ void it_should_update_taint_vulnerability_in_storage_with_new_severity(SonarLint storage -> storage.withProject("projectKey", project -> project.withMainBranch("branchName", branch -> branch.withTaintIssue(aServerTaintIssue("key1").withSeverity(IssueSeverity.INFO))))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readTaintVulnerabilities(backend, "connectionId", "projectKey", "branchName")) @@ -279,7 +279,7 @@ void it_should_update_taint_vulnerability_in_storage_with_new_type(SonarLintTest storage -> storage.withProject("projectKey", project -> project.withMainBranch("branchName", branch -> branch.withTaintIssue(aServerTaintIssue("key1").withType(RuleType.VULNERABILITY))))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readTaintVulnerabilities(backend, "connectionId", "projectKey", "branchName")) @@ -314,7 +314,7 @@ void it_should_notify_client(SonarLintTestHarness harness) { branch -> branch.withTaintIssue(aServerTaintIssue("key1").withIntroductionDate(introductionDate).withSeverity(IssueSeverity.MINOR))))) .withBoundConfigScope("configScope", "connectionId", "projectKey") .withFullSynchronization() - .build(client); + .start(client); // Wait for synchronization so that the local storage has the correct severity mode client.waitForSynchronization(); var storedTaintIssues = await().atMost(Duration.ofSeconds(2)).until(() -> readTaintVulnerabilities(backend, "connectionId", "projectKey", "branchName"), @@ -354,7 +354,7 @@ void it_should_remove_taint_vulnerability_from_storage(SonarLintTestHarness harn storage -> storage.withProject("projectKey", project -> project.withMainBranch("branchName", branch -> branch.withTaintIssue(aServerTaintIssue("key1").withType(RuleType.VULNERABILITY))))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); sseServer.shouldSendServerEventOnce(); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(readTaintVulnerabilities(backend, "connectionId", "projectKey", "branchName")) @@ -381,7 +381,7 @@ void it_should_notify_client(SonarLintTestHarness harness) { storage -> storage.withProject("projectKey", project -> project.withMainBranch("branchName", branch -> branch.withTaintIssue(aServerTaintIssue("key1").withType(RuleType.VULNERABILITY))))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); var storedTaintIssues = await().atMost(Duration.ofSeconds(2)).until(() -> readTaintVulnerabilities(backend, "connectionId", "projectKey", "branchName"), taints -> taints.size() == 1); sseServer.shouldSendServerEventOnce(); @@ -417,7 +417,7 @@ void it_should_notify_client(SonarLintTestHarness harness) { branch -> branch.withTaintIssue(aServerTaintIssue("key1").withIntroductionDate(introductionDate).withType(RuleType.VULNERABILITY))))) .withBoundConfigScope("configScope", "connectionId", "projectKey") .withFullSynchronization() - .build(client); + .start(client); // Wait for synchronization so that the local storage has the correct severity mode client.waitForSynchronization(); var storedTaintIssues = await().atMost(Duration.ofSeconds(2)).until(() -> readTaintVulnerabilities(backend, "connectionId", "projectKey", "branchName"), @@ -459,7 +459,7 @@ void it_should_notify_client_with_correct_mqr_severity_mode(SonarLintTestHarness branch -> branch.withTaintIssue(aServerTaintIssue("key1").withIntroductionDate(introductionDate).withType(RuleType.VULNERABILITY))))) .withBoundConfigScope("configScope", "connectionId", "projectKey") .withFullSynchronization() - .build(client); + .start(client); // Wait for synchronization so that the local storage has the correct severity mode client.waitForSynchronization(); var storedTaintIssues = await().atMost(Duration.ofSeconds(2)).until(() -> readTaintVulnerabilities(backend, "connectionId", "projectKey", "branchName"), diff --git a/medium-tests/src/test/java/mediumtest/tracking/IssueTrackingMediumTests.java b/medium-tests/src/test/java/mediumtest/tracking/IssueTrackingMediumTests.java index 291bad978b..c6295442ee 100644 --- a/medium-tests/src/test/java/mediumtest/tracking/IssueTrackingMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/tracking/IssueTrackingMediumTests.java @@ -109,7 +109,7 @@ void it_should_raise_tracked_and_untracked_issues_in_standalone_mode(SonarLintTe .withMainBranch(branchName))) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) .withUnboundConfigScope(CONFIG_SCOPE_ID) - .build(client); + .start(client); var firstAnalysisPublishedIssues = analyzeFileAndGetAllIssuesOfRule(backend, fileUri, client, ruleKey); @@ -158,7 +158,7 @@ void it_should_raise_tracked_and_untracked_issues_after_match_with_server_issues project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule(ruleKey, "MINOR")) .withMainBranch(branchName))) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getConfigurationService() .didAddConfigurationScopes(new DidAddConfigurationScopesParams(List.of( @@ -218,7 +218,7 @@ void it_should_use_server_new_code_definition_for_server_issues_and_set_true_for .withMainBranch(branchName))) .withFullSynchronization() .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getConfigurationService() .didAddConfigurationScopes(new DidAddConfigurationScopesParams(List.of( @@ -258,7 +258,7 @@ void it_should_use_git_blame_to_set_introduction_date_for_git_repos(SonarLintTes var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); var issue = analyzeFileAndGetIssue(backend, client, fileUri); @@ -285,7 +285,7 @@ void it_should_use_git_blame_to_set_introduction_date_for_git_repos_for_given_co var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); Instant analysisTime = Instant.now(); var issues = analyzeFileAndGetAllIssues(backend, fileUri, client); @@ -333,7 +333,7 @@ void it_should_track_issue_secondary_locations(SonarLintTestHarness harness, @Te project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule(ruleKey, "MINOR")) .withMainBranch(branchName))) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getConfigurationService() .didAddConfigurationScopes(new DidAddConfigurationScopesParams(List.of( @@ -406,7 +406,7 @@ void it_should_track_line_level_server_issue_on_same_line(SonarLintTestHarness h project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule(ruleKey, "MINOR")) .withMainBranch(branchName))) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getConfigurationService() .didAddConfigurationScopes(new DidAddConfigurationScopesParams(List.of( @@ -453,7 +453,7 @@ void it_should_track_line_level_server_issue_on_different_line(SonarLintTestHarn project -> project.withRuleSet("java", ruleSet -> ruleSet.withActiveRule(ruleKey, "MINOR")) .withMainBranch(branchName))) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getConfigurationService() .didAddConfigurationScopes(new DidAddConfigurationScopesParams(List.of( @@ -479,7 +479,7 @@ void it_should_track_file_level_issue(SonarLintTestHarness harness, @TempDir Pat var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); var firstPublishedIssue = analyzeFileAndGetIssue(backend, client, fileUri); @@ -511,7 +511,7 @@ void it_should_test_quick_fixes(SonarLintTestHarness harness, @TempDir Path base var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); var issues = analyzeFileAndGetAllIssues(backend, fileUri, client); @@ -545,7 +545,7 @@ void it_should_start_tracking_an_issue_in_standalone_mode_when_detected_for_the_ var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); var startTime = System.currentTimeMillis(); var publishedIssue = analyzeFileAndGetIssue(backend, client, fileUri); @@ -565,7 +565,7 @@ void it_should_match_an_already_tracked_issue_in_standalone_mode_when_detected_f var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); var firstPublishedIssue = analyzeFileAndGetIssue(backend, client, fileUri); @@ -589,7 +589,7 @@ void it_should_start_tracking_an_issue_in_connected_mode_when_detected_for_the_f storage -> storage.withPlugin(TestPlugin.XML).withProject("projectKey", project -> project.withRuleSet("xml", ruleSet -> ruleSet.withActiveRule("xml:S3421", "MINOR")))) .withBoundConfigScope(CONFIG_SCOPE_ID, "connectionId", "projectKey") .withExtraEnabledLanguagesInConnectedMode(Language.XML) - .build(client); + .start(client); var startTime = System.currentTimeMillis(); var publishedIssue = analyzeFileAndGetIssue(backend, client, fileUri); @@ -612,7 +612,7 @@ void it_should_match_an_already_tracked_issue_in_connected_mode_when_detected_fo storage -> storage.withPlugin(TestPlugin.XML).withProject("projectKey", project -> project.withRuleSet("xml", ruleSet -> ruleSet.withActiveRule("xml:S3421", "MINOR")))) .withBoundConfigScope(CONFIG_SCOPE_ID, "connectionId", "projectKey") .withExtraEnabledLanguagesInConnectedMode(Language.XML) - .build(client); + .start(client); var firstPublishedIssue = analyzeFileAndGetIssue(backend, client, fileUri); @@ -646,7 +646,7 @@ void it_should_match_a_local_issue_with_a_server_issue_in_connected_mode_when_de .withIntroductionDate(serverIssueIntroductionDate))))) .withBoundConfigScope(CONFIG_SCOPE_ID, "connectionId", "projectKey") .withExtraEnabledLanguagesInConnectedMode(Language.XML) - .build(client); + .start(client); var publishedIssue = analyzeFileAndGetIssue(backend, client, fileUri); @@ -681,7 +681,7 @@ void it_should_match_a_previously_tracked_issue_with_a_server_issue_when_binding .withIntroductionDate(serverIssueIntroductionDate))))) .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); var firstPublishedIssue = analyzeFileAndGetIssue(backend, client, fileUri); @@ -741,7 +741,7 @@ void it_should_submit_server_path_to_sc_web_api(SonarLintTestHarness harness, @T .withSonarCloudUrl(server.baseUrl()) .withBoundConfigScope(CONFIG_SCOPE_ID, connectionId, projectKey) .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.XML) - .build(client); + .start(client); backend.getConfigurationService().didUpdateBinding(new DidUpdateBindingParams(CONFIG_SCOPE_ID, new BindingConfigurationDto(connectionId, projectKey, true))); @@ -774,7 +774,7 @@ void it_should_stream_issues(SonarLintTestHarness harness, @TempDir Path baseDir .withStandaloneEmbeddedPlugin(pluginPath) .withEnabledLanguageInStandaloneMode(Language.JAVA) .withUnboundConfigScope(CONFIG_SCOPE_ID) - .build(client); + .start(client); analyzeFileAndGetAllIssues(backend, fileUri, client); @@ -816,7 +816,7 @@ void it_should_stream_issues_on_two_analyses_in_a_row(SonarLintTestHarness harne .withStandaloneEmbeddedPlugin(pluginPath) .withEnabledLanguageInStandaloneMode(Language.JAVA) .withUnboundConfigScope(CONFIG_SCOPE_ID) - .build(client); + .start(client); analyzeFileAndGetAllIssues(backend, fileUri, client); reset(client); @@ -855,7 +855,7 @@ void it_should_include_a_file_without_issues_when_raising_issues(SonarLintTestHa .withStandaloneEmbeddedPlugin(pluginPath) .withEnabledLanguageInStandaloneMode(Language.JAVA) .withUnboundConfigScope(CONFIG_SCOPE_ID) - .build(client); + .start(client); backend.getAnalysisService().analyzeFilesAndTrack( new AnalyzeFilesAndTrackParams(CONFIG_SCOPE_ID, UUID.randomUUID(), List.of(fileUri), Map.of(), true, System.currentTimeMillis())) .join(); diff --git a/medium-tests/src/test/java/mediumtest/tracking/SecurityHotspotTrackingMediumTests.java b/medium-tests/src/test/java/mediumtest/tracking/SecurityHotspotTrackingMediumTests.java index 7aab538f6d..7229b8d648 100644 --- a/medium-tests/src/test/java/mediumtest/tracking/SecurityHotspotTrackingMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/tracking/SecurityHotspotTrackingMediumTests.java @@ -101,7 +101,7 @@ void it_should_track_server_hotspot(SonarLintTestHarness harness, @TempDir Path .withMainBranch(branchName))) .withSecurityHotspotsEnabled() .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getConfigurationService() .didAddConfigurationScopes(new DidAddConfigurationScopesParams(List.of( new ConfigurationScopeDto(CONFIG_SCOPE_ID, null, true, CONFIG_SCOPE_ID, @@ -159,7 +159,7 @@ void it_should_track_known_server_hotspots(SonarLintTestHarness harness, @TempDi .withMainBranch(branchName))) .withSecurityHotspotsEnabled() .withConnectedEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); backend.getConfigurationService() .didAddConfigurationScopes(new DidAddConfigurationScopesParams(List.of( new ConfigurationScopeDto(CONFIG_SCOPE_ID, null, true, CONFIG_SCOPE_ID, @@ -205,7 +205,7 @@ void it_should_not_track_server_hotspots_in_standalone_mode(SonarLintTestHarness .withSecurityHotspotsEnabled() .withUnboundConfigScope(CONFIG_SCOPE_ID) .withStandaloneEmbeddedPluginAndEnabledLanguage(TestPlugin.JAVA) - .build(client); + .start(client); analyzeFileAndAssertNoHotspotsRaised(backend, fileUri, client); } diff --git a/medium-tests/src/test/java/mediumtest/websockets/WebSocketMediumTests.java b/medium-tests/src/test/java/mediumtest/websockets/WebSocketMediumTests.java index 28779e1c57..f47ea8f67a 100644 --- a/medium-tests/src/test/java/mediumtest/websockets/WebSocketMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/websockets/WebSocketMediumTests.java @@ -86,7 +86,7 @@ void should_create_connection_and_subscribe_to_events(SonarLintTestHarness harne var backend = newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withUnboundConfigScope("configScope") - .build(client); + .start(client); bind(backend, "configScope", "connectionId", "projectKey"); @@ -101,7 +101,7 @@ void should_set_user_agent(SonarLintTestHarness harness) { var backend = newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withUnboundConfigScope("configScope") - .build(client); + .start(client); bind(backend, "configScope", "connectionId", "projectKey"); @@ -118,7 +118,7 @@ void should_not_create_websocket_connection_and_subscribe_when_bound_to_sonarqub var backend = newBackendWithWebSockets(harness) .withSonarQubeConnection("connectionId") .withUnboundConfigScope("configScope") - .build(client); + .start(client); bind(backend, "configScope", "connectionId", "projectKey"); @@ -133,7 +133,7 @@ void should_unsubscribe_from_old_project_and_subscribe_to_new_project_when_key_c var backend = newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); bind(backend, "configScope", "connectionId", "newProjectKey"); @@ -153,7 +153,7 @@ void should_unsubscribe_from_old_project_and_not_subscribe_to_new_project_if_it_ .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope1", "connectionId", "projectKey1") .withBoundConfigScope("configScope2", "connectionId", "projectKey2") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey2", "projectKey1"); bind(backend, "configScope1", "connectionId", "projectKey2"); @@ -172,7 +172,7 @@ void should_not_open_connection_or_subscribe_if_notifications_disabled_on_connec var backend = newBackendWithWebSockets(harness) .withSonarCloudConnection("connectionId", "orgKey", true, null) .withUnboundConfigScope("configScope") - .build(client); + .start(client); bind(backend, "configScope", "connectionId", "newProjectKey"); @@ -187,7 +187,7 @@ void should_not_resubscribe_if_project_already_bound(SonarLintTestHarness harnes var backend = newBackendWithWebSockets(harness) .withSonarCloudConnection("connectionId", "orgKey", true, null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); bind(backend, "configScope", "connectionId", "newProjectKey"); @@ -210,7 +210,7 @@ void should_unsubscribe_bound_project(SonarLintTestHarness harness) { var backend = newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); unbind(backend, "configScope"); @@ -232,7 +232,7 @@ void should_not_unsubscribe_if_the_same_project_key_is_used_in_another_binding(S .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope1", "connectionId", "projectKey") .withBoundConfigScope("configScope2", "connectionId", "projectKey") - .build(client); + .start(client); unbind(backend, "configScope1"); @@ -249,7 +249,7 @@ void should_not_unsubscribe_if_notifications_disabled_on_connection(SonarLintTes var backend = newBackendWithWebSockets(harness) .withSonarCloudConnection("connectionId", "orgKey", true, null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); unbind(backend, "configScope"); @@ -272,7 +272,7 @@ void should_subscribe_if_bound_to_sonarcloud(SonarLintTestHarness harness) { newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> { assertThat(webSocketServer.getConnections()) @@ -289,7 +289,7 @@ void should_not_subscribe_if_not_bound(SonarLintTestHarness harness) { newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withUnboundConfigScope("configScope") - .build(client); + .start(client); await().pollDelay(Duration.ofMillis(200)).atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(webSocketServer.getConnections()).isEmpty()); } @@ -302,7 +302,7 @@ void should_not_subscribe_if_bound_to_sonarqube(SonarLintTestHarness harness) { newBackendWithWebSockets(harness) .withSonarQubeConnection("connectionId") .withUnboundConfigScope("configScope") - .build(client); + .start(client); await().pollDelay(Duration.ofMillis(200)).atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(webSocketServer.getConnections()).isEmpty()); } @@ -315,7 +315,7 @@ void should_not_subscribe_if_bound_to_sonarcloud_but_notifications_are_disabled( newBackendWithWebSockets(harness) .withSonarCloudConnection("connectionId", "orgKey", true, null) .withUnboundConfigScope("configScope") - .build(client); + .start(client); await().pollDelay(Duration.ofMillis(200)).atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertThat(webSocketServer.getConnections()).isEmpty()); } @@ -331,7 +331,7 @@ void should_unsubscribe_from_project(SonarLintTestHarness harness) { var backend = newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); backend.getConfigurationService().didRemoveConfigurationScope(new DidRemoveConfigurationScopeParams("configScope")); @@ -355,7 +355,7 @@ void should_not_unsubscribe_if_another_scope_is_bound_to_same_project(SonarLintT .withSonarCloudConnectionAndNotifications("connectionId2", "orgKey2", null) .withBoundConfigScope("configScope1", "connectionId1", "projectKey") .withBoundConfigScope("configScope2", "connectionId2", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); backend.getConfigurationService().didRemoveConfigurationScope(new DidRemoveConfigurationScopeParams("configScope1")); @@ -373,7 +373,7 @@ void should_not_unsubscribe_if_connection_was_already_closed(SonarLintTestHarnes var backend = newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); backend.getConnectionService().didUpdateConnections(new DidUpdateConnectionsParams(emptyList(), List.of(new SonarCloudConnectionConfigurationDto("connectionId", "orgKey", true)))); @@ -395,7 +395,7 @@ void should_close_and_reopen_connection_for_sonarcloud_if_already_open(SonarLint var backend = newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); client.setToken("connectionId", "secondToken"); @@ -414,7 +414,7 @@ void should_do_nothing_for_sonarcloud_if_not_already_open(SonarLintTestHarness h .build(); var backend = newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) - .build(client); + .start(client); backend.getConnectionService().didChangeCredentials(new DidChangeCredentialsParams("connectionId")); @@ -429,7 +429,7 @@ void should_do_nothing_for_sonarqube(SonarLintTestHarness harness) { var backend = newBackendWithWebSockets(harness) .withSonarQubeConnection("connectionId") .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); backend.getConnectionService().didChangeCredentials(new DidChangeCredentialsParams("connectionId")); @@ -447,7 +447,7 @@ void should_subscribe_all_projects_bound_to_added_connection(SonarLintTestHarnes .build(); var backend = newBackendWithWebSockets(harness) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); backend.getConnectionService() .didUpdateConnections(new DidUpdateConnectionsParams(emptyList(), List.of(new SonarCloudConnectionConfigurationDto("connectionId", "orgKey", false)))); @@ -465,7 +465,7 @@ void should_log_failure_and_reconnect_later_if_server_unavailable(SonarLintTestH webSocketServer.stop(); var backend = newBackendWithWebSockets(harness) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); backend.getConnectionService() .didUpdateConnections(new DidUpdateConnectionsParams(emptyList(), List.of(new SonarCloudConnectionConfigurationDto("connectionId", "orgKey", false)))); @@ -492,7 +492,7 @@ void should_close_connection(SonarLintTestHarness harness) { var backend = newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); backend.getConnectionService().didUpdateConnections(new DidUpdateConnectionsParams(emptyList(), emptyList())); @@ -513,7 +513,7 @@ void should_not_close_connection_if_another_sonarcloud_connection_is_active(Sona .withSonarCloudConnectionAndNotifications("connectionId2", "orgKey2", null) .withBoundConfigScope("configScope1", "connectionId1", "projectKey1") .withBoundConfigScope("configScope2", "connectionId2", "projectKey2") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey2", "projectKey1"); backend.getConnectionService() @@ -536,7 +536,7 @@ void should_do_nothing_for_sonarqube(SonarLintTestHarness harness) { var backend = newBackendWithWebSockets(harness) .withSonarQubeConnection("connectionId") .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); backend.getConnectionService() .didUpdateConnections(new DidUpdateConnectionsParams(List.of(new SonarQubeConnectionConfigurationDto("connectionid", "url", @@ -552,7 +552,7 @@ void should_do_nothing_when_no_project_bound_to_sonarcloud(SonarLintTestHarness .build(); var backend = newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) - .build(client); + .start(client); backend.getConnectionService() .didUpdateConnections(new DidUpdateConnectionsParams(emptyList(), List.of(new SonarCloudConnectionConfigurationDto("connectionId", "orgKey2", false)))); @@ -568,7 +568,7 @@ void should_close_websocket_if_notifications_disabled(SonarLintTestHarness harne var backend = newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); backend.getConnectionService() @@ -590,7 +590,7 @@ void should_close_and_reopen_websocket_if_notifications_are_disabled_but_other_c .withSonarCloudConnectionAndNotifications("connectionId2", "orgKey2", null) .withBoundConfigScope("configScope1", "connectionId1", "projectKey1") .withBoundConfigScope("configScope2", "connectionId2", "projectKey2") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey2", "projectKey1"); backend.getConnectionService().didUpdateConnections(new DidUpdateConnectionsParams(emptyList(), @@ -611,7 +611,7 @@ void should_open_websocket_and_subscribe_to_all_bound_projects_if_enabled_notifi var backend = newBackendWithWebSockets(harness) .withSonarCloudConnection("connectionId", "orgKey", true, null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); backend.getConnectionService() .didUpdateConnections(new DidUpdateConnectionsParams(emptyList(), List.of(new SonarCloudConnectionConfigurationDto("connectionId", "orgKey", false)))); @@ -633,7 +633,7 @@ void should_forward_to_client_as_smart_notifications(SonarLintTestHarness harnes .withSmartNotifications() .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); webSocketServer.getConnections().get(0).sendMessage( @@ -656,7 +656,7 @@ void should_forward_my_new_issues_to_client_as_smart_notifications(SonarLintTest .withSmartNotifications() .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); webSocketServer.getConnections().get(0).sendMessage( @@ -679,7 +679,7 @@ void should_not_forward_to_client_if_the_event_data_is_malformed(SonarLintTestHa .withSmartNotifications() .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); webSocketServer.getConnections().get(0).sendMessage("{\"event\": [\"QualityGateChanged\"], \"data\": {\"message\": 0}}"); @@ -719,7 +719,7 @@ void should_not_forward_to_client(SonarLintTestHarness harness, String payload) .withSmartNotifications() .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); webSocketServer.getConnections().get(0).sendMessage(payload); @@ -741,7 +741,7 @@ void should_change_issue_status(SonarLintTestHarness harness) { .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", storage -> storage .withProject("projectKey", project -> project.withMainBranch("master", branch -> branch.withIssue(serverIssue)))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); var issueStorage = backend.getIssueStorageService().connection("connectionId").project("projectKey").findings(); @@ -776,7 +776,7 @@ void should_not_change_issue_if_the_event_data_is_malformed(SonarLintTestHarness .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", storage -> storage .withProject("projectKey", project -> project.withMainBranch("master", branch -> branch.withIssue(serverIssue)))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); var issueStorage = backend.getIssueStorageService().connection("connectionId").project("projectKey").findings(); @@ -811,7 +811,7 @@ void should_change_issue_if_the_issue_key_is_missing(SonarLintTestHarness harnes .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", storage -> storage .withProject("projectKey", project -> project.withMainBranch("master", branch -> branch.withIssue(serverIssue)))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); var issueStorage = backend.getIssueStorageService().connection("connectionId").project("projectKey").findings(); @@ -845,7 +845,7 @@ void should_not_change_issue_if_the_resolution_is_missing(SonarLintTestHarness h .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", storage -> storage .withProject("projectKey", project -> project.withMainBranch("master", branch -> branch.withIssue(serverIssue)))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); var issueStorage = backend.getIssueStorageService().connection("connectionId").project("projectKey").findings(); @@ -879,7 +879,7 @@ void should_not_change_issue_if_the_project_is_missing(SonarLintTestHarness harn .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", storage -> storage .withProject("projectKey", project -> project.withMainBranch("master", branch -> branch.withIssue(serverIssue)))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); var issueStorage = backend.getIssueStorageService().connection("connectionId").project("projectKey").findings(); @@ -914,7 +914,7 @@ void should_create_taint_vulnerability(SonarLintTestHarness harness) { .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", storage -> storage .withProject("projectKey")) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); var issueStorage = backend.getIssueStorageService().connection("connectionId").project("projectKey").findings(); @@ -984,7 +984,7 @@ void should_not_create_taint_vulnerability_event_data_is_malformed(SonarLintTest .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", storage -> storage .withProject("projectKey")) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); var issueStorage = backend.getIssueStorageService().connection("connectionId").project("projectKey").findings(); @@ -1059,7 +1059,7 @@ void should_remove_taint_vulnerability(SonarLintTestHarness harness) { .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", storage -> storage .withProject("projectKey", project -> project.withMainBranch(branch -> branch.withTaintIssue(serverTaintIssue)))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); var issueStorage = backend.getIssueStorageService().connection("connectionId").project("projectKey").findings(); @@ -1088,7 +1088,7 @@ void should_not_remove_taint_vulnerability_event_data_is_malformed(SonarLintTest .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", storage -> storage .withProject("projectKey", project -> project.withMainBranch(branch -> branch.withTaintIssue(serverTaintIssue)))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); var issueStorage = backend.getIssueStorageService().connection("connectionId").project("projectKey").findings(); @@ -1120,7 +1120,7 @@ void should_update_security_hotspot(SonarLintTestHarness harness) { .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", storage -> storage .withProject("projectKey", project -> project.withMainBranch(branch -> branch.withHotspot(serverHotspot)))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); var issueStorage = backend.getIssueStorageService().connection("connectionId").project("projectKey").findings(); @@ -1154,7 +1154,7 @@ void should_not_update_security_hotspot_if_event_data_is_malformed(SonarLintTest .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", storage -> storage .withProject("projectKey", project -> project.withMainBranch(branch -> branch.withHotspot(serverHotspot)))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); var issueStorage = backend.getIssueStorageService().connection("connectionId").project("projectKey").findings(); @@ -1189,7 +1189,7 @@ void should_create_new_security_hotspot(SonarLintTestHarness harness) { .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", storage -> storage .withProject("projectKey")) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); var issueStorage = backend.getIssueStorageService().connection("connectionId").project("projectKey").findings(); @@ -1231,7 +1231,7 @@ void should_not_create_security_hotspot_if_event_data_is_malformed(SonarLintTest .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", storage -> storage .withProject("projectKey")) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); var issueStorage = backend.getIssueStorageService().connection("connectionId").project("projectKey").findings(); @@ -1278,7 +1278,7 @@ void should_remove_security_hotspot(SonarLintTestHarness harness) { .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", storage -> storage .withProject("projectKey", project -> project.withMainBranch(branch -> branch.withHotspot(serverHotspot)))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); var issueStorage = backend.getIssueStorageService().connection("connectionId").project("projectKey").findings(); @@ -1308,7 +1308,7 @@ void should_not_remove_security_hotspot(SonarLintTestHarness harness) { .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", storage -> storage .withProject("projectKey", project -> project.withMainBranch(branch -> branch.withHotspot(serverHotspot)))) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); var issueStorage = backend.getIssueStorageService().connection("connectionId").project("projectKey").findings(); @@ -1338,7 +1338,7 @@ void should_ignore_if_the_event_type_is_unknown(SonarLintTestHarness harness) { newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); webSocketServer.getConnections().get(0).sendMessage("{\"event\": \"UnknownEvent\", \"data\": {\"message\": \"msg\"}}"); @@ -1354,7 +1354,7 @@ void should_ignore_if_the_event_is_malformed(SonarLintTestHarness harness) { newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); await().atMost(Duration.ofSeconds(2)).until(() -> !webSocketServer.getConnections().isEmpty()); webSocketServer.getConnections().get(0).sendMessage("{\"event\": \"Malformed"); @@ -1370,7 +1370,7 @@ void should_not_forward_to_client_duplicated_event(SonarLintTestHarness harness) newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); webSocketServer.getConnections().get(0).sendMessage( @@ -1398,7 +1398,7 @@ void should_refresh_connection_if_closed_by_server(SonarLintTestHarness harness) newBackendWithWebSockets(harness) .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); webSocketServer.getConnections().get(0).close(); @@ -1417,7 +1417,7 @@ void should_send_one_subscribe_message_per_project_key_when_reopening_connection .withSonarCloudConnectionAndNotifications("connectionId", "orgKey", null) .withBoundConfigScope("configScope", "connectionId", "projectKey") .withBoundConfigScope("configScope2", "connectionId", "projectKey") - .build(client); + .start(client); awaitUntilFirstWebSocketSubscribedTo("projectKey"); webSocketServer.getConnections().get(0).close(); diff --git a/test-utils/src/main/java/org/sonarsource/sonarlint/core/test/utils/SonarLintBackendFixture.java b/test-utils/src/main/java/org/sonarsource/sonarlint/core/test/utils/SonarLintBackendFixture.java index bbf7087114..43ec7bddc0 100644 --- a/test-utils/src/main/java/org/sonarsource/sonarlint/core/test/utils/SonarLintBackendFixture.java +++ b/test-utils/src/main/java/org/sonarsource/sonarlint/core/test/utils/SonarLintBackendFixture.java @@ -125,8 +125,8 @@ public static SonarLintBackendBuilder newBackend() { return newBackend(null); } - public static SonarLintBackendBuilder newBackend(@Nullable Consumer onBuild) { - return new SonarLintBackendBuilder(onBuild); + public static SonarLintBackendBuilder newBackend(@Nullable Consumer afterStartCallback) { + return new SonarLintBackendBuilder(afterStartCallback); } public static SonarLintClientBuilder newFakeClient() { @@ -134,7 +134,7 @@ public static SonarLintClientBuilder newFakeClient() { } public static class SonarLintBackendBuilder { - private final Consumer onBuild; + private final Consumer afterStartCallback; private final List sonarQubeConnections = new ArrayList<>(); private final List sonarCloudConnections = new ArrayList<>(); private final List configurationScopes = new ArrayList<>(); @@ -172,8 +172,8 @@ public static class SonarLintBackendBuilder { private TelemetryMigrationDto telemetryMigration; private LanguageSpecificRequirements languageSpecificRequirements; - public SonarLintBackendBuilder(@Nullable Consumer onBuild) { - this.onBuild = onBuild; + public SonarLintBackendBuilder(@Nullable Consumer afterStartCallback) { + this.afterStartCallback = afterStartCallback; } public SonarLintBackendBuilder withSonarQubeConnection() { @@ -470,7 +470,7 @@ public SonarLintBackendBuilder withTelemetryMigration(TelemetryMigrationDto tele return this; } - public SonarLintTestRpcServer build(SonarLintRpcClientDelegate client) { + public SonarLintTestRpcServer start(SonarLintRpcClientDelegate client) { var sonarlintUserHome = tempDirectory("slUserHome"); var workDir = tempDirectory("work"); var storageParentPath = tempDirectory("storage"); @@ -505,8 +505,8 @@ public SonarLintTestRpcServer build(SonarLintRpcClientDelegate client) { standaloneConfigByKey, isFocusOnNewCode, languageSpecificRequirements, automaticAnalysisEnabled, telemetryMigration)) .get(); sonarLintBackend.getConfigurationService().didAddConfigurationScopes(new DidAddConfigurationScopesParams(configurationScopes)); - if (onBuild != null) { - onBuild.accept(sonarLintBackend); + if (afterStartCallback != null) { + afterStartCallback.accept(sonarLintBackend); } return sonarLintBackend; } catch (Exception e) { @@ -570,8 +570,8 @@ private static Path tempDirectory(String prefix) { } } - public SonarLintTestRpcServer build() { - return build(newFakeClient().build()); + public SonarLintTestRpcServer start() { + return start(newFakeClient().build()); } } From 5091a96665c6131878f285ab0aafd1e84626c5c0 Mon Sep 17 00:00:00 2001 From: Damien Urruty Date: Wed, 22 Jan 2025 08:56:38 +0100 Subject: [PATCH 2/2] SLCORE-1134 Fix flaky tests Mockito throws random errors when methods are called on a spy at the same time it is being stubbed in another thread. To fix this, some tests were changed to stub before starting the backend. A trace was removed at the end of the backend creation to avoid using the spy --- .../core/rpc/impl/SonarLintRpcServerImpl.java | 2 -- .../hotspots/OpenHotspotInIdeMediumTests.java | 12 ++++--- .../OpenFixSuggestionInIdeMediumTests.java | 24 +++++++++----- .../issues/OpenIssueInIdeMediumTests.java | 31 +++++++++++++------ .../test/utils/SonarLintBackendFixture.java | 7 +++++ 5 files changed, 52 insertions(+), 24 deletions(-) diff --git a/backend/rpc-impl/src/main/java/org/sonarsource/sonarlint/core/rpc/impl/SonarLintRpcServerImpl.java b/backend/rpc-impl/src/main/java/org/sonarsource/sonarlint/core/rpc/impl/SonarLintRpcServerImpl.java index 14122feab5..46bcf670d3 100644 --- a/backend/rpc-impl/src/main/java/org/sonarsource/sonarlint/core/rpc/impl/SonarLintRpcServerImpl.java +++ b/backend/rpc-impl/src/main/java/org/sonarsource/sonarlint/core/rpc/impl/SonarLintRpcServerImpl.java @@ -121,8 +121,6 @@ public SonarLintRpcServerImpl(InputStream in, OutputStream out) { rootLogger.addAppender(rpcAppender); this.clientListener = launcher.startListening(); - - LOG.info("SonarLint backend started, instance={}", this); } private static PrintWriter getMessageTracer() { diff --git a/medium-tests/src/test/java/mediumtest/hotspots/OpenHotspotInIdeMediumTests.java b/medium-tests/src/test/java/mediumtest/hotspots/OpenHotspotInIdeMediumTests.java index 42a8684755..fd65d6aed5 100644 --- a/medium-tests/src/test/java/mediumtest/hotspots/OpenHotspotInIdeMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/hotspots/OpenHotspotInIdeMediumTests.java @@ -153,9 +153,11 @@ void it_should_assist_creating_the_connection_when_server_url_unknown(SonarLintT var backend = harness.newBackend() .withUnboundConfigScope(SCOPE_ID, SONAR_PROJECT_NAME) .withEmbeddedServer() + .beforeInitialize(createdBackend -> { + mockAssistCreatingConnection(createdBackend, fakeClient, serverWithHotspot, CONNECTION_ID); + mockAssistBinding(createdBackend, fakeClient, SCOPE_ID, CONNECTION_ID, PROJECT_KEY); + }) .start(fakeClient); - mockAssistCreatingConnection(backend, fakeClient, serverWithHotspot, CONNECTION_ID); - mockAssistBinding(backend, fakeClient, SCOPE_ID, CONNECTION_ID, PROJECT_KEY); var statusCode = requestGetOpenHotspotWithParams(backend, serverWithHotspot, "server=" + urlEncode(serverWithHotspot.baseUrl()) + "&project=projectKey&hotspot=key"); assertThat(statusCode).isEqualTo(200); @@ -178,9 +180,11 @@ void it_should_assist_creating_the_binding_if_scope_not_bound(SonarLintTestHarne .withSonarQubeConnection(CONNECTION_ID, serverWithHotspot) .withUnboundConfigScope(SCOPE_ID, SONAR_PROJECT_NAME) .withEmbeddedServer() + .beforeInitialize(createdBackend -> { + mockAssistCreatingConnection(createdBackend, fakeClient, serverWithHotspot, CONNECTION_ID); + mockAssistBinding(createdBackend, fakeClient, SCOPE_ID, CONNECTION_ID, PROJECT_KEY); + }) .start(fakeClient); - mockAssistCreatingConnection(backend, fakeClient, serverWithHotspot, CONNECTION_ID); - mockAssistBinding(backend, fakeClient, SCOPE_ID, CONNECTION_ID, PROJECT_KEY); var statusCode = requestGetOpenHotspotWithParams(backend, serverWithHotspot, "server=" + urlEncode(serverWithHotspot.baseUrl()) + "&project=projectKey&hotspot=key"); assertThat(statusCode).isEqualTo(200); diff --git a/medium-tests/src/test/java/mediumtest/issues/OpenFixSuggestionInIdeMediumTests.java b/medium-tests/src/test/java/mediumtest/issues/OpenFixSuggestionInIdeMediumTests.java index 52a3d3c1eb..e5849fb5a3 100644 --- a/medium-tests/src/test/java/mediumtest/issues/OpenFixSuggestionInIdeMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/issues/OpenFixSuggestionInIdeMediumTests.java @@ -167,9 +167,11 @@ void it_should_assist_creating_the_binding_if_scope_not_bound(SonarLintTestHarne .withUnboundConfigScope(CONFIG_SCOPE_ID, PROJECT_KEY) .withEmbeddedServer() .withOpenFixSuggestion() + .beforeInitialize(createdBackend -> { + mockAssistCreatingConnection(createdBackend, fakeClient, CONNECTION_ID); + mockAssistBinding(createdBackend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); + }) .start(fakeClient); - mockAssistCreatingConnection(backend, fakeClient, CONNECTION_ID); - mockAssistBinding(backend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); var statusCode = executeOpenFixSuggestionRequestWithoutToken(backend, scServer, FIX_PAYLOAD, ISSUE_KEY, PROJECT_KEY, BRANCH_NAME, ORG_KEY); assertThat(statusCode).isEqualTo(200); @@ -191,9 +193,11 @@ void it_should_not_assist_binding_if_multiple_suggestions(SonarLintTestHarness h .withUnboundConfigScope("configScopeB", PROJECT_KEY + " 2") .withEmbeddedServer() .withOpenFixSuggestion() + .beforeInitialize(createdBackend -> { + mockAssistCreatingConnection(createdBackend, fakeClient, CONNECTION_ID); + mockAssistBinding(createdBackend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); + }) .start(fakeClient); - mockAssistCreatingConnection(backend, fakeClient, CONNECTION_ID); - mockAssistBinding(backend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); var statusCode = executeOpenFixSuggestionRequestWithoutToken(backend, scServer, FIX_PAYLOAD, ISSUE_KEY, PROJECT_KEY, BRANCH_NAME, ORG_KEY); @@ -217,9 +221,11 @@ void it_should_assist_binding_if_multiple_suggestions_but_scopes_are_parent_and_ .withUnboundConfigScope("configScopeChild", PROJECT_KEY, "configScopeParent") .withEmbeddedServer() .withOpenFixSuggestion() + .beforeInitialize(createdBackend -> { + mockAssistCreatingConnection(createdBackend, fakeClient, CONNECTION_ID); + mockAssistBinding(createdBackend, fakeClient, "configScopeParent", CONNECTION_ID, PROJECT_KEY); + }) .start(fakeClient); - mockAssistCreatingConnection(backend, fakeClient, CONNECTION_ID); - mockAssistBinding(backend, fakeClient, "configScopeParent", CONNECTION_ID, PROJECT_KEY); var statusCode = executeOpenFixSuggestionRequestWithoutToken(backend, scServer, FIX_PAYLOAD, ISSUE_KEY, PROJECT_KEY, BRANCH_NAME, ORG_KEY); @@ -241,9 +247,11 @@ void it_should_assist_creating_the_connection_when_no_sc_connection(SonarLintTes .withUnboundConfigScope(CONFIG_SCOPE_ID, PROJECT_KEY) .withEmbeddedServer() .withOpenFixSuggestion() + .beforeInitialize(createdBackend -> { + mockAssistCreatingConnection(createdBackend, fakeClient, CONNECTION_ID); + mockAssistBinding(createdBackend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); + }) .start(fakeClient); - mockAssistCreatingConnection(backend, fakeClient, CONNECTION_ID); - mockAssistBinding(backend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); var statusCode = executeOpenFixSuggestionRequestWithToken(backend, scServer, FIX_PAYLOAD, ISSUE_KEY, PROJECT_KEY, BRANCH_NAME, ORG_KEY, "token-name", "token-value"); assertThat(statusCode).isEqualTo(200); diff --git a/medium-tests/src/test/java/mediumtest/issues/OpenIssueInIdeMediumTests.java b/medium-tests/src/test/java/mediumtest/issues/OpenIssueInIdeMediumTests.java index 8da4ae6d9f..2bdc569bd9 100644 --- a/medium-tests/src/test/java/mediumtest/issues/OpenIssueInIdeMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/issues/OpenIssueInIdeMediumTests.java @@ -215,9 +215,12 @@ void it_should_assist_creating_the_binding_if_scope_not_bound(SonarLintTestHarne .withSonarQubeConnection(CONNECTION_ID, fakeServerWithIssue) .withUnboundConfigScope(CONFIG_SCOPE_ID, SONAR_PROJECT_NAME) .withEmbeddedServer() + .beforeInitialize(createdBackend -> { + mockAssistCreatingConnection(createdBackend, fakeClient, fakeServerWithIssue, CONNECTION_ID); + mockAssistBinding(createdBackend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); + }) .start(fakeClient); - mockAssistCreatingConnection(backend, fakeClient, fakeServerWithIssue, CONNECTION_ID); - mockAssistBinding(backend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); + var statusCode = executeOpenIssueRequest(backend, fakeServerWithIssue, ISSUE_KEY, PROJECT_KEY, BRANCH_NAME); assertThat(statusCode).isEqualTo(200); @@ -236,9 +239,11 @@ void it_should_not_assist_binding_if_multiple_suggestions(SonarLintTestHarness h .withUnboundConfigScope("configScopeA", SONAR_PROJECT_NAME + " 1") .withUnboundConfigScope("configScopeB", SONAR_PROJECT_NAME + " 2") .withEmbeddedServer() + .beforeInitialize(createdBackend -> { + mockAssistCreatingConnection(createdBackend, fakeClient, fakeServerWithIssue, CONNECTION_ID); + mockAssistBinding(createdBackend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); + }) .start(fakeClient); - mockAssistCreatingConnection(backend, fakeClient, fakeServerWithIssue, CONNECTION_ID); - mockAssistBinding(backend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); var statusCode = executeOpenIssueRequest(backend, fakeServerWithIssue, ISSUE_KEY, PROJECT_KEY, BRANCH_NAME); @@ -258,9 +263,11 @@ void it_should_assist_binding_if_multiple_suggestions_but_scopes_are_parent_and_ .withUnboundConfigScope("configScopeParent", SONAR_PROJECT_NAME) .withUnboundConfigScope("configScopeChild", SONAR_PROJECT_NAME, "configScopeParent") .withEmbeddedServer() + .beforeInitialize(createdBackend -> { + mockAssistCreatingConnection(createdBackend, fakeClient, fakeServerWithIssue, CONNECTION_ID); + mockAssistBinding(createdBackend, fakeClient, "configScopeParent", CONNECTION_ID, PROJECT_KEY); + }) .start(fakeClient); - mockAssistCreatingConnection(backend, fakeClient, fakeServerWithIssue, CONNECTION_ID); - mockAssistBinding(backend, fakeClient, "configScopeParent", CONNECTION_ID, PROJECT_KEY); var statusCode = executeOpenIssueRequest(backend, fakeServerWithIssue, ISSUE_KEY, PROJECT_KEY, BRANCH_NAME); @@ -276,9 +283,11 @@ void it_should_assist_creating_the_connection_when_server_url_unknown(SonarLintT var backend = harness.newBackend() .withUnboundConfigScope(CONFIG_SCOPE_ID, SONAR_PROJECT_NAME) .withEmbeddedServer() + .beforeInitialize(createdBackend -> { + mockAssistCreatingConnection(createdBackend, fakeClient, fakeServerWithIssue, CONNECTION_ID); + mockAssistBinding(createdBackend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); + }) .start(fakeClient); - mockAssistCreatingConnection(backend, fakeClient, fakeServerWithIssue, CONNECTION_ID); - mockAssistBinding(backend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); var statusCode = executeOpenIssueRequest(backend, fakeServerWithIssue, ISSUE_KEY, PROJECT_KEY, BRANCH_NAME); assertThat(statusCode).isEqualTo(200); @@ -304,9 +313,11 @@ void it_should_assist_creating_the_connection_when_no_sc_connection(SonarLintTes .withSonarCloudUrl("https://sonar.my") .withUnboundConfigScope(CONFIG_SCOPE_ID, SONAR_PROJECT_NAME) .withEmbeddedServer() + .beforeInitialize(createdBackend -> { + mockAssistCreatingConnection(createdBackend, fakeClient, fakeServerWithIssue, CONNECTION_ID); + mockAssistBinding(createdBackend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); + }) .start(fakeClient); - mockAssistCreatingConnection(backend, fakeClient, fakeServerWithIssue, CONNECTION_ID); - mockAssistBinding(backend, fakeClient, CONFIG_SCOPE_ID, CONNECTION_ID, PROJECT_KEY); var statusCode = executeOpenSCIssueRequest(backend, ISSUE_KEY, PROJECT_KEY, BRANCH_NAME, "orgKey"); assertThat(statusCode).isEqualTo(200); diff --git a/test-utils/src/main/java/org/sonarsource/sonarlint/core/test/utils/SonarLintBackendFixture.java b/test-utils/src/main/java/org/sonarsource/sonarlint/core/test/utils/SonarLintBackendFixture.java index 43ec7bddc0..3dffda555b 100644 --- a/test-utils/src/main/java/org/sonarsource/sonarlint/core/test/utils/SonarLintBackendFixture.java +++ b/test-utils/src/main/java/org/sonarsource/sonarlint/core/test/utils/SonarLintBackendFixture.java @@ -171,6 +171,7 @@ public static class SonarLintBackendBuilder { private boolean automaticAnalysisEnabled = true; private TelemetryMigrationDto telemetryMigration; private LanguageSpecificRequirements languageSpecificRequirements; + private final List> beforeInitializeCallbacks = new ArrayList<>(); public SonarLintBackendBuilder(@Nullable Consumer afterStartCallback) { this.afterStartCallback = afterStartCallback; @@ -470,6 +471,11 @@ public SonarLintBackendBuilder withTelemetryMigration(TelemetryMigrationDto tele return this; } + public SonarLintBackendBuilder beforeInitialize(Consumer backendConsumer) { + this.beforeInitializeCallbacks.add(backendConsumer); + return this; + } + public SonarLintTestRpcServer start(SonarLintRpcClientDelegate client) { var sonarlintUserHome = tempDirectory("slUserHome"); var workDir = tempDirectory("work"); @@ -481,6 +487,7 @@ public SonarLintTestRpcServer start(SonarLintRpcClientDelegate client) { } try { var sonarLintBackend = createTestBackend(client); + beforeInitializeCallbacks.forEach(callback -> callback.accept(sonarLintBackend)); var telemetryInitDto = new TelemetryClientConstantAttributesDto("mediumTests", "mediumTests", "1.2.3", "4.5.6", emptyMap()); var clientInfo = new ClientConstantInfoDto(clientName, userAgent, 0);