Updated dependencies and resolved most version conflicts (#1018)

This commit is contained in:
tracyboehrer 2021-02-24 09:44:40 -06:00 коммит произвёл GitHub
Родитель 94e5eef926
Коммит 9c13651965
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
24 изменённых файлов: 241 добавлений и 160 удалений

Просмотреть файл

@ -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>

Просмотреть файл

@ -452,7 +452,7 @@ public class LuisRecognizerOptionsV3 extends LuisRecognizerOptions {
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);
@ -482,7 +482,7 @@ public class LuisRecognizerOptionsV3 extends LuisRecognizerOptions {
RecognizerResult recognizerResult;
JsonNode luisResponse = null;
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
if (utterance == null || utterance.isEmpty()) {
recognizerResult = new RecognizerResult() {
@ -691,7 +691,7 @@ public class LuisRecognizerOptionsV3 extends LuisRecognizerOptions {
JsonNode luisResponse,
TurnContext turnContext
) {
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
try {
ObjectNode traceInfo = JsonNodeFactory.instance.objectNode();
traceInfo

Просмотреть файл

@ -99,7 +99,7 @@ public class LuisRecognizerOptionsV3Tests {
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");
@ -176,7 +176,7 @@ public class LuisRecognizerOptionsV3Tests {
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");
@ -308,7 +308,7 @@ public class LuisRecognizerOptionsV3Tests {
}
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")
@ -320,7 +320,7 @@ public class LuisRecognizerOptionsV3Tests {
}
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(

Просмотреть файл

@ -142,7 +142,7 @@ public class LuisRecognizerTests {
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();
@ -197,7 +197,7 @@ public class LuisRecognizerTests {
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();
@ -256,7 +256,7 @@ public class LuisRecognizerTests {
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();

Просмотреть файл

@ -417,7 +417,7 @@ public class QnAMakerRecognizer extends Recognizer {
}
});
}
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
ObjectNode entitiesNode = mapper.createObjectNode();
List<String> answerArray = new ArrayList<String>();
answerArray.add(topAnswer.getAnswer());

Просмотреть файл

@ -53,7 +53,7 @@ public class HttpRequestUtils {
return Async.completeExceptionally(new IllegalArgumentException("endpoint"));
}
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
String endpointKey = endpoint.getEndpointKey();
Response response;
JsonNode qnaResponse = null;

Просмотреть файл

@ -72,7 +72,7 @@ public class QnAMakerRecognizerTests {
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/";
@ -114,7 +114,7 @@ public class QnAMakerRecognizerTests {
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/";
@ -154,7 +154,7 @@ public class QnAMakerRecognizerTests {
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/";
@ -194,7 +194,7 @@ public class QnAMakerRecognizerTests {
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/";
@ -237,7 +237,7 @@ public class QnAMakerRecognizerTests {
}
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")

Просмотреть файл

@ -368,7 +368,7 @@ public class QnAMakerTests {
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);
String url = this.getRequestUrl();
String endpoint = "";
@ -421,7 +421,7 @@ public class QnAMakerTests {
@Test
public void qnaMakerCallTrain() {
MockWebServer mockWebServer = new MockWebServer();
ObjectMapper objectMapper = new ObjectMapper();
ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules();
String url = this.getTrainRequestUrl();
String endpoint = "";
try {
@ -499,7 +499,7 @@ public class QnAMakerTests {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_UsesStrictFilters_ToReturnAnswer.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
String url = this.getRequestUrl();
String endpoint = "";
@ -526,7 +526,7 @@ public class QnAMakerTests {
}
};
QnAMaker qna = new QnAMaker(qnaMakerEndpoint, qnaMakerOptions);
ObjectMapper objectMapper = new ObjectMapper();
ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules();
QueryResult[] results = qna.getAnswers(getContext("how do I clean the stove?"), qnaMakerOptions).join();
Assert.assertNotNull(results);
@ -563,7 +563,7 @@ public class QnAMakerTests {
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);
String url = this.getRequestUrl();
String endpoint = "";
@ -608,7 +608,7 @@ public class QnAMakerTests {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_TestThreshold.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
String url = this.getRequestUrl();
String endpoint = "";
@ -686,7 +686,7 @@ public class QnAMakerTests {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_ReturnsAnswerWithContext.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
String url = this.getRequestUrl();
String endpoint = "";
@ -737,7 +737,7 @@ public class QnAMakerTests {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_ReturnsAnswerWithoutContext.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
String url = this.getRequestUrl();
String endpoint = "";
@ -780,7 +780,7 @@ public class QnAMakerTests {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_ReturnsAnswerWithContext.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
String url = this.getRequestUrl();
String endpoint = "";
@ -904,7 +904,7 @@ public class QnAMakerTests {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_LegacyEndpointAnswer.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
String url = this.getV2LegacyRequestUrl();
String endpoint = "";
@ -938,7 +938,7 @@ public class QnAMakerTests {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_LegacyEndpointAnswer.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
String url = this.getV3LegacyRequestUrl();
String endpoint = "";
@ -972,7 +972,7 @@ public class QnAMakerTests {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_ReturnsAnswersWithMetadataBoost.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
String url = this.getRequestUrl();
String endpoint = "";
@ -1015,7 +1015,7 @@ public class QnAMakerTests {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_ReturnsAnswer_GivenScoreThresholdQueryOption.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
String url = this.getRequestUrl();
String endpoint = "";
@ -1039,7 +1039,7 @@ public class QnAMakerTests {
QnAMaker qna = new QnAMaker(qnAMakerEndpoint, queryOptionsWithScoreThreshold);
ObjectMapper objectMapper = new ObjectMapper();
ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules();
QueryResult[] results = qna.getAnswers(getContext("What happens when you hug a porcupine?"), queryOptionsWithScoreThreshold).join();
RecordedRequest request = mockWebServer.takeRequest();
@ -1093,7 +1093,7 @@ public class QnAMakerTests {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_IsTest_True.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
String url = this.getRequestUrl();
String endpoint = "";
@ -1136,7 +1136,7 @@ public class QnAMakerTests {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_RankerType_QuestionOnly.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
String url = this.getRequestUrl();
String endpoint = "";
@ -1181,7 +1181,7 @@ public class QnAMakerTests {
String url = this.getRequestUrl();
String endpoint = "";
String content = readFileContent("QnaMaker_ReturnsAnswer.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
if (this.mockQnAResponse) {
endpoint = String.format("%s:%s", hostname, initializeMockServer(mockWebServer, response, url).port());
@ -1248,7 +1248,7 @@ public class QnAMakerTests {
// Ensure that options from previous requests do not bleed over to the next,
// And that the options set in the constructor are not overwritten improperly by options passed into .GetAnswersAsync()
CapturedRequest[] requestContent = new CapturedRequest[6];
ObjectMapper objectMapper = new ObjectMapper();
ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules();
RecordedRequest request;
qna.getAnswers(context, noFiltersOptions).join();
@ -1315,7 +1315,7 @@ public class QnAMakerTests {
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);
String url = this.getRequestUrl();
String endpoint = "";
@ -1354,7 +1354,7 @@ public class QnAMakerTests {
QnAMaker qna = new QnAMaker(qnAMakerEndpoint, oneFilteredOption);
TurnContext context = getContext("up");
ObjectMapper objectMapper = new ObjectMapper();
ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules();
QueryResult[] noFilterResults1 = qna.getAnswers(context, oneFilteredOption).join();
RecordedRequest request = mockWebServer.takeRequest();
@ -1378,7 +1378,7 @@ public class QnAMakerTests {
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);
String url = this.getRequestUrl();
String endpoint = "";
@ -1426,7 +1426,7 @@ public class QnAMakerTests {
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);
String url = this.getRequestUrl();
String endpoint = "";
@ -1494,7 +1494,7 @@ public class QnAMakerTests {
MockWebServer mockWebServer = new MockWebServer();
try {
String content = readFileContent("QnaMaker_ReturnsAnswer_WhenNoAnswerFoundInKb.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
String url = this.getRequestUrl();
String endpoint = "";
@ -1562,7 +1562,7 @@ public class QnAMakerTests {
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);
String url = this.getRequestUrl();
String endpoint = "";
@ -1632,7 +1632,7 @@ public class QnAMakerTests {
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);
String url = this.getRequestUrl();
String endpoint = "";
@ -1706,7 +1706,7 @@ public class QnAMakerTests {
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);
String url = this.getRequestUrl();
String endpoint = "";
@ -1793,7 +1793,7 @@ public class QnAMakerTests {
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);
String url = this.getRequestUrl();
String endpoint = "";
@ -1876,7 +1876,7 @@ public class QnAMakerTests {
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);
String url = this.getRequestUrl();
String endpoint = "";
@ -2030,7 +2030,7 @@ public class QnAMakerTests {
private QnAMaker qnaReturnsAnswer(MockWebServer mockWebServer) {
try {
String content = readFileContent("QnaMaker_ReturnsAnswer.json");
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode response = mapper.readTree(content);
String url = this.getRequestUrl();
String endpoint = "";
@ -2065,7 +2065,7 @@ public class QnAMakerTests {
}
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")
@ -2080,7 +2080,7 @@ public class QnAMakerTests {
}
private void enqueueResponse(MockWebServer mockWebServer, JsonNode response) throws JsonProcessingException {
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")

Просмотреть файл

@ -1302,7 +1302,8 @@ public class BotFrameworkAdapter extends BotAdapter implements
&& turnContext.getActivity().getConversation() != null
&& StringUtils.isEmpty(turnContext.getActivity().getConversation().getTenantId())) {
JsonNode teamsChannelData = new ObjectMapper().valueToTree(turnContext.getActivity().getChannelData());
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
JsonNode teamsChannelData = mapper.valueToTree(turnContext.getActivity().getChannelData());
if (teamsChannelData != null && teamsChannelData.has("tenant")
&& teamsChannelData.get("tenant").has("id")) {

Просмотреть файл

@ -38,6 +38,8 @@ public abstract class BotState implements PropertyManager {
*/
private Storage storage;
private ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
/**
* Initializes a new instance of the BotState class.
*
@ -221,7 +223,7 @@ public abstract class BotState implements PropertyManager {
String stateKey = getClass().getSimpleName();
CachedBotState cachedState = turnContext.getTurnState().get(stateKey);
return new ObjectMapper().valueToTree(cachedState.state);
return mapper.valueToTree(cachedState.state);
}
/**
@ -355,7 +357,7 @@ public abstract class BotState implements PropertyManager {
/**
* Object-JsonNode converter.
*/
private ObjectMapper mapper = new ObjectMapper();
private ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
/**
* Construct with empty state.

Просмотреть файл

@ -663,7 +663,7 @@ public class TeamsActivityHandler extends ActivityHandler {
TeamInfo teamInfo,
TurnContext turnContext
) {
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
mapper.findAndRegisterModules();
List<TeamsChannelAccount> teamsMembersAdded = new ArrayList<>();
@ -731,7 +731,7 @@ public class TeamsActivityHandler extends ActivityHandler {
TeamInfo teamInfo,
TurnContext turnContext
) {
ObjectMapper mapper = new ObjectMapper();
ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
mapper.findAndRegisterModules();
List<TeamsChannelAccount> teamsMembersRemoved = new ArrayList<>();

Просмотреть файл

@ -58,7 +58,6 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1-jre</version>
</dependency>
<dependency>
@ -93,7 +92,7 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.11</version>
<version>1.15</version>
</dependency>
<dependency>
@ -188,4 +187,30 @@
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<configuration>
<excludes>com/microsoft/bot/restclient/**</excludes>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
</project>

Просмотреть файл

@ -34,7 +34,7 @@ import java.util.zip.GZIPInputStream;
public class LoggingInterceptor implements Interceptor {
private static final String LOGGING_HEADER = "x-ms-logging-context";
private static final String BODY_LOGGING = "x-ms-body-logging";
private static final ObjectMapper MAPPER = new ObjectMapper();
private static final ObjectMapper MAPPER = new ObjectMapper().findAndRegisterModules();
private LogLevel logLevel;
/**

Просмотреть файл

@ -56,13 +56,16 @@
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-documentdb</artifactId>
<version>2.6.0</version>
<version>2.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.8.0</version>
<version>12.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.microsoft.bot</groupId>
<artifactId>bot-integration-core</artifactId>
@ -79,10 +82,10 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>24.1.1-jre</version>
</dependency>
<dependency>
<groupId>org.javatuples</groupId>
@ -92,12 +95,11 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.20</version>
<version>1.27</version>
</dependency>
</dependencies>
@ -149,4 +151,30 @@
</build>
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<configuration>
<excludes>com/microsoft/recognizers/**</excludes>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
</project>

Просмотреть файл

@ -13,16 +13,16 @@ import com.microsoft.bot.connector.Async;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
/**
* A collection of Dialog objects that can all call each other.
*/
public class DialogSet {
private Map<String, Dialog> dialogs = new HashedMap<>();
private Map<String, Dialog> dialogs = new HashMap<>();
private StatePropertyAccessor<DialogState> dialogState;
@JsonIgnore
private BotTelemetryClient telemetryClient;

Просмотреть файл

@ -22,73 +22,8 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
import org.apache.commons.collections4.IteratorUtils;
import org.apache.commons.lang3.StringUtils;
/**
* Generic Arraylist of Object.
*/
class Segments extends ArrayList<Object> {
/**
* Returns the first item in the collection.
* @return the first object.
*/
public Object first() {
return get(0);
}
/**
* Returns the last item in the collection.
* @return the last object.
*/
public Object last() {
return get(size() - 1);
}
/**
* Gets the SegmentType at the specified index.
* @param index Index of the requested segment.
* @return The SegmentType of item at the requested index.
*/
public SegmentType getSegment(int index) {
return new SegmentType(get(index));
}
}
/**
* A class wraps an Object and can assist in determining if it's an integer.
*/
@SuppressWarnings("checkstyle:VisibilityModifier")
class SegmentType {
public boolean isInt;
public int intValue;
public Segments segmentsValue;
public String stringValue;
/**
*
* @param value The object to create a SegmentType for.
*/
SegmentType(Object value) {
try {
intValue = Integer.parseInt((String) value);
isInt = true;
} catch (NumberFormatException e) {
isInt = false;
}
if (!isInt) {
if (value instanceof Segments) {
segmentsValue = (Segments) value;
} else {
stringValue = (String) value;
}
}
}
}
/**
* Helper methods for working with dynamic json objects.
*/
@ -307,7 +242,9 @@ public final class ObjectPath {
} else if (obj instanceof Map) {
return ((Map<String, Object>) obj).keySet();
} else if (obj instanceof JsonNode) {
return IteratorUtils.toList(((JsonNode) obj).fieldNames());
List<String> fields = new ArrayList<>();
((JsonNode) obj).fieldNames().forEachRemaining(fields::add);
return fields;
} else {
List<String> fields = new ArrayList<>();
for (Field field : obj.getClass().getDeclaredFields()) {

Просмотреть файл

@ -0,0 +1,33 @@
package com.microsoft.bot.dialogs;
/**
* A class wraps an Object and can assist in determining if it's an integer.
*/
@SuppressWarnings("checkstyle:VisibilityModifier")
class SegmentType {
public boolean isInt;
public int intValue;
public Segments segmentsValue;
public String stringValue;
/**
* @param value The object to create a SegmentType for.
*/
SegmentType(Object value) {
try {
intValue = Integer.parseInt((String) value);
isInt = true;
} catch (NumberFormatException e) {
isInt = false;
}
if (!isInt) {
if (value instanceof Segments) {
segmentsValue = (Segments) value;
} else {
stringValue = (String) value;
}
}
}
}

Просмотреть файл

@ -0,0 +1,37 @@
package com.microsoft.bot.dialogs;
import java.util.ArrayList;
/**
* Generic Arraylist of Object.
*/
class Segments extends ArrayList<Object> {
/**
* Returns the first item in the collection.
*
* @return the first object.
*/
public Object first() {
return get(0);
}
/**
* Returns the last item in the collection.
*
* @return the last object.
*/
public Object last() {
return get(size() - 1);
}
/**
* Gets the SegmentType at the specified index.
*
* @param index Index of the requested segment.
* @return The SegmentType of item at the requested index.
*/
public SegmentType getSegment(int index) {
return new SegmentType(get(index));
}
}

Просмотреть файл

@ -52,6 +52,8 @@ public class DialogStateManager implements Map<String, Object> {
private final DialogContext dialogContext;
private int version;
private ObjectMapper mapper = new ObjectMapper().findAndRegisterModules();
/**
* Initializes a new instance of the
* {@link com.microsoft.bot.dialogs.memory.DialogStateManager} class.
@ -147,7 +149,6 @@ public class DialogStateManager implements Map<String, Object> {
if (key.indexOf(SEPARATORS[0]) == -1 && key.indexOf(SEPARATORS[1]) == -1) {
MemoryScope scope = getMemoryScope(key);
if (scope != null) {
ObjectMapper mapper = new ObjectMapper();
try {
scope.setMemory(dialogContext, mapper.writeValueAsString(element));
} catch (JsonProcessingException e) {
@ -398,7 +399,6 @@ public class DialogStateManager implements Map<String, Object> {
}
if (value != null) {
ObjectMapper mapper = new ObjectMapper();
value = mapper.valueToTree(value);
}
@ -433,7 +433,6 @@ public class DialogStateManager implements Map<String, Object> {
* @return JsonNode that which represents all memory scopes.
*/
public JsonNode getMemorySnapshot() {
ObjectMapper mapper = new ObjectMapper();
ObjectNode result = mapper.createObjectNode();
List<MemoryScope> scopes = configuration.getMemoryScopes().stream().filter((x) -> x.getIncludeInSnapshot())

Просмотреть файл

@ -3,15 +3,15 @@
package com.microsoft.bot.dialogs.memory.scopes;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.microsoft.bot.schema.Serialization;
import java.util.Optional;
import com.microsoft.bot.dialogs.DialogContext;
import com.microsoft.bot.dialogs.DialogInstance;
import com.microsoft.bot.dialogs.ScopePath;
import org.json.JSONArray;
import org.json.JSONObject;
/**
* DialogContextMemoryScope maps "dialogcontext" -> properties.
*/
@ -39,8 +39,8 @@ public class DialogContextMemoryScope extends MemoryScope {
throw new IllegalArgumentException("dialogContext cannot be null.");
}
JSONObject memory = new JSONObject();
JSONArray stack = new JSONArray();
ObjectNode memory = Serialization.createObjectNode();
ArrayNode stack = Serialization.createArrayNode();
DialogContext currentDc = dialogContext;
// go to leaf node
@ -52,7 +52,7 @@ public class DialogContextMemoryScope extends MemoryScope {
// (PORTERS NOTE: javascript stack is reversed with top of stack on end)
currentDc.getStack().forEach(item -> {
if (item.getId().startsWith("ActionScope[")) {
stack.put(item.getId());
stack.add(item.getId());
}
});
@ -61,7 +61,7 @@ public class DialogContextMemoryScope extends MemoryScope {
}
// top of stack is stack[0].
memory.put(stackKey, stack);
memory.set(stackKey, stack);
memory.put(activeDialogKey, Optional.ofNullable(dialogContext)
.map(DialogContext::getActiveDialog)
.map(DialogInstance::getId)

Просмотреть файл

@ -230,11 +230,7 @@ public class ComponentDialogTests {
new TestFlow(adapter, (turnContext) -> {
DialogState state = dialogState.get(turnContext, () -> new DialogState()).join();
DialogSet dialogs = new DialogSet(dialogState);
try {
dialogs.add(new TestComponentDialog());
} catch (UnsupportedDataTypeException e) {
e.printStackTrace();
}
dialogs.add(new TestComponentDialog());
DialogContext dc = dialogs.createContext(turnContext).join();
@ -272,11 +268,7 @@ public class ComponentDialogTests {
DialogState state = dialogState.get(turnContext, () -> new DialogState()).join();
DialogSet dialogs = new DialogSet(dialogState);
try {
dialogs.add(new TestNestedComponentDialog());
} catch (UnsupportedDataTypeException e) {
e.printStackTrace();
}
dialogs.add(new TestNestedComponentDialog());
DialogContext dc = dialogs.createContext(turnContext).join();
@ -491,7 +483,7 @@ public class ComponentDialogTests {
}
private class TestComponentDialog extends ComponentDialog {
private TestComponentDialog() throws UnsupportedDataTypeException {
private TestComponentDialog() {
super("TestComponentDialog");
addDialog(createWaterfall());
addDialog(new NumberPrompt<Integer>("number", null, PromptCultureModels.ENGLISH_CULTURE, Integer.class));
@ -499,7 +491,7 @@ public class ComponentDialogTests {
}
private final class TestNestedComponentDialog extends ComponentDialog {
private TestNestedComponentDialog() throws UnsupportedDataTypeException {
private TestNestedComponentDialog() {
super("TestNestedComponentDialog");
WaterfallStep[] steps = new WaterfallStep[] {
new WaterfallStep1(),

Просмотреть файл

@ -180,6 +180,7 @@ public class DialogStateManagerTests {
DialogTestFunction testFunction = dc -> {
ObjectMapper mapper = new ObjectMapper();
mapper.findAndRegisterModules();
String[] array = new String[] {
"test1",

Просмотреть файл

@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
@ -259,5 +260,13 @@ public final class Serialization {
public static ObjectNode createObjectNode() {
return objectMapper.createObjectNode();
}
/**
* Creates an ArrayNode.
* @return ArrayNode.
*/
public static ArrayNode createArrayNode() {
return objectMapper.createArrayNode();
}
}

23
pom.xml
Просмотреть файл

@ -243,22 +243,22 @@
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-parameter-names</artifactId>
<version>2.9.9</version>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<version>2.9.9</version>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.9</version>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.10.7</version>
<version>2.12.1</version>
</dependency>
<dependency>
@ -269,12 +269,12 @@
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.8.2</version>
<version>3.13.0</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>jwks-rsa</artifactId>
<version>0.8.3</version>
<version>0.15.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@ -289,7 +289,12 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1-jre</version>
</dependency>
<dependency>
@ -590,12 +595,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
<version>3.9.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.1</version>
</plugin>
</plugins>