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

Commit

Permalink
Updated dependencies and resolved most version conflicts (#1018)
Browse files Browse the repository at this point in the history
  • Loading branch information
tracyboehrer authored Feb 24, 2021
1 parent 94e5eef commit 9c13651
Show file tree
Hide file tree
Showing 24 changed files with 241 additions and 160 deletions.
12 changes: 12 additions & 0 deletions libraries/bot-ai-luis-v3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@
<artifactId>json</artifactId>
<version>20190722</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.13</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
<scope>compile</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ private Request buildRequest(RequestBody body) {

private RequestBody buildRequestBody(String utterance) throws JsonProcessingException {

ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
ObjectNode content = JsonNodeFactory.instance.objectNode().put("query", utterance);
ObjectNode queryOptions =
JsonNodeFactory.instance.objectNode().put("preferExternalEntities", preferExternalEntities);
Expand Down Expand Up @@ -482,7 +482,7 @@ private CompletableFuture<RecognizerResult> recognizeInternal(TurnContext turnCo

RecognizerResult recognizerResult;
JsonNode luisResponse = null;
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();

if (utterance == null || utterance.isEmpty()) {
recognizerResult = new RecognizerResult() {
Expand Down Expand Up @@ -691,7 +691,7 @@ private CompletableFuture<ResourceResponse> sendTraceActivity(
JsonNode luisResponse,
TurnContext turnContext
) {
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
try {
ObjectNode traceInfo = JsonNodeFactory.instance.objectNode();
traceInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void shouldParseLuisResponsesCorrectly_TurnContextPassed(String fileName
String content = readFileContent("/src/test/java/com/microsoft/bot/ai/luis/testdata/" + fileName);

//Extract V3 response
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode testData = mapper.readTree(content);
JsonNode v3SettingsAndResponse = testData.get("v3");
JsonNode v3Response = v3SettingsAndResponse.get("response");
Expand Down Expand Up @@ -176,7 +176,7 @@ public void shouldBuildExternalEntities_DialogContextPassed_ExternalRecognizer()
String content = readFileContent("/src/test/java/com/microsoft/bot/ai/luis/testdata/ExternalRecognizer.json");

//Extract V3 response
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode testData = mapper.readTree(content);
JsonNode v3SettingsAndResponse = testData.get("v3");
JsonNode v3Response = v3SettingsAndResponse.get("response");
Expand Down Expand Up @@ -308,7 +308,7 @@ private String buildUrl(StringBuilder pathToMock, JsonNode testSettings) {
}

private HttpUrl initializeMockServer(MockWebServer mockWebServer, JsonNode v3Response, String url) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
String mockResponse = mapper.writeValueAsString(v3Response);
mockWebServer.enqueue(new MockResponse()
.addHeader("Content-Type", "application/json; charset=utf-8")
Expand All @@ -320,7 +320,7 @@ private HttpUrl initializeMockServer(MockWebServer mockWebServer, JsonNode v3Res
}

private LuisRecognizerOptionsV3 buildTestRecognizer (String endpoint, JsonNode testSettings) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
ObjectReader readerDynamicList = mapper.readerFor(new TypeReference<List<DynamicList>>() {});
ObjectReader readerExternalentities = mapper.readerFor(new TypeReference<List<ExternalEntity>>() {});
return new LuisRecognizerOptionsV3(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void recognizerResult() {
RecognizerResult actual = null;
try {
actual = recognizer.recognize(turnContext).get();
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
assertEquals(mapper.writeValueAsString(expected), mapper.writeValueAsString(actual));
} catch (InterruptedException | ExecutionException | JsonProcessingException e) {
e.printStackTrace();
Expand Down Expand Up @@ -197,7 +197,7 @@ public void recognizerResult_nullTelemetryClient() {
RecognizerResult actual = null;
try {
actual = recognizer.recognize(turnContext).get();
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
assertEquals(mapper.writeValueAsString(expected), mapper.writeValueAsString(actual));
} catch (InterruptedException | ExecutionException | JsonProcessingException e) {
e.printStackTrace();
Expand Down Expand Up @@ -256,7 +256,7 @@ public void recognizerResultDialogContext() {
LuisRecognizer recognizer = new LuisRecognizer(options);
try {
actual = recognizer.recognize(dialogContext, turnContext.getActivity()).get();
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
assertEquals(mapper.writeValueAsString(expected), mapper.writeValueAsString(actual));
} catch (InterruptedException | ExecutionException | JsonProcessingException e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public CompletableFuture<RecognizerResult> recognize(
}
});
}
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
ObjectNode entitiesNode = mapper.createObjectNode();
List<String> answerArray = new ArrayList<String>();
answerArray.add(topAnswer.getAnswer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public CompletableFuture<JsonNode> executeHttpRequest(
return Async.completeExceptionally(new IllegalArgumentException("endpoint"));
}

ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
String endpointKey = endpoint.getEndpointKey();
Response response;
JsonNode qnaResponse = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void noAnswer() {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_ReturnsNoAnswer.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
// Set mock response in MockWebServer
String url = "/qnamaker/knowledgebases/";
Expand Down Expand Up @@ -114,7 +114,7 @@ public void returnAnswers() {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_ReturnsAnswer.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
// Set mock response in MockWebServer
String url = "/qnamaker/knowledgebases/";
Expand Down Expand Up @@ -154,7 +154,7 @@ public void topNAnswers() {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_TopNAnswer.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
// Set mock response in MockWebServer
String url = "/qnamaker/knowledgebases/";
Expand Down Expand Up @@ -194,7 +194,7 @@ public void returnAnswersWithIntents() {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_ReturnsAnswerWithIntent.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
// Set mock response in MockWebServer
String url = "/qnamaker/knowledgebases/";
Expand Down Expand Up @@ -237,7 +237,7 @@ private String readFileContent (String fileName) throws IOException {
}

private HttpUrl initializeMockServer(MockWebServer mockWebServer, JsonNode response, String url) throws IOException {
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
String mockResponse = mapper.writeValueAsString(response);
mockWebServer.enqueue(new MockResponse()
.addHeader("Content-Type", "application/json; charset=utf-8")
Expand Down
Loading

0 comments on commit 9c13651

Please sign in to comment.