Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit c170250

Browse files
authored
[Bot-AI-QnA] Fix disparities (#1214)
* Remove testData to be renamed * Rename testData to testdata in order to be consistent with other Java libraries * Fix typo in javadoc * Consistency of StringUtils * Make props as final * Update property from 0.4 to 0.42
1 parent 40094f9 commit c170250

24 files changed

+12
-13
lines changed

libraries/bot-ai-qna/src/main/java/com/microsoft/bot/ai/qna/QnAMaker.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import java.util.concurrent.CompletableFuture;
3434

3535
import com.fasterxml.jackson.annotation.JsonIgnore;
36-
import com.google.common.base.Strings;
3736
import org.apache.commons.lang3.StringUtils;
3837
import org.slf4j.LoggerFactory;
3938

@@ -91,15 +90,15 @@ public QnAMaker(
9190
}
9291
this.endpoint = withEndpoint;
9392

94-
if (Strings.isNullOrEmpty(this.endpoint.getKnowledgeBaseId())) {
93+
if (StringUtils.isBlank(this.endpoint.getKnowledgeBaseId())) {
9594
throw new IllegalArgumentException("knowledgeBaseId");
9695
}
9796

98-
if (Strings.isNullOrEmpty(this.endpoint.getHost())) {
97+
if (StringUtils.isBlank(this.endpoint.getHost())) {
9998
throw new IllegalArgumentException("host");
10099
}
101100

102-
if (Strings.isNullOrEmpty(this.endpoint.getEndpointKey())) {
101+
if (StringUtils.isBlank(this.endpoint.getEndpointKey())) {
103102
throw new IllegalArgumentException("endpointKey");
104103
}
105104

@@ -222,7 +221,7 @@ public CompletableFuture<QueryResults> getAnswersRaw(
222221
return Async.completeExceptionally(new IllegalArgumentException("Activity type is not a message"));
223222
}
224223

225-
if (Strings.isNullOrEmpty(turnContext.getActivity().getText())) {
224+
if (StringUtils.isBlank(turnContext.getActivity().getText())) {
226225
return Async.completeExceptionally(new IllegalArgumentException("Null or empty text"));
227226
}
228227

libraries/bot-ai-qna/src/main/java/com/microsoft/bot/ai/qna/models/FeedbackRecord.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class FeedbackRecord {
1919
private Integer qnaId;
2020

2121
/**
22-
* Gets the feedback recod's user ID.
22+
* Gets the feedback record's user ID.
2323
*
2424
* @return The user ID.
2525
*/
@@ -28,7 +28,7 @@ public String getUserId() {
2828
}
2929

3030
/**
31-
* Sets the feedback recod's user ID.
31+
* Sets the feedback record's user ID.
3232
*
3333
* @param withUserId The user ID.
3434
*/

libraries/bot-ai-qna/src/main/java/com/microsoft/bot/ai/qna/utils/BindToActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* Class to bind activities.
1515
*/
1616
public class BindToActivity {
17-
private Activity activity;
17+
private final Activity activity;
1818

1919
/**
2020
* Construct to bind an Activity.
21-
*
21+
*
2222
* @param withActivity activity to bind.
2323
*/
2424
public BindToActivity(Activity withActivity) {
@@ -37,7 +37,7 @@ public CompletableFuture<Activity> bind(DialogContext context, @Nullable Object
3737

3838
/**
3939
* Get the activity text.
40-
*
40+
*
4141
* @return The activity text.
4242
*/
4343
public String toString() {

libraries/bot-ai-qna/src/main/java/com/microsoft/bot/ai/qna/utils/HttpRequestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Helper for HTTP requests.
2525
*/
2626
public class HttpRequestUtils {
27-
private OkHttpClient httpClient = new OkHttpClient();
27+
private final OkHttpClient httpClient = new OkHttpClient();
2828

2929
/**
3030
* Execute Http request.

libraries/bot-ai-qna/src/test/java/com/microsoft/bot/ai/qna/QnAMakerRecognizerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public void returnAnswersWithIntents() {
219219

220220
private String readFileContent (String fileName) throws IOException {
221221
String path = Paths.get("", "src", "test", "java", "com", "microsoft", "bot", "ai", "qna",
222-
"testData", fileName).toAbsolutePath().toString();
222+
"testdata", fileName).toAbsolutePath().toString();
223223
File file = new File(path);
224224
return FileUtils.readFileToString(file, "utf-8");
225225
}

libraries/bot-ai-qna/src/test/java/com/microsoft/bot/ai/qna/QnAMakerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ public void qnaMakerTestOptionsHydration() {
11091109

11101110
QnAMakerOptions allChangedRequestOptions = new QnAMakerOptions();
11111111
allChangedRequestOptions.setTop(2000);
1112-
allChangedRequestOptions.setScoreThreshold(0.4f);
1112+
allChangedRequestOptions.setScoreThreshold(0.42f);
11131113
allChangedRequestOptions.setStrictFilters(allChangedRequestOptionsFilters);
11141114

11151115
QnAMaker qna = new QnAMaker(qnAMakerEndpoint, noFiltersOptions);

libraries/bot-ai-qna/src/test/java/com/microsoft/bot/ai/qna/testData/QnaMaker_IsTest_True.json renamed to libraries/bot-ai-qna/src/test/java/com/microsoft/bot/ai/qna/testdata/QnaMaker_IsTest_True.json

File renamed without changes.

libraries/bot-ai-qna/src/test/java/com/microsoft/bot/ai/qna/testData/QnaMaker_LegacyEndpointAnswer.json renamed to libraries/bot-ai-qna/src/test/java/com/microsoft/bot/ai/qna/testdata/QnaMaker_LegacyEndpointAnswer.json

File renamed without changes.

libraries/bot-ai-qna/src/test/java/com/microsoft/bot/ai/qna/testData/QnaMaker_RankerType_QuestionOnly.json renamed to libraries/bot-ai-qna/src/test/java/com/microsoft/bot/ai/qna/testdata/QnaMaker_RankerType_QuestionOnly.json

File renamed without changes.

libraries/bot-ai-qna/src/test/java/com/microsoft/bot/ai/qna/testData/QnaMaker_ReturnAnswer_MultiTurnLevel1.json renamed to libraries/bot-ai-qna/src/test/java/com/microsoft/bot/ai/qna/testdata/QnaMaker_ReturnAnswer_MultiTurnLevel1.json

File renamed without changes.

0 commit comments

Comments
 (0)