* Updates for Issue 1065

* Tweak to kick off new build.
This commit is contained in:
Lee Parrish 2021-03-22 15:37:31 -05:00 коммит произвёл GitHub
Родитель 3ca313aea3
Коммит 5d3d1c3cd7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 88 добавлений и 6 удалений

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

@ -311,13 +311,16 @@ public abstract class Dialog {
public static CompletableFuture<Void> run(Dialog dialog, TurnContext turnContext,
StatePropertyAccessor<DialogState> accessor) {
DialogSet dialogSet = new DialogSet(accessor);
dialogSet.add(dialog);
dialogSet.setTelemetryClient(dialog.getTelemetryClient());
if (turnContext.getTurnState().get(BotTelemetryClient.class) != null) {
dialogSet.setTelemetryClient(turnContext.getTurnState().get(BotTelemetryClient.class));
} else if (dialog.getTelemetryClient() != null) {
dialogSet.setTelemetryClient(dialog.getTelemetryClient());
} else {
dialogSet.setTelemetryClient(new NullBotTelemetryClient());
}
dialogSet.add(dialog);
// return dialogSet.createContext(turnContext)
// .thenCompose(dialogContext -> continueOrStart(dialogContext, dialog,
// turnContext))
// .thenApply(result -> null);
return dialogSet.createContext(turnContext)
.thenAccept(dialogContext -> innerRun(turnContext, dialog.getId(), dialogContext));
}

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

@ -3,6 +3,8 @@
package com.microsoft.bot.dialogs;
import java.time.Duration;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -12,13 +14,16 @@ import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;
import com.microsoft.bot.builder.BotAdapter;
import com.microsoft.bot.builder.BotTelemetryClient;
import com.microsoft.bot.builder.ConversationState;
import com.microsoft.bot.builder.MemoryStorage;
import com.microsoft.bot.builder.SendActivitiesHandler;
import com.microsoft.bot.builder.Severity;
import com.microsoft.bot.builder.Storage;
import com.microsoft.bot.builder.TraceTranscriptLogger;
import com.microsoft.bot.builder.TranscriptLoggerMiddleware;
import com.microsoft.bot.builder.TurnContext;
import com.microsoft.bot.builder.TurnContextImpl;
import com.microsoft.bot.builder.skills.SkillConversationReference;
import com.microsoft.bot.builder.skills.SkillHandler;
import com.microsoft.bot.connector.authentication.AuthenticationConstants;
@ -30,6 +35,7 @@ import com.microsoft.bot.dialogs.prompts.PromptOptions;
import com.microsoft.bot.dialogs.prompts.TextPrompt;
import com.microsoft.bot.schema.Activity;
import com.microsoft.bot.schema.ActivityTypes;
import com.microsoft.bot.schema.ConversationAccount;
import com.microsoft.bot.schema.ResourceResponse;
import com.microsoft.bot.schema.ResultPair;
@ -189,6 +195,22 @@ public class DialogManagerTests {
.join();
}
@Test
public void RunShouldSetTelemetryClient() {
TestAdapter adapter = new TestAdapter();
Dialog dialog = CreateTestDialog("conversation.name");
ConversationState conversationState = new ConversationState(new MemoryStorage());
Activity activity = new Activity(ActivityTypes.MESSAGE);
activity.setChannelId("test-channel");
ConversationAccount conversation = new ConversationAccount("test-conversation-id");
activity.setConversation(conversation);
MockBotTelemetryClient telemetryClient = new MockBotTelemetryClient();
TurnContext turnContext = new TurnContextImpl(adapter, activity);
turnContext.getTurnState().add(BotTelemetryClient.class.getName(), telemetryClient);
Dialog.run(dialog, turnContext, conversationState.createProperty("DialogState"));
Assert.assertEquals(telemetryClient, dialog.getTelemetryClient());
}
// @Test
// public CompletableFuture<Void> DialogManager_OnErrorEvent_Leaf() {
// TestUtilities.RunTestScript();
@ -559,4 +581,61 @@ public class DialogManagerTests {
return outerDc.endDialog(result);
}
}
private class MockBotTelemetryClient implements BotTelemetryClient {
@Override
public void trackAvailability(
String name,
OffsetDateTime timeStamp,
Duration duration,
String runLocation,
boolean success,
String message,
Map<String, String> properties,
Map<String, Double> metrics
) {
}
@Override
public void trackDependency(
String dependencyTypeName,
String target,
String dependencyName,
String data,
OffsetDateTime startTime,
Duration duration,
String resultCode,
boolean success
) {
}
@Override
public void trackEvent(String eventName, Map<String, String> properties, Map<String, Double> metrics) {
}
@Override
public void trackException(Exception exception, Map<String, String> properties, Map<String, Double> metrics) {
}
@Override
public void trackTrace(String message, Severity severityLevel, Map<String, String> properties) {
}
@Override
public void trackDialogView(String dialogName, Map<String, String> properties, Map<String, Double> metrics) {
}
@Override
public void flush() {
}
}
}