From 4323099d64d3a9e3c63203dc8b4125d5ddf985c3 Mon Sep 17 00:00:00 2001 From: Serhat Yenican Date: Fri, 31 May 2024 11:22:17 +0200 Subject: [PATCH] SLCORE-828 rename field, method and types from connection to connectionParams --- .../RequestHandlerBindingAssistant.java | 2 +- .../server/ShowHotspotRequestHandler.java | 4 +-- .../server/ShowIssueRequestHandler.java | 8 ++--- .../issues/OpenIssueInIdeMediumTests.java | 6 ++-- ...ubeSonarCloudConnectionAdapterFactory.java | 10 +++---- .../AssistCreatingConnectionParams.java | 30 +++++++++---------- ...n.java => SonarCloudConnectionParams.java} | 4 +-- ...on.java => SonarQubeConnectionParams.java} | 4 +-- 8 files changed, 34 insertions(+), 34 deletions(-) rename rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/{AssistSonarCloudConnection.java => SonarCloudConnectionParams.java} (93%) rename rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/{AssistSonarQubeConnection.java => SonarQubeConnectionParams.java} (93%) diff --git a/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/RequestHandlerBindingAssistant.java b/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/RequestHandlerBindingAssistant.java index e6c4bd9ab0..cb10ea4055 100644 --- a/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/RequestHandlerBindingAssistant.java +++ b/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/RequestHandlerBindingAssistant.java @@ -110,7 +110,7 @@ private void assistConnectionAndBindingIfNeeded(AssistCreatingConnectionParams c } private String getServerUrl(AssistCreatingConnectionParams connectionParams) { - return connectionParams.getConnection().isLeft() ? connectionParams.getConnection().getLeft().getServerUrl() : sonarCloudUrl; + return connectionParams.getConnectionParams().isLeft() ? connectionParams.getConnectionParams().getLeft().getServerUrl() : sonarCloudUrl; } private AssistCreatingConnectionResponse assistCreatingConnectionAndWaitForRepositoryUpdate( diff --git a/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/ShowHotspotRequestHandler.java b/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/ShowHotspotRequestHandler.java index 625d73d92f..58cdb2fe91 100644 --- a/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/ShowHotspotRequestHandler.java +++ b/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/ShowHotspotRequestHandler.java @@ -42,7 +42,7 @@ import org.sonarsource.sonarlint.core.file.PathTranslationService; import org.sonarsource.sonarlint.core.rpc.protocol.SonarLintRpcClient; import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.AssistCreatingConnectionParams; -import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.AssistSonarQubeConnection; +import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.SonarQubeConnectionParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.hotspot.HotspotDetailsDto; import org.sonarsource.sonarlint.core.rpc.protocol.client.hotspot.ShowHotspotParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.message.MessageType; @@ -79,7 +79,7 @@ public void handle(ClassicHttpRequest request, ClassicHttpResponse response, Htt return; } telemetryService.showHotspotRequestReceived(); - var sonarQubeConnection = new AssistSonarQubeConnection(showHotspotQuery.serverUrl, null, null); + var sonarQubeConnection = new SonarQubeConnectionParams(showHotspotQuery.serverUrl, null, null); var connectionParams = new AssistCreatingConnectionParams(sonarQubeConnection); requestHandlerBindingAssistant.assistConnectionAndBindingIfNeededAsync(connectionParams, showHotspotQuery.projectKey, (connectionId, configScopeId, cancelMonitor) -> { diff --git a/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/ShowIssueRequestHandler.java b/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/ShowIssueRequestHandler.java index b4fb9c97e3..ba0e4d12dd 100644 --- a/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/ShowIssueRequestHandler.java +++ b/backend/core/src/main/java/org/sonarsource/sonarlint/core/embedded/server/ShowIssueRequestHandler.java @@ -48,8 +48,8 @@ import org.sonarsource.sonarlint.core.file.PathTranslationService; import org.sonarsource.sonarlint.core.rpc.protocol.SonarLintRpcClient; import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.AssistCreatingConnectionParams; -import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.AssistSonarCloudConnection; -import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.AssistSonarQubeConnection; +import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.SonarCloudConnectionParams; +import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.SonarQubeConnectionParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.issue.IssueDetailsDto; import org.sonarsource.sonarlint.core.rpc.protocol.client.issue.ShowIssueParams; import org.sonarsource.sonarlint.core.rpc.protocol.client.message.MessageType; @@ -116,8 +116,8 @@ private static AssistCreatingConnectionParams createAssistServerConnectionParams String tokenName = query.getTokenName(); String tokenValue = query.getTokenValue(); return query.isSonarCloud ? - new AssistCreatingConnectionParams(new AssistSonarCloudConnection(query.getOrganizationKey(), tokenName, tokenValue)) - : new AssistCreatingConnectionParams(new AssistSonarQubeConnection(query.getServerUrl(), tokenName, tokenValue)); + new AssistCreatingConnectionParams(new SonarCloudConnectionParams(query.getOrganizationKey(), tokenName, tokenValue)) + : new AssistCreatingConnectionParams(new SonarQubeConnectionParams(query.getServerUrl(), tokenName, tokenValue)); } private boolean isSonarCloud(ClassicHttpRequest request) throws ProtocolException { diff --git a/medium-tests/src/test/java/mediumtest/issues/OpenIssueInIdeMediumTests.java b/medium-tests/src/test/java/mediumtest/issues/OpenIssueInIdeMediumTests.java index bb3a14bcc7..1713843f31 100644 --- a/medium-tests/src/test/java/mediumtest/issues/OpenIssueInIdeMediumTests.java +++ b/medium-tests/src/test/java/mediumtest/issues/OpenIssueInIdeMediumTests.java @@ -317,8 +317,8 @@ void it_should_assist_creating_the_connection_when_server_url_unknown() throws E ArgumentCaptor captor = ArgumentCaptor.captor(); verify(fakeClient, timeout(1000)).assistCreatingConnection(captor.capture(), any()); assertThat(captor.getAllValues()) - .extracting(connectionParams -> connectionParams.getConnection().getLeft().getServerUrl(), - connectionParams -> connectionParams.getConnection().getLeft() != null, + .extracting(connectionParams -> connectionParams.getConnectionParams().getLeft().getServerUrl(), + connectionParams -> connectionParams.getConnectionParams().getLeft() != null, AssistCreatingConnectionParams::getTokenName, AssistCreatingConnectionParams::getTokenValue) .containsExactly(tuple(serverWithIssues.baseUrl(), true, null, null)); @@ -345,7 +345,7 @@ void it_should_assist_creating_the_connection_when_no_sc_connection() throws Exc ArgumentCaptor captor = ArgumentCaptor.captor(); verify(fakeClient, timeout(1000)).assistCreatingConnection(captor.capture(), any()); assertThat(captor.getAllValues()) - .extracting(connectionParams -> connectionParams.getConnection().getRight().getOrganizationKey(), + .extracting(connectionParams -> connectionParams.getConnectionParams().getRight().getOrganizationKey(), AssistCreatingConnectionParams::getTokenName, AssistCreatingConnectionParams::getTokenValue) .containsExactly(tuple("orgKey", null, null)); diff --git a/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/adapter/EitherAssistSonarQubeSonarCloudConnectionAdapterFactory.java b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/adapter/EitherAssistSonarQubeSonarCloudConnectionAdapterFactory.java index 49e9d95cfd..b197abc4c0 100644 --- a/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/adapter/EitherAssistSonarQubeSonarCloudConnectionAdapterFactory.java +++ b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/adapter/EitherAssistSonarQubeSonarCloudConnectionAdapterFactory.java @@ -21,17 +21,17 @@ import com.google.gson.reflect.TypeToken; import org.eclipse.lsp4j.jsonrpc.json.adapters.EitherTypeAdapter; -import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.AssistSonarCloudConnection; -import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.AssistSonarQubeConnection; +import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.SonarCloudConnectionParams; +import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.SonarQubeConnectionParams; import org.sonarsource.sonarlint.core.rpc.protocol.common.Either; -public class EitherAssistSonarQubeSonarCloudConnectionAdapterFactory extends CustomEitherAdapterFactory { +public class EitherAssistSonarQubeSonarCloudConnectionAdapterFactory extends CustomEitherAdapterFactory { - private static final TypeToken> ELEMENT_TYPE = new TypeToken<>() { + private static final TypeToken> ELEMENT_TYPE = new TypeToken<>() { }; public EitherAssistSonarQubeSonarCloudConnectionAdapterFactory() { - super(ELEMENT_TYPE, AssistSonarQubeConnection.class, AssistSonarCloudConnection.class, new EitherTypeAdapter.PropertyChecker("serverUrl")); + super(ELEMENT_TYPE, SonarQubeConnectionParams.class, SonarCloudConnectionParams.class, new EitherTypeAdapter.PropertyChecker("serverUrl")); } } diff --git a/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/AssistCreatingConnectionParams.java b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/AssistCreatingConnectionParams.java index ced46c63dd..4182ba1fca 100644 --- a/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/AssistCreatingConnectionParams.java +++ b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/AssistCreatingConnectionParams.java @@ -25,41 +25,41 @@ public class AssistCreatingConnectionParams { @JsonAdapter(EitherAssistSonarQubeSonarCloudConnectionAdapterFactory.class) - private final Either connection; + private final Either connectionParams; - public AssistCreatingConnectionParams(Either connection) { - this.connection = connection; + public AssistCreatingConnectionParams(Either connectionParams) { + this.connectionParams = connectionParams; } - public AssistCreatingConnectionParams(AssistSonarQubeConnection sonarQubeConnection) { + public AssistCreatingConnectionParams(SonarQubeConnectionParams sonarQubeConnection) { this(Either.forLeft(sonarQubeConnection)); } - public AssistCreatingConnectionParams(AssistSonarCloudConnection sonarCloudConnection) { + public AssistCreatingConnectionParams(SonarCloudConnectionParams sonarCloudConnection) { this(Either.forRight(sonarCloudConnection)); } - public Either getConnection() { - return connection; + public Either getConnectionParams() { + return connectionParams; } /** - * @deprecated Use {@link #getConnection()}.getLeft().getServerUrl() instead. + * @deprecated Use {@link #getConnectionParams()}.getLeft().getServerUrl() instead. */ @Deprecated(since = "10.3", forRemoval = true) public String getServerUrl() { - return connection.isLeft() ? connection.getLeft().getServerUrl() : null; + return connectionParams.isLeft() ? connectionParams.getLeft().getServerUrl() : null; } public String getTokenName() { - return connection.isLeft() ? - connection.getLeft().getTokenName() - : connection.getRight().getTokenName(); + return connectionParams.isLeft() ? + connectionParams.getLeft().getTokenName() + : connectionParams.getRight().getTokenName(); } public String getTokenValue() { - return connection.isLeft() ? - connection.getLeft().getTokenValue() - : connection.getRight().getTokenValue(); + return connectionParams.isLeft() ? + connectionParams.getLeft().getTokenValue() + : connectionParams.getRight().getTokenValue(); } } diff --git a/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/AssistSonarCloudConnection.java b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/SonarCloudConnectionParams.java similarity index 93% rename from rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/AssistSonarCloudConnection.java rename to rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/SonarCloudConnectionParams.java index 68393987e9..9d1af62cda 100644 --- a/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/AssistSonarCloudConnection.java +++ b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/SonarCloudConnectionParams.java @@ -22,12 +22,12 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; -public class AssistSonarCloudConnection { +public class SonarCloudConnectionParams { private final String organizationKey; private final String tokenName; private final String tokenValue; - public AssistSonarCloudConnection(String organizationKey, @Nullable String tokenName, @Nullable String tokenValue) { + public SonarCloudConnectionParams(String organizationKey, @Nullable String tokenName, @Nullable String tokenValue) { this.organizationKey = organizationKey; this.tokenName = tokenName; this.tokenValue = tokenValue; diff --git a/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/AssistSonarQubeConnection.java b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/SonarQubeConnectionParams.java similarity index 93% rename from rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/AssistSonarQubeConnection.java rename to rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/SonarQubeConnectionParams.java index 4060992d95..7aab3404a8 100644 --- a/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/AssistSonarQubeConnection.java +++ b/rpc-protocol/src/main/java/org/sonarsource/sonarlint/core/rpc/protocol/client/connection/SonarQubeConnectionParams.java @@ -22,12 +22,12 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; -public class AssistSonarQubeConnection { +public class SonarQubeConnectionParams { private final String serverUrl; private final String tokenName; private final String tokenValue; - public AssistSonarQubeConnection(String serverUrl, @Nullable String tokenName, @Nullable String tokenValue) { + public SonarQubeConnectionParams(String serverUrl, @Nullable String tokenName, @Nullable String tokenValue) { this.serverUrl = serverUrl; this.tokenName = tokenName; this.tokenValue = tokenValue;