Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ For more information jump to a section below.

| Branch | Description | Build Status | Coverage Status |
|--------|-------------|--------------|-----------------|
|Main | Preview 8 Builds | [![Build Status](https://travis-ci.org/Microsoft/botbuilder-java.svg?branch=main)](https://travis-ci.org/Microsoft/botbuilder-java) | [![Coverage Status](https://coveralls.io/repos/github/microsoft/botbuilder-java/badge.svg?branch=823847c676b7dbb0fa348a308297ae375f5141ef)](https://coveralls.io/github/microsoft/botbuilder-java?branch=823847c676b7dbb0fa348a308297ae375f5141ef) |
|Main | Preview 8 Builds | [![Build Status](https://fuselabs.visualstudio.com/SDK_v4/_apis/build/status/Java/BotBuilder-Java-4.0-daily?branchName=main)](https://fuselabs.visualstudio.com/SDK_v4/_build/latest?definitionId=1202&branchName=main) | [![Coverage Status](https://coveralls.io/repos/github/microsoft/botbuilder-java/badge.svg?branch=823847c676b7dbb0fa348a308297ae375f5141ef)](https://coveralls.io/github/microsoft/botbuilder-java?branch=823847c676b7dbb0fa348a308297ae375f5141ef) |

## Getting Started
To get started building bots using the SDK, see the [Azure Bot Service Documentation](https://docs.microsoft.com/en-us/azure/bot-service/?view=azure-bot-service-4.0).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.microsoft.bot.builder.UserState;
import com.microsoft.bot.builder.adapters.TestAdapter;
import com.microsoft.bot.builder.adapters.TestFlow;
import com.microsoft.bot.connector.Async;
import com.microsoft.bot.dialogs.Dialog;
import com.microsoft.bot.dialogs.DialogContext;
import com.microsoft.bot.dialogs.DialogManager;
Expand Down Expand Up @@ -167,13 +168,13 @@ public CompletableFuture<DialogTurnResult> beginDialog(DialogContext dc, Object
try {
date = LocalDateTime.parse(dateString);
} catch (DateTimeParseException ex) {
throw new IllegalArgumentException("Date is invalid");
return Async.completeExceptionally(new IllegalArgumentException("Date is invalid"));
}

ZonedDateTime zonedDate = date.atZone(ZoneOffset.UTC);
ZonedDateTime now = LocalDateTime.now().atZone(ZoneOffset.UTC);
if (zonedDate.isBefore(now)) {
throw new IllegalArgumentException("Date must be in the future");
return Async.completeExceptionally(new IllegalArgumentException("Date must be in the future"));
}

// create ContinuationActivity from the conversation reference.
Expand All @@ -185,7 +186,7 @@ public CompletableFuture<DialogTurnResult> beginDialog(DialogContext dc, Object

QueueStorage queueStorage = dc.getContext().getTurnState().get("QueueStorage");
if (queueStorage == null) {
throw new NullPointerException("Unable to locate QueueStorage in HostContext");
return Async.completeExceptionally(new NullPointerException("Unable to locate QueueStorage in HostContext"));
}
return queueStorage.queueActivity(activity, visibility, ttl).thenCompose(receipt -> {
// return the receipt as the result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.microsoft.bot.builder.TranscriptStore;
import com.microsoft.bot.builder.adapters.TestAdapter;
import com.microsoft.bot.builder.adapters.TestFlow;
import com.microsoft.bot.connector.Async;
import com.microsoft.bot.schema.Activity;
import com.microsoft.bot.schema.ActivityTypes;
import com.microsoft.bot.schema.ChannelAccount;
Expand Down Expand Up @@ -536,7 +537,7 @@ private CompletableFuture<PagedResult<Activity>> getPagedResult(ConversationRefe
}

if(pagedResult == null) {
throw new TimeoutException("Unable to retrieve pagedResult in time");
return Async.completeExceptionally(new TimeoutException("Unable to retrieve pagedResult in time"));
}

return CompletableFuture.completedFuture(pagedResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.microsoft.bot.builder;

import com.microsoft.bot.connector.Async;
import com.microsoft.bot.schema.*;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -467,23 +468,23 @@ public CompletableFuture<ResourceResponse[]> sendActivities(
TurnContext context,
List<Activity> activities
) {
throw new RuntimeException();
return Async.completeExceptionally(new RuntimeException());
}

@Override
public CompletableFuture<ResourceResponse> updateActivity(
TurnContext context,
Activity activity
) {
throw new RuntimeException();
return Async.completeExceptionally(new RuntimeException());
}

@Override
public CompletableFuture<Void> deleteActivity(
TurnContext context,
ConversationReference reference
) {
throw new RuntimeException();
return Async.completeExceptionally(new RuntimeException());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public CompletableFuture<Void> delete(String[] keys) {
Assert.assertEquals(1, readCount[0]);
Assert.assertEquals(0, storeCount[0]);

propertyA.set(context, "there");
propertyA.set(context, "there").join();
Assert.assertEquals(0, storeCount[0]); // Set on property should not bump

userState.saveChanges(context).join();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ public void ValidateIMBackWithNoTest() {
null
);

turnContext.sendActivity(activity);
turnContext.sendActivity(activity).join();
}
return CompletableFuture.completedFuture(null);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void OnTurnError_Test() {

new TestFlow(adapter, (turnContext -> {
if (StringUtils.equals(turnContext.getActivity().getText(), "foo")) {
turnContext.sendActivity(turnContext.getActivity().getText());
turnContext.sendActivity(turnContext.getActivity().getText()).join();
}

if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void SkillConversationIdFactoryHappyPath() {
skillConversationIdFactory.getSkillConversationReference(skillConversationId).join();

// Delete
skillConversationIdFactory.deleteConversationReference(skillConversationId);
skillConversationIdFactory.deleteConversationReference(skillConversationId).join();

// Retrieve again
SkillConversationReference deletedConversationReference =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.microsoft.bot.builder.adapters.TestAdapter;
import com.microsoft.bot.builder.adapters.TestFlow;
import com.microsoft.bot.connector.Async;
import com.microsoft.bot.schema.ActionTypes;
import com.microsoft.bot.schema.Activity;
import com.microsoft.bot.schema.ActivityTypes;
Expand Down Expand Up @@ -71,7 +72,7 @@ public void TestAdapter_ExceptionInBotOnReceive() {
try {

new TestFlow(adapter, turnContext -> {
throw new RuntimeException(uniqueExceptionId);
return Async.completeExceptionally(new RuntimeException(uniqueExceptionId));
}).test("foo", activity -> {
Assert.assertNull(activity);
}).startTest().join();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.microsoft.bot.builder.adapters.TestAdapter;
import com.microsoft.bot.builder.adapters.TestFlow;
import com.microsoft.bot.connector.Async;
import com.microsoft.bot.connector.Attachments;
import com.microsoft.bot.connector.ConnectorClient;
import com.microsoft.bot.connector.Conversations;
Expand Down Expand Up @@ -63,7 +64,7 @@ public void CacheValueUsingSetAndGet() {

case "TestResponded":
if (turnContext.getResponded()) {
throw new RuntimeException("Responded is true");
return Async.completeExceptionally(new RuntimeException("Responded is true"));
}

return turnContext.sendActivity(
Expand Down Expand Up @@ -419,7 +420,7 @@ public void DeleteOneActivityToAdapter() {

TurnContext c = new TurnContextImpl(a, TestMessage.Message());

c.deleteActivity("12345");
c.deleteActivity("12345").join();
Assert.assertTrue(activityDeleted[0]);
}

Expand All @@ -440,7 +441,7 @@ public void DeleteConversationReferenceToAdapter() {
}
};

c.deleteActivity(reference);
c.deleteActivity(reference).join();
Assert.assertTrue(activityDeleted[0]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.microsoft.bot.builder.MessageFactory;
import com.microsoft.bot.builder.TurnContext;
import com.microsoft.bot.builder.TurnContextImpl;
import com.microsoft.bot.connector.Async;
import com.microsoft.bot.schema.Activity;
import com.microsoft.bot.schema.ActivityTypes;
import com.microsoft.bot.schema.ChannelAccount;
Expand Down Expand Up @@ -346,23 +347,23 @@ public CompletableFuture<ResourceResponse[]> sendActivities(
TurnContext context,
List<Activity> activities
) {
throw new RuntimeException();
return Async.completeExceptionally(new RuntimeException());
}

@Override
public CompletableFuture<ResourceResponse> updateActivity(
TurnContext context,
Activity activity
) {
throw new RuntimeException();
return Async.completeExceptionally(new RuntimeException());
}

@Override
public CompletableFuture<Void> deleteActivity(
TurnContext context,
ConversationReference reference
) {
throw new RuntimeException();
return Async.completeExceptionally(new RuntimeException());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void PromptValidatorContextRetryEnd() {
return CompletableFuture.completedFuture(true);
} else {
promptContext.getContext().sendActivity(
MessageFactory.text("Please send a name that is longer than 3 characters."));
MessageFactory.text("Please send a name that is longer than 3 characters.")).join();
}

return CompletableFuture.completedFuture(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public void ShouldThrowHttpExceptionOnPostFailure() {
conversationState);

// Send something to the dialog
Assert.assertThrows(Exception.class, () -> client.sendActivity("irrelevant"));
Assert.assertThrows(Exception.class, () -> client.sendActivity("irrelevant").join());
}

@Test
Expand Down Expand Up @@ -548,7 +548,7 @@ public void EndOfConversationFromExpectRepliesCallsDeleteConversationReference()
conversationState);

// Send something to the dialog to start it
client.sendActivity("hello");
client.sendActivity("hello").join();

SimpleConversationIdFactory factory = null;
if (dialogOptions.getConversationIdFactory() != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ public void Waterfall() {
DialogSet dialogs = new DialogSet(dialogState);
WaterfallStep[] steps = new WaterfallStep[]
{(step) -> {
step.getContext().sendActivity("step1");
step.getContext().sendActivity("step1").join();
return CompletableFuture.completedFuture(Dialog.END_OF_TURN);
}, (step) -> {
step.getContext().sendActivity("step2");
step.getContext().sendActivity("step2").join();
return CompletableFuture.completedFuture(Dialog.END_OF_TURN);
}, (step) -> {
step.getContext().sendActivity("step3");
step.getContext().sendActivity("step3").join();
return CompletableFuture.completedFuture(Dialog.END_OF_TURN);
},
};
Expand Down Expand Up @@ -140,13 +140,13 @@ public void WaterfallWithCallback() {
StatePropertyAccessor<DialogState> dialogState = convoState.createProperty("dialogState");
DialogSet dialogs = new DialogSet(dialogState);
WaterfallStep[] steps = new WaterfallStep[] {(step) -> {
step.getContext().sendActivity("step1");
step.getContext().sendActivity("step1").join();
return CompletableFuture.completedFuture(Dialog.END_OF_TURN);
}, (step) -> {
step.getContext().sendActivity("step2");
step.getContext().sendActivity("step2").join();
return CompletableFuture.completedFuture(Dialog.END_OF_TURN);
}, (step) -> {
step.getContext().sendActivity("step3");
step.getContext().sendActivity("step3").join();
return CompletableFuture.completedFuture(Dialog.END_OF_TURN);
}, };
WaterfallDialog waterfallDialog = new WaterfallDialog("test", Arrays.asList(steps));
Expand Down Expand Up @@ -375,7 +375,7 @@ private WaterfallDialog Create_Waterfall2() {
private class Waterfall2_Step1 implements WaterfallStep {
@Override
public CompletableFuture<DialogTurnResult> waterfallStep(WaterfallStepContext stepContext) {
stepContext.getContext().sendActivity("step1");
stepContext.getContext().sendActivity("step1").join();
PromptOptions options = new PromptOptions();
options.setPrompt(MessageFactory.text("Enter a number."));
options.setRetryPrompt(MessageFactory.text("It must be a number"));
Expand All @@ -388,10 +388,10 @@ private class Waterfall2_Step2 implements WaterfallStep {
public CompletableFuture<DialogTurnResult> waterfallStep(WaterfallStepContext stepContext) {
if (stepContext.getValues() != null) {
int numberResult = (int) stepContext.getResult();
stepContext.getContext().sendActivity(String.format("Thanks for '%d'", numberResult));
stepContext.getContext().sendActivity(String.format("Thanks for '%d'", numberResult)).join();
}

stepContext.getContext().sendActivity("step2");
stepContext.getContext().sendActivity("step2").join();
PromptOptions options = new PromptOptions();
options.setPrompt(MessageFactory.text("Enter a number."));
options.setRetryPrompt(MessageFactory.text("It must be a number"));
Expand All @@ -404,10 +404,10 @@ private class Waterfall2_Step3 implements WaterfallStep {
public CompletableFuture<DialogTurnResult> waterfallStep(WaterfallStepContext stepContext) {
if (stepContext.getValues() != null) {
int numberResult = (int) stepContext.getResult();
stepContext.getContext().sendActivity(String.format("Thanks for '%d'", numberResult));
stepContext.getContext().sendActivity(String.format("Thanks for '%d'", numberResult)).join();
}

stepContext.getContext().sendActivity("step3");
stepContext.getContext().sendActivity("step3").join();
Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put("Value", "All Done!");
return stepContext.endDialog(resultMap);
Expand All @@ -416,47 +416,47 @@ public CompletableFuture<DialogTurnResult> waterfallStep(WaterfallStepContext st
private class Waterfall3_Step1 implements WaterfallStep {
@Override
public CompletableFuture<DialogTurnResult> waterfallStep(WaterfallStepContext stepContext) {
stepContext.getContext().sendActivity(MessageFactory.text("step1"));
stepContext.getContext().sendActivity(MessageFactory.text("step1")).join();
return stepContext.beginDialog("test-waterfall-b", null);
}
}

private class Waterfall3_Step2 implements WaterfallStep {
@Override
public CompletableFuture<DialogTurnResult> waterfallStep(WaterfallStepContext stepContext) {
stepContext.getContext().sendActivity(MessageFactory.text("step2"));
stepContext.getContext().sendActivity(MessageFactory.text("step2")).join();
return stepContext.beginDialog("test-waterfall-c", null);
}
}

private class Waterfall4_Step1 implements WaterfallStep {
@Override
public CompletableFuture<DialogTurnResult> waterfallStep(WaterfallStepContext stepContext) {
stepContext.getContext().sendActivity(MessageFactory.text("step1.1"));
stepContext.getContext().sendActivity(MessageFactory.text("step1.1")).join();
return CompletableFuture.completedFuture(Dialog.END_OF_TURN);
}
}

private class Waterfall4_Step2 implements WaterfallStep {
@Override
public CompletableFuture<DialogTurnResult> waterfallStep(WaterfallStepContext stepContext) {
stepContext.getContext().sendActivity(MessageFactory.text("step1.2"));
stepContext.getContext().sendActivity(MessageFactory.text("step1.2")).join();
return CompletableFuture.completedFuture(Dialog.END_OF_TURN);
}
}

private class Waterfall5_Step1 implements WaterfallStep {
@Override
public CompletableFuture<DialogTurnResult> waterfallStep(WaterfallStepContext stepContext) {
stepContext.getContext().sendActivity(MessageFactory.text("step2.1"));
stepContext.getContext().sendActivity(MessageFactory.text("step2.1")).join();
return CompletableFuture.completedFuture(Dialog.END_OF_TURN);
}
}

private class Waterfall5_Step2 implements WaterfallStep {
@Override
public CompletableFuture<DialogTurnResult> waterfallStep(WaterfallStepContext stepContext) {
stepContext.getContext().sendActivity(MessageFactory.text("step2.2"));
stepContext.getContext().sendActivity(MessageFactory.text("step2.2")).join();
return stepContext.endDialog();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ public void ShouldCallCustomValidator() {
DialogSet dialogs = new DialogSet(dialogState);

PromptValidator<FoundChoice> validator = (promptContext) -> {
promptContext.getContext().sendActivity(MessageFactory.text("validator called"));
promptContext.getContext().sendActivity(MessageFactory.text("validator called")).join();
return CompletableFuture.completedFuture(true);
};

Expand Down
Loading