Skip to content

Commit

Permalink
SLCORE-828 rename field, method and types from connection to connecti…
Browse files Browse the repository at this point in the history
…onParams
  • Loading branch information
serhat-yenican-sonarsource committed May 31, 2024
1 parent e9fa3c2 commit 4323099
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ void it_should_assist_creating_the_connection_when_server_url_unknown() throws E
ArgumentCaptor<AssistCreatingConnectionParams> 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));
Expand All @@ -345,7 +345,7 @@ void it_should_assist_creating_the_connection_when_no_sc_connection() throws Exc
ArgumentCaptor<AssistCreatingConnectionParams> 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<AssistSonarQubeConnection, AssistSonarCloudConnection> {
public class EitherAssistSonarQubeSonarCloudConnectionAdapterFactory extends CustomEitherAdapterFactory<SonarQubeConnectionParams, SonarCloudConnectionParams> {

private static final TypeToken<Either<AssistSonarQubeConnection, AssistSonarCloudConnection>> ELEMENT_TYPE = new TypeToken<>() {
private static final TypeToken<Either<SonarQubeConnectionParams, SonarCloudConnectionParams>> 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"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,41 @@

public class AssistCreatingConnectionParams {
@JsonAdapter(EitherAssistSonarQubeSonarCloudConnectionAdapterFactory.class)
private final Either<AssistSonarQubeConnection, AssistSonarCloudConnection> connection;
private final Either<SonarQubeConnectionParams, SonarCloudConnectionParams> connectionParams;

public AssistCreatingConnectionParams(Either<AssistSonarQubeConnection, AssistSonarCloudConnection> connection) {
this.connection = connection;
public AssistCreatingConnectionParams(Either<SonarQubeConnectionParams, SonarCloudConnectionParams> 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<AssistSonarQubeConnection, AssistSonarCloudConnection> getConnection() {
return connection;
public Either<SonarQubeConnectionParams, SonarCloudConnectionParams> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4323099

Please sign in to comment.