Merge branch 'master' into tb-botbuilder

# Conflicts:
#	libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotFrameworkAdapter.java
This commit is contained in:
Tracy Boehrer 2019-09-09 15:02:44 -05:00
Родитель 0b8f4e2e67 5a3fcb6f19
Коммит ff682e6537
12 изменённых файлов: 77 добавлений и 477 удалений

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

@ -16,17 +16,6 @@ import java.util.concurrent.CompletableFuture;
* in Attachments.
*/
public interface Attachments {
/**
* GetAttachmentInfo.
* Get AttachmentInfo structure describing the attachment views.
*
* @param attachmentId attachment id
* @return the AttachmentInfo object if successful.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
*/
AttachmentInfo getAttachmentInfo(String attachmentId);
/**
* GetAttachmentInfo.
* Get AttachmentInfo structure describing the attachment views.
@ -37,18 +26,6 @@ public interface Attachments {
*/
CompletableFuture<AttachmentInfo> getAttachmentInfo(String attachmentId);
/**
* GetAttachment.
* Get the named view as binary content.
*
* @param attachmentId attachment id
* @param viewId View id from attachmentInfo
* @return the InputStream object if successful.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
*/
InputStream getAttachment(String attachmentId, String viewId);
/**
* GetAttachment.
* Get the named view as binary content.

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

@ -21,23 +21,6 @@ import java.util.concurrent.CompletableFuture;
* in Conversations.
*/
public interface Conversations {
/**
* GetConversations.
* List the Conversations in which this bot has participated.
* GET from this method with a skip token
* The return value is a ConversationsResult, which contains an array of ConversationMembers and a skip token.
* If the skip token is not empty, then there are further values to be returned. Call this method again with
* the returned token to get more values.
*
* Each ConversationMembers object contains the ID of the conversation and an array of ChannelAccounts that
* describe the members of the conversation.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the ConversationsResult object if successful.
*/
ConversationsResult getConversations();
/**
* GetConversations.
* List the Conversations in which this bot has participated.
@ -54,24 +37,6 @@ public interface Conversations {
*/
CompletableFuture<ConversationsResult> getConversations();
/**
* GetConversations.
* List the Conversations in which this bot has participated.
* GET from this method with a skip token
* The return value is a ConversationsResult, which contains an array of ConversationMembers and a skip token.
* If the skip token is not empty, then there are further values to be returned. Call this method again with the
* returned token to get more values.
*
* Each ConversationMembers object contains the ID of the conversation and an array of ChannelAccounts that
* describe the members of the conversation.
*
* @param continuationToken skip or continuation token
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the ConversationsResult object if successful.
*/
ConversationsResult getConversations(String continuationToken);
/**
* GetConversations.
* List the Conversations in which this bot has participated.
@ -88,30 +53,6 @@ public interface Conversations {
*/
CompletableFuture<ConversationsResult> getConversations(String continuationToken);
/**
* CreateConversation.
* Create a new Conversation.
* POST to this method with a
* Bot being the bot creating the conversation
* IsGroup set to true if this is not a direct message (default is false)
* Members array contining the members you want to have be in the conversation.
* The return value is a ResourceResponse which contains a conversation id which is suitable for use in the
* message payload and REST API uris.
* Most channels only support the semantics of bots initiating a direct message conversation. An example of how
* to do that would be:
* ```
* var resource = await connector.conversations.CreateConversation(new ConversationParameters(){ Bot = bot,
* members = new ChannelAccount[] { new ChannelAccount("user1") } );
* await connect.Conversations.SendToConversation(resource.Id, new Activity() ... ) ;
* ```.
*
* @param parameters Parameters to create the conversation from
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the ConversationResourceResponse object if successful.
*/
ConversationResourceResponse createConversation(ConversationParameters parameters);
/**
* CreateConversation.
* Create a new Conversation.
@ -135,25 +76,6 @@ public interface Conversations {
*/
CompletableFuture<ConversationResourceResponse> createConversation(ConversationParameters parameters);
/**
* SendToConversation.
* This method allows you to send an activity to the end of a conversation.
* This is slightly different from ReplyToActivity().
* SendToConverstion(conversationId) - will append the activity to the end of the conversation according to the
* timestamp or semantics of the channel.
* ReplyToActivity(conversationId,ActivityId) - adds the activity as a reply to another activity, if the channel
* supports it. If the channel does not support nested replies, ReplyToActivity falls back to SendToConversation.
* Use ReplyToActivity when replying to a specific activity in the conversation.
* Use SendToConversation in all other cases.
*
* @param conversationId Conversation ID
* @param activity Activity to send
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the ResourceResponse object if successful.
*/
ResourceResponse sendToConversation(String conversationId, Activity activity);
/**
* SendToConversation.
* This method allows you to send an activity to the end of a conversation.
@ -172,21 +94,6 @@ public interface Conversations {
*/
CompletableFuture<ResourceResponse> sendToConversation(String conversationId, Activity activity);
/**
* UpdateActivity.
* Edit an existing activity.
* Some channels allow you to edit an existing activity to reflect the new state of a bot conversation.
* For example, you can remove buttons after someone has clicked "Approve" button.
*
* @param conversationId Conversation ID
* @param activityId activityId to update
* @param activity replacement Activity
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the ResourceResponse object if successful.
*/
ResourceResponse updateActivity(String conversationId, String activityId, Activity activity);
/**
* UpdateActivity.
* Edit an existing activity.
@ -201,26 +108,6 @@ public interface Conversations {
*/
CompletableFuture<ResourceResponse> updateActivity(String conversationId, String activityId, Activity activity);
/**
* ReplyToActivity.
* This method allows you to reply to an activity.
* This is slightly different from SendToConversation().
* SendToConverstion(conversationId) - will append the activity to the end of the conversation according to the
* timestamp or semantics of the channel.
* ReplyToActivity(conversationId,ActivityId) - adds the activity as a reply to another activity, if the channel
* supports it. If the channel does not support nested replies, ReplyToActivity falls back to SendToConversation.
* Use ReplyToActivity when replying to a specific activity in the conversation.
* Use SendToConversation in all other cases.
*
* @param conversationId Conversation ID
* @param activityId activityId the reply is to (OPTIONAL)
* @param activity Activity to send
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the ResourceResponse object if successful.
*/
ResourceResponse replyToActivity(String conversationId, String activityId, Activity activity);
/**
* ReplyToActivity.
* This method allows you to reply to an activity.
@ -240,19 +127,6 @@ public interface Conversations {
*/
CompletableFuture<ResourceResponse> replyToActivity(String conversationId, String activityId, Activity activity);
/**
* DeleteActivity.
* Delete an existing activity.
* Some channels allow you to delete an existing activity, and if successful this method will remove the
* specified activity.
*
* @param conversationId Conversation ID
* @param activityId activityId to delete
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
*/
void deleteActivity(String conversationId, String activityId);
/**
* DeleteActivity.
* Delete an existing activity.
@ -266,19 +140,6 @@ public interface Conversations {
*/
CompletableFuture<Void> deleteActivity(String conversationId, String activityId);
/**
* GetConversationMembers.
* Enumerate the members of a converstion.
* This REST API takes a ConversationId and returns an array of ChannelAccount objects representing the members
* of the conversation.
*
* @param conversationId Conversation ID
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the List&lt;ChannelAccount&gt; object if successful.
*/
List<ChannelAccount> getConversationMembers(String conversationId);
/**
* GetConversationMembers.
* Enumerate the members of a converstion.
@ -291,19 +152,6 @@ public interface Conversations {
*/
CompletableFuture<List<ChannelAccount>> getConversationMembers(String conversationId);
/**
* DeleteConversationMember.
* Deletes a member from a conversation.
* This REST API takes a ConversationId and a memberId (of type string) and removes that member from the
* conversation. If that member was the last member of the conversation, the conversation will also be deleted.
*
* @param conversationId Conversation ID
* @param memberId ID of the member to delete from this conversation
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
*/
void deleteConversationMember(String conversationId, String memberId);
/**
* DeleteConversationMember.
* Deletes a member from a conversation.
@ -317,20 +165,6 @@ public interface Conversations {
*/
CompletableFuture<Void> deleteConversationMember(String conversationId, String memberId);
/**
* GetActivityMembers.
* Enumerate the members of an activity.
* This REST API takes a ConversationId and a ActivityId, returning an array of ChannelAccount objects
* representing the members of the particular activity in the conversation.
*
* @param conversationId Conversation ID
* @param activityId Activity ID
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the List&lt;ChannelAccount&gt; object if successful.
*/
List<ChannelAccount> getActivityMembers(String conversationId, String activityId);
/**
* GetActivityMembers.
* Enumerate the members of an activity.
@ -344,21 +178,6 @@ public interface Conversations {
*/
CompletableFuture<List<ChannelAccount>> getActivityMembers(String conversationId, String activityId);
/**
* UploadAttachment.
* Upload an attachment directly into a channel's blob storage.
* This is useful because it allows you to store data in a compliant store when dealing with enterprises.
* The response is a ResourceResponse which contains an AttachmentId which is suitable for using with the
* attachments API.
*
* @param conversationId Conversation ID
* @param attachmentUpload Attachment data
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the ResourceResponse object if successful.
*/
ResourceResponse uploadAttachment(String conversationId, AttachmentData attachmentUpload);
/**
* UploadAttachment.
* Upload an attachment directly into a channel's blob storage.
@ -373,21 +192,6 @@ public interface Conversations {
*/
CompletableFuture<ResourceResponse> uploadAttachment(String conversationId, AttachmentData attachmentUpload);
/**
* This method allows you to upload the historic activities to the conversation.
*
* Sender must ensure that the historic activities have unique ids and appropriate timestamps.
* The ids are used by the client to deal with duplicate activities and the timestamps are used by
* the client to render the activities in the right order.
*
* @param conversationId Conversation ID
* @param history Historic activities
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the ResourceResponse object if successful.
*/
ResourceResponse sendConversationHistory(String conversationId, Transcript history);
/**
* This method allows you to upload the historic activities to the conversation.
*
@ -403,28 +207,6 @@ public interface Conversations {
*/
CompletableFuture<ResourceResponse> sendConversationHistory(String conversationId, Transcript history);
/**
* Enumerate the members of a conversation one page at a time.
*
* This REST API takes a ConversationId. Optionally a pageSize and/or continuationToken can be provided.
* It returns a PagedMembersResult, which contains an array of ChannelAccounts representing the members
* of the conversation and a continuation token that can be used to get more values.
*
* One page of ChannelAccounts records are returned with each call. The number of records in a page may
* vary between channels and calls. The pageSize parameter can be used as a suggestion. If there are no
* additional results the response will not contain a continuation token. If there are no members in the
* conversation the Members will be empty or not present in the response.
*
* A response to a request that has a continuation token from a prior request may rarely return members
* from a previous request.
*
* @param conversationId Conversation ID
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the PagedMembersResult object if successful.
*/
PagedMembersResult getConversationPagedMembers(String conversationId);
/**
* Enumerate the members of a conversation one page at a time.
*

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

@ -96,7 +96,7 @@ public class EnterpriseChannelValidation {
public static CompletableFuture<ClaimsIdentity> validateIdentity(ClaimsIdentity identity,
CredentialProvider credentials,
String serviceUrl) {
return CompletableFuture.supply(() -> {
return CompletableFuture.supplyAsync(() -> {
if (identity == null || !identity.isAuthenticated()) {
throw new AuthenticationException("Invalid Identity");
}

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

@ -89,7 +89,7 @@ public class GovernmentChannelValidation {
CredentialProvider credentials,
String serviceUrl) {
return CompletableFuture.supply(() -> {
return CompletableFuture.supplyAsync(() -> {
if (identity == null || !identity.isAuthenticated()) {
throw new AuthenticationException("Invalid Identity");
}

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

@ -92,7 +92,7 @@ public class JwtTokenExtractor {
return CompletableFuture.completedFuture(null);
}
return CompletableFuture.supply(() -> {
return CompletableFuture.supplyAsync(() -> {
Verification verification = JWT.require(Algorithm.RSA256(key.key, null));
try {
verification.build().verify(token);

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

@ -47,7 +47,7 @@ public class JwtTokenValidation {
CredentialProvider credentials,
ChannelProvider channelProvider,
AuthenticationConfiguration authConfig) {
return CompletableFuture.supply(() -> {
return CompletableFuture.supplyAsync(() -> {
if (StringUtils.isEmpty(authHeader)) {
// No auth header was sent. We might be on the anonymous code path.
boolean isAuthDisable = credentials.isAuthenticationDisabled().join();

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

@ -111,7 +111,7 @@ public class OAuthClient extends ServiceClient {
throw new IllegalArgumentException("connectionName");
}
return CompletableFuture.supply(() -> {
return CompletableFuture.supplyAsync(() -> {
// Construct URL
HashMap<String, String> qstrings = new HashMap<>();
qstrings.put("userId", userId);
@ -180,7 +180,7 @@ public class OAuthClient extends ServiceClient {
throw new IllegalArgumentException("connectionName");
}
return CompletableFuture.supply(() -> {
return CompletableFuture.supplyAsync(() -> {
// Construct URL
HashMap<String, String> qstrings = new HashMap<>();
qstrings.put("userId", userId);
@ -264,7 +264,7 @@ public class OAuthClient extends ServiceClient {
String strUri = String.format("%sapi/botsignin/getsigninurl", this.uri);
final URI tokenUrl = MakeUri(strUri, qstrings);
return CompletableFuture.supply(() -> {
return CompletableFuture.supplyAsync(() -> {
// add botframework api service url to the list of trusted service url's for these app credentials.
MicrosoftAppCredentials.trustServiceUrl(tokenUrl);
@ -310,7 +310,7 @@ public class OAuthClient extends ServiceClient {
// add botframework api service url to the list of trusted service url's for these app credentials.
MicrosoftAppCredentials.trustServiceUrl(tokenUrl);
return CompletableFuture.run(() -> {
return CompletableFuture.runAsync(() -> {
// Construct dummy body
RequestBody body = RequestBody.create(JSON, "{}");

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

@ -65,20 +65,6 @@ public class RestAttachments implements Attachments {
}
/**
* GetAttachmentInfo.
* Get AttachmentInfo structure describing the attachment views.
*
* @param attachmentId attachment id
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws ErrorResponseException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the AttachmentInfo object if successful.
*/
public AttachmentInfo getAttachmentInfo(String attachmentId) {
return getAttachmentInfo(attachmentId).join();
}
/**
* GetAttachmentInfo.
* Get AttachmentInfo structure describing the attachment views.
@ -113,21 +99,6 @@ public class RestAttachments implements Attachments {
.build(response);
}
/**
* GetAttachment.
* Get the named view as binary content.
*
* @param attachmentId attachment id
* @param viewId View id from attachmentInfo
* @throws IllegalArgumentException thrown if parameters fail the validation
* @throws ErrorResponseException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the InputStream object if successful.
*/
public InputStream getAttachment(String attachmentId, String viewId) {
return getAttachment(attachmentId, viewId).join();
}
/**
* GetAttachment.
* Get the named view as binary content.

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

@ -138,40 +138,20 @@ public class RestConversations implements Conversations {
@Header("User-Agent") String userAgent);
}
/**
* Implementation of getConversations.
*
* @see Conversations#getConversations
*/
@Override
public ConversationsResult getConversations() {
return getConversations().join();
}
/**
* Implementation of getConversationsAsync.
*
* @see Conversations#getConversationsAsync
* @see Conversations#getConversations
*/
@Override
public CompletableFuture<ConversationsResult> getConversations() {
return getConversations(null);
}
/**
* Implementation of getConversations.
*
* @see Conversations#getConversations
*/
@Override
public ConversationsResult getConversations(String continuationToken) {
return getConversations(continuationToken).join();
}
/**
* Implementation of getConversationsAsync.
*
* @see Conversations#getConversationsAsync
* @see Conversations#getConversations
*/
@Override
public CompletableFuture<ConversationsResult> getConversations(String continuationToken) {
@ -196,20 +176,10 @@ public class RestConversations implements Conversations {
.build(response);
}
/**
* Implementation of CreateConversation.
*
* @see Conversations#createConversation
*/
@Override
public ConversationResourceResponse createConversation(ConversationParameters parameters) {
return createConversation(parameters).join();
}
/**
* Implementation of createConversationWithServiceResponseAsync.
*
* @see Conversations#createConversationAsync
* @see Conversations#createConversation
*/
@Override
public CompletableFuture<ConversationResourceResponse> createConversation(ConversationParameters parameters) {
@ -241,20 +211,10 @@ public class RestConversations implements Conversations {
.build(response);
}
/**
* Implementation of sendToConversation.
*
* @see Conversations#sendToConversation
*/
@Override
public ResourceResponse sendToConversation(String conversationId, Activity activity) {
return sendToConversation(conversationId, activity).join();
}
/**
* Implementation of sendToConversationAsync.
*
* @see Conversations#sendToConversationAsync
* @see Conversations#sendToConversation
*/
@Override
public CompletableFuture<ResourceResponse> sendToConversation(String conversationId, Activity activity) {
@ -289,20 +249,10 @@ public class RestConversations implements Conversations {
.build(response);
}
/**
* Implementation of updateActivity.
*
* @see Conversations#updateActivity
*/
@Override
public ResourceResponse updateActivity(String conversationId, String activityId, Activity activity) {
return updateActivity(conversationId, activityId, activity).join();
}
/**
* Implementation of updateActivityAsync.
*
* @see Conversations#updateActivityAsync
* @see Conversations#updateActivity
*/
@Override
public CompletableFuture<ResourceResponse> updateActivity(String conversationId, String activityId, Activity activity) {
@ -340,20 +290,10 @@ public class RestConversations implements Conversations {
.build(response);
}
/**
* Implementation of replyToActivity.
*
* @see Conversations#replyToActivity
*/
@Override
public ResourceResponse replyToActivity(String conversationId, String activityId, Activity activity) {
return replyToActivity(conversationId, activityId, activity).join();
}
/**
* Implementation of replyToActivityAsync.
*
* @see Conversations#replyToActivityAsync
* @see Conversations#replyToActivity
*/
@Override
public CompletableFuture<ResourceResponse> replyToActivity(String conversationId,
@ -393,20 +333,10 @@ public class RestConversations implements Conversations {
.build(response);
}
/**
* Implementation of deleteActivity.
*
* @see Conversations#deleteActivity
*/
@Override
public void deleteActivity(String conversationId, String activityId) {
deleteActivity(conversationId, activityId).join();
}
/**
* Implementation of deleteActivityWithServiceResponseAsync.
*
* @see Conversations#deleteActivityAsync
* @see Conversations#deleteActivity
*/
@Override
public CompletableFuture<Void> deleteActivity(String conversationId, String activityId) {
@ -439,20 +369,10 @@ public class RestConversations implements Conversations {
.build(response);
}
/**
* Implementation of getConversationMembers.
*
* @see Conversations#getConversationMembers
*/
@Override
public List<ChannelAccount> getConversationMembers(String conversationId) {
return getConversationMembers(conversationId).join();
}
/**
* Implementation of getConversationMembersAsync.
*
* @see Conversations#getConversationMembersAsync
* @see Conversations#getConversationMembers
*/
@Override
public CompletableFuture<List<ChannelAccount>> getConversationMembers(String conversationId) {
@ -480,20 +400,10 @@ public class RestConversations implements Conversations {
.build(response);
}
/**
* Implementation of deleteConversationMember.
*
* @see Conversations#deleteConversationMember
*/
@Override
public void deleteConversationMember(String conversationId, String memberId) {
deleteConversationMember(conversationId, memberId).join();
}
/**
* Implementation of deleteConversationMemberWithServiceResponseAsync.
*
* @see Conversations#deleteConversationMemberAsync
* @see Conversations#deleteConversationMember
*/
@Override
public CompletableFuture<Void> deleteConversationMember(String conversationId, String memberId) {
@ -527,20 +437,10 @@ public class RestConversations implements Conversations {
.build(response);
}
/**
* Implementation of getActivityMembers.
*
* @see Conversations#getActivityMembers
*/
@Override
public List<ChannelAccount> getActivityMembers(String conversationId, String activityId) {
return getActivityMembers(conversationId, activityId).join();
}
/**
* Implementation of getActivityMembersAsync.
*
* @see Conversations#getActivityMembersAsync
* @see Conversations#getActivityMembers
*/
@Override
public CompletableFuture<List<ChannelAccount>> getActivityMembers(String conversationId, String activityId) {
@ -572,20 +472,10 @@ public class RestConversations implements Conversations {
.build(response);
}
/**
* Implementation of uploadAttachment.
*
* @see Conversations#uploadAttachment
*/
@Override
public ResourceResponse uploadAttachment(String conversationId, AttachmentData attachmentUpload) {
return uploadAttachment(conversationId, attachmentUpload).join();
}
/**
* Implementation of uploadAttachmentAsync.
*
* @see Conversations#uploadAttachmentAsync
* @see Conversations#uploadAttachment
*/
@Override
public CompletableFuture<ResourceResponse> uploadAttachment(String conversationId, AttachmentData attachmentUpload) {
@ -621,20 +511,10 @@ public class RestConversations implements Conversations {
}
/**
* Implementation of sendConversationHistory.
*
* @see Conversations#sendConversationHistory
*/
@Override
public ResourceResponse sendConversationHistory(String conversationId, Transcript history) {
return sendConversationHistory(conversationId, history).join();
}
/**
* Implementation of sendConversationHistoryAsync.
*
* @see Conversations#sendConversationHistoryAsync
* @see Conversations#sendConversationHistory
*/
@Override
public CompletableFuture<ResourceResponse> sendConversationHistory(String conversationId, Transcript history) {
@ -670,20 +550,10 @@ public class RestConversations implements Conversations {
}
/**
* Implementation of getConversationPagedMembers.
*
* @see Conversations#getConversationPagedMembers
*/
@Override
public PagedMembersResult getConversationPagedMembers(String conversationId){
return getConversationPagedMembers(conversationId).join();
}
/**
* Implementation of getConversationPagedMembersAsync.
*
* @see Conversations#getConversationPagedMembersAsync
* @see Conversations#getConversationPagedMembers
*/
@Override
public CompletableFuture<PagedMembersResult> getConversationPagedMembers(String conversationId){

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

@ -24,11 +24,11 @@ public class AttachmentsTest extends BotConnectorTestBase {
setBot(bot);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
ResourceResponse attachmentResponse = connector.getConversations().uploadAttachment(conversation.getId(), attachment);
ResourceResponse attachmentResponse = connector.getConversations().uploadAttachment(conversation.getId(), attachment).join();
AttachmentInfo response = connector.getAttachments().getAttachmentInfo(attachmentResponse.getId());
AttachmentInfo response = connector.getAttachments().getAttachmentInfo(attachmentResponse.getId()).join();
Assert.assertEquals(attachment.getName(), response.getName());
}
@ -57,14 +57,14 @@ public class AttachmentsTest extends BotConnectorTestBase {
setBot(bot);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
ResourceResponse attachmentResponse = connector.getConversations().uploadAttachment(conversation.getId(), attachment);
ResourceResponse attachmentResponse = connector.getConversations().uploadAttachment(conversation.getId(), attachment).join();
AttachmentInfo attachmentInfo = connector.getAttachments().getAttachmentInfo(attachmentResponse.getId());
AttachmentInfo attachmentInfo = connector.getAttachments().getAttachmentInfo(attachmentResponse.getId()).join();
for (AttachmentView attView : attachmentInfo.getViews()) {
InputStream retrievedAttachment = connector.getAttachments().getAttachment(attachmentResponse.getId(), attView.getViewId());
InputStream retrievedAttachment = connector.getAttachments().getAttachment(attachmentResponse.getId(), attView.getViewId()).join();
Assert.assertTrue(isSame(retrievedAttachment, attachmentStream));
}

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

@ -33,7 +33,7 @@ public class ConversationsTest extends BotConnectorTestBase {
setActivity(activity);
}};
ConversationResourceResponse result = connector.getConversations().createConversation(params);
ConversationResourceResponse result = connector.getConversations().createConversation(params).join();
Assert.assertNotNull(result.getActivityId());
}
@ -55,7 +55,7 @@ public class ConversationsTest extends BotConnectorTestBase {
}};
try {
ConversationResourceResponse result = connector.getConversations().createConversation(params);
ConversationResourceResponse result = connector.getConversations().createConversation(params).join();
Assert.fail("expected exception did not occur.");
} catch (CompletionException e) {
if (e.getCause() instanceof ErrorResponseException) {
@ -83,7 +83,7 @@ public class ConversationsTest extends BotConnectorTestBase {
}};
try {
ConversationResourceResponse result = connector.getConversations().createConversation(params);
ConversationResourceResponse result = connector.getConversations().createConversation(params).join();
Assert.fail("expected exception did not occur.");
} catch (CompletionException e) {
if (e.getCause() instanceof ErrorResponseException) {
@ -111,7 +111,7 @@ public class ConversationsTest extends BotConnectorTestBase {
}};
try {
ConversationResourceResponse result = connector.getConversations().createConversation(params);
ConversationResourceResponse result = connector.getConversations().createConversation(params).join();
Assert.fail("expected exception did not occur.");
} catch (CompletionException e) {
Assert.assertEquals("BadArgument", ((ErrorResponseException)e.getCause()).body().getError().getCode());
@ -121,7 +121,7 @@ public class ConversationsTest extends BotConnectorTestBase {
@Test
public void CreateConversationWithNullParameter() {
try {
ConversationResourceResponse result = connector.getConversations().createConversation(null);
ConversationResourceResponse result = connector.getConversations().createConversation(null).join();
Assert.fail("expected exception did not occur.");
} catch (IllegalArgumentException e) {
Assert.assertTrue(e.getMessage().contains("cannot be null"));
@ -136,9 +136,9 @@ public class ConversationsTest extends BotConnectorTestBase {
setBot(bot);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
List<ChannelAccount> members = connector.getConversations().getConversationMembers(conversation.getId());
List<ChannelAccount> members = connector.getConversations().getConversationMembers(conversation.getId()).join();
boolean hasUser = false;
@ -158,10 +158,10 @@ public class ConversationsTest extends BotConnectorTestBase {
setBot(bot);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
try {
List<ChannelAccount> members = connector.getConversations().getConversationMembers(conversation.getId().concat("M"));
List<ChannelAccount> members = connector.getConversations().getConversationMembers(conversation.getId().concat("M")).join();
Assert.fail("expected exception did not occur.");
} catch (CompletionException e) {
if (e.getCause() instanceof ErrorResponseException) {
@ -176,7 +176,7 @@ public class ConversationsTest extends BotConnectorTestBase {
@Test
public void GetConversationMembersWithNullConversationId() {
try {
List<ChannelAccount> members = connector.getConversations().getConversationMembers(null);
List<ChannelAccount> members = connector.getConversations().getConversationMembers(null).join();
Assert.fail("expected exception did not occur.");
} catch (IllegalArgumentException e) {
Assert.assertTrue(e.getMessage().contains("cannot be null"));
@ -190,10 +190,10 @@ public class ConversationsTest extends BotConnectorTestBase {
setBot(bot);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
try {
PagedMembersResult pagedMembers = connector.getConversations().getConversationPagedMembers(conversation.getId());
PagedMembersResult pagedMembers = connector.getConversations().getConversationPagedMembers(conversation.getId()).join();
boolean hasUser = false;
for (ChannelAccount member : pagedMembers.getMembers()) {
@ -222,10 +222,10 @@ public class ConversationsTest extends BotConnectorTestBase {
setActivity(activity);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
try {
connector.getConversations().getConversationPagedMembers(conversation.getId().concat("M"));
connector.getConversations().getConversationPagedMembers(conversation.getId().concat("M")).join();
Assert.fail("expected exception did not occur.");
} catch (CompletionException e) {
if (e.getCause() instanceof ErrorResponseException) {
@ -251,9 +251,9 @@ public class ConversationsTest extends BotConnectorTestBase {
setBot(bot);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity);
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity).join();
Assert.assertNotNull(response.getId());
}
@ -273,10 +273,10 @@ public class ConversationsTest extends BotConnectorTestBase {
setBot(bot);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
try {
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId().concat("M"), activity);
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId().concat("M"), activity).join();
Assert.fail("expected exception did not occur.");
} catch (CompletionException e) {
if (e.getCause() instanceof ErrorResponseException) {
@ -296,7 +296,7 @@ public class ConversationsTest extends BotConnectorTestBase {
setBot(bot);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
bot.setId("B21S8SG7K:T03CWQ0QB");
Activity activity = new Activity(ActivityTypes.MESSAGE) {{
@ -307,7 +307,7 @@ public class ConversationsTest extends BotConnectorTestBase {
}};
try {
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity);
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity).join();
Assert.fail("expected exception did not occur.");
} catch (CompletionException e) {
if (e.getCause() instanceof ErrorResponseException) {
@ -383,9 +383,9 @@ public class ConversationsTest extends BotConnectorTestBase {
setBot(bot);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity);
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity).join();
Assert.assertNotNull(response.getId());
}
@ -405,9 +405,9 @@ public class ConversationsTest extends BotConnectorTestBase {
setActivity(activity);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
List<ChannelAccount> members = connector.getConversations().getActivityMembers(conversation.getId(), conversation.getActivityId());
List<ChannelAccount> members = connector.getConversations().getActivityMembers(conversation.getId(), conversation.getActivityId()).join();
boolean hasUser = false;
@ -434,10 +434,10 @@ public class ConversationsTest extends BotConnectorTestBase {
setActivity(activity);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
try {
List<ChannelAccount> members = connector.getConversations().getActivityMembers(conversation.getId().concat("M"), conversation.getActivityId());
List<ChannelAccount> members = connector.getConversations().getActivityMembers(conversation.getId().concat("M"), conversation.getActivityId()).join();
Assert.fail("expected exception did not occur.");
} catch (CompletionException e) {
if (e.getCause() instanceof ErrorResponseException) {
@ -489,11 +489,11 @@ public class ConversationsTest extends BotConnectorTestBase {
setBot(bot);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity);
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity).join();
ResourceResponse replyResponse = connector.getConversations().replyToActivity(conversation.getId(), response.getId(), reply);
ResourceResponse replyResponse = connector.getConversations().replyToActivity(conversation.getId(), response.getId(), reply).join();
Assert.assertNotNull(replyResponse.getId());
}
@ -518,12 +518,12 @@ public class ConversationsTest extends BotConnectorTestBase {
setBot(bot);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity);
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity).join();
try {
ResourceResponse replyResponse = connector.getConversations().replyToActivity(conversation.getId().concat("M"), response.getId(), reply);
ResourceResponse replyResponse = connector.getConversations().replyToActivity(conversation.getId().concat("M"), response.getId(), reply).join();
Assert.fail("expected exception did not occur.");
} catch (CompletionException e) {
if (e.getCause() instanceof ErrorResponseException) {
@ -590,12 +590,12 @@ public class ConversationsTest extends BotConnectorTestBase {
setBot(bot);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity);
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity).join();
try {
ResourceResponse replyResponse = connector.getConversations().replyToActivity(conversation.getId(), response.getId(), null);
ResourceResponse replyResponse = connector.getConversations().replyToActivity(conversation.getId(), response.getId(), null).join();
Assert.fail("expected exception did not occur.");
} catch (IllegalArgumentException e) {
Assert.assertTrue(e.getMessage().contains("cannot be null"));
@ -617,7 +617,7 @@ public class ConversationsTest extends BotConnectorTestBase {
setActivity(activity);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
connector.getConversations().deleteActivity(conversation.getId(), conversation.getActivityId());
@ -639,10 +639,10 @@ public class ConversationsTest extends BotConnectorTestBase {
setActivity(activity);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
try {
connector.getConversations().deleteActivity("B21S8SG7K:T03CWQ0QB", conversation.getActivityId());
connector.getConversations().deleteActivity("B21S8SG7K:T03CWQ0QB", conversation.getActivityId()).join();
Assert.fail("expected exception did not occur.");
} catch (CompletionException e) {
if (e.getCause() instanceof ErrorResponseException) {
@ -657,7 +657,7 @@ public class ConversationsTest extends BotConnectorTestBase {
@Test
public void DeleteActivityWithNullConversationId() {
try {
connector.getConversations().deleteActivity(null, "id");
connector.getConversations().deleteActivity(null, "id").join();
Assert.fail("expected exception did not occur.");
} catch(IllegalArgumentException e) {
Assert.assertTrue(e.getMessage().contains("cannot be null"));
@ -667,7 +667,7 @@ public class ConversationsTest extends BotConnectorTestBase {
@Test
public void DeleteActivityWithNullActivityId() {
try {
connector.getConversations().deleteActivity("id", null);
connector.getConversations().deleteActivity("id", null).join();
Assert.fail("expected exception did not occur.");
} catch(IllegalArgumentException e) {
Assert.assertTrue(e.getMessage().contains("cannot be null"));
@ -688,14 +688,14 @@ public class ConversationsTest extends BotConnectorTestBase {
setBot(bot);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity);
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity).join();
activity.setId(response.getId());
activity.setText("TEST Update Activity");
ResourceResponse updateResponse = connector.getConversations().updateActivity(conversation.getId(), response.getId(), activity);
ResourceResponse updateResponse = connector.getConversations().updateActivity(conversation.getId(), response.getId(), activity).join();
Assert.assertNotNull(updateResponse.getId());
}
@ -714,15 +714,15 @@ public class ConversationsTest extends BotConnectorTestBase {
setBot(bot);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity);
ResourceResponse response = connector.getConversations().sendToConversation(conversation.getId(), activity).join();
activity.setId(response.getId());
activity.setText("TEST Update Activity");
try {
ResourceResponse updateResponse = connector.getConversations().updateActivity("B21S8SG7K:T03CWQ0QB", response.getId(), activity);
ResourceResponse updateResponse = connector.getConversations().updateActivity("B21S8SG7K:T03CWQ0QB", response.getId(), activity).join();
Assert.fail("expected exception did not occur.");
} catch (CompletionException e) {
if (e.getCause() instanceof ErrorResponseException) {
@ -790,9 +790,9 @@ public class ConversationsTest extends BotConnectorTestBase {
setBot(bot);
}};
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage);
ConversationResourceResponse conversation = connector.getConversations().createConversation(createMessage).join();
ResourceResponse response = connector.getConversations().uploadAttachment(conversation.getId(), attachment);
ResourceResponse response = connector.getConversations().uploadAttachment(conversation.getId(), attachment).join();
Assert.assertNotNull(response.getId());
}

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

@ -106,7 +106,7 @@ public class OAuthTestBase extends TestBase {
}
public CompletableFuture<Void> UseOAuthClientFor(Function<OAuthClient, CompletableFuture<Void>> doTest, String className, String methodName) throws MalformedURLException, URISyntaxException {
return CompletableFuture.run(() -> {
return CompletableFuture.runAsync(() -> {
OAuthClient oauthClient = null;
try {
oauthClient = new OAuthClient(this.connector, AuthenticationConstants.OAUTH_URL);