Fix guice binding issue on GerritClientPatchSet
Fix confusion which happened due to concrete class and interface
having the identical naming, which meant the refactor operation
changed some wrong fields.
Updated so that the interface has a clear name, which fixes the
binding issue.
Change-Id: Id1bd9c06b104b73e4bbb1636d9669e809c94cf3c
diff --git a/src/main/java/com/googlesource/gerrit/plugins/aicodereview/interfaces/mode/common/client/api/gerrit/GerritClientPatchSet.java b/src/main/java/com/googlesource/gerrit/plugins/aicodereview/interfaces/mode/common/client/api/gerrit/GerritClientPatchSetInfo.java
similarity index 96%
rename from src/main/java/com/googlesource/gerrit/plugins/aicodereview/interfaces/mode/common/client/api/gerrit/GerritClientPatchSet.java
rename to src/main/java/com/googlesource/gerrit/plugins/aicodereview/interfaces/mode/common/client/api/gerrit/GerritClientPatchSetInfo.java
index 8044bd2..1d899cd 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/aicodereview/interfaces/mode/common/client/api/gerrit/GerritClientPatchSet.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/aicodereview/interfaces/mode/common/client/api/gerrit/GerritClientPatchSetInfo.java
@@ -19,7 +19,7 @@
import com.googlesource.gerrit.plugins.aicodereview.mode.common.model.data.ChangeSetData;
import java.util.HashMap;
-public interface GerritClientPatchSet {
+public interface GerritClientPatchSetInfo {
String getPatchSet(ChangeSetData changeSetData, GerritChange gerritChange) throws Exception;
boolean isDisabledUser(String authorUsername);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/aicodereview/listener/GerritEventContextModule.java b/src/main/java/com/googlesource/gerrit/plugins/aicodereview/listener/GerritEventContextModule.java
index 9eebf35..f3a956d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/aicodereview/listener/GerritEventContextModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/aicodereview/listener/GerritEventContextModule.java
@@ -23,9 +23,9 @@
import com.googlesource.gerrit.plugins.aicodereview.data.ChangeSetDataProvider;
import com.googlesource.gerrit.plugins.aicodereview.data.PluginDataHandler;
import com.googlesource.gerrit.plugins.aicodereview.data.PluginDataHandlerProvider;
+import com.googlesource.gerrit.plugins.aicodereview.interfaces.mode.common.client.api.gerrit.GerritClientPatchSetInfo;
import com.googlesource.gerrit.plugins.aicodereview.interfaces.mode.common.client.api.openapi.ChatAIClient;
import com.googlesource.gerrit.plugins.aicodereview.mode.common.client.api.gerrit.GerritChange;
-import com.googlesource.gerrit.plugins.aicodereview.mode.common.client.api.gerrit.GerritClientPatchSet;
import com.googlesource.gerrit.plugins.aicodereview.mode.common.model.data.ChangeSetData;
import com.googlesource.gerrit.plugins.aicodereview.mode.stateful.client.api.chatai.AIChatClientStateful;
import com.googlesource.gerrit.plugins.aicodereview.mode.stateful.client.api.gerrit.GerritClientPatchSetStateful;
@@ -44,7 +44,7 @@
@Override
protected void configure() {
bind(ChatAIClient.class).to(getChatAIMode());
- bind(GerritClientPatchSet.class).to(getClientPatchSet());
+ bind(GerritClientPatchSetInfo.class).to(getClientPatchSet());
bind(Configuration.class).toInstance(config);
bind(GerritChange.class).toInstance(new GerritChange(event));
@@ -59,7 +59,7 @@
};
}
- private Class<? extends GerritClientPatchSet> getClientPatchSet() {
+ private Class<? extends GerritClientPatchSetInfo> getClientPatchSet() {
return switch (config.getAIMode()) {
case stateful -> GerritClientPatchSetStateful.class;
case stateless -> GerritClientPatchSetStateless.class;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/common/client/api/gerrit/GerritClientFacade.java b/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/common/client/api/gerrit/GerritClientFacade.java
index bee18aa..81f3eda 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/common/client/api/gerrit/GerritClientFacade.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/common/client/api/gerrit/GerritClientFacade.java
@@ -17,7 +17,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.inject.Inject;
import com.googlesource.gerrit.plugins.aicodereview.config.Configuration;
-import com.googlesource.gerrit.plugins.aicodereview.interfaces.mode.common.client.api.gerrit.GerritClientPatchSet;
+import com.googlesource.gerrit.plugins.aicodereview.interfaces.mode.common.client.api.gerrit.GerritClientPatchSetInfo;
import com.googlesource.gerrit.plugins.aicodereview.mode.common.client.patch.diff.FileDiffProcessed;
import com.googlesource.gerrit.plugins.aicodereview.mode.common.model.api.gerrit.GerritPermittedVotingRange;
import com.googlesource.gerrit.plugins.aicodereview.mode.common.model.data.ChangeSetData;
@@ -30,7 +30,7 @@
private final ChangeSetData changeSetData;
private final GerritClientDetail gerritClientDetail;
private final GerritClientComments gerritClientComments;
- private final GerritClientPatchSet gerritClientPatchSet;
+ private final GerritClientPatchSetInfo gerritClientPatchSetInfo;
@VisibleForTesting
@Inject
@@ -38,9 +38,9 @@
Configuration config,
ChangeSetData changeSetData,
GerritClientComments gerritClientComments,
- GerritClientPatchSet gerritClientPatchSet) {
+ GerritClientPatchSetInfo gerritClientPatchSetInfo) {
gerritClientDetail = new GerritClientDetail(config, changeSetData);
- this.gerritClientPatchSet = gerritClientPatchSet;
+ this.gerritClientPatchSetInfo = gerritClientPatchSetInfo;
this.changeSetData = changeSetData;
this.gerritClientComments = gerritClientComments;
}
@@ -50,15 +50,15 @@
}
public String getPatchSet(GerritChange change) throws Exception {
- return gerritClientPatchSet.getPatchSet(changeSetData, change);
+ return gerritClientPatchSetInfo.getPatchSet(changeSetData, change);
}
public boolean isDisabledUser(String authorUsername) {
- return gerritClientPatchSet.isDisabledUser(authorUsername);
+ return gerritClientPatchSetInfo.isDisabledUser(authorUsername);
}
public boolean isDisabledTopic(String topic) {
- return gerritClientPatchSet.isDisabledTopic(topic);
+ return gerritClientPatchSetInfo.isDisabledTopic(topic);
}
public boolean isWorkInProgress(GerritChange change) {
@@ -66,11 +66,11 @@
}
public HashMap<String, FileDiffProcessed> getFileDiffsProcessed() {
- return gerritClientPatchSet.getFileDiffsProcessed();
+ return gerritClientPatchSetInfo.getFileDiffsProcessed();
}
public Integer getNotNullAccountId(String authorUsername) {
- return gerritClientPatchSet.getNotNullAccountId(authorUsername);
+ return gerritClientPatchSetInfo.getNotNullAccountId(authorUsername);
}
public boolean retrieveLastComments(GerritChange change) {
@@ -79,14 +79,14 @@
public void retrievePatchSetInfo(GerritChange change) {
gerritClientComments.retrieveAllComments(change);
- gerritClientPatchSet.retrieveRevisionBase(change);
+ gerritClientPatchSetInfo.retrieveRevisionBase(change);
}
public GerritClientData getClientData(GerritChange change) {
return new GerritClientData(
- gerritClientPatchSet.getFileDiffsProcessed(),
+ gerritClientPatchSetInfo.getFileDiffsProcessed(),
gerritClientDetail.getMessages(change),
gerritClientComments.getCommentData(),
- gerritClientPatchSet.getRevisionBase());
+ gerritClientPatchSetInfo.getRevisionBase());
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/common/model/api/openai/AIChatCompletionRequest.java b/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/common/model/api/openai/AIChatCompletionRequest.java
index 58f6445..e1a061d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/common/model/api/openai/AIChatCompletionRequest.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/common/model/api/openai/AIChatCompletionRequest.java
@@ -15,7 +15,6 @@
package com.googlesource.gerrit.plugins.aicodereview.mode.common.model.api.openai;
import com.google.gson.annotations.SerializedName;
-
import java.util.List;
import lombok.Builder;
import lombok.Data;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/stateful/client/api/gerrit/GerritClientPatchSetStateful.java b/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/stateful/client/api/gerrit/GerritClientPatchSetStateful.java
index 9cd1d3a..144e54b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/stateful/client/api/gerrit/GerritClientPatchSetStateful.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/stateful/client/api/gerrit/GerritClientPatchSetStateful.java
@@ -23,17 +23,16 @@
import com.google.gerrit.server.util.ManualRequestContext;
import com.google.inject.Inject;
import com.googlesource.gerrit.plugins.aicodereview.config.Configuration;
-import com.googlesource.gerrit.plugins.aicodereview.interfaces.mode.common.client.api.gerrit.GerritClientPatchSet;
+import com.googlesource.gerrit.plugins.aicodereview.interfaces.mode.common.client.api.gerrit.GerritClientPatchSetInfo;
import com.googlesource.gerrit.plugins.aicodereview.mode.common.client.api.gerrit.GerritChange;
+import com.googlesource.gerrit.plugins.aicodereview.mode.common.client.api.gerrit.GerritClientPatchSet;
import com.googlesource.gerrit.plugins.aicodereview.mode.common.model.data.ChangeSetData;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
@Slf4j
-public class GerritClientPatchSetStateful
- extends com.googlesource.gerrit.plugins.aicodereview.mode.common.client.api.gerrit
- .GerritClientPatchSet
- implements GerritClientPatchSet {
+public class GerritClientPatchSetStateful extends GerritClientPatchSet
+ implements GerritClientPatchSetInfo {
private GerritChange change;
@VisibleForTesting
diff --git a/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/stateless/client/api/chatai/AIChatClientStateless.java b/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/stateless/client/api/chatai/AIChatClientStateless.java
index c65e61c..b46de41 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/stateless/client/api/chatai/AIChatClientStateless.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/stateless/client/api/chatai/AIChatClientStateless.java
@@ -34,7 +34,6 @@
import com.googlesource.gerrit.plugins.aicodereview.mode.common.model.data.ChangeSetData;
import com.googlesource.gerrit.plugins.aicodereview.mode.stateless.client.api.UriResourceLocatorStateless;
import com.googlesource.gerrit.plugins.aicodereview.mode.stateless.client.prompt.AIChatPromptStateless;
-
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpRequest;
@@ -62,9 +61,7 @@
isCommentEvent = change.getIsCommentEvent();
String changeId = change.getFullChangeId();
log.info(
- "Processing STATELESS AIChat Request with changeId: {}, Patch Set: {}",
- changeId,
- patchSet);
+ "Processing STATELESS AIChat Request with changeId: {}, Patch Set: {}", changeId, patchSet);
for (int attemptInd = 0; attemptInd < REVIEW_ATTEMPT_LIMIT; attemptInd++) {
HttpRequest request = createRequest(config, changeSetData, patchSet);
log.debug("AIChat request: {}", request.toString());
diff --git a/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/stateless/client/api/gerrit/GerritClientPatchSetStateless.java b/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/stateless/client/api/gerrit/GerritClientPatchSetStateless.java
index dc7ad66..255ba09 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/stateless/client/api/gerrit/GerritClientPatchSetStateless.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/aicodereview/mode/stateless/client/api/gerrit/GerritClientPatchSetStateless.java
@@ -22,18 +22,17 @@
import com.google.gerrit.server.util.ManualRequestContext;
import com.google.inject.Inject;
import com.googlesource.gerrit.plugins.aicodereview.config.Configuration;
-import com.googlesource.gerrit.plugins.aicodereview.interfaces.mode.common.client.api.gerrit.GerritClientPatchSet;
+import com.googlesource.gerrit.plugins.aicodereview.interfaces.mode.common.client.api.gerrit.GerritClientPatchSetInfo;
import com.googlesource.gerrit.plugins.aicodereview.mode.common.client.api.gerrit.GerritChange;
+import com.googlesource.gerrit.plugins.aicodereview.mode.common.client.api.gerrit.GerritClientPatchSet;
import com.googlesource.gerrit.plugins.aicodereview.mode.common.model.data.ChangeSetData;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
@Slf4j
-public class GerritClientPatchSetStateless
- extends com.googlesource.gerrit.plugins.aicodereview.mode.common.client.api.gerrit
- .GerritClientPatchSet
- implements GerritClientPatchSet {
+public class GerritClientPatchSetStateless extends GerritClientPatchSet
+ implements GerritClientPatchSetInfo {
@VisibleForTesting
@Inject
public GerritClientPatchSetStateless(Configuration config, AccountCache accountCache) {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/aicodereview/AIChatReviewTestBase.java b/src/test/java/com/googlesource/gerrit/plugins/aicodereview/AIChatReviewTestBase.java
index 83885e0..a31a7c6 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/aicodereview/AIChatReviewTestBase.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/aicodereview/AIChatReviewTestBase.java
@@ -51,7 +51,7 @@
import com.googlesource.gerrit.plugins.aicodereview.config.Configuration;
import com.googlesource.gerrit.plugins.aicodereview.data.PluginDataHandler;
import com.googlesource.gerrit.plugins.aicodereview.data.PluginDataHandlerProvider;
-import com.googlesource.gerrit.plugins.aicodereview.interfaces.mode.common.client.api.gerrit.GerritClientPatchSet;
+import com.googlesource.gerrit.plugins.aicodereview.interfaces.mode.common.client.api.gerrit.GerritClientPatchSetInfo;
import com.googlesource.gerrit.plugins.aicodereview.interfaces.mode.common.client.api.openapi.ChatAIClient;
import com.googlesource.gerrit.plugins.aicodereview.listener.EventHandlerTask;
import com.googlesource.gerrit.plugins.aicodereview.localization.Localizer;
@@ -399,7 +399,7 @@
};
}
- private GerritClientPatchSet getGerritClientPatchSet() {
+ private GerritClientPatchSetInfo getGerritClientPatchSet() {
return switch (config.getAIMode()) {
case stateful -> new GerritClientPatchSetStateful(config, accountCacheMock);
case stateless -> new GerritClientPatchSetStateless(config, accountCacheMock);