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

Added a gaggle of missing joins in unit tests #1099

Merged
merged 3 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -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 @@ -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
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,31 +416,31 @@ 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ public void OAuthPromptWithMagicCode() {
dc.prompt("OAuthPrompt", new PromptOptions());
} else if (results.getStatus() == DialogTurnStatus.COMPLETE) {
if (results.getResult() instanceof TokenResponse) {
turnContext.sendActivity(MessageFactory.text("Logged in."));
turnContext.sendActivity(MessageFactory.text("Logged in.")).join();
} else {
turnContext.sendActivity(MessageFactory.text("Failed."));
turnContext.sendActivity(MessageFactory.text("Failed.")).join();
}
}
return CompletableFuture.completedFuture(null);
Expand Down Expand Up @@ -599,9 +599,9 @@ private void OAuthPrompt(Storage storage) {
dc.prompt("OAuthPrompt", new PromptOptions());
} else if (results.getStatus() == DialogTurnStatus.COMPLETE) {
if (results.getResult() instanceof TokenResponse) {
turnContext.sendActivity(MessageFactory.text("Logged in."));
turnContext.sendActivity(MessageFactory.text("Logged in.")).join();
} else {
turnContext.sendActivity(MessageFactory.text("Failed."));
turnContext.sendActivity(MessageFactory.text("Failed.")).join();
}
}
return CompletableFuture.completedFuture(null);
Expand Down