Convert comments from C# to java style

This commit is contained in:
nyxsys 2018-07-05 14:37:11 -07:00
Родитель 525b3d7553
Коммит d6f78f3733
51 изменённых файлов: 1521 добавлений и 1509 удалений

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

@ -109,4 +109,4 @@ public class App {
}
}
}
}

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

@ -18,9 +18,9 @@ public final class AuthenticationConstants {
public static final String ServiceUrlClaim = "serviceurl";
public static final String VersionClaim = "ver";
public static final String AppIdClaim = "appid";
/// <summary>
/// OAuth Url used to get a token from OAuthApiClient
/// </summary>
/**
* OAuth Url used to get a token from OAuthApiClient
*/
public static final String OAuthUrl = "https://api.botframework.com";

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

@ -95,10 +95,10 @@ public class MicrosoftAppCredentials implements ServiceClientCredentials {
return this.GetTokenAsync(false);
}
/// <summary>
/// Apply the credentials to the HTTP request.
/// </summary>
/// <param name="request">The HTTP request.</param><param name="cancellationToken">Cancellation token.</param>
/**
* Apply the credentials to the HTTP request.
* @param request The HTTP request.
*/
public CompletableFuture<Response> ProcessHttpRequestAsync(boolean applyCredentials, String httpVerb, String url) throws InvalidParameterException, IOException, URISyntaxException {
return ProcessHttpRequestAsync(applyCredentials, httpVerb, url, null);
}

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

@ -32,9 +32,9 @@ import static java.net.HttpURLConnection.HTTP_OK;
import static java.util.concurrent.CompletableFuture.completedFuture;
import static java.util.stream.Collectors.joining;
/// <summary>
/// Service client to handle requests to the botframework api service.
/// </summary>
/**
* Service client to handle requests to the botframework api service.
*/
public class OAuthClient extends ServiceClient {
private final ConnectorClientImpl client;
private final String uri;
@ -58,15 +58,13 @@ public class OAuthClient extends ServiceClient {
this.mapper = new ObjectMapper();
}
/// <summary>
/// Get User Token for given user and connection.
/// </summary>
/// <param name="userId"></param>
/// <param name="connectionName"></param>
/// <param name="magicCode"></param>
/// <param name="customHeaders"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/**
* Get User Token for given user and connection.
* @param userId
* @param connectionName
* @param magicCode
* @return
*/
public CompletableFuture<TokenResponse> GetUserTokenAsync(String userId, String connectionName, String magicCode) throws IOException, URISyntaxException, ExecutionException, InterruptedException {
return GetUserTokenAsync(userId, connectionName, magicCode, null);
}
@ -129,13 +127,12 @@ public class OAuthClient extends ServiceClient {
}
}
/// <summary>
/// Signs Out the User for the given ConnectionName.
/// </summary>
/// <param name="userId"></param>
/// <param name="connectionName"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/**
* Signs Out the User for the given ConnectionName.
* @param userId
* @param connectionName
* @return
*/
public CompletableFuture<Boolean> SignOutUserAsync(String userId, String connectionName) throws URISyntaxException, IOException {
if (StringUtils.isEmpty(userId)) {
throw new IllegalArgumentException("userId");
@ -168,13 +165,12 @@ public class OAuthClient extends ServiceClient {
}
/// <summary>
/// Gets the Link to be sent to the user for signin into the given ConnectionName
/// </summary>
/// <param name="activity"></param>
/// <param name="connectionName"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
/**
* Gets the Link to be sent to the user for signin into the given ConnectionName
* @param activity
* @param connectionName
* @return
*/
public CompletableFuture<String> GetSignInLinkAsync(Activity activity, String connectionName) throws IOException, URISyntaxException {
if (StringUtils.isEmpty(connectionName)) {
throw new IllegalArgumentException("connectionName");
@ -220,11 +216,11 @@ public class OAuthClient extends ServiceClient {
return completedFuture(null);
}
/// <summary>
/// Send a dummy OAuth card when the bot is being used on the emulator for testing without fetching a real token.
/// </summary>
/// <param name="emulateOAuthCards"></param>
/// <returns></returns>
/**
* Send a dummy OAuth card when the bot is being used on the emulator for testing without fetching a real token.
* @param emulateOAuthCards
* @return
*/
public CompletableFuture SendEmulateOAuthCardsAsync(Boolean emulateOAuthCards) throws URISyntaxException, IOException {
// Construct URL

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

@ -8,10 +8,12 @@ import org.joda.time.DateTime;
import java.util.HashMap;
/// <remarks>
/// Member variables to this class follow the RFC Naming conventions
/// "properties" house any "extra" properties that aren't used at the moment.
/// </remarks>
/**
*
* Member variables to this class follow the RFC Naming conventions
* "properties" house any "extra" properties that aren't used at the moment.
*
*/
public class OAuthResponse
{

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

@ -9,4 +9,4 @@ import java.util.List;
class OpenIdMetadataKey {
RSAPublicKey key;
List<String> endorsements;
}
}

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

@ -21,4 +21,4 @@ public class ResponseFuture implements Callback {
@Override public void onResponse(Call call, Response response) throws IOException {
future.complete(response);
}
}
}

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

@ -28,4 +28,4 @@ public class BotConnectorTestBase extends TestBase {
@Override
protected void cleanUpResources() {
}
}
}

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

@ -18,30 +18,30 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/// <summary>
/// An Activity is the basic communication type for the Bot Framework 3.0 protocol
/// </summary>
/// <remarks>
/// The Activity class contains all properties that individual, more specific activities
/// could contain. It is a superset type.
/// </remarks>
/**
* An Activity is the basic communication type for the Bot Framework 3.0 protocol
*
* The Activity class contains all properties that individual, more specific activities
* could contain. It is a superset type.
*
*/
public class ActivityImpl extends Activity {
/// <summary>
/// Content-type for an Activity
/// </summary>
/**
* Content-type for an Activity
*/
public final String ContentType = "application/vnd.microsoft.activity";
private static final ObjectMapper mapper = new ObjectMapper();
void CustomInit() {
}
/// <summary>
/// Take a message and create a reply message for it with the routing information
/// set up to correctly route a reply to the source message
/// </summary>
/// <param name="text">text you want to reply with</param>
/// <param name="locale">language of your reply</param>
/// <returns>message set up to route back to the sender</returns>
/**
* Take a message and create a reply message for it with the routing information
* set up to correctly route a reply to the source message
* @param text text you want to reply with
* @param locale language of your reply
* @return message set up to route back to the sender
*/
public ActivityImpl CreateReply() {
return CreateReply(null, null);
}
@ -74,14 +74,14 @@ public class ActivityImpl extends Activity {
return reply;
}
/// <summary>
/// Create a trace activity based of this activity
/// </summary>
/// <param name="name">Name of the operation</param>
/// <param name="value">value of the operation</param>
/// <param name="valueType">valueType if helpful to identify the value schema (default is value.GetType().Name)</param>
/// <param name="label">descritive label of context. (Default is calling function name)</param>
/// <returns></returns>
/**
* Create a trace activity based of this activity
* @param name Name of the operation
* @param value value of the operation
* @param valueType valueType if helpful to identify the value schema (default is value.GetType().Name)
* @param label descritive label of context. (Default is calling function name)
* @return
*/
public TraceActivity CreateTrace(String name) {
return CreateTrace(name, null, null, null);
}
@ -120,13 +120,13 @@ public class ActivityImpl extends Activity {
return reply;
}
/// <summary>
/// Create an instance of the TraceActivity
/// </summary>
/// <param name="name">Name of the operation</param>
/// <param name="value">value of the operation</param>
/// <param name="valueType">valueType if helpful to identify the value schema (default is value.GetType().Name)</param>
/// <param name="label">descritive label of context. (Default is calling function name)</param>
/**
* Create an instance of the TraceActivity
* @param name Name of the operation
* @param value value of the operation
* @param valueType valueType if helpful to identify the value schema (default is value.GetType().Name)
* @param label descritive label of context. (Default is calling function name)
*/
public static TraceActivity CreateTraceActivity(String name, String valueType) {
return CreateTraceActivity(name, valueType, null, null);
}
@ -147,15 +147,15 @@ public class ActivityImpl extends Activity {
}
/// <summary>
/// Extension data for overflow of properties
/// </summary>
/**
* Extension data for overflow of properties
*/
// [JsonExtensionData(ReadData = true, WriteData = true)]
//public JObject Properties { get; set; } = new JObject();
/// <summary>
/// Create an instance of the Activity class with IMessageActivity masking
/// </summary>
/**
* Create an instance of the Activity class with MessageActivity masking
*/
public static MessageActivity CreateMessageActivity() {
MessageActivity reply = new MessageActivity();
reply.withType(ActivityTypes.TRACE);
@ -165,18 +165,18 @@ public class ActivityImpl extends Activity {
return reply;
}
/// <summary>
/// Create an instance of the Activity class with IContactRelationUpdateActivity masking
/// </summary>
/**
* Create an instance of the Activity class with IContactRelationUpdateActivity masking
*/
public static ContactRelationUpdateActivity CreateContactRelationUpdateActivity() {
ContactRelationUpdateActivity reply = new ContactRelationUpdateActivity();
reply.withType(ActivityTypes.CONTACT_RELATION_UPDATE);
return reply;
}
/// <summary>
/// Create an instance of the Activity class with IConversationUpdateActivity masking
/// </summary>
/**
* Create an instance of the Activity class with IConversationUpdateActivity masking
*/
public static ConversationUpdateActivity CreateConversationUpdateActivity() {
ConversationUpdateActivity reply = new ConversationUpdateActivity();
reply.withType(ActivityTypes.CONVERSATION_UPDATE);
@ -185,37 +185,37 @@ public class ActivityImpl extends Activity {
return reply;
}
/// <summary>
/// Create an instance of the Activity class with ITypingActivity masking
/// </summary>
/**
* Create an instance of the Activity class with ITypingActivity masking
*/
//public static TypingActivity CreateTypingActivity() { return new Activity(ActivityTypes.Typing); }
/// <summary>
/// Create an instance of the Activity class with IActivity masking
/// </summary>
/**
* Create an instance of the Activity class with Activity masking
*/
public static Activity CreatePingActivity() {
return new Activity().withType(ActivityTypes.PING);
}
/// <summary>
/// Create an instance of the Activity class with IEndOfConversationActivity masking
/// </summary>
/**
* Create an instance of the Activity class with IEndOfConversationActivity masking
*/
//public static IEndOfConversationActivity CreateEndOfConversationActivity() { return new Activity(ActivityTypes.EndOfConversation); }
/// <summary>
/// Create an instance of the Activity class with an IEventActivity masking
/// </summary>
/**
* Create an instance of the Activity class with an IEventActivity masking
*/
//public static IEventActivity CreateEventActivity() { return new Activity(ActivityTypes.Event); }
/// <summary>
/// Create an instance of the Activity class with IInvokeActivity masking
/// </summary>
/**
* Create an instance of the Activity class with IInvokeActivity masking
*/
//public static IInvokeActivity CreateInvokeActivity() { return new Activity(ActivityTypes.Invoke); }
/// <summary>
/// True if the Activity is of the specified activity type
/// </summary>
/**
* True if the Activity is of the specified activity type
*/
protected boolean IsActivity(String activityType) {
/*
* NOTE: While it is possible to come up with a fancy looking "one-liner" to solve
@ -360,86 +360,86 @@ public class ActivityImpl extends Activity {
return this;
}
/// <summary>
/// Return an IMessageActivity mask if this is a message activity
/// </summary>
/**
* Return an MessageActivity mask if this is a message activity
*/
public MessageActivity AsMessageActivity() {
return IsActivity(ActivityTypes.MESSAGE.toString()) ? (MessageActivity) (Activity) this : null;
}
/// <summary>
/// Return an IContactRelationUpdateActivity mask if this is a contact relation update activity
/// </summary>
/**
* Return an ContactRelationUpdateActivity mask if this is a contact relation update activity
*/
public ContactRelationUpdateActivity AsContactRelationUpdateActivity() {
return IsActivity(ActivityTypes.CONTACT_RELATION_UPDATE.toString()) ? (ContactRelationUpdateActivity) (Activity) this : null;
}
/// <summary>
/// Return an IInstallationUpdateActivity mask if this is a installation update activity
/// </summary>
/**
* Return an InstallationUpdateActivity mask if this is a installation update activity
*/
//public InstallationUpdateActivity AsInstallationUpdateActivity() { return IsActivity(ActivityTypes.INSTALLATION_UPDATE.toString()) ? this : null; }
/// <summary>
/// Return an IConversationUpdateActivity mask if this is a conversation update activity
/// </summary>
/**
* Return an ConversationUpdateActivity mask if this is a conversation update activity
*/
//public ConversationUpdateActivity AsConversationUpdateActivity() { return IsActivity(ActivityTypes.ConversationUpdate) ? this : null; }
/// <summary>
/// Return an ITypingActivity mask if this is a typing activity
/// </summary>
/**
* Return an TypingActivity mask if this is a typing activity
*/
// public TypingActivity AsTypingActivity() { return IsActivity(ActivityTypes.TYPING.toString()) ? (TypingActivity)(Activity)this : null; }
/// <summary>
/// Return an IEndOfConversationActivity mask if this is an end of conversation activity
/// </summary>
/**
* Return an IEndOfConversationActivity mask if this is an end of conversation activity
*/
//public IEndOfConversationActivity AsEndOfConversationActivity() { return IsActivity(ActivityTypes.EndOfConversation) ? this : null; }
/// <summary>
/// Return an IEventActivity mask if this is an event activity
/// </summary>
/**
* Return an IEventActivity mask if this is an event activity
*/
//public IEventActivity AsEventActivity() { return IsActivity(ActivityTypes.Event) ? this : null; }
/// <summary>
/// Return an IInvokeActivity mask if this is an invoke activity
/// </summary>
/**
* Return an IInvokeActivity mask if this is an invoke activity
*/
//public IInvokeActivity AsInvokeActivity() { return IsActivity(ActivityTypes.Invoke) ? this : null; }
/// <summary>
/// Return an IMessageUpdateAcitvity if this is a MessageUpdate activity
/// </summary>
/// <returns></returns>
/**
* Return an IMessageUpdateAcitvity if this is a MessageUpdate activity
* @return
*/
//public IMessageUpdateActivity AsMessageUpdateActivity() { return IsActivity(ActivityTypes.MessageUpdate) ? this : null; }
/// <summary>
/// Return an IMessageDeleteActivity if this is a MessageDelete activity
/// </summary>
/// <returns></returns>
/**
* Return an IMessageDeleteActivity if this is a MessageDelete activity
* @return
*/
//public IMessageDeleteActivity AsMessageDeleteActivity() { return IsActivity(ActivityTypes.MessageDelete) ? this : null; }
/// <summary>
/// Return an IMessageReactionActivity if this is a MessageReaction activity
/// </summary>
/// <returns></returns>
/**
* Return an IMessageReactionActivity if this is a MessageReaction activity
* @return
*/
//public IMessageReactionActivity AsMessageReactionActivity() { return IsActivity(ActivityTypes.MessageReaction) ? this : null; }
/// <summary>
/// Return an ISuggestionActivity if this is a Suggestion activity
/// </summary>
/// <returns></returns>
/**
* Return an ISuggestionActivity if this is a Suggestion activity
* @return
*/
//public ISuggestionActivity AsSuggestionActivity() { return IsActivity(ActivityTypes.Suggestion) ? this : null; }
/// <summary>
/// Return an ITraceActivity if this is a Trace activity
/// </summary>
/// <returns></returns>
/**
* Return an ITraceActivity if this is a Trace activity
* @return
*/
//public ITraceActivity AsTraceActivity() { return IsActivity(ActivityTypes.Trace) ? this : null; }
/// <summary>
/// Checks if this (message) activity has content.
/// </summary>
/// <returns>Returns true, if this message has any content to send. False otherwise.</returns>
/**
* Checks if this (message) activity has content.
* @return Returns true, if this message has any content to send. False otherwise.
*/
public boolean HasContent() {
if (!StringUtils.isBlank(this.text()))
return true;
@ -465,11 +465,11 @@ public class ActivityImpl extends Activity {
return null;
}
/// <summary>
/// Resolves the mentions from the entities of this (message) activity.
/// </summary>
/// <returns>The array of mentions or an empty array, if none found.</returns>
/// TODO: Need to see how mentions are formated in the message
/**
* Resolves the mentions from the entities of this (message) activity.
* @return The array of mentions or an empty array, if none found.
* TODO: Need to see how mentions are formated in the message
*/
public ArrayList<Mention> GetMentions() {
ArrayList<Mention> list = null;
// (ArrayList) this.entities().stream()
@ -479,12 +479,12 @@ public class ActivityImpl extends Activity {
return list;
}
/// <summary>
/// Get channeldata as typed structure
/// </summary>
/// <param name="activity"></param>
/// <typeparam name="TypeT">type to use</typeparam>
/// <returns>typed Object or default(TypeT)</returns>
/**
* Get channeldata as typed structure
* @param activity
* @param TypeT type to use
* @return typed Object or default(TypeT)
*/
public <TypeT> TypeT GetChannelData(Class<TypeT> classType) throws JsonProcessingException {
if (this.channelData() == null)
return null;
@ -496,15 +496,14 @@ public class ActivityImpl extends Activity {
return mapper.treeToValue((TreeNode) node, classType);
}
/// <summary>
/// Get channeldata as typed structure
/// </summary>
/// <param name="activity"></param>
/// <typeparam name="TypeT">type to use</typeparam>
/// <param name="instance">The resulting instance, if possible</param>
/// <returns>
/// <c>true</c> if value of <seealso cref="IActivity.ChannelData"/> was coerceable to <typeparamref name="TypeT"/>, <c>false</c> otherwise.
/// </returns>
/**
* Get channeldata as typed structure
* @param activity
* @param TypeT type to use
* @param instance The resulting instance, if possible
* @return
* {@code true} if value of {@linkalso Activity.ChannelData} was coerceable to {@code TypeT}, {@code false} otherwise.
*/
public <TypeT> ResultPair<Boolean, TypeT> TryGetChannelData(Class<TypeT> clsType) {
TypeT instance = null;

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

@ -3,9 +3,9 @@ package com.microsoft.bot.schema;
import com.microsoft.bot.schema.models.Activity;
public class ContactRelationUpdateActivity extends Activity {
/// <summary>
/// add|remove
/// </summary>
/**
* add|remove
*/
private String _action;
public String getAction() {
@ -15,4 +15,4 @@ public class ContactRelationUpdateActivity extends Activity {
public void setAction(String action) {
this._action = action;
}
}
}

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

@ -18,32 +18,32 @@ import java.util.Map;
public class EntityImpl extends Entity {
private ObjectMapper objectMapper = new ObjectMapper();
/// <summary>
/// Initializes a new instance of the Entity class.
/// </summary>
/**
* Initializes a new instance of the Entity class.
*/
public EntityImpl() {
CustomInit();
}
/// <summary>
/// Initializes a new instance of the Entity class.
/// </summary>
/// <param name="type">Entity Type (typically from schema.org
/// types)</param>
/**
* Initializes a new instance of the Entity class.
* @param type Entity Type (typically from schema.org
* types)
*/
public EntityImpl(String type) {
this.type = type;
CustomInit();
}
/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
/**
* An initialization method that performs custom operations like setting defaults
*/
void CustomInit() {
}
/// <summary>
/// Gets or sets entity Type (typically from schema.org types)
/// </summary>
/**
* Gets or sets entity Type (typically from schema.org types)
*/
public String type;
@ -66,15 +66,23 @@ public class EntityImpl extends Entity {
}
/// <summary>
/**
*/
/// Retrieve internal payload.
/**
* Retrieve internal payload.
*/
/// </summary>
/**
*/
/// <typeparam name="T"></typeparam>
/**
* @param T
*/
/// <returns></returns>
/**
* @return
*/
public <T> T GetAs(Class<T> type) {
@ -102,11 +110,11 @@ public class EntityImpl extends Entity {
}
/// <summary>
/// Set internal payload.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="obj"></param>
/**
* Set internal payload.
* @param T
* @param obj
*/
public <T> boolean SetAs(T obj) {
// Serialize

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

@ -3,14 +3,14 @@ package com.microsoft.bot.schema;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.microsoft.bot.schema.models.ConversationReference;
/// <summary>
/// State object passed to the bot token service.
/// </summary>
/**
* State object passed to the bot token service.
*/
public class TokenExchangeState
{
/// <summary>
/// The connection name that was used
/// </summary>
/**
* The connection name that was used
*/
@JsonProperty(value = "connectionName")
private String connectionName;
public String connectionName() {
@ -21,9 +21,9 @@ public class TokenExchangeState
return this;
}
/// <summary>
/// A reference to the conversation
/// </summary>
/**
* A reference to the conversation
*/
@JsonProperty(value = "conversation")
private ConversationReference conversation;
public ConversationReference conversation() {
@ -34,9 +34,9 @@ public class TokenExchangeState
return this;
}
/// <summary>
/// The URL of the bot messaging endpoint
/// </summary>
/**
* The URL of the bot messaging endpoint
*/
@JsonProperty("botUrl")
private String botUrl;
public String botUrl() {
@ -47,9 +47,9 @@ public class TokenExchangeState
return this;
}
/// <summary>
/// The bot's registered application ID
/// </summary>
/**
* The bot's registered application ID
*/
@JsonProperty("msAppId")
String msAppId;
public String msAppId() {

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

@ -3,13 +3,13 @@ package com.microsoft.bot.schema;
import com.microsoft.bot.schema.models.Activity;
import com.microsoft.bot.schema.models.ConversationReference;
/// <summary>
/// An activity by which a bot can log internal information into a logged conversation transcript
/// </summary>
/**
* An activity by which a bot can log internal information into a logged conversation transcript
*/
public class TraceActivity extends ActivityImpl {
/// <summary>
/// Name of the trace activity
/// </summary>
/**
* Name of the trace activity
*/
private String _name;
public String getName() {
@ -20,9 +20,9 @@ public class TraceActivity extends ActivityImpl {
_name = name;
}
/// <summary>
/// Descriptive label for the trace
/// </summary>
/**
* Descriptive label for the trace
*/
private String _label;
public String getLabel() {
@ -33,9 +33,9 @@ public class TraceActivity extends ActivityImpl {
this._label = label;
}
/// <summary>
/// Unique string which identifies the format of the value object
/// </summary>
/**
* Unique string which identifies the format of the value object
*/
private String _value_type;
public String getValueType() {
@ -46,9 +46,9 @@ public class TraceActivity extends ActivityImpl {
_value_type = value_type;
}
/// <summary>
/// Open-ended value
/// </summary>
/**
* Open-ended value
*/
private Object _value;
Object getValue() {
@ -59,9 +59,9 @@ public class TraceActivity extends ActivityImpl {
_value = value;
}
/// <summary>
/// Reference to another conversation or activity
/// </summary>
/**
* Reference to another conversation or activity
*/
private ConversationReference _relates_to;
ConversationReference getRelatesTo() {

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

@ -9,9 +9,9 @@ public class ConversationReferenceHelper {
public ConversationReferenceHelper(ConversationReference reference) {
this.reference = reference;
}
/// <summary>
/// Creates <see cref="Activity"/> from conversation reference as it is posted to bot.
/// </summary>
/**
* Creates {@link Activity} from conversation reference as it is posted to bot.
*/
public ActivityImpl GetPostToBotMessage()
{
return (ActivityImpl) new ActivityImpl()
@ -31,9 +31,9 @@ public class ConversationReferenceHelper {
.withName(reference.user().name()));
}
/// <summary>
/// Creates <see cref="Activity"/> from conversation reference that can be posted to user as reply.
/// </summary>
/**
* Creates {@link Activity} from conversation reference that can be posted to user as reply.
*/
public ActivityImpl GetPostToUserMessage()
{
Activity msg = this.GetPostToBotMessage();

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

@ -5,9 +5,9 @@ package com.microsoft.bot.schema.models;
import java.util.List;
public class ConversationUpdateActivity extends MessageActivity {
/// <summary>
/// Members added to the conversation
/// </summary>
/**
* Members added to the conversation
*/
private List<ChannelAccount> membersAdded;
@Override
@ -20,9 +20,9 @@ public class ConversationUpdateActivity extends MessageActivity {
return this;
}
/// <summary>
/// Members removed from the conversation
/// </summary>
/**
* Members removed from the conversation
*/
private List<ChannelAccount> membersRemoved;
public List<ChannelAccount> membersRemoved() {
return this.membersRemoved;
@ -34,9 +34,9 @@ public class ConversationUpdateActivity extends MessageActivity {
return this;
}
/// <summary>
/// The conversation's updated topic name
/// </summary>
/**
* The conversation's updated topic name
*/
private String topicName;
@Override
public String topicName() {
@ -49,10 +49,10 @@ public class ConversationUpdateActivity extends MessageActivity {
}
/// <summary>
/// True if prior history of the channel is disclosed
/// Note: Boolean (class) is used, may be null
/// </summary>
/**
* True if prior history of the channel is disclosed
* Note: Boolean (class) is used, may be null
*/
private Boolean historyDisclosed;
public Boolean historyDisclosed() {
return this.historyDisclosed;

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

@ -10,14 +10,14 @@ import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;
/// <summary>
/// A message in a conversation
/// </summary>
/**
* A message in a conversation
*/
public class MessageActivity extends ActivityImpl
{
/// <summary>
/// The language code of the Text field
/// </summary>
/**
* The language code of the Text field
*/
private String locale;
public String getLocale() {
return this.locale;
@ -27,9 +27,9 @@ public class MessageActivity extends ActivityImpl
}
/// <summary>
/// Content for the message
/// </summary>
/**
* Content for the message
*/
private String text;
public void setText(String text){
this.text = text;
@ -39,9 +39,9 @@ public class MessageActivity extends ActivityImpl
return this.text;
}
/// <summary>
/// Speak tag (SSML markup for text to speech)
/// </summary>
/**
* Speak tag (SSML markup for text to speech)
*/
private String speak;
public void setSpeak(String speak){
this.speak = speak;
@ -50,9 +50,9 @@ public class MessageActivity extends ActivityImpl
return this.speak;
}
/// <summary>
/// Indicates whether the bot is accepting, expecting, or ignoring input
/// </summary>
/**
* Indicates whether the bot is accepting, expecting, or ignoring input
*/
private String inputHint;
public String getInputHint(){
return this.inputHint;
@ -61,9 +61,9 @@ public class MessageActivity extends ActivityImpl
this.inputHint = inputHint;
}
/// <summary>
/// Text to display if the channel cannot render cards
/// </summary>
/**
* Text to display if the channel cannot render cards
*/
private String summary;
public String getSummary(){
return this.summary;
@ -72,9 +72,9 @@ public class MessageActivity extends ActivityImpl
this.summary = summary;
}
/// <summary>
/// Format of text fields [plain|markdown] Default:markdown
/// </summary>
/**
* Format of text fields [plain|markdown] Default:markdown
*/
private String textFormat;
public String getTextFormat() {
@ -84,9 +84,9 @@ public class MessageActivity extends ActivityImpl
this.textFormat = textFormat;
}
/// <summary>
/// Hint for how to deal with multiple attachments: [list|carousel] Default:list
/// </summary>
/**
* Hint for how to deal with multiple attachments: [list|carousel] Default:list
*/
private String attachmentLayout;
public String getAttachmentLayout() {
return this.attachmentLayout;
@ -95,9 +95,9 @@ public class MessageActivity extends ActivityImpl
this.attachmentLayout = attachmentLayout;
}
/// <summary>
/// Attachments
/// </summary>
/**
* Attachments
*/
private List<Attachment> attachments;
public List<Attachment> getAttachments() {
return this.attachments;
@ -106,9 +106,9 @@ public class MessageActivity extends ActivityImpl
this.attachments = attachments;
}
/// <summary>
/// SuggestedActions are used to express actions for interacting with a card like keyboards/quickReplies
/// </summary>
/**
* SuggestedActions are used to express actions for interacting with a card like keyboards/quickReplies
*/
private SuggestedActions suggestedActions;
public SuggestedActions getSuggestedActions() {
return this.suggestedActions;
@ -118,10 +118,10 @@ public class MessageActivity extends ActivityImpl
}
/// <summary>
/// Importance of the activity
/// Valid values are "low", "normal", and "high". Default value is "normal."
/// </summary>
/**
* Importance of the activity
* Valid values are "low", "normal", and "high". Default value is "normal."
*/
private String importance;
public String getImportance() {
return this.importance;
@ -130,12 +130,12 @@ public class MessageActivity extends ActivityImpl
this.importance = importance;
}
/// <summary>
/// Hint to describe how this activity should be delivered.
/// null or "default" = default delivery
/// "notification" = notification semantics
/// See DeliveryModes for current constants
/// </summary>
/**
* Hint to describe how this activity should be delivered.
* null or "default" = default delivery
* "notification" = notification semantics
* See DeliveryModes for current constants
*/
private String deliveryMode;
public String getDeliveryMode() {
return this.deliveryMode;
@ -144,9 +144,9 @@ public class MessageActivity extends ActivityImpl
this.deliveryMode = deliveryMode;
}
/// <summary>
/// DateTime to expire the activity as ISO 8601 encoded datetime
/// </summary>
/**
* DateTime to expire the activity as ISO 8601 encoded datetime
*/
private OffsetDateTime expiration;
public OffsetDateTime getExpiration() {
return this.expiration;
@ -155,17 +155,17 @@ public class MessageActivity extends ActivityImpl
this.expiration = expiration;
}
/// <summary>
/// Get mentions
/// </summary>
/**
* Get mentions
*/
private ArrayList<Mention> mentions;
public ArrayList<Mention> GetMentions() {
return this.mentions;
}
/// <summary>
/// Value provided with CardAction
/// </summary>
/**
* Value provided with CardAction
*/
private Object value;
public Object getValue() {
return this.value;
@ -175,9 +175,9 @@ public class MessageActivity extends ActivityImpl
}
/// <summary>
/// Create an instance of the Activity class with IConversationUpdateActivity masking
/// </summary>
/**
* Create an instance of the Activity class with IConversationUpdateActivity masking
*/
public static ConversationUpdateActivity CreateConversationUpdateActivity()
{
ConversationUpdateActivity conversationActivity = new ConversationUpdateActivity();

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

@ -2,19 +2,19 @@ package com.microsoft.bot.builder;
import java.util.concurrent.CompletableFuture;
/// <summary>
/// Helper class for defining middleware by using a delegate or anonymous method.
/// </summary>
/**
* Helper class for defining middleware by using a delegate or anonymous method.
*/
public class AnonymousReceiveMiddleware implements Middleware
{
private MiddlewareCall _toCall;
/// <summary>
/// Creates a middleware object that uses the provided method as its
/// process request handler.
/// </summary>
/// <param name="anonymousMethod">The method to use as the middleware's process
/// request handler.</param>
/**
* Creates a middleware object that uses the provided method as its
* process request handler.
* @param anonymousMethod The method to use as the middleware's process
* request handler.
*/
public AnonymousReceiveMiddleware(MiddlewareCall anonymousMethod)
{
if (anonymousMethod == null)
@ -23,13 +23,13 @@ public class AnonymousReceiveMiddleware implements Middleware
_toCall = anonymousMethod;
}
/// <summary>
/// Uses the method provided in the <see cref="AnonymousReceiveMiddleware"/> to
/// process an incoming activity.
/// </summary>
/// <param name="context">The context object for this turn.</param>
/// <param name="next">The delegate to call to continue the bot middleware pipeline.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/**
* Uses the method provided in the {@link AnonymousReceiveMiddleware} to
* process an incoming activity.
* @param context The context object for this turn.
* @param next The delegate to call to continue the bot middleware pipeline.
* @return A task that represents the work queued to execute.
*/
public CompletableFuture OnTurn(TurnContext context, NextDelegate next) throws Exception {
return _toCall.requestHandler(context, next);
}

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

@ -17,114 +17,113 @@ import java.util.function.Function;
import static com.ea.async.Async.await;
import static java.util.concurrent.CompletableFuture.completedFuture;
/// <summary>
/// Represents a bot adapter that can connect a bot to a service endpoint.
/// This class is abstract.
/// </summary>
/// <remarks>The bot adapter encapsulates authentication processes and sends
/// activities to and receives activities from the Bot Connector Service. When your
/// bot receives an activity, the adapter creates a context object, passes it to your
/// bot's application logic, and sends responses back to the user's channel.
/// <para>Use <see cref="Use(IMiddleware)"/> to add <see cref="IMiddleware"/> objects
/// to your adapters middleware collection. The adapter processes and directs
/// incoming activities in through the bot middleware pipeline to your bots logic
/// and then back out again. As each activity flows in and out of the bot, each piece
/// of middleware can inspect or act upon the activity, both before and after the bot
/// logic runs.</para>
/// </remarks>
/// <seealso cref="ITurnContext"/>
/// <seealso cref="IActivity"/>
/// <seealso cref="IBot"/>
/// <seealso cref="IMiddleware"/>
/**
* Represents a bot adapter that can connect a bot to a service endpoint.
* This class is abstract.
* The bot adapter encapsulates authentication processes and sends
* activities to and receives activities from the Bot Connector Service. When your
* bot receives an activity, the adapter creates a context object, passes it to your
* bot's application logic, and sends responses back to the user's channel.
* <p>Use {@link Use(Middleware)} to add {@link Middleware} objects
* to your adapters middleware collection. The adapter processes and directs
* incoming activities in through the bot middleware pipeline to your bots logic
* and then back out again. As each activity flows in and out of the bot, each piece
* of middleware can inspect or act upon the activity, both before and after the bot
* logic runs.</p>
*
* {@linkalso TurnContext}
* {@linkalso Activity}
* {@linkalso Bot}
* {@linkalso Middleware}
*/
public abstract class BotAdapter {
/// <summary>
/// The collection of middleware in the adapter's pipeline.
/// </summary>
/**
* The collection of middleware in the adapter's pipeline.
*/
protected final MiddlewareSet _middlewareSet = new MiddlewareSet();
/// <summary>
/// Creates a default adapter.
/// </summary>
/**
* Creates a default adapter.
*/
public BotAdapter() {
super();
}
/// <summary>
/// Adds middleware to the adapter's pipeline.
/// </summary>
/// <param name="middleware">The middleware to add.</param>
/// <returns>The updated adapter object.</returns>
/// <remarks>Middleware is added to the adapter at initialization time.
/// For each turn, the adapter calls middleware in the order in which you added it.
/// </remarks>
/**
* Adds middleware to the adapter's pipeline.
* @param middleware The middleware to add.
* @return The updated adapter object.
* Middleware is added to the adapter at initialization time.
* For each turn, the adapter calls middleware in the order in which you added it.
*
*/
public BotAdapter Use(Middleware middleware) {
_middlewareSet.Use(middleware);
return this;
}
/// <summary>
/// When overridden in a derived class, sends activities to the conversation.
/// </summary>
/// <param name="context">The context object for the turn.</param>
/// <param name="activities">The activities to send.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>If the activities are successfully sent, the task result contains
/// an array of <see cref="ResourceResponse"/> objects containing the IDs that
/// the receiving channel assigned to the activities.</remarks>
/// <seealso cref="ITurnContext.OnSendActivities(SendActivitiesHandler)"/>
/**
* When overridden in a derived class, sends activities to the conversation.
* @param context The context object for the turn.
* @param activities The activities to send.
* @return A task that represents the work queued to execute.
* If the activities are successfully sent, the task result contains
* an array of {@link ResourceResponse} objects containing the IDs that
* the receiving channel assigned to the activities.
* {@linkalso TurnContext.OnSendActivities(SendActivitiesHandler)}
*/
public abstract CompletableFuture<ResourceResponse[]> SendActivities(TurnContext context, Activity[] activities) throws InterruptedException ;
/// <summary>
/// When overridden in a derived class, replaces an existing activity in the
/// conversation.
/// </summary>
/// <param name="context">The context object for the turn.</param>
/// <param name="activity">New replacement activity.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>If the activity is successfully sent, the task result contains
/// a <see cref="ResourceResponse"/> object containing the ID that the receiving
/// channel assigned to the activity.
/// <para>Before calling this, set the ID of the replacement activity to the ID
/// of the activity to replace.</para></remarks>
/// <seealso cref="ITurnContext.OnUpdateActivity(UpdateActivityHandler)"/>
/**
* When overridden in a derived class, replaces an existing activity in the
* conversation.
* @param context The context object for the turn.
* @param activity New replacement activity.
* @return A task that represents the work queued to execute.
* If the activity is successfully sent, the task result contains
* a {@link ResourceResponse} object containing the ID that the receiving
* channel assigned to the activity.
* <p>Before calling this, set the ID of the replacement activity to the ID
* of the activity to replace.</p>
* {@linkalso TurnContext.OnUpdateActivity(UpdateActivityHandler)}
*/
public abstract CompletableFuture<ResourceResponse> UpdateActivity(TurnContext context, Activity activity);
/// <summary>
/// When overridden in a derived class, deletes an existing activity in the
/// conversation.
/// </summary>
/// <param name="context">The context object for the turn.</param>
/// <param name="reference">Conversation reference for the activity to delete.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>The <see cref="ConversationReference.ActivityId"/> of the conversation
/// reference identifies the activity to delete.</remarks>
/// <seealso cref="ITurnContext.OnDeleteActivity(DeleteActivityHandler)"/>
/**
* When overridden in a derived class, deletes an existing activity in the
* conversation.
* @param context The context object for the turn.
* @param reference Conversation reference for the activity to delete.
* @return A task that represents the work queued to execute.
* The {@link ConversationReference.ActivityId} of the conversation
* reference identifies the activity to delete.
* {@linkalso TurnContext.OnDeleteActivity(DeleteActivityHandler)}
*/
public abstract CompletableFuture<Void> DeleteActivity(TurnContext context, ConversationReference reference) throws ExecutionException, InterruptedException;
/// <summary>
/// Starts activity processing for the current bot turn.
/// </summary>
/// <param name="context">The turn's context object.</param>
/// <param name="callback">A callback method to run at the end of the pipeline.</param>
/// <param name="cancelToken">A cancellation token for the task.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="context"/> is null.</exception>
/// <remarks>The adapter calls middleware in the order in which you added it.
/// The adapter passes in the context object for the turn and a next delegate,
/// and the middleware calls the delegate to pass control to the next middleware
/// in the pipeline. Once control reaches the end of the pipeline, the adapter calls
/// the <paramref name="callback"/> method. If a middleware component doesnt call
/// the next delegate, the adapter does not call any of the subsequent middlewares
/// <see cref="IMiddleware.OnTurn(ITurnContext, MiddlewareSet.NextDelegate)"/>
/// methods or the callback method, and the pipeline short circuits.
/// <para>When the turn is initiated by a user activity (reactive messaging), the
/// callback method will be a reference to the bot's
/// <see cref="IBot.OnTurn(ITurnContext)"/> method. When the turn is
/// initiated by a call to <see cref="ContinueConversation(ConversationReference, Func{ITurnContext, Task})"/>
/// (proactive messaging), the callback method is the callback method that was provided in the call.</para>
/// </remarks>
/**
* Starts activity processing for the current bot turn.
* @param context The turn's context object.
* @param callback A callback method to run at the end of the pipeline.
* @return A task that represents the work queued to execute.
* @throws NullPointerException
* {@code context} is null.
* The adapter calls middleware in the order in which you added it.
* The adapter passes in the context object for the turn and a next delegate,
* and the middleware calls the delegate to pass control to the next middleware
* in the pipeline. Once control reaches the end of the pipeline, the adapter calls
* the {@code callback} method. If a middleware component doesnt call
* the next delegate, the adapter does not call any of the subsequent middlewares
* {@link Middleware.OnTurn(TurnContext, MiddlewareSet.NextDelegate)}
* methods or the callback method, and the pipeline short circuits.
* <p>When the turn is initiated by a user activity (reactive messaging), the
* callback method will be a reference to the bot's
* {@link Bot.OnTurn(TurnContext)} method. When the turn is
* initiated by a call to {@link ContinueConversation(ConversationReference, Func{TurnContext, Task})}
* (proactive messaging), the callback method is the callback method that was provided in the call.</p>
*
*/
protected CompletableFuture RunPipeline(TurnContext context, Function<TurnContext, CompletableFuture> callback) throws Exception {
BotAssert.ContextNotNull(context);
@ -142,32 +141,32 @@ public abstract class BotAdapter {
}
/// <summary>
/// Creates a conversation on the specified channel.
/// </summary>
/// <param name="channelId">The ID of the channel.</param>
/// <param name="callback">A method to call when the new conversation is available.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <exception cref="NotImplementedException"></exception>
/// <remarks>No base implementation is provided.</remarks>
/**
* Creates a conversation on the specified channel.
* @param channelId The ID of the channel.
* @param callback A method to call when the new conversation is available.
* @return A task that represents the work queued to execute.
* @throws UnsupportedOperationException
* No base implementation is provided.
*/
public CompletableFuture CreateConversation(String channelId, Function<TurnContext, CompletableFuture> callback)
{
throw new UnsupportedOperationException("Adapter does not support CreateConversation with this arguments");
}
/// <summary>
/// Sends a proactive message to a conversation.
/// </summary>
/// <param name="botAppId">The application ID of the bot. This paramter is ignored in
/// single tenant the Adpters (Console, Test, etc) but is critical to the BotFrameworkAdapter
/// which is multi-tenant aware. </param>
/// <param name="reference">A reference to the conversation to continue.</param>
/// <param name="callback">The method to call for the resulting bot turn.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>Call this method to proactively send a message to a conversation.
/// Most channels require a user to initaiate a conversation with a bot
/// before the bot can send activities to the user.</remarks>
/// <seealso cref="RunPipeline(ITurnContext, Func{ITurnContext, Task}, CancellationTokenSource)"/>
/**
* Sends a proactive message to a conversation.
* @param botId The application ID of the bot. This paramter is ignored in
* single tenant the Adpters (Console, Test, etc) but is critical to the BotFrameworkAdapter
* which is multi-tenant aware.
* @param reference A reference to the conversation to continue.
* @param callback The method to call for the resulting bot turn.
* @return A task that represents the work queued to execute.
* Call this method to proactively send a message to a conversation.
* Most channels require a user to initaiate a conversation with a bot
* before the bot can send activities to the user.
* {@linkalso RunPipeline(TurnContext, Func{TurnContext, Task})}
*/
public CompletableFuture ContinueConversation(String botId, ConversationReference reference, Function<TurnContext, CompletableFuture> callback) throws Exception {
ConversationReferenceHelper conv = new ConversationReferenceHelper(reference);

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

@ -8,89 +8,89 @@ import com.microsoft.bot.schema.models.ConversationReference;
import java.util.ArrayList;
/// <summary>
/// Provides methods for debugging Bot Builder code.
/// </summary>
/**
* Provides methods for debugging Bot Builder code.
*/
public class BotAssert
{
/// <summary>
/// Checks that an activity object is not <c>null</c>.
/// </summary>
/// <param name="activity">The activity object.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="activity"/> is <c>null</c>.</exception>
/**
* Checks that an activity object is not {@code null}.
* @param activity The activity object.
* @throws NullPointerException
* {@code activity} is {@code null}.
*/
public static void ActivityNotNull(ActivityImpl activity)
{
if (activity == null)
throw new IllegalArgumentException ("Activity");
}
/// <summary>
/// Checks that an activity object is not <c>null</c>.
/// </summary>
/// <param name="activity">The activity object.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="activity"/> is <c>null</c>.</exception>
/**
* Checks that an activity object is not {@code null}.
* @param activity The activity object.
* @throws NullPointerException
* {@code activity} is {@code null}.
*/
public static void ActivityNotNull(Activity activity)
{
if (activity == null)
throw new IllegalArgumentException ("Activity");
}
/// <summary>
/// Checks that a context object is not <c>null</c>.
/// </summary>
/// <param name="context">The context object.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="context"/> is <c>null</c>.</exception>
/**
* Checks that a context object is not {@code null}.
* @param context The context object.
* @throws NullPointerException
* {@code context} is {@code null}.
*/
public static void ContextNotNull(TurnContext context)
{
if (context == null)
throw new IllegalArgumentException ("TurnContext");
}
/// <summary>
/// Checks that a conversation reference object is not <c>null</c>.
/// </summary>
/// <param name="reference">The conversation reference object.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="reference"/> is <c>null</c>.</exception>
/**
* Checks that a conversation reference object is not {@code null}.
* @param reference The conversation reference object.
* @throws NullPointerException
* {@code reference} is {@code null}.
*/
public static void ConversationReferenceNotNull(ConversationReference reference)
{
if (reference == null)
throw new IllegalArgumentException ("ConversationReference");
}
/// <summary>
/// Checks that an activity collection is not <c>null</c>.
/// </summary>
/// <param name="activities">The activities.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="activities"/> is <c>null</c>.</exception>
/**
* Checks that an activity collection is not {@code null}.
* @param activities The activities.
* @throws NullPointerException
* {@code activities} is {@code null}.
*/
public static void ActivityListNotNull(ArrayList<Activity> activities)
{
if (activities == null)
throw new NullPointerException("List<Activity>");
}
/// <summary>
/// Checks that a middleware object is not <c>null</c>.
/// </summary>
/// <param name="middleware">The middleware object.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="middleware"/> is <c>null</c>.</exception>
/**
* Checks that a middleware object is not {@code null}.
* @param middleware The middleware object.
* @throws NullPointerException
* {@code middleware} is {@code null}.
*/
public static void MiddlewareNotNull(Middleware middleware)
{
if (middleware == null)
throw new NullPointerException("Middleware");
}
/// <summary>
/// Checks that a middleware collection is not <c>null</c>.
/// </summary>
/// <param name="middleware">The middleware.</param>
/// <exception cref="ArgumentNullException">
/// <paramref name="middleware"/> is <c>null</c>.</exception>
/**
* Checks that a middleware collection is not {@code null}.
* @param middleware The middleware.
* @throws NullPointerException
* {@code middleware} is {@code null}.
*/
public static void MiddlewareNotNull(ArrayList<Middleware> middleware)
{
if (middleware == null)

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

@ -25,24 +25,24 @@ import java.util.function.Function;
import static com.ea.async.Async.await;
import static java.util.concurrent.CompletableFuture.completedFuture;
/// <summary>
/// A bot adapter that can connect a bot to a service endpoint.
/// </summary>
/// <remarks>The bot adapter encapsulates authentication processes and sends
/// activities to and receives activities from the Bot Connector Service. When your
/// bot receives an activity, the adapter creates a context object, passes it to your
/// bot's application logic, and sends responses back to the user's channel.
/// <para>Use <see cref="Use(IMiddleware)"/> to add <see cref="IMiddleware"/> objects
/// to your adapters middleware collection. The adapter processes and directs
/// incoming activities in through the bot middleware pipeline to your bots logic
/// and then back out again. As each activity flows in and out of the bot, each piece
/// of middleware can inspect or act upon the activity, both before and after the bot
/// logic runs.</para>
/// </remarks>
/// <seealso cref="TurnContext"/>
/// <seealso cref="IActivity"/>
/// <seealso cref="IBot"/>
/// <seealso cref="IMiddleware"/>
/**
* A bot adapter that can connect a bot to a service endpoint.
* The bot adapter encapsulates authentication processes and sends
* activities to and receives activities from the Bot Connector Service. When your
* bot receives an activity, the adapter creates a context object, passes it to your
* bot's application logic, and sends responses back to the user's channel.
* <p>Use {@link Use(Middleware)} to add {@link Middleware} objects
* to your adapters middleware collection. The adapter processes and directs
* incoming activities in through the bot middleware pipeline to your bots logic
* and then back out again. As each activity flows in and out of the bot, each piece
* of middleware can inspect or act upon the activity, both before and after the bot
* logic runs.</p>
*
* {@linkalso TurnContext}
* {@linkalso Activity}
* {@linkalso Bot}
* {@linkalso Middleware}
*/
public class BotFrameworkAdapter extends BotAdapter {
private final CredentialProvider _credentialProvider;
@ -52,20 +52,20 @@ public class BotFrameworkAdapter extends BotAdapter {
private final String InvokeReponseKey = "BotFrameworkAdapter.InvokeResponse";
private boolean isEmulatingOAuthCards = false;
/// <summary>
/// Initializes a new instance of the <see cref="BotFrameworkAdapter"/> class,
/// using a credential provider.
/// </summary>
/// <param name="credentialProvider">The credential provider.</param>
/// <param name="connectorClientRetryStrategy">Retry strategy for retrying HTTP operations.</param>
/// <param name="httpClient">The HTTP client.</param>
/// <param name="middleware">The middleware to initially add to the adapter.</param>
/// <exception cref="IllegalArgumentException">
/// <paramref name="credentialProvider"/> is <c>null</c>.</exception>
/// <remarks>Use a <see cref="MiddlewareSet"/> object to add multiple middleware
/// components in the conustructor. Use the <see cref="Use(IMiddleware)"/> method to
/// add additional middleware to the adapter after construction.
/// </remarks>
/**
* Initializes a new instance of the {@link BotFrameworkAdapter} class,
* using a credential provider.
* @param credentialProvider The credential provider.
* @param connectorClientRetryStrategy Retry strategy for retrying HTTP operations.
* @param httpClient The HTTP client.
* @param middleware The middleware to initially add to the adapter.
* @throws IllegalArgumentException
* {@code credentialProvider} is {@code null}.
* Use a {@link MiddlewareSet} object to add multiple middleware
* components in the conustructor. Use the {@link Use(Middleware)} method to
* add additional middleware to the adapter after construction.
*
*/
public BotFrameworkAdapter(CredentialProvider credentialProvider) {
this(credentialProvider, null, null, null);
}
@ -90,32 +90,32 @@ public class BotFrameworkAdapter extends BotAdapter {
}
}
/// <summary>
/// Sends a proactive message from the bot to a conversation.
/// </summary>
/// <param name="botAppId">The application ID of the bot. This is the appId returned by Portal registration, and is
/// generally found in the "MicrosoftAppId" parameter in appSettings.json.</param>
/// <param name="reference">A reference to the conversation to continue.</param>
/// <param name="callback">The method to call for the resulting bot turn.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <exception cref="IllegalArgumentException">
/// <paramref name="botAppId"/>, <paramref name="reference"/>, or
/// <paramref name="callback"/> is <c>null</c>.</exception>
/// <remarks>Call this method to proactively send a message to a conversation.
/// Most channels require a user to initaiate a conversation with a bot
/// before the bot can send activities to the user.
/// <para>This method registers the following.services().for the turn.<list type="bullet">
/// <item><see cref="IIdentity"/> (key = "BotIdentity"), a claims identity for the bot.</item>
/// <item><see cref="ConnectorClient"/>, the channel connector client to use this turn.</item>
/// </list></para>
/// <para>
/// This overload differers from the Node implementation by requiring the BotId to be
/// passed in. The .Net code allows multiple bots to be hosted in a single adapter which
/// isn't something supported by Node.
/// </para>
/// </remarks>
/// <seealso cref="ProcessActivity(String, Activity, Func{TurnContext, Task})"/>
/// <seealso cref="BotAdapter.RunPipeline(TurnContext, Func{TurnContext, Task}, System.Threading.CancellationTokenSource)"/>
/**
* Sends a proactive message from the bot to a conversation.
* @param botAppId The application ID of the bot. This is the appId returned by Portal registration, and is
* generally found in the "MicrosoftAppId" parameter in appSettings.json.
* @param reference A reference to the conversation to continue.
* @param callback The method to call for the resulting bot turn.
* @return A task that represents the work queued to execute.
* @throws IllegalArgumentException
* {@code botAppId}, {@code reference}, or
* {@code callback} is {@code null}.
* Call this method to proactively send a message to a conversation.
* Most channels require a user to initaiate a conversation with a bot
* before the bot can send activities to the user.
* <p>This method registers the following.services().for the turn.<list type="bullet
* <item>{@link Identity} (key = "BotIdentity"), a claims identity for the bot.</item>
* <item>{@link ConnectorClient}, the channel connector client to use this turn.</item>
* </list></p>
* <p>
* This overload differers from the Node implementation by requiring the BotId to be
* passed in. The .Net code allows multiple bots to be hosted in a single adapter which
* isn't something supported by Node.
* </p>
*
* {@linkalso ProcessActivity(String, Activity, Func{TurnContext, Task})}
* {@linkalso BotAdapter.RunPipeline(TurnContext, Func{TurnContext, Task}}
*/
@Override
public CompletableFuture ContinueConversation(String botAppId, ConversationReference reference, Function<TurnContext, CompletableFuture> callback) throws Exception {
if (StringUtils.isEmpty(botAppId))
@ -143,19 +143,19 @@ public class BotFrameworkAdapter extends BotAdapter {
return completedFuture(null);
}
/// <summary>
/// Initializes a new instance of the <see cref="BotFrameworkAdapter"/> class,
/// using an application ID and secret.
/// </summary>
/// <param name="appId">The application ID of the bot.</param>
/// <param name="appPassword">The application secret for the bot.</param>
/// <param name="connectorClientRetryStrategy">Retry policy for retrying HTTP operations.</param>
/// <param name="httpClient">The HTTP client.</param>
/// <param name="middleware">The middleware to initially add to the adapter.</param>
/// <remarks>Use a <see cref="MiddlewareSet"/> object to add multiple middleware
/// components in the conustructor. Use the <see cref="Use(IMiddleware)"/> method to
/// add additional middleware to the adapter after construction.
/// </remarks>
/**
* Initializes a new instance of the {@link BotFrameworkAdapter} class,
* using an application ID and secret.
* @param appId The application ID of the bot.
* @param appPassword The application secret for the bot.
* @param connectorClientRetryStrategy Retry policy for retrying HTTP operations.
* @param httpClient The HTTP client.
* @param middleware The middleware to initially add to the adapter.
* Use a {@link MiddlewareSet} object to add multiple middleware
* components in the conustructor. Use the {@link Use(Middleware)} method to
* add additional middleware to the adapter after construction.
*
*/
public BotFrameworkAdapter(String appId, String appPassword) {
this(appId, appPassword, null, null, null);
}
@ -172,42 +172,42 @@ public class BotFrameworkAdapter extends BotAdapter {
this(new SimpleCredentialProvider(appId, appPassword), connectorClientRetryStrategy, httpClient, middleware);
}
/// <summary>
/// Adds middleware to the adapter's pipeline.
/// </summary>
/// <param name="middleware">The middleware to add.</param>
/// <returns>The updated adapter object.</returns>
/// <remarks>Middleware is added to the adapter at initialization time.
/// For each turn, the adapter calls middleware in the order in which you added it.
/// </remarks>
/**
* Adds middleware to the adapter's pipeline.
* @param middleware The middleware to add.
* @return The updated adapter object.
* Middleware is added to the adapter at initialization time.
* For each turn, the adapter calls middleware in the order in which you added it.
*
*/
public BotFrameworkAdapter Use(Middleware middleware) {
super._middlewareSet.Use(middleware);
return this;
}
/// <summary>
/// Creates a turn context and runs the middleware pipeline for an incoming activity.
/// </summary>
/// <param name="authHeader">The HTTP authentication header of the request.</param>
/// <param name="activity">The incoming activity.</param>
/// <param name="callback">The code to run at the end of the adapter's middleware
/// pipeline.</param>
/// <returns>A task that represents the work queued to execute. If the activity type
/// was 'Invoke' and the corresponding key (channelId + activityId) was found
/// then an InvokeResponse is returned, otherwise null is returned.</returns>
/// <exception cref="IllegalArgumentException">
/// <paramref name="activity"/> is <c>null</c>.</exception>
/// <exception cref="UnauthorizedAccessException">
/// authentication failed.</exception>
/// <remarks>Call this method to reactively send a message to a conversation.
/// <para>This method registers the following.services().for the turn.<list type="bullet">
/// <item><see cref="IIdentity"/> (key = "BotIdentity"), a claims identity for the bot.</item>
/// <item><see cref="ConnectorClient"/>, the channel connector client to use this turn.</item>
/// </list></para>
/// </remarks>
/// <seealso cref="ContinueConversation(String, ConversationReference, Func{TurnContext, Task})"/>
/// <seealso cref="BotAdapter.RunPipeline(TurnContext, Func{TurnContext, Task}, System.Threading.CancellationTokenSource)"/>
/**
* Creates a turn context and runs the middleware pipeline for an incoming activity.
* @param authHeader The HTTP authentication header of the request.
* @param activity The incoming activity.
* @param callback The code to run at the end of the adapter's middleware
* pipeline.
* @return A task that represents the work queued to execute. If the activity type
* was 'Invoke' and the corresponding key (channelId + activityId) was found
* then an InvokeResponse is returned, otherwise null is returned.
* @throws IllegalArgumentException
* {@code activity} is {@code null}.
* @throws UnauthorizedAccessException
* authentication failed.
* Call this method to reactively send a message to a conversation.
* <p>This method registers the following.services().for the turn.<list type="bullet
* <item>{@link Identity} (key = "BotIdentity"), a claims identity for the bot.</item>
* <item>{@link ConnectorClient}, the channel connector client to use this turn.</item>
* </list></p>
*
* {@linkalso ContinueConversation(String, ConversationReference, Func{TurnContext, Task})}
* {@linkalso BotAdapter.RunPipeline(TurnContext, Func{TurnContext, Task})}
*/
public CompletableFuture<InvokeResponse> ProcessActivity(String authHeader, ActivityImpl activity, Function<TurnContextImpl, CompletableFuture> callback) throws Exception {
BotAssert.ActivityNotNull(activity);
@ -247,16 +247,16 @@ public class BotFrameworkAdapter extends BotAdapter {
}
}
/// <summary>
/// Sends activities to the conversation.
/// </summary>
/// <param name="context">The context object for the turn.</param>
/// <param name="activities">The activities to send.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>If the activities are successfully sent, the task result contains
/// an array of <see cref="ResourceResponse"/> objects containing the IDs that
/// the receiving channel assigned to the activities.</remarks>
/// <seealso cref="TurnContext.OnSendActivities(SendActivitiesHandler)"/>
/**
* Sends activities to the conversation.
* @param context The context object for the turn.
* @param activities The activities to send.
* @return A task that represents the work queued to execute.
* If the activities are successfully sent, the task result contains
* an array of {@link ResourceResponse} objects containing the IDs that
* the receiving channel assigned to the activities.
* {@linkalso TurnContext.OnSendActivities(SendActivitiesHandler)}
*/
public CompletableFuture<ResourceResponse[]> SendActivities(TurnContext context, Activity[] activities) throws InterruptedException {
if (context == null) {
throw new IllegalArgumentException("context");
@ -323,18 +323,18 @@ public class BotFrameworkAdapter extends BotAdapter {
return completedFuture(responses);
}
/// <summary>
/// Replaces an existing activity in the conversation.
/// </summary>
/// <param name="context">The context object for the turn.</param>
/// <param name="activity">New replacement activity.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>If the activity is successfully sent, the task result contains
/// a <see cref="ResourceResponse"/> object containing the ID that the receiving
/// channel assigned to the activity.
/// <para>Before calling this, set the ID of the replacement activity to the ID
/// of the activity to replace.</para></remarks>
/// <seealso cref="TurnContext.OnUpdateActivity(UpdateActivityHandler)"/>
/**
* Replaces an existing activity in the conversation.
* @param context The context object for the turn.
* @param activity New replacement activity.
* @return A task that represents the work queued to execute.
* If the activity is successfully sent, the task result contains
* a {@link ResourceResponse} object containing the ID that the receiving
* channel assigned to the activity.
* <p>Before calling this, set the ID of the replacement activity to the ID
* of the activity to replace.</p>
* {@linkalso TurnContext.OnUpdateActivity(UpdateActivityHandler)}
*/
@Override
public CompletableFuture<ResourceResponse> UpdateActivity(TurnContext context, Activity activity) {
ConnectorClient connectorClient = context.getServices().Get("ConnectorClient");
@ -343,15 +343,15 @@ public class BotFrameworkAdapter extends BotAdapter {
return completedFuture(null);
}
/// <summary>
/// Deletes an existing activity in the conversation.
/// </summary>
/// <param name="context">The context object for the turn.</param>
/// <param name="reference">Conversation reference for the activity to delete.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>The <see cref="ConversationReference.ActivityId"/> of the conversation
/// reference identifies the activity to delete.</remarks>
/// <seealso cref="TurnContext.OnDeleteActivity(DeleteActivityHandler)"/>
/**
* Deletes an existing activity in the conversation.
* @param context The context object for the turn.
* @param reference Conversation reference for the activity to delete.
* @return A task that represents the work queued to execute.
* The {@link ConversationReference.ActivityId} of the conversation
* reference identifies the activity to delete.
* {@linkalso TurnContext.OnDeleteActivity(DeleteActivityHandler)}
*/
public CompletableFuture<Void> DeleteActivity(TurnContext context, ConversationReference reference) {
return CompletableFuture.supplyAsync(() -> {
ConnectorClientImpl connectorClient = context.getServices().Get("ConnectorClient");
@ -368,12 +368,12 @@ public class BotFrameworkAdapter extends BotAdapter {
});
}
/// <summary>
/// Deletes a member from the current conversation
/// </summary>
/// <param name="context">The context object for the turn.</param>
/// <param name="memberId">ID of the member to delete from the conversation</param>
/// <returns></returns>
/**
* Deletes a member from the current conversation
* @param context The context object for the turn.
* @param memberId ID of the member to delete from the conversation
* @return
*/
public CompletableFuture<Void> DeleteConversationMember(TurnContextImpl context, String memberId) {
if (context.getActivity().conversation() == null)
throw new IllegalArgumentException("BotFrameworkAdapter.deleteConversationMember(): missing conversation");
@ -390,12 +390,12 @@ public class BotFrameworkAdapter extends BotAdapter {
return completedFuture(null);
}
/// <summary>
/// Lists the members of a given activity.
/// </summary>
/// <param name="context">The context object for the turn.</param>
/// <param name="activityId">(Optional) Activity ID to enumerate. If not specified the current activities ID will be used.</param>
/// <returns>List of Members of the activity</returns>
/**
* Lists the members of a given activity.
* @param context The context object for the turn.
* @param activityId (Optional) Activity ID to enumerate. If not specified the current activities ID will be used.
* @return List of Members of the activity
*/
public CompletableFuture<List<ChannelAccount>> GetActivityMembers(TurnContextImpl context) {
return GetActivityMembers(context, null);
}
@ -420,11 +420,11 @@ public class BotFrameworkAdapter extends BotAdapter {
return completedFuture(null);
}
/// <summary>
/// Lists the members of the current conversation.
/// </summary>
/// <param name="context">The context object for the turn.</param>
/// <returns>List of Members of the current conversation</returns>
/**
* Lists the members of the current conversation.
* @param context The context object for the turn.
* @return List of Members of the current conversation
*/
public CompletableFuture<List<ChannelAccount>> GetConversationMembers(TurnContextImpl context) {
if (context.getActivity().conversation() == null)
throw new IllegalArgumentException("BotFrameworkAdapter.GetActivityMembers(): missing conversation");
@ -440,22 +440,22 @@ public class BotFrameworkAdapter extends BotAdapter {
return completedFuture(null);
}
/// <summary>
/// Lists the Conversations in which this bot has participated for a given channel server. The
/// channel server returns results in pages and each page will include a `continuationToken`
/// that can be used to fetch the next page of results from the server.
/// </summary>
/// <param name="serviceUrl">The URL of the channel server to query. This can be retrieved
/// from `context.activity.serviceUrl`. </param>
/// <param name="credentials">The credentials needed for the Bot to connect to the.services().</param>
/// <param name="continuationToken">(Optional) token used to fetch the next page of results
/// from the channel server. This should be left as `null` to retrieve the first page
/// of results.</param>
/// <returns>List of Members of the current conversation</returns>
/// <remarks>
/// This overload may be called from outside the context of a conversation, as only the
/// Bot's ServiceUrl and credentials are required.
/// </remarks>
/**
* Lists the Conversations in which this bot has participated for a given channel server. The
* channel server returns results in pages and each page will include a `continuationToken`
* that can be used to fetch the next page of results from the server.
* @param serviceUrl The URL of the channel server to query. This can be retrieved
* from `context.activity.serviceUrl`.
* @param credentials The credentials needed for the Bot to connect to the.services().
* @param continuationToken (Optional) token used to fetch the next page of results
* from the channel server. This should be left as `null` to retrieve the first page
* of results.
* @return List of Members of the current conversation
*
* This overload may be called from outside the context of a conversation, as only the
* Bot's ServiceUrl and credentials are required.
*
*/
public CompletableFuture<ConversationsResult> GetConversations(String serviceUrl, MicrosoftAppCredentials credentials) throws MalformedURLException, URISyntaxException {
return GetConversations(serviceUrl, credentials, null);
}
@ -473,21 +473,21 @@ public class BotFrameworkAdapter extends BotAdapter {
return completedFuture(null);
}
/// <summary>
/// Lists the Conversations in which this bot has participated for a given channel server. The
/// channel server returns results in pages and each page will include a `continuationToken`
/// that can be used to fetch the next page of results from the server.
/// </summary>
/// <param name="context">The context object for the turn.</param>
/// <param name="continuationToken">(Optional) token used to fetch the next page of results
/// from the channel server. This should be left as `null` to retrieve the first page
/// of results.</param>
/// <returns>List of Members of the current conversation</returns>
/// <remarks>
/// This overload may be called during standard Activity processing, at which point the Bot's
/// service URL and credentials that are part of the current activity processing pipeline
/// will be used.
/// </remarks>
/**
* Lists the Conversations in which this bot has participated for a given channel server. The
* channel server returns results in pages and each page will include a `continuationToken`
* that can be used to fetch the next page of results from the server.
* @param context The context object for the turn.
* @param continuationToken (Optional) token used to fetch the next page of results
* from the channel server. This should be left as `null` to retrieve the first page
* of results.
* @return List of Members of the current conversation
*
* This overload may be called during standard Activity processing, at which point the Bot's
* service URL and credentials that are part of the current activity processing pipeline
* will be used.
*
*/
public CompletableFuture<ConversationsResult> GetConversations(TurnContextImpl context) {
return GetConversations(context, null);
}
@ -500,12 +500,13 @@ public class BotFrameworkAdapter extends BotAdapter {
}
/// Attempts to retrieve the token for a user that's in a login flow.
/// </summary>
/// <param name="context">Context for the current turn of conversation with the user.</param>
/// <param name="connectionName">Name of the auth connection to use.</param>
/// <param name="magicCode">(Optional) Optional user entered code to validate.</param>
/// <returns>Token Response</returns>
/**
* Attempts to retrieve the token for a user that's in a login flow.
* @param context Context for the current turn of conversation with the user.
* @param connectionName Name of the auth connection to use.
* @param magicCode (Optional) Optional user entered code to validate.
* @return Token Response
*/
public CompletableFuture<TokenResponse> GetUserToken(TurnContextImpl context, String connectionName, String magicCode) {
BotAssert.ContextNotNull(context);
if (context.getActivity().from() == null || StringUtils.isEmpty(context.getActivity().from().id()))
@ -519,12 +520,12 @@ public class BotFrameworkAdapter extends BotAdapter {
return completedFuture(null);
}
/// <summary>
/// Get the raw signin link to be sent to the user for signin for a connection name.
/// </summary>
/// <param name="context">Context for the current turn of conversation with the user.</param>
/// <param name="connectionName">Name of the auth connection to use.</param>
/// <returns></returns>
/**
* Get the raw signin link to be sent to the user for signin for a connection name.
* @param context Context for the current turn of conversation with the user.
* @param connectionName Name of the auth connection to use.
* @return
*/
public CompletableFuture<String> GetOauthSignInLink(TurnContextImpl context, String connectionName) {
BotAssert.ContextNotNull(context);
if (StringUtils.isEmpty(connectionName))
@ -535,12 +536,12 @@ public class BotFrameworkAdapter extends BotAdapter {
return completedFuture(null);
}
/// <summary>
/// Signs the user out with the token server.
/// </summary>
/// <param name="context">Context for the current turn of conversation with the user.</param>
/// <param name="connectionName">Name of the auth connection to use.</param>
/// <returns></returns>
/**
* Signs the user out with the token server.
* @param context Context for the current turn of conversation with the user.
* @param connectionName Name of the auth connection to use.
* @return
*/
public CompletableFuture SignOutUser(TurnContextImpl context, String connectionName) {
BotAssert.ContextNotNull(context);
if (StringUtils.isEmpty(connectionName))
@ -551,26 +552,26 @@ public class BotFrameworkAdapter extends BotAdapter {
return completedFuture(null);
}
/// <summary>
/// Creates a conversation on the specified channel.
/// </summary>
/// <param name="channelId">The ID for the channel.</param>
/// <param name="serviceUrl">The channel's service URL endpoint.</param>
/// <param name="credentials">The application credentials for the bot.</param>
/// <param name="conversationParameters">The conversation information to use to
/// create the conversation.</param>
/// <param name="callback">The method to call for the resulting bot turn.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>To start a conversation, your bot must know its account information
/// and the user's account information on that channel.
/// Most channels only support initiating a direct message (non-group) conversation.
/// <para>The adapter attempts to create a new conversation on the channel, and
/// then sends a <c>conversationUpdate</c> activity through its middleware pipeline
/// to the <paramref name="callback"/> method.</para>
/// <para>If the conversation is established with the
/// specified users, the ID of the activity's <see cref="IActivity.Conversation"/>
/// will contain the ID of the new conversation.</para>
/// </remarks>
/**
* Creates a conversation on the specified channel.
* @param channelId The ID for the channel.
* @param serviceUrl The channel's service URL endpoint.
* @param credentials The application credentials for the bot.
* @param conversationParameters The conversation information to use to
* create the conversation.
* @param callback The method to call for the resulting bot turn.
* @return A task that represents the work queued to execute.
* To start a conversation, your bot must know its account information
* and the user's account information on that channel.
* Most channels only support initiating a direct message (non-group) conversation.
* <p>The adapter attempts to create a new conversation on the channel, and
* then sends a {@code conversationUpdate} activity through its middleware pipeline
* to the {@code callback} method.</p>
* <p>If the conversation is established with the
* specified users, the ID of the activity's {@link Activity.Conversation}
* will contain the ID of the new conversation.</p>
*
*/
public CompletableFuture CreateConversation(String channelId, String serviceUrl, MicrosoftAppCredentials
credentials, ConversationParameters conversationParameters, Function<TurnContext, CompletableFuture> callback) throws Exception {
// Validate serviceUrl - can throw
@ -651,13 +652,13 @@ public class BotFrameworkAdapter extends BotAdapter {
return new OAuthClient(client, AuthenticationConstants.OAuthUrl);
}
/// <summary>
/// Creates the connector client asynchronous.
/// </summary>
/// <param name="serviceUrl">The service URL.</param>
/// <param name="claimsIdentity">The claims identity.</param>
/// <returns>ConnectorClient instance.</returns>
/// <exception cref="UnsupportedOperationException">ClaimsIdemtity cannot be null. Pass Anonymous ClaimsIdentity if authentication is turned off.</exception>
/**
* Creates the connector client asynchronous.
* @param serviceUrl The service URL.
* @param claimsIdentity The claims identity.
* @return ConnectorClient instance.
* @throws UnsupportedOperationException ClaimsIdemtity cannot be null. Pass Anonymous ClaimsIdentity if authentication is turned off.
*/
private CompletableFuture<ConnectorClient> CreateConnectorClientAsync(String serviceUrl, ClaimsIdentity claimsIdentity) {
return CompletableFuture.supplyAsync(() -> {
@ -720,12 +721,12 @@ public class BotFrameworkAdapter extends BotAdapter {
}
/// <summary>
/// Creates the connector client.
/// </summary>
/// <param name="serviceUrl">The service URL.</param>
/// <param name="appCredentials">The application credentials for the bot.</param>
/// <returns>Connector client instance.</returns>
/**
* Creates the connector client.
* @param serviceUrl The service URL.
* @param appCredentials The application credentials for the bot.
* @return Connector client instance.
*/
private ConnectorClient CreateConnectorClient(String serviceUrl) throws MalformedURLException, URISyntaxException {
return CreateConnectorClient(serviceUrl, null);
}
@ -749,12 +750,12 @@ public class BotFrameworkAdapter extends BotAdapter {
}
/// <summary>
/// Gets the application credentials. App Credentials are cached so as to ensure we are not refreshing
/// token everytime.
/// </summary>
/// <param name="appId">The application identifier (AAD Id for the bot).</param>
/// <returns>App credentials.</returns>
/**
* Gets the application credentials. App Credentials are cached so as to ensure we are not refreshing
* token everytime.
* @param appId The application identifier (AAD Id for the bot).
* @return App credentials.
*/
private CompletableFuture<MicrosoftAppCredentials> GetAppCredentialsAsync(String appId) {
CompletableFuture<MicrosoftAppCredentials> result = CompletableFuture.supplyAsync(() -> {
if (appId == null) {

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

@ -15,11 +15,11 @@ import java.util.stream.StreamSupport;
import static com.ea.async.Async.await;
import static java.util.concurrent.CompletableFuture.completedFuture;
/// <summary>
/// Abstract Base class which manages details of automatic loading and saving of bot state.
/// </summary>
/// <typeparam name="TState">The type of the bot state object.</typeparam>
//public class BotState<TState> : IMiddleware
/**
* Abstract Base class which manages details of automatic loading and saving of bot state.
* @param TState The type of the bot state object.
*/
//public class BotState<TState> : Middleware
// where TState : class, new()
public class BotState<TState> implements Middleware
{
@ -30,12 +30,12 @@ public class BotState<TState> implements Middleware
private final String propertyName;
private final Supplier<? extends TState> ctor;
/// <summary>
/// Creates a new <see cref="BotState{TState}"/> middleware object.
/// </summary>
/// <param name="name">The name to use to load or save the state object.</param>
/// <param name="storage">The storage provider to use.</param>
/// <param name="settings">The state persistance options to use.</param>
/**
* Creates a new {@link BotState{TState}} middleware object.
* @param name The name to use to load or save the state object.
* @param storage The storage provider to use.
* @param settings The state persistance options to use.
*/
public BotState(Storage storage, String propertyName, Function<TurnContext, String> keyDelegate, Supplier<? extends TState> ctor) {
this(storage, propertyName, keyDelegate, ctor, null);
}
@ -63,15 +63,15 @@ public class BotState<TState> implements Middleware
}
/// <summary>
/// Processess an incoming activity.
/// </summary>
/// <param name="context">The context object for this turn.</param>
/// <param name="next">The delegate to call to continue the bot middleware pipeline.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>This middleware loads the state object on the leading edge of the middleware pipeline
/// and persists the state object on the trailing edge.
/// </remarks>
/**
* Processess an incoming activity.
* @param context The context object for this turn.
* @param next The delegate to call to continue the bot middleware pipeline.
* @return A task that represents the work queued to execute.
* This middleware loads the state object on the leading edge of the middleware pipeline
* and persists the state object on the trailing edge.
*
*/
public CompletableFuture OnTurn(TurnContext context, NextDelegate next) throws Exception {
await(ReadToContextService(context));
await(next.next());
@ -116,11 +116,11 @@ public class BotState<TState> implements Middleware
return completedFuture(await(Write(context, state)));
}
/// <summary>
/// Reads state from storage.
/// </summary>
/// <typeparam name="TState">The type of the bot state object.</typeparam>
/// <param name="context">The context object for this turn.</param>
/**
* Reads state from storage.
* @param TState The type of the bot state object.
* @param context The context object for this turn.
*/
public CompletableFuture<TState> Read(TurnContext context) throws JsonProcessingException {
String key = this.keyDelegate.apply(context);
Map<String, ?> items = await( storage.Read(new String[] { key }));
@ -136,11 +136,11 @@ public class BotState<TState> implements Middleware
return completedFuture(state);
}
/// <summary>
/// Writes state to storage.
/// </summary>
/// <param name="context">The context object for this turn.</param>
/// <param name="state">The state object.</param>
/**
* Writes state to storage.
* @param context The context object for this turn.
* @param state The state object.
*/
public CompletableFuture Write(TurnContext context, TState state) throws Exception {
HashMap<String, TState> changes = new HashMap<String, TState>();
//List<Map.Entry<String, ?>> changes = new ArrayList<Map.Entry<String, ?>>();

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

@ -7,17 +7,16 @@ import java.util.concurrent.CompletableFuture;
import static com.ea.async.Async.await;
import static java.util.concurrent.CompletableFuture.completedFuture;
/// <summary>
/// This piece of middleware can be added to allow you to handle exceptions when they are thrown
/// within your bot's code or middleware further down the pipeline. Using this handler you might
/// send an appropriate message to the user to let them know that something has gone wrong.
/// You can specify the type of exception the middleware should catch and this middleware can be added
/// multiple times to allow you to handle different exception types in different ways.
/// </summary>
/// <typeparam name="T">
/// The type of the exception that you want to catch. This can be 'Exception' to
/// catch all or a specific type of exception
/// </typeparam>
/**
* This piece of middleware can be added to allow you to handle exceptions when they are thrown
* within your bot's code or middleware further down the pipeline. Using this handler you might
* send an appropriate message to the user to let them know that something has gone wrong.
* You can specify the type of exception the middleware should catch and this middleware can be added
* multiple times to allow you to handle different exception types in different ways.
* @param T
* The type of the exception that you want to catch. This can be 'Exception' to
* catch all or a specific type of exception
*/
public class CatchExceptionMiddleware<T extends Exception> implements Middleware {
private final CallOnException _handler;
private final Class<T> _exceptionType;

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

@ -4,15 +4,15 @@ import com.microsoft.bot.builder.TurnContext;
import java.util.function.Supplier;
/// <summary>
/// Handles persistence of a conversation state object using the conversation ID as part of the key.
/// </summary>
/// <typeparam name="TState">The type of the conversation state object.</typeparam>
/**
* Handles persistence of a conversation state object using the conversation ID as part of the key.
* @param TState The type of the conversation state object.
*/
public class ConversationState<TState> extends BotState<TState>
{
/// <summary>
/// The key to use to read and write this conversation state object to storage.
/// </summary>
/**
* The key to use to read and write this conversation state object to storage.
*/
//
// Note: Hard coded to maintain compatibility with C#
// "ConversationState:{typeof(ConversationState<TState>).Namespace}.{typeof(ConversationState<TState>).Name}"
@ -20,11 +20,11 @@ public class ConversationState<TState> extends BotState<TState>
return String.format("ConversationState:Microsoft.Bot.Builder.Core.Extensions.ConversationState`1");
}
/// <summary>
/// Creates a new <see cref="ConversationState{TState}"/> object.
/// </summary>
/// <param name="storage">The storage provider to use.</param>
/// <param name="settings">The state persistance options to use.</param>
/**
* Creates a new {@link ConversationState{TState}} object.
* @param storage The storage provider to use.
* @param settings The state persistance options to use.
*/
public ConversationState(Storage storage, Supplier<? extends TState> ctor) {
this(storage, null, ctor);
}
@ -38,11 +38,11 @@ public class ConversationState<TState> extends BotState<TState>
settings);
}
/// <summary>
/// Gets the conversation state object from turn context.
/// </summary>
/// <param name="context">The context object for this turn.</param>
/// <returns>The coversation state object.</returns>
/**
* Gets the conversation state object from turn context.
* @param context The context object for this turn.
* @return The coversation state object.
*/
public static <TState> TState Get(TurnContext context) throws IllegalArgumentException {
return context.getServices().Get(PropertyName());
}

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

@ -5,23 +5,23 @@ import com.microsoft.bot.schema.models.ConversationReference;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
/// <summary>
/// A method that can participate in delete activity events for the current turn.
/// </summary>
/// <param name="context">The context object for the turn.</param>
/// <param name="reference">The conversation containing the activity.</param>
/// <param name="next">The delegate to call to continue event processing.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>A handler calls the <paramref name="next"/> delegate to pass control to
/// the next registered handler. If a handler doesnt call the next delegate,
/// the adapter does not call any of the subsequent handlers and does not delete the
///activity.
/// <para>The conversation reference's <see cref="ConversationReference.ActivityId"/>
/// indicates the activity in the conversation to replace.</para>
/// </remarks>
/// <seealso cref="BotAdapter"/>
/// <seealso cref="SendActivitiesHandler"/>
/// <seealso cref="UpdateActivityHandler"/>
/**
* A method that can participate in delete activity events for the current turn.
* @param context The context object for the turn.
* @param reference The conversation containing the activity.
* @param next The delegate to call to continue event processing.
* @return A task that represents the work queued to execute.
* A handler calls the {@code next} delegate to pass control to
* the next registered handler. If a handler doesnt call the next delegate,
* the adapter does not call any of the subsequent handlers and does not delete the
*activity.
* <p>The conversation reference's {@link ConversationReference.ActivityId}
* indicates the activity in the conversation to replace.</p>
*
* {@linkalso BotAdapter}
* {@linkalso SendActivitiesHandler}
* {@linkalso UpdateActivityHandler}
*/
@FunctionalInterface
public interface DeleteActivityHandler {
CompletableFuture handle(TurnContext context, ConversationReference reference, Callable<CompletableFuture> next);

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

@ -1,16 +1,16 @@
package com.microsoft.bot.builder;
/// <summary>
/// Tuple class containing an HTTP Status Code and a JSON Serializable
/// object. The HTTP Status code is, in the invoke activity scenario, what will
/// be set in the resulting POST. The Body of the resulting POST will be
/// the JSON Serialized content from the Body property.
/// </summary>
/**
* Tuple class containing an HTTP Status Code and a JSON Serializable
* object. The HTTP Status code is, in the invoke activity scenario, what will
* be set in the resulting POST. The Body of the resulting POST will be
* the JSON Serialized content from the Body property.
*/
public class InvokeResponse {
/// <summary>
/// The POST that is generated in response to the incoming Invoke Activity
/// will have the HTTP Status code specificied by this field.
/// </summary>
/**
* The POST that is generated in response to the incoming Invoke Activity
* will have the HTTP Status code specificied by this field.
*/
private int _status;
public int getStatus() {
@ -21,10 +21,10 @@ public class InvokeResponse {
this._status = status;
}
/// <summary>
/// The POST that is generated in response to the incoming Invoke Activity
/// will have a body generated by JSON serializing the object in the Body field.
/// </summary>
/**
* The POST that is generated in response to the incoming Invoke Activity
* will have a body generated by JSON serializing the object in the Body field.
*/
private Object _body;
public Object getBody() {

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

@ -4,54 +4,54 @@ package com.microsoft.bot.builder;
import java.util.concurrent.CompletableFuture;
/// <summary>
/// Represents middleware that can operate on incoming activities.
/// </summary>
/// <remarks>A <see cref="BotAdapter"/> passes incoming activities from the user's
/// channel to the middleware's <see cref="OnTurn(ITurnContext, NextDelegate)"/>
/// method.
/// <para>You can add middleware objects to your adapters middleware collection. The
/// adapter processes and directs incoming activities in through the bot middleware
/// pipeline to your bots logic and then back out again. As each activity flows in
/// and out of the bot, each piece of middleware can inspect or act upon the activity,
/// both before and after the bot logic runs.</para>
/// <para>For each activity, the adapter calls middleware in the order in which you
/// added it.</para>
/// </remarks>
/// <example>
/// This defines middleware that sends "before" and "after" messages
/// before and after the adapter calls the bot's
/// <see cref="IBot.OnTurn(ITurnContext)"/> method.
/// <code>
/// public class SampleMiddleware : IMiddleware
/// {
/// public async Task OnTurn(ITurnContext context, MiddlewareSet.NextDelegate next)
/// {
/// context.SendActivity("before");
/// await next().ConfigureAwait(false);
/// context.SendActivity("after");
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="IBot"/>
/**
* Represents middleware that can operate on incoming activities.
* A {@link BotAdapter} passes incoming activities from the user's
* channel to the middleware's {@link OnTurn(TurnContext, NextDelegate)}
* method.
* <p>You can add middleware objects to your adapters middleware collection. The
* adapter processes and directs incoming activities in through the bot middleware
* pipeline to your bots logic and then back out again. As each activity flows in
* and out of the bot, each piece of middleware can inspect or act upon the activity,
* both before and after the bot logic runs.</p>
* <p>For each activity, the adapter calls middleware in the order in which you
* added it.</p>
*
* <example>
* This defines middleware that sends "before" and "after" messages
* before and after the adapter calls the bot's
* {@link Bot.OnTurn(TurnContext)} method.
* <code>
* public class SampleMiddleware : Middleware
* {
* public async Task OnTurn(TurnContext context, MiddlewareSet.NextDelegate next)
* {
* context.SendActivity("before");
* await next().ConfigureAwait(false);
* context.SendActivity("after");
* }
* }
* </code>
* </example>
* {@linkalso Bot}
*/
public interface Middleware
{
/// <summary>
/// Processess an incoming activity.
/// </summary>
/// <param name="context">The context object for this turn.</param>
/// <param name="next">The delegate to call to continue the bot middleware pipeline.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>Middleware calls the <paramref name="next"/> delegate to pass control to
/// the next middleware in the pipeline. If middleware doesnt call the next delegate,
/// the adapter does not call any of the subsequent middlewares request handlers or the
/// bots receive handler, and the pipeline short circuits.
/// <para>The <paramref name="context"/> provides information about the
/// incoming activity, and other data needed to process the activity.</para>
/// </remarks>
/// <seealso cref="ITurnContext"/>
/// <seealso cref="Bot.Schema.IActivity"/>
/**
* Processess an incoming activity.
* @param context The context object for this turn.
* @param next The delegate to call to continue the bot middleware pipeline.
* @return A task that represents the work queued to execute.
* Middleware calls the {@code next} delegate to pass control to
* the next middleware in the pipeline. If middleware doesnt call the next delegate,
* the adapter does not call any of the subsequent middlewares request handlers or the
* bots receive handler, and the pipeline short circuits.
* <p>The {@code context} provides information about the
* incoming activity, and other data needed to process the activity.</p>
*
* {@linkalso TurnContext}
* {@linkalso Bot.Schema.Activity}
*/
CompletableFuture OnTurn(TurnContext context, NextDelegate next) throws Exception;
}

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

@ -52,11 +52,11 @@ public class MiddlewareSet implements Middleware
return null;
}
/// <summary>
/// Intended to be called from Bot, this method performs exactly the same as the
/// standard ReceiveActivity, except that it runs a user-defined delegate returns
/// if all Middleware in the receive pipeline was run.
/// </summary>
/**
* Intended to be called from Bot, this method performs exactly the same as the
* standard ReceiveActivity, except that it runs a user-defined delegate returns
* if all Middleware in the receive pipeline was run.
*/
public CompletableFuture ReceiveActivityWithStatus(TurnContext context, Function<TurnContext, CompletableFuture> callback)
throws Exception {
return ReceiveActivityInternal(context, callback);

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

@ -12,4 +12,4 @@ import java.util.concurrent.CompletableFuture;
public interface SendActivitiesHandler {
CompletableFuture<ResourceResponse[]> handle(TurnContext context, List<Activity> activities, Callable<CompletableFuture<ResourceResponse[]>> next);
}
// public delegate CompletableFuture<ResourceResponse[]> SendActivitiesHandler(ITurnContext context, List<Activity> activities, Func<Task<ResourceResponse[]>> next);
// public delegate CompletableFuture<ResourceResponse[]> SendActivitiesHandler(TurnContext context, List<Activity> activities, Func<Task<ResourceResponse[]>> next);

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

@ -4,28 +4,28 @@ import com.microsoft.bot.builder.ConversationState;
import com.microsoft.bot.builder.TurnContext;
import com.microsoft.bot.builder.UserState;
/// <summary>
/// Provides helper methods for getting state objects from the turn context.
/// </summary>
/**
* Provides helper methods for getting state objects from the turn context.
*/
public class StateTurnContextExtensions
{
/// <summary>
/// Gets a conversation state object from the turn context.
/// </summary>
/// <typeparam name="TState">The type of the state object to get.</typeparam>
/// <param name="context">The context object for this turn.</param>
/// <returns>The state object.</returns>
/**
* Gets a conversation state object from the turn context.
* @param TState The type of the state object to get.
* @param context The context object for this turn.
* @return The state object.
*/
public static <TState extends Object> TState GetConversationState(TurnContext context) throws IllegalArgumentException {
return ConversationState.<TState>Get(context);
}
/// <summary>
/// Gets a user state object from the turn context.
/// </summary>
/// <typeparam name="TState">The type of the state object to get.</typeparam>
/// <param name="context">The context object for this turn.</param>
/// <returns>The state object.</returns>
/**
* Gets a user state object from the turn context.
* @param TState The type of the state object to get.
* @param context The context object for this turn.
* @return The state object.
*/
public static <TState> TState GetUserState(TurnContext context) throws IllegalArgumentException {
return UserState.<TState>Get(context);
}

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

@ -11,23 +11,23 @@ import java.util.concurrent.CompletableFuture;
public interface Storage
{
/// <summary>
/// Read StoreItems from storage
/// </summary>
/// <param name="keys">keys of the storeItems to read</param>
/// <returns>StoreItem dictionary</returns>
/**
* Read StoreItems from storage
* @param keys keys of the storeItems to read
* @return StoreItem dictionary
*/
CompletableFuture<Map<String, ? extends Object>> Read(String... keys) throws JsonProcessingException;
/// <summary>
/// Write StoreItems to storage
/// </summary>
/// <param name="changes"></param>
/**
* Write StoreItems to storage
* @param changes
*/
CompletableFuture Write(Map<String, ? extends Object> changes) throws Exception;
/// <summary>
/// Delete StoreItems from storage
/// </summary>
/// <param name="keys">keys of the storeItems to delete</param>
/**
* Delete StoreItems from storage
* @param keys keys of the storeItems to delete
*/
CompletableFuture Delete(String... keys);
}

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

@ -12,13 +12,13 @@ import static com.ea.async.Async.await;
public class StorageExtensions {
/// <summary>
/// Storage extension to Read as strong typed StoreItem objects
/// </summary>
/// <typeparam name="StoreItemT"></typeparam>
/// <param name="storage"></param>
/// <param name="keys"></param>
/// <returns></returns>
/**
* Storage extension to Read as strong typed StoreItem objects
* @param StoreItemT
* @param storage
* @param keys
* @return
*/
@SuppressWarnings("unchecked")
public static <StoreItemT extends Object> CompletableFuture<Map<String, StoreItemT>> Read(Storage storage, String... keys) throws JsonProcessingException {
Map<String, ?> storeItems = await(storage.Read(keys));

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

@ -2,9 +2,9 @@ package com.microsoft.bot.builder;
public interface StoreItem
{
/// <summary>
/// eTag for concurrency
/// </summary>
/**
* eTag for concurrency
*/
String geteTag();
void seteTag(String eTag);

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

@ -2,21 +2,21 @@
// Licensed under the MIT License.
package com.microsoft.bot.builder;
/// <summary>
/// A method that can participate in send activity events for the current turn.
/// </summary>
/// <param name="context">The context object for the turn.</param>
/// <param name="activities">The activities to send.</param>
/// <param name="next">The delegate to call to continue event processing.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>A handler calls the <paramref name="next"/> delegate to pass control to
/// the next registered handler. If a handler doesnt call the next delegate,
/// the adapter does not call any of the subsequent handlers and does not send the
/// <paramref name="activities"/>.
/// </remarks>
/// <seealso cref="BotAdapter"/>
/// <seealso cref="UpdateActivityHandler"/>
/// <seealso cref="DeleteActivityHandler"/>
/**
* A method that can participate in send activity events for the current turn.
* @param context The context object for the turn.
* @param activities The activities to send.
* @param next The delegate to call to continue event processing.
* @return A task that represents the work queued to execute.
* A handler calls the {@code next} delegate to pass control to
* the next registered handler. If a handler doesnt call the next delegate,
* the adapter does not call any of the subsequent handlers and does not send the
* {@code activities}.
*
* {@linkalso BotAdapter}
* {@linkalso UpdateActivityHandler}
* {@linkalso DeleteActivityHandler}
*/
import com.microsoft.bot.schema.ActivityImpl;
import com.microsoft.bot.schema.models.Activity;
@ -25,147 +25,147 @@ import com.microsoft.bot.schema.models.ResourceResponse;
import java.util.concurrent.CompletableFuture;
//public delegate Task DeleteActivityHandler(ITurnContext context, ConversationReference reference, Func<Task> next);
//public delegate Task DeleteActivityHandler(TurnContext context, ConversationReference reference, Func<Task> next);
/// <summary>
/// Provides context for a turn of a bot.
/// </summary>
/// <remarks>Context provides information needed to process an incoming activity.
/// The context object is created by a <see cref="BotAdapter"/> and persists for the
/// length of the turn.</remarks>
/// <seealso cref="IBot"/>
/// <seealso cref="IMiddleware"/>
/**
* Provides context for a turn of a bot.
* Context provides information needed to process an incoming activity.
* The context object is created by a {@link BotAdapter} and persists for the
* length of the turn.
* {@linkalso Bot}
* {@linkalso Middleware}
*/
public interface TurnContext
{
/// <summary>
/// Gets the bot adapter that created this context object.
/// </summary>
/**
* Gets the bot adapter that created this context object.
*/
BotAdapter getAdapter();
/// <summary>
/// Gets the services registered on this context object.
/// </summary>
/**
* Gets the services registered on this context object.
*/
TurnContextServiceCollection getServices();
/// <summary>
/// Incoming request
/// </summary>
/**
* Incoming request
*/
Activity getActivity();
/// <summary>
/// Indicates whether at least one response was sent for the current turn.
/// </summary>
/// <value><c>true</c> if at least one response was sent for the current turn.</value>
/**
* Indicates whether at least one response was sent for the current turn.
* @return {@code true} if at least one response was sent for the current turn.
*/
boolean getResponded();
void setResponded(boolean responded);
/// <summary>
/// Sends a message activity to the sender of the incoming activity.
/// </summary>
/// <param name="textReplyToSend">The text of the message to send.</param>
/// <param name="speak">Optional, text to be spoken by your bot on a speech-enabled
/// channel.</param>
/// <param name="inputHint">Optional, indicates whether your bot is accepting,
/// expecting, or ignoring user input after the message is delivered to the client.
/// One of: "acceptingInput", "ignoringInput", or "expectingInput".
/// Default is "acceptingInput".</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>If the activity is successfully sent, the task result contains
/// a <see cref="ResourceResponse"/> object containing the ID that the receiving
/// channel assigned to the activity.
/// <para>See the channel's documentation for limits imposed upon the contents of
/// <paramref name="textReplyToSend"/>.</para>
/// <para>To control various characteristics of your bot's speech such as voice,
/// rate, volume, pronunciation, and pitch, specify <paramref name="speak"/> in
/// Speech Synthesis Markup Language (SSML) format.</para>
/// </remarks>
/**
* Sends a message activity to the sender of the incoming activity.
* @param textReplyToSend The text of the message to send.
* @param speak Optional, text to be spoken by your bot on a speech-enabled
* channel.
* @param inputHint Optional, indicates whether your bot is accepting,
* expecting, or ignoring user input after the message is delivered to the client.
* One of: "acceptingInput", "ignoringInput", or "expectingInput".
* Default is "acceptingInput".
* @return A task that represents the work queued to execute.
* If the activity is successfully sent, the task result contains
* a {@link ResourceResponse} object containing the ID that the receiving
* channel assigned to the activity.
* <p>See the channel's documentation for limits imposed upon the contents of
* {@code textReplyToSend}.</p>
* <p>To control various characteristics of your bot's speech such as voice,
* rate, volume, pronunciation, and pitch, specify {@code speak} in
* Speech Synthesis Markup Language (SSML) format.</p>
*
*/
CompletableFuture<ResourceResponse> SendActivity(String textReplyToSend) throws Exception;
CompletableFuture<ResourceResponse> SendActivity(String textReplyToSend, String speak) throws Exception;
//CompletableFuture<ResourceResponse> SendActivity(String textReplyToSend, String speak = null, String inputHint = InputHints.AcceptingInput);
CompletableFuture<ResourceResponse> SendActivity(String textReplyToSend, String speak, String inputHint) throws Exception;
/// <summary>
/// Sends an activity to the sender of the incoming activity.
/// </summary>
/// <param name="activity">The activity to send.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>If the activity is successfully sent, the task result contains
/// a <see cref="ResourceResponse"/> object containing the ID that the receiving
/// channel assigned to the activity.</remarks>
/**
* Sends an activity to the sender of the incoming activity.
* @param activity The activity to send.
* @return A task that represents the work queued to execute.
* If the activity is successfully sent, the task result contains
* a {@link ResourceResponse} object containing the ID that the receiving
* channel assigned to the activity.
*/
CompletableFuture<ResourceResponse> SendActivity(Activity activity) throws Exception;
/// <summary>
/// Sends a set of activities to the sender of the incoming activity.
/// </summary>
/// <param name="activities">The activities to send.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>If the activities are successfully sent, the task result contains
/// an array of <see cref="ResourceResponse"/> objects containing the IDs that
/// the receiving channel assigned to the activities.</remarks>
/**
* Sends a set of activities to the sender of the incoming activity.
* @param activities The activities to send.
* @return A task that represents the work queued to execute.
* If the activities are successfully sent, the task result contains
* an array of {@link ResourceResponse} objects containing the IDs that
* the receiving channel assigned to the activities.
*/
CompletableFuture<ResourceResponse[]> SendActivities(Activity[] activities) throws Exception;
/// <summary>
/// Replaces an existing activity.
/// </summary>
/// <param name="activity">New replacement activity.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>If the activity is successfully sent, the task result contains
/// a <see cref="ResourceResponse"/> object containing the ID that the receiving
/// channel assigned to the activity.
/// <para>Before calling this, set the ID of the replacement activity to the ID
/// of the activity to replace.</para></remarks>
/**
* Replaces an existing activity.
* @param activity New replacement activity.
* @return A task that represents the work queued to execute.
* If the activity is successfully sent, the task result contains
* a {@link ResourceResponse} object containing the ID that the receiving
* channel assigned to the activity.
* <p>Before calling this, set the ID of the replacement activity to the ID
* of the activity to replace.</p>
*/
ResourceResponse UpdateActivity(Activity activity) throws Exception;
/// <summary>
/// Deletes an existing activity.
/// </summary>
/// <param name="activityId">The ID of the activity to delete.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/**
* Deletes an existing activity.
* @param activityId The ID of the activity to delete.
* @return A task that represents the work queued to execute.
*/
CompletableFuture DeleteActivity(String activityId) throws Exception;
/// <summary>
/// Deletes an existing activity.
/// </summary>
/// <param name="conversationReference">The conversation containing the activity to delete.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>The conversation reference's <see cref="ConversationReference.ActivityId"/>
/// indicates the activity in the conversation to delete.</remarks>
/**
* Deletes an existing activity.
* @param conversationReference The conversation containing the activity to delete.
* @return A task that represents the work queued to execute.
* The conversation reference's {@link ConversationReference.ActivityId}
* indicates the activity in the conversation to delete.
*/
CompletableFuture DeleteActivity(ConversationReference conversationReference) throws Exception;
/// <summary>
/// Adds a response handler for send activity operations.
/// </summary>
/// <param name="handler">The handler to add to the context object.</param>
/// <returns>The updated context object.</returns>
/// <remarks>When the context's <see cref="SendActivity(IActivity)"/>
/// or <see cref="SendActivities(IActivity[])"/> methods are called,
/// the adapter calls the registered handlers in the order in which they were
/// added to the context object.
/// </remarks>
/**
* Adds a response handler for send activity operations.
* @param handler The handler to add to the context object.
* @return The updated context object.
* When the context's {@link SendActivity(Activity)}
* or {@link SendActivities(Activity[])} methods are called,
* the adapter calls the registered handlers in the order in which they were
* added to the context object.
*
*/
TurnContext OnSendActivities(SendActivitiesHandler handler);
/// <summary>
/// Adds a response handler for update activity operations.
/// </summary>
/// <param name="handler">The handler to add to the context object.</param>
/// <returns>The updated context object.</returns>
/// <remarks>When the context's <see cref="UpdateActivity(IActivity)"/> is called,
/// the adapter calls the registered handlers in the order in which they were
/// added to the context object.
/// </remarks>
/**
* Adds a response handler for update activity operations.
* @param handler The handler to add to the context object.
* @return The updated context object.
* When the context's {@link UpdateActivity(Activity)} is called,
* the adapter calls the registered handlers in the order in which they were
* added to the context object.
*
*/
TurnContext OnUpdateActivity(UpdateActivityHandler handler);
/// <summary>
/// Adds a response handler for delete activity operations.
/// </summary>
/// <param name="handler">The handler to add to the context object.</param>
/// <returns>The updated context object.</returns>
/// <exception cref="ArgumentNullException"><paramref name="handler"/> is <c>null</c>.</exception>
/// <remarks>When the context's <see cref="DeleteActivity(String)"/> is called,
/// the adapter calls the registered handlers in the order in which they were
/// added to the context object.
/// </remarks>
/**
* Adds a response handler for delete activity operations.
* @param handler The handler to add to the context object.
* @return The updated context object.
* @throws NullPointerException {@code handler} is {@code null}.
* When the context's {@link DeleteActivity(String)} is called,
* the adapter calls the registered handlers in the order in which they were
* added to the context object.
*
*/
TurnContext OnDeleteActivity(DeleteActivityHandler handler);
}

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

@ -20,14 +20,14 @@ import static com.microsoft.bot.schema.models.ActivityTypes.TRACE;
import static java.util.concurrent.CompletableFuture.completedFuture;
import static java.util.stream.Collectors.toList;
/// <summary>
/// Provides context for a turn of a bot.
/// </summary>
/// <remarks>Context provides information needed to process an incoming activity.
/// The context object is created by a <see cref="BotAdapter"/> and persists for the
/// length of the turn.</remarks>
/// <seealso cref="IBot"/>
/// <seealso cref="IMiddleware"/>
/**
* Provides context for a turn of a bot.
* Context provides information needed to process an incoming activity.
* The context object is created by a {@link BotAdapter} and persists for the
* length of the turn.
* {@linkalso Bot}
* {@linkalso Middleware}
*/
public class TurnContextImpl implements TurnContext, AutoCloseable {
private final BotAdapter adapter;
private final ActivityImpl activity;
@ -39,15 +39,15 @@ public class TurnContextImpl implements TurnContext, AutoCloseable {
private final TurnContextServiceCollection turnServices;
/// <summary>
/// Creates a context object.
/// </summary>
/// <param name="adapter">The adapter creating the context.</param>
/// <param name="activity">The incoming activity for the turn;
/// or <c>null</c> for a turn for a proactive message.</param>
/// <exception cref="IllegalArgumentException"><paramref name="activity"/> or
/// <paramref name="adapter"/> is <c>null</c>.</exception>
/// <remarks>For use by bot adapter implementations only.</remarks>
/**
* Creates a context object.
* @param adapter The adapter creating the context.
* @param activity The incoming activity for the turn;
* or {@code null} for a turn for a proactive message.
* @throws IllegalArgumentException {@code activity} or
* {@code adapter} is {@code null}.
* For use by bot adapter implementations only.
*/
public TurnContextImpl(BotAdapter adapter, ActivityImpl activity) {
if (adapter == null)
throw new IllegalArgumentException("adapter");
@ -61,17 +61,17 @@ public class TurnContextImpl implements TurnContext, AutoCloseable {
/// <summary>
/// Adds a response handler for send activity operations.
/// </summary>
/// <param name="handler">The handler to add to the context object.</param>
/// <returns>The updated context object.</returns>
/// <exception cref="IllegalArgumentException"><paramref name="handler"/> is <c>null</c>.</exception>
/// <remarks>When the context's <see cref="SendActivity(IActivity)"/>
/// or <see cref="SendActivities(IActivity[])"/> methods are called,
/// the adapter calls the registered handlers in the order in which they were
/// added to the context object.
/// </remarks>
/**
* Adds a response handler for send activity operations.
* @param handler The handler to add to the context object.
* @return The updated context object.
* @throws IllegalArgumentException {@code handler} is {@code null}.
* When the context's {@link SendActivity(Activity)}
* or {@link SendActivities(Activity[])} methods are called,
* the adapter calls the registered handlers in the order in which they were
* added to the context object.
*
*/
public TurnContextImpl OnSendActivities(SendActivitiesHandler handler) {
if (handler == null)
throw new IllegalArgumentException("handler");
@ -80,16 +80,16 @@ public class TurnContextImpl implements TurnContext, AutoCloseable {
return this;
}
/// <summary>
/// Adds a response handler for update activity operations.
/// </summary>
/// <param name="handler">The handler to add to the context object.</param>
/// <returns>The updated context object.</returns>
/// <exception cref="IllegalArgumentException"><paramref name="handler"/> is <c>null</c>.</exception>
/// <remarks>When the context's <see cref="UpdateActivity(IActivity)"/> is called,
/// the adapter calls the registered handlers in the order in which they were
/// added to the context object.
/// </remarks>
/**
* Adds a response handler for update activity operations.
* @param handler The handler to add to the context object.
* @return The updated context object.
* @throws IllegalArgumentException {@code handler} is {@code null}.
* When the context's {@link UpdateActivity(Activity)} is called,
* the adapter calls the registered handlers in the order in which they were
* added to the context object.
*
*/
public TurnContextImpl OnUpdateActivity(UpdateActivityHandler handler) {
if (handler == null)
throw new IllegalArgumentException("handler");
@ -98,16 +98,16 @@ public class TurnContextImpl implements TurnContext, AutoCloseable {
return this;
}
/// <summary>
/// Adds a response handler for delete activity operations.
/// </summary>
/// <param name="handler">The handler to add to the context object.</param>
/// <returns>The updated context object.</returns>
/// <exception cref="IllegalArgumentException"><paramref name="handler"/> is <c>null</c>.</exception>
/// <remarks>When the context's <see cref="DeleteActivity(string)"/> is called,
/// the adapter calls the registered handlers in the order in which they were
/// added to the context object.
/// </remarks>
/**
* Adds a response handler for delete activity operations.
* @param handler The handler to add to the context object.
* @return The updated context object.
* @throws IllegalArgumentException {@code handler} is {@code null}.
* When the context's {@link DeleteActivity(string)} is called,
* the adapter calls the registered handlers in the order in which they were
* added to the context object.
*
*/
public TurnContextImpl OnDeleteActivity(DeleteActivityHandler handler) {
if (handler == null)
throw new IllegalArgumentException("handler");
@ -116,34 +116,34 @@ public class TurnContextImpl implements TurnContext, AutoCloseable {
return this;
}
/// <summary>
/// Gets the bot adapter that created this context object.
/// </summary>
/**
* Gets the bot adapter that created this context object.
*/
public BotAdapter getAdapter() {
return this.adapter;
}
/// <summary>
/// Gets the services registered on this context object.
/// </summary>
/**
* Gets the services registered on this context object.
*/
public TurnContextServiceCollection getServices() {
return this.turnServices;
}
/// <summary>
/// Gets the activity associated with this turn; or <c>null</c> when processing
/// a proactive message.
/// </summary>
/**
* Gets the activity associated with this turn; or {@code null} when processing
* a proactive message.
*/
@Override
public Activity getActivity() {
return this.activity;
}
/// <summary>
/// Indicates whether at least one response was sent for the current turn.
/// </summary>
/// <value><c>true</c> if at least one response was sent for the current turn.</value>
/// <exception cref="ArgumentException">You attempted to set the value to <c>false</c>.</exception>
/**
* Indicates whether at least one response was sent for the current turn.
* @return {@code true} if at least one response was sent for the current turn.
* @throws IllegalArgumentException You attempted to set the value to {@code false}.
*/
public boolean getResponded() {
return this.responded;
}
@ -155,28 +155,28 @@ public class TurnContextImpl implements TurnContext, AutoCloseable {
this.responded = true;
}
/// <summary>
/// Sends a message activity to the sender of the incoming activity.
/// </summary>
/// <param name="textReplyToSend">The text of the message to send.</param>
/// <param name="speak">Optional, text to be spoken by your bot on a speech-enabled
/// channel.</param>
/// <param name="inputHint">Optional, indicates whether your bot is accepting,
/// expecting, or ignoring user input after the message is delivered to the client.
/// One of: "acceptingInput", "ignoringInput", or "expectingInput".
/// Default is null.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <exception cref="IllegalArgumentException">
/// <paramref name="textReplyToSend"/> is <c>null</c> or whitespace.</exception>
/// <remarks>If the activity is successfully sent, the task result contains
/// a <see cref="ResourceResponse"/> object containing the ID that the receiving
/// channel assigned to the activity.
/// <para>See the channel's documentation for limits imposed upon the contents of
/// <paramref name="textReplyToSend"/>.</para>
/// <para>To control various characteristics of your bot's speech such as voice,
/// rate, volume, pronunciation, and pitch, specify <paramref name="speak"/> in
/// Speech Synthesis Markup Language (SSML) format.</para>
/// </remarks>
/**
* Sends a message activity to the sender of the incoming activity.
* @param textReplyToSend The text of the message to send.
* @param speak Optional, text to be spoken by your bot on a speech-enabled
* channel.
* @param inputHint Optional, indicates whether your bot is accepting,
* expecting, or ignoring user input after the message is delivered to the client.
* One of: "acceptingInput", "ignoringInput", or "expectingInput".
* Default is null.
* @return A task that represents the work queued to execute.
* @throws IllegalArgumentException
* {@code textReplyToSend} is {@code null} or whitespace.
* If the activity is successfully sent, the task result contains
* a {@link ResourceResponse} object containing the ID that the receiving
* channel assigned to the activity.
* <p>See the channel's documentation for limits imposed upon the contents of
* {@code textReplyToSend}.</p>
* <p>To control various characteristics of your bot's speech such as voice,
* rate, volume, pronunciation, and pitch, specify {@code speak} in
* Speech Synthesis Markup Language (SSML) format.</p>
*
*/
@Override
public CompletableFuture<ResourceResponse> SendActivity(String textReplyToSend) throws Exception {
return SendActivity(textReplyToSend, null, null);
@ -202,15 +202,15 @@ public class TurnContextImpl implements TurnContext, AutoCloseable {
return completedFuture(await(SendActivity(activityToSend)));
}
/// <summary>
/// Sends an activity to the sender of the incoming activity.
/// </summary>
/// <param name="activity">The activity to send.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <exception cref="IllegalArgumentException"><paramref name="activity"/> is <c>null</c>.</exception>
/// <remarks>If the activity is successfully sent, the task result contains
/// a <see cref="ResourceResponse"/> object containing the ID that the receiving
/// channel assigned to the activity.</remarks>
/**
* Sends an activity to the sender of the incoming activity.
* @param activity The activity to send.
* @return A task that represents the work queued to execute.
* @throws IllegalArgumentException {@code activity} is {@code null}.
* If the activity is successfully sent, the task result contains
* a {@link ResourceResponse} object containing the ID that the receiving
* channel assigned to the activity.
*/
@Override
public CompletableFuture<ResourceResponse> SendActivity(Activity activity) throws Exception {
if (activity == null)
@ -237,14 +237,14 @@ public class TurnContextImpl implements TurnContext, AutoCloseable {
}
/// <summary>
/// Sends a set of activities to the sender of the incoming activity.
/// </summary>
/// <param name="activities">The activities to send.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>If the activities are successfully sent, the task result contains
/// an array of <see cref="ResourceResponse"/> objects containing the IDs that
/// the receiving channel assigned to the activities.</remarks>
/**
* Sends a set of activities to the sender of the incoming activity.
* @param activities The activities to send.
* @return A task that represents the work queued to execute.
* If the activities are successfully sent, the task result contains
* an array of {@link ResourceResponse} objects containing the IDs that
* the receiving channel assigned to the activities.
*/
@Override
public CompletableFuture<ResourceResponse[]> SendActivities(Activity[] activities) throws Exception {
// Bind the relevant Conversation Reference properties, such as URLs and
@ -296,20 +296,20 @@ public class TurnContextImpl implements TurnContext, AutoCloseable {
return completedFuture(await(SendActivitiesInternal(act_list, onSendActivities.iterator(), ActuallySendStuff)));
}
/// <summary>
/// Replaces an existing activity.
/// </summary>
/// <param name="activity">New replacement activity.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <exception cref="Microsoft.Bot.Schema.ErrorResponseException">
/// The HTTP operation failed and the response contained additional information.</exception>
/// <exception cref="System.AggregateException">
/// One or more exceptions occurred during the operation.</exception>
/// <remarks>If the activity is successfully sent, the task result contains
/// a <see cref="ResourceResponse"/> object containing the ID that the receiving
/// channel assigned to the activity.
/// <para>Before calling this, set the ID of the replacement activity to the ID
/// of the activity to replace.</para></remarks>
/**
* Replaces an existing activity.
* @param activity New replacement activity.
* @return A task that represents the work queued to execute.
* @throws Microsoft.Bot.Schema.ErrorResponseException
* The HTTP operation failed and the response contained additional information.
* @throws System.AggregateException
* One or more exceptions occurred during the operation.
* If the activity is successfully sent, the task result contains
* a {@link ResourceResponse} object containing the ID that the receiving
* channel assigned to the activity.
* <p>Before calling this, set the ID of the replacement activity to the ID
* of the activity to replace.</p>
*/
@Override
public ResourceResponse UpdateActivity(Activity activity) throws Exception {
@ -322,13 +322,13 @@ public class TurnContextImpl implements TurnContext, AutoCloseable {
return await(UpdateActivityInternal(activity, onUpdateActivity.iterator(), ActuallyUpdateStuff));
}
/// <summary>
/// Deletes an existing activity.
/// </summary>
/// <param name="activityId">The ID of the activity to delete.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <exception cref="Microsoft.Bot.Schema.ErrorResponseException">
/// The HTTP operation failed and the response contained additional information.</exception>
/**
* Deletes an existing activity.
* @param activityId The ID of the activity to delete.
* @return A task that represents the work queued to execute.
* @throws Microsoft.Bot.Schema.ErrorResponseException
* The HTTP operation failed and the response contained additional information.
*/
public CompletableFuture DeleteActivity(String activityId) throws Exception {
if (StringUtils.isWhitespace(activityId) || activityId == null)
throw new IllegalArgumentException("activityId");
@ -345,15 +345,15 @@ public class TurnContextImpl implements TurnContext, AutoCloseable {
return completedFuture(null);
}
/// <summary>
/// Deletes an existing activity.
/// </summary>
/// <param name="conversationReference">The conversation containing the activity to delete.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <exception cref="Microsoft.Bot.Schema.ErrorResponseException">
/// The HTTP operation failed and the response contained additional information.</exception>
/// <remarks>The conversation reference's <see cref="ConversationReference.ActivityId"/>
/// indicates the activity in the conversation to delete.</remarks>
/**
* Deletes an existing activity.
* @param conversationReference The conversation containing the activity to delete.
* @return A task that represents the work queued to execute.
* @throws Microsoft.Bot.Schema.ErrorResponseException
* The HTTP operation failed and the response contained additional information.
* The conversation reference's {@link ConversationReference.ActivityId}
* indicates the activity in the conversation to delete.
*/
public CompletableFuture DeleteActivity(ConversationReference conversationReference) throws Exception {
if (conversationReference == null)
throw new IllegalArgumentException("conversationReference");
@ -415,18 +415,24 @@ public class TurnContextImpl implements TurnContext, AutoCloseable {
// return null;
// }
//
// // Default to "No more Middleware after this".
// /**
// */ Default to "No more Middleware after this".
// */
// async Task<ResourceResponse> next()
// {
// // Remove the first item from the list of middleware to call,
// // so that the next call just has the remaining items to worry about.
// /**
// */ Remove the first item from the list of middleware to call,
// */ so that the next call just has the remaining items to worry about.
// */
// IEnumerable<UpdateActivityHandler> remaining = updateHandlers.Skip(1);
// var result = await UpdateActivityInternal(activity, remaining, callAtBottom).ConfigureAwait(false);
// activity.Id = result.Id;
// return result;
// }
//
// // Grab the current middleware, which is the 1st element in the array, and execute it
// /**
// */ Grab the current middleware, which is the 1st element in the array, and execute it
// */
// UpdateActivityHandler toCall = updateHandlers.First();
// return await toCall(this, activity, next);
// }
@ -494,13 +500,13 @@ public class TurnContextImpl implements TurnContext, AutoCloseable {
return completedFuture(null);
}
/// <summary>
/// Creates a conversation reference from an activity.
/// </summary>
/// <param name="activity">The activity.</param>
/// <returns>A conversation reference for the conversation that contains the activity.</returns>
/// <exception cref="IllegalArgumentException">
/// <paramref name="activity"/> is <c>null</c>.</exception>
/**
* Creates a conversation reference from an activity.
* @param activity The activity.
* @return A conversation reference for the conversation that contains the activity.
* @throws IllegalArgumentException
* {@code activity} is {@code null}.
*/
public static ConversationReference GetConversationReference(Activity activity) {
BotAssert.ActivityNotNull(activity);
@ -515,21 +521,21 @@ public class TurnContextImpl implements TurnContext, AutoCloseable {
return r;
}
/// <summary>
/// Updates an activity with the delivery information from an existing
/// conversation reference.
/// </summary>
/// <param name="activity">The activity to update.</param>
/// <param name="reference">The conversation reference.</param>
/// <param name="isIncoming">(Optional) <c>true</c> to treat the activity as an
/// incoming activity, where the bot is the recipient; otherwaire <c>false</c>.
/// Default is <c>false</c>, and the activity will show the bot as the sender.</param>
/// <remarks>Call <see cref="GetConversationReference(Activity)"/> on an incoming
/// activity to get a conversation reference that you can then use to update an
/// outgoing activity with the correct delivery information.
/// <para>The <see cref="SendActivity(IActivity)"/> and <see cref="SendActivities(IActivity[])"/>
/// methods do this for you.</para>
/// </remarks>
/**
* Updates an activity with the delivery information from an existing
* conversation reference.
* @param activity The activity to update.
* @param reference The conversation reference.
* @param isIncoming (Optional) {@code true} to treat the activity as an
* incoming activity, where the bot is the recipient; otherwaire {@code false}.
* Default is {@code false}, and the activity will show the bot as the sender.
* Call {@link GetConversationReference(Activity)} on an incoming
* activity to get a conversation reference that you can then use to update an
* outgoing activity with the correct delivery information.
* <p>The {@link SendActivity(Activity)} and {@link SendActivities(Activity[])}
* methods do this for you.</p>
*
*/
public static Activity ApplyConversationReference(Activity activity, ConversationReference reference) {
return ApplyConversationReference(activity, reference, false);
}

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

@ -2,28 +2,28 @@ package com.microsoft.bot.builder;
import java.util.Map;
/// <summary>
/// Represents a set of collection of services associated with the <see cref="ITurnContext"/>.
/// </summary>
/// <remarks>
/// TODO: add more details on what kind of services can/should be stored here, by whom and what the lifetime semantics are, etc.
/// </remarks>
/**
* Represents a set of collection of services associated with the {@link TurnContext}.
*
* TODO: add more details on what kind of services can/should be stored here, by whom and what the lifetime semantics are, etc.
*
*/
public interface TurnContextServiceCollection extends Iterable<Map.Entry<String, Object>>, AutoCloseable {
/// <summary>
/// Add a service with a specified key.
/// </summary>
/// <typeparam name="TService">The type of service to be added.</typeparam>
/// <param name="key">The key to store the service under.</param>
/// <param name="service">The service to add.</param>
/// <exception cref="IllegalArgumentException">Thrown when a service is already registered with the specified <paramref name="key"/></exception>
/**
* Add a service with a specified key.
* @param TService The type of service to be added.
* @param key The key to store the service under.
* @param service The service to add.
* @throws IllegalArgumentException Thrown when a service is already registered with the specified {@code key}
*/
<TService extends Object> void Add(String key, TService service) throws IllegalArgumentException;
/// <summary>
/// Get a service by its key.
/// </summary>
/// <typeparam name="TService">The type of service to be retrieved.</typeparam>
/// <param name="key">The key of the service to get.</param>
/// <returns>The service stored under the specified key.</returns>
/**
* Get a service by its key.
* @param TService The type of service to be retrieved.
* @param key The key of the service to get.
* @return The service stored under the specified key.
*/
<TService extends Object> TService Get(String key) throws IllegalArgumentException;
}

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

@ -22,11 +22,11 @@ public final class TurnContextServiceCollectionImpl implements TurnContextServic
// TODO: log that we didn't find the requested service
return (TService) service;
}
/// <summary>
/// Get a service by type using its full type name as the key.
/// </summary>
/// <typeparam name="TService">The type of service to be retrieved.</typeparam>
/// <returns>The service stored under the specified key.</returns>
/**
* Get a service by type using its full type name as the key.
* @param TService The type of service to be retrieved.
* @return The service stored under the specified key.
*/
public <TService> TService Get(Class<TService> type) throws IllegalArgumentException {
return this.Get(type.getName());
}
@ -40,11 +40,11 @@ public final class TurnContextServiceCollectionImpl implements TurnContextServic
throw new IllegalArgumentException (String.format("Key %s already exists", key));
_services.put(key, service);
}
/// <summary>
/// Add a service using its full type name as the key.
/// </summary>
/// <typeparam name="TService">The type of service to be added.</typeparam>
/// <param name="service">The service to add.</param>
/**
* Add a service using its full type name as the key.
* @param TService The type of service to be added.
* @param service The service to add.
*/
public <TService> void Add(TService service, Class<TService> type) throws IllegalArgumentException {
Add(type.getName(), service);

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

@ -7,27 +7,27 @@ import com.microsoft.bot.schema.models.ResourceResponse;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
/// <summary>
/// A method that can participate in update activity events for the current turn.
/// </summary>
/// <param name="context">The context object for the turn.</param>
/// <param name="activity">The replacement activity.</param>
/// <param name="next">The delegate to call to continue event processing.</param>
/// <returns>A task that represents the work queued to execute.</returns>
/// <remarks>A handler calls the <paramref name="next"/> delegate to pass control to
/// the next registered handler. If a handler doesnt call the next delegate,
/// the adapter does not call any of the subsequent handlers and does not update the
/// activity.
/// <para>The activity's <see cref="IActivity.Id"/> indicates the activity in the
/// conversation to replace.</para>
/// </remarks>
/// <seealso cref="BotAdapter"/>
/// <seealso cref="SendActivitiesHandler"/>
/// <seealso cref="DeleteActivityHandler"/>
/**
* A method that can participate in update activity events for the current turn.
* @param context The context object for the turn.
* @param activity The replacement activity.
* @param next The delegate to call to continue event processing.
* @return A task that represents the work queued to execute.
* A handler calls the {@code next} delegate to pass control to
* the next registered handler. If a handler doesnt call the next delegate,
* the adapter does not call any of the subsequent handlers and does not update the
* activity.
* <p>The activity's {@link Activity.Id} indicates the activity in the
* conversation to replace.</p>
*
* {@linkalso BotAdapter}
* {@linkalso SendActivitiesHandler}
* {@linkalso DeleteActivityHandler}
*/
// public delegate Task<ResourceResponse> UpdateActivityHandler(ITurnContext context, Activity activity, Func<Task<ResourceResponse>> next);
// public delegate Task<ResourceResponse> UpdateActivityHandler(TurnContext context, Activity activity, Func<Task<ResourceResponse>> next);
@FunctionalInterface
public interface UpdateActivityHandler {
CompletableFuture<ResourceResponse> handle(TurnContext context, Activity activity, Callable<CompletableFuture<ResourceResponse[]>> next);

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

@ -7,26 +7,26 @@ import com.microsoft.bot.builder.TurnContext;
import java.util.function.Supplier;
/// <summary>
/// Handles persistence of a user state object using the user ID as part of the key.
/// </summary>
/// <typeparam name="TState">The type of the user state object.</typeparam>
/**
* Handles persistence of a user state object using the user ID as part of the key.
* @param TState The type of the user state object.
*/
public class UserState<TState> extends BotState<TState>
{
/// <summary>
/// The key to use to read and write this conversation state object to storage.
/// </summary>
/**
* The key to use to read and write this conversation state object to storage.
*/
// Note: Hard coded to maintain compatibility with C#
// "UserState:{typeof(UserState<TState>).Namespace}.{typeof(UserState<TState>).Name}"
public static String PropertyName() {
return String.format("UserState:Microsoft.Bot.Builder.Core.Extensions.UserState`1");
}
/// <summary>
/// Creates a new <see cref="UserState{TState}"/> object.
/// </summary>
/// <param name="storage">The storage provider to use.</param>
/// <param name="settings">The state persistance options to use.</param>
/**
* Creates a new {@link UserState{TState}} object.
* @param storage The storage provider to use.
* @param settings The state persistance options to use.
*/
public UserState(Storage storage, Supplier<? extends TState> ctor) {
this(storage, ctor, null);
}
@ -39,11 +39,11 @@ public class UserState<TState> extends BotState<TState>
settings);
}
/// <summary>
/// Gets the user state object from turn context.
/// </summary>
/// <param name="context">The context object for this turn.</param>
/// <returns>The user state object.</returns>
/**
* Gets the user state object from turn context.
* @param context The context object for this turn.
* @return The user state object.
*/
public static <TState> TState Get(TurnContext context) throws IllegalArgumentException {
return context.getServices().<TState>Get(PropertyName());
}

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

@ -170,12 +170,12 @@ public class TestAdapter extends BotAdapter {
return completedFuture(null);
}
/// <summary>
/// NOTE: this resets the queue, it doesn't actually maintain multiple converstion queues
/// </summary>
/// <param name="channelId"></param>
/// <param name="callback"></param>
/// <returns></returns>
/**
* NOTE: this resets the queue, it doesn't actually maintain multiple converstion queues
* @param channelId
* @param callback
* @return
*/
//@Override
public CompletableFuture CreateConversation(String channelId,Function<TurnContext, CompletableFuture> callback) {
this.activeQueue().clear();
@ -186,10 +186,10 @@ public class TestAdapter extends BotAdapter {
return callback.apply(context);
}
/// <summary>
/// Called by TestFlow to check next reply
/// </summary>
/// <returns></returns>
/**
* Called by TestFlow to check next reply
* @return
*/
public Activity GetNextReply() {
synchronized (this.botReplies) {
if(this.botReplies.size()>0) {
@ -199,11 +199,11 @@ public class TestAdapter extends BotAdapter {
return null;
}
/// <summary>
/// Called by TestFlow to get appropriate activity for conversationReference of testbot
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
/**
* Called by TestFlow to get appropriate activity for conversationReference of testbot
* @param text
* @return
*/
public Activity MakeActivity() {
return MakeActivity(null);
}
@ -223,11 +223,11 @@ public class TestAdapter extends BotAdapter {
}
/// <summary>
/// Called by TestFlow to send text to the bot
/// </summary>
/// <param name="userSays"></param>
/// <returns></returns>
/**
* Called by TestFlow to send text to the bot
* @param userSays
* @return
*/
public CompletableFuture SendTextToBot(String userSays,Function<TurnContext, CompletableFuture> callback) throws Exception {
return this.ProcessActivity(this.MakeActivity(userSays),callback);
}

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

@ -9,20 +9,20 @@ import com.microsoft.bot.builder.TurnContext;
import java.util.HashMap;
import java.util.concurrent.CompletableFuture;
/// <summary>
/// Base class for controls
/// </summary>
/**
* Base class for controls
*/
public abstract class Dialog
{
/// <summary>
/// Starts the dialog. Depending on the dialog, its possible for the dialog to finish
/// immediately so it's advised to check the completion Object returned by `begin()` and ensure
/// that the dialog is still active before continuing.
/// </summary>
/// <param name="context">Context for the current turn of the conversation with the user.</param>
/// <param name="state">A state Object that the dialog will use to persist its current state. This should be an empty Object which the dialog will populate. The bot should persist this with its other conversation state for as long as the dialog is still active.</param>
/// <param name="options">(Optional) additional options supported by the dialog.</param>
/// <returns>DialogCompletion result</returns>
/**
* Starts the dialog. Depending on the dialog, its possible for the dialog to finish
* immediately so it's advised to check the completion Object returned by `begin()` and ensure
* that the dialog is still active before continuing.
* @param context Context for the current turn of the conversation with the user.
* @param state A state Object that the dialog will use to persist its current state. This should be an empty Object which the dialog will populate. The bot should persist this with its other conversation state for as long as the dialog is still active.
* @param options (Optional) additional options supported by the dialog.
* @return DialogCompletion result
*/
public CompletableFuture<DialogCompletion> Begin(TurnContext context, HashMap<String, Object> state)
{
return Begin(context, state, null);
@ -63,15 +63,15 @@ public abstract class Dialog
return result;
}
/// <summary>
/// Passes a users reply to the dialog for further processing.The bot should keep calling
/// 'continue()' for future turns until the dialog returns a completion Object with
/// 'isCompleted == true'. To cancel or interrupt the prompt simply delete the `state` Object
/// being persisted.
/// </summary>
/// <param name="context">Context for the current turn of the conversation with the user.</param>
/// <param name="state">A state Object that was previously initialized by a call to [begin()](#begin).</param>
/// <returns>DialogCompletion result</returns>
/**
* Passes a users reply to the dialog for further processing.The bot should keep calling
* 'continue()' for future turns until the dialog returns a completion Object with
* 'isCompleted == true'. To cancel or interrupt the prompt simply delete the `state` Object
* being persisted.
* @param context Context for the current turn of the conversation with the user.
* @param state A state Object that was previously initialized by a call to [begin()](#begin).
* @return DialogCompletion result
*/
public CompletableFuture<DialogCompletion> Continue(TurnContext context, HashMap<String, Object> state)
{
BotAssert.ContextNotNull(context);

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

@ -5,17 +5,17 @@ package com.microsoft.bot.builder.dialogs;
import java.util.HashMap;
/// <summary>
/// Result returned to the caller of one of the various stack manipulation methods and used to
/// return the result from a final call to `DialogContext.end()` to the bots logic.
/// </summary>
/**
* Result returned to the caller of one of the various stack manipulation methods and used to
* return the result from a final call to `DialogContext.end()` to the bots logic.
*/
public class DialogCompletion
{
/// <summary>
/// If 'true' the dialog is still active.
/// </summary>
/**
* If 'true' the dialog is still active.
*/
boolean _isActive;
public void setIsActive(boolean isActive) {
this._isActive = isActive;
@ -24,9 +24,9 @@ public class DialogCompletion
return this._isActive;
}
/// <summary>
/// If 'true' the dialog just completed and the final [result](#result) can be retrieved.
/// </summary>
/**
* If 'true' the dialog just completed and the final [result](#result) can be retrieved.
*/
boolean _isCompleted;
public void setIsCompleted(boolean isCompleted)
{
@ -37,15 +37,13 @@ public class DialogCompletion
return this._isCompleted;
}
/// <summary>
/// Result returned by a dialog that was just ended.This will only be populated in certain
/// cases:
///
/// - The bot calls `dc.begin()` to start a new dialog and the dialog ends immediately.
/// - The bot calls `dc.continue()` and a dialog that was active ends.
///
/// In all cases where it's populated, [active](#active) will be `false`.
/// </summary>
/**
* Result returned by a dialog that was just ended.This will only be populated in certain
* cases:
* - The bot calls `dc.begin()` to start a new dialog and the dialog ends immediately.
* - The bot calls `dc.continue()` and a dialog that was active ends.
* In all cases where it's populated, [active](#active) will be `false`.
*/
HashMap<String, Object> _result;
public HashMap<String, Object> getResult() {
return _result;

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

@ -47,4 +47,4 @@ public class DialogContainer implements IDialogContinue
}
}
}
*/
*/

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

@ -33,16 +33,16 @@ package com.microsoft.bot.builder.dialogs;
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
/// <summary>
/// Encapsulates a method that represents the code to execute after a result is available.
/// </summary>
/// <remarks>
/// The result is often a message from the user.
/// </remarks>
/// <typeparam name="T">The type of the result.</typeparam>
/// <param name="context">The dialog context.</param>
/// <param name="result">The result.</param>
/// <returns>A task that represents the code that will resume after the result is available.</returns>
/**
* Encapsulates a method that represents the code to execute after a result is available.
*
* The result is often a message from the user.
*
* @param T The type of the result.
* @param context The dialog context.
* @param result The result.
* @return A task that represents the code that will resume after the result is available.
*/
/*
public interface ResumeAfter
@ -51,44 +51,44 @@ public interface ResumeAfter
}
public delegate Task ResumeAfter<in T>(IDialogContext context, IAwaitable<T> result);
/// <summary>
/// Encapsulate a method that represents the code to start a dialog.
/// </summary>
/// <param name="context">The dialog context.</param>
/// <returns>A task that represents the start code for a dialog.</returns>
public delegate Task StartAsync(IDialogContext context);
*/
/**
* Encapsulate a method that represents the code to start a dialog.
* @param context The dialog context.
* @return A task that represents the start code for a dialog.
*/
//public delegate Task StartAsync(IDialogContext context);
/// <summary>
/// The context for the execution of a dialog's conversational process.
/// </summary>
/**
* The context for the execution of a dialog's conversational process.
*/
// DAVETA: TODO
// public interface DialogContext extends
public interface DialogContext {
}
/// <summary>
/// Helper methods.
/// </summary>
/**
* Helper methods.
*/
/*
public static partial class Extensions
{
/// <summary>
/// Post a message to be sent to the user, using previous messages to establish a conversation context.
/// </summary>
/// <remarks>
/// If the locale parameter is not set, locale of the incoming message will be used for reply.
/// </remarks>
/// <param name="botToUser">Communication channel to use.</param>
/// <param name="text">The message text.</param>
/// <param name="locale">The locale of the text.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A task that represents the post operation.</returns>
public static async Task PostAsync(this IBotToUser botToUser, string text, string locale = null, CancellationToken cancellationToken = default(CancellationToken))
{*/
/**
* Post a message to be sent to the user, using previous messages to establish a conversation context.
*
* If the locale parameter is not set, locale of the incoming message will be used for reply.
*
* @param botToUser Communication channel to use.
* @param text The message text.
* @param locale The locale of the text.
* @return A task that represents the post operation.
*/
/*
public static async Task PostAsync(this BotToUser botToUser, string text, string locale = null)
{
var message = botToUser.MakeMessage();
message.Text = text;
@ -98,24 +98,24 @@ public static partial class Extensions
message.Locale = locale;
}
await botToUser.PostAsync(message, cancellationToken);
await botToUser.PostAsync(message);
}
*/
/// <summary>
/// Post a message and optional SSML to be sent to the user, using previous messages to establish a conversation context.
/// </summary>
/// <remarks>
/// If the locale parameter is not set, locale of the incoming message will be used for reply.
/// </remarks>
/// <param name="botToUser">Communication channel to use.</param>
/// <param name="text">The message text.</param>
/// <param name="speak">The SSML markup for text to speech.</param>
/// <param name="options">The options for the message.</param>
/// <param name="locale">The locale of the text.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A task that represents the post operation.</returns>
public static async Task SayAsync(this IBotToUser botToUser, string text, string speak = null, MessageOptions options = null, string locale = null, CancellationToken cancellationToken = default(CancellationToken))
/**
* Post a message and optional SSML to be sent to the user, using previous messages to establish a conversation context.
*
* If the locale parameter is not set, locale of the incoming message will be used for reply.
*
* @param botToUser Communication channel to use.
* @param text The message text.
* @param speak The SSML markup for text to speech.
* @param options The options for the message.
* @param locale The locale of the text.
* @return A task that represents the post operation.
*/
/* public static async Task SayAsync(this BotToUser botToUser, string text, string speak = null, MessageOptions options = null, string locale = null)
{
var message = botToUser.MakeMessage();
@ -136,32 +136,32 @@ public static partial class Extensions
message.Entities = options.Entities;
}
await botToUser.PostAsync(message, cancellationToken);
}
await botToUser.PostAsync(message);
}*/
/// <summary>
/// Suspend the current dialog until the user has sent a message to the bot.
/// </summary>
/// <param name="stack">The dialog stack.</param>
/// <param name="resume">The method to resume when the message has been received.</param>
public static void Wait(this IDialogStack stack, ResumeAfter<IMessageActivity> resume)
/**
* Suspend the current dialog until the user has sent a message to the bot.
* @param stack The dialog stack.
* @param resume The method to resume when the message has been received.
*/
/*
public static void Wait(this IDialogStack stack, ResumeAfter<MessageActivity> resume)
{
stack.Wait<IMessageActivity>(resume);
stack.Wait<MessageActivity>(resume);
}
*/
/// <summary>
/// Call a child dialog, add it to the top of the stack and post the message to the child dialog.
/// </summary>
/// <typeparam name="R">The type of result expected from the child dialog.</typeparam>
/// <param name="stack">The dialog stack.</param>
/// <param name="child">The child dialog.</param>
/// <param name="resume">The method to resume when the child dialog has completed.</param>
/// <param name="message">The message that will be posted to child dialog.</param>
/// <param name="token">A cancellation token.</param>
/// <returns>A task representing the Forward operation.</returns>
public static async Task Forward<R>(this IDialogStack stack, IDialog<R> child, ResumeAfter<R> resume, IMessageActivity message, CancellationToken token = default(CancellationToken))
/**
* Call a child dialog, add it to the top of the stack and post the message to the child dialog.
* @param R The type of result expected from the child dialog.
* @param stack The dialog stack.
* @param child The child dialog.
* @param resume The method to resume when the child dialog has completed.
* @param message The message that will be posted to child dialog.
* @return A task representing the Forward operation.
*/
/* public static async Task Forward<R>(this IDialogStack stack, IDialog<R> child, ResumeAfter<R> resume, MessageActivity message)
{
await stack.Forward<R, IMessageActivity>(child, resume, message, token);
await stack.Forward<R, MessageActivity>(child, resume, message, token);
}
}
*/
}*/

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

@ -1,19 +1,19 @@
package com.microsoft.bot.builder.dialogs;
// TODO: daveta remove this - not sure where this came from
/// <summary>
/// Interface for all Dialog objects that can be added to a `DialogSet`. The dialog should generally
/// be a singleton and added to a dialog set using `DialogSet.add()` at which point it will be
/// assigned a unique ID.
/// </summary>
/**
* Interface for all Dialog objects that can be added to a `DialogSet`. The dialog should generally
* be a singleton and added to a dialog set using `DialogSet.add()` at which point it will be
* assigned a unique ID.
*/
public interface IDialog
{
/// <summary>
/// Method called when a new dialog has been pushed onto the stack and is being activated.
/// </summary>
/// <param name="dc">The dialog context for the current turn of conversation.</param>
/// <param name="dialogArgs">(Optional) arguments that were passed to the dialog during `begin()` call that started the instance.</param>
/**
* Method called when a new dialog has been pushed onto the stack and is being activated.
* @param dc The dialog context for the current turn of conversation.
* @param dialogArgs (Optional) arguments that were passed to the dialog during `begin()` call that started the instance.
*/
//CompleteableFuture DialogBegin(DialogContext dc, IDictionary<string, object> dialogArgs = null);
//CompleteableFuture DialogBegin(DialogContext dc, HashMap<string, object> dialogArgs);
//CompleteableFuture DialogBegin(DialogContext dc);
}
}

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

@ -5,17 +5,17 @@ package com.microsoft.bot.builder.dialogs;
import java.util.concurrent.CompletableFuture;
/// <summary>
/// Interface Dialog objects that can be continued.
/// </summary>
/**
* Interface Dialog objects that can be continued.
*/
public interface IDialogContinue extends IDialog
{
/// <summary>
/// Method called when an instance of the dialog is the "current" dialog and the
/// user replies with a new activity. The dialog will generally continue to receive the users
/// replies until it calls either `DialogSet.end()` or `DialogSet.begin()`.
/// If this method is NOT implemented then the dialog will automatically be ended when the user replies.
/// </summary>
/// <param name="dc">The dialog context for the current turn of conversation.</param>
/**
* Method called when an instance of the dialog is the "current" dialog and the
* user replies with a new activity. The dialog will generally continue to receive the users
* replies until it calls either `DialogSet.end()` or `DialogSet.begin()`.
* If this method is NOT implemented then the dialog will automatically be ended when the user replies.
* @param dc The dialog context for the current turn of conversation.
*/
CompletableFuture DialogContinue(DialogContext dc);
}

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

@ -3,9 +3,9 @@ package com.microsoft.bot.builder.dialogs;
import com.microsoft.bot.schema.models.AttachmentLayoutTypes;
import com.microsoft.bot.schema.models.TextFormatTypes;
/// <summary>
/// Optional message properties that can be sent <see cref="Extensions.SayAsync(IBotToUser, string, string, MessageOptions, string, CancellationToken)"/>
/// </summary>
/**
* Optional message properties that can be sent {@link Extensions.SayAsync(BotToUser, String MessageOptions,)}
*/
public class MessageOptions
{
public MessageOptions()
@ -16,14 +16,14 @@ public class MessageOptions
// this.Entities = new ArrayList<Entity>();
}
/// <summary>
/// Indicates whether the bot is accepting, expecting, or ignoring input
/// </summary>
/**
* Indicates whether the bot is accepting, expecting, or ignoring input
*/
//public string InputHint { get; set; }
/// <summary>
/// Format of text fields [plain|markdown] Default:markdown
/// </summary>
/**
* Format of text fields [plain|markdown] Default:markdown
*/
String textFormat;
public String getTextFormat() {
return this.textFormat;
@ -34,9 +34,9 @@ public class MessageOptions
/// <summary>
/// Hint for how to deal with multiple attachments: [list|carousel] Default:list
/// </summary>
/**
* Hint for how to deal with multiple attachments: [list|carousel] Default:list
*/
String attachmentLayout;
public String getAttachmentLayout() {
return this.attachmentLayout;
@ -45,13 +45,13 @@ public class MessageOptions
this.attachmentLayout = attachmentLayout;
}
/// <summary>
/// Attachments
/// </summary>
/**
* Attachments
*/
//public IList<Attachment> Attachments { get; set; }
/// <summary>
/// Collection of Entity objects, each of which contains metadata about this activity. Each Entity object is typed.
/// </summary>
/**
* Collection of Entity objects, each of which contains metadata about this activity. Each Entity object is typed.
*/
//public IList<Microsoft.Bot.Schema.Entity> Entities { get; set; }
}

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

@ -4,9 +4,9 @@ import java.util.ArrayList;
public class Choice
{
///<summary>
/// Value to return when selected.
///</summary>
/**
* Value to return when selected.
*/
String _value;
public void setValue(String value) {
this._value = value;
@ -15,9 +15,9 @@ public class Choice
return this._value;
}
///<summary>
/// (Optional) action to use when rendering the choice as a suggested action.
///</summary>
/**
* (Optional) action to use when rendering the choice as a suggested action.
*/
CardAction _action;
public CardAction getAction() {
return this._action;
@ -26,9 +26,9 @@ public class Choice
this._action = action;
}
///<summary>
/// (Optional) list of synonyms to recognize in addition to the value.
///</summary>
/**
* (Optional) list of synonyms to recognize in addition to the value.
*/
ArrayList<String> _synonyms;
public ArrayList<String> getSynonyms() {
return _synonyms;

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

@ -13,9 +13,9 @@ import java.util.concurrent.CompletableFuture;
import static java.util.concurrent.CompletableFuture.completedFuture;
/// <summary>
/// Models IStorage around a dictionary
/// </summary>
/**
* Models IStorage around a dictionary
*/
public class DictionaryStorage implements Storage {
private static ObjectMapper objectMapper;

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

@ -2,9 +2,9 @@ package com.microsoft.bot.builder;
import com.microsoft.bot.builder.DictionaryStorage;
/// <summary>
/// RamStorage stores data in volative dictionary
/// </summary>
/**
* RamStorage stores data in volative dictionary
*/
public class MemoryStorage extends DictionaryStorage {
public MemoryStorage() {

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

@ -129,7 +129,7 @@ public class TurnContextTests {
var message1 = TestMessage.Message("message1");
var message2 = TestMessage.Message("message2");
var response = await c.SendActivities(new IActivity[] { message1, message2 } );
var response = await c.SendActivities(new Activity[] { message1, message2 } );
Assert.IsTrue(c.Responded);
Assert.IsTrue(response.Length == 2);
@ -138,13 +138,13 @@ public class TurnContextTests {
}
[TestMethod]
public async Task SendAndSetRespondedUsingIMessageActivity()
public async Task SendAndSetRespondedUsingMessageActivity()
{
SimpleAdapter a = new SimpleAdapter();
TurnContext c = new TurnContext(a, new Activity());
Assert.IsFalse(c.Responded);
IMessageActivity msg = TestMessage.Message().AsMessageActivity();
MessageActivity msg = TestMessage.Message().AsMessageActivity();
await c.SendActivity(msg);
Assert.IsTrue(c.Responded);
}
@ -163,7 +163,7 @@ public class TurnContextTests {
// Just to sanity check everything, send a Message and verify the
// responded flag IS set.
IMessageActivity msg = TestMessage.Message().AsMessageActivity();
MessageActivity msg = TestMessage.Message().AsMessageActivity();
await c.SendActivity(msg);
Assert.IsTrue(c.Responded);
}
@ -478,7 +478,7 @@ public class TurnContextTests {
}
}
public async Task MyBotLogic(ITurnContext context)
public async Task MyBotLogic(TurnContext context)
{
switch (context.Activity.AsMessageActivity().Text)
{

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

@ -40,19 +40,19 @@ public class TestFlow {
this.adapter = flow.adapter;
}
/// <summary>
/// Start the execution of the test flow
/// </summary>
/// <returns></returns>
/**
* Start the execution of the test flow
* @return
*/
public CompletableFuture<String> StartTest() throws ExecutionException, InterruptedException {
return (CompletableFuture<String>) this.testTask;
}
/// <summary>
/// Send a message from the user to the bot
/// </summary>
/// <param name="userSays"></param>
/// <returns></returns>
/**
* Send a message from the user to the bot
* @param userSays
* @return
*/
// public TestFlow Send(String userSays) throws IllegalArgumentException {
// if (userSays == null)
// throw new IllegalArgumentException("You have to pass a userSays parameter");
@ -60,9 +60,13 @@ public class TestFlow {
// System.out.print(String.format("USER SAYS: %s", userSays));
// System.out.flush();
//
// // Function<TurnContextImpl, CompletableFuture>
// /**
// */ Function<TurnContextImpl, CompletableFuture>
// */
// return new TestFlow(this.testTask.thenCompose(task -> supplyAsync(() ->{
// // task.Wait();
// /**
// */ task.Wait();
// */
//
// try {
// this.adapter.SendTextToBot(userSays, this.callback);
@ -92,11 +96,11 @@ public class TestFlow {
})), this);
}
/// <summary>
/// Send an activity from the user to the bot
/// </summary>
/// <param name="userActivity"></param>
/// <returns></returns>
/**
* Send an activity from the user to the bot
* @param userActivity
* @return
*/
public TestFlow Send(Activity userActivity) {
if (userActivity == null)
throw new IllegalArgumentException("You have to pass an Activity");
@ -114,11 +118,11 @@ public class TestFlow {
})), this);
}
/// <summary>
/// Delay for time period
/// </summary>
/// <param name="ms"></param>
/// <returns></returns>
/**
* Delay for time period
* @param ms
* @return
*/
public TestFlow Delay(int ms) {
return new TestFlow(this.testTask.thenCompose(task -> supplyAsync(() ->{
@ -135,13 +139,13 @@ public class TestFlow {
})), this);
}
/// <summary>
/// Assert that reply is expected text
/// </summary>
/// <param name="expected"></param>
/// <param name="description"></param>
/// <param name="timeout"></param>
/// <returns></returns>
/**
* Assert that reply is expected text
* @param expected
* @param description
* @param timeout
* @return
*/
public TestFlow AssertReply(String expected) {
return this.AssertReply(expected, null, 3000);
}
@ -154,13 +158,13 @@ public class TestFlow {
return this.AssertReply(this.adapter.MakeActivity(expected), description, timeout);
}
/// <summary>
/// Assert that the reply is expected activity
/// </summary>
/// <param name="expected"></param>
/// <param name="description"></param>
/// <param name="timeout"></param>
/// <returns></returns>
/**
* Assert that the reply is expected activity
* @param expected
* @param description
* @param timeout
* @return
*/
public TestFlow AssertReply(Activity expected) {
String description = Thread.currentThread().getStackTrace()[1].getMethodName();
return AssertReply(expected, description, 3000);
@ -184,13 +188,13 @@ public class TestFlow {
}, description, timeout);
}
/// <summary>
/// Assert that the reply matches a custom validation routine
/// </summary>
/// <param name="validateActivity"></param>
/// <param name="description"></param>
/// <param name="timeout"></param>
/// <returns></returns>
/**
* Assert that the reply matches a custom validation routine
* @param validateActivity
* @param description
* @param timeout
* @return
*/
public TestFlow AssertReply(Function<Activity, String> validateActivity) {
String description = Thread.currentThread().getStackTrace()[1].getMethodName();
return AssertReply(validateActivity, description, 3000);
@ -330,14 +334,14 @@ public class TestFlow {
return this;
}
/// <summary>
/// Say() -> shortcut for .Send(user).AssertReply(Expected)
/// </summary>
/// <param name="userSays"></param>
/// <param name="expected"></param>
/// <param name="description"></param>
/// <param name="timeout"></param>
/// <returns></returns>
/**
* Say() -> shortcut for .Send(user).AssertReply(Expected)
* @param userSays
* @param expected
* @param description
* @param timeout
* @return
*/
public TestFlow Test(String userSays, String expected) {
return Test(userSays, expected, null, 3000);
}
@ -352,14 +356,14 @@ public class TestFlow {
.AssertReply(expected, description, timeout);
}
/// <summary>
/// Test() -> shortcut for .Send(user).AssertReply(Expected)
/// </summary>
/// <param name="userSays"></param>
/// <param name="expected"></param>
/// <param name="description"></param>
/// <param name="timeout"></param>
/// <returns></returns>
/**
* Test() -> shortcut for .Send(user).AssertReply(Expected)
* @param userSays
* @param expected
* @param description
* @param timeout
* @return
*/
public TestFlow Test(String userSays, Activity expected) {
return Test(userSays, expected, null, 3000);
}
@ -374,14 +378,14 @@ public class TestFlow {
.AssertReply(expected, description, timeout);
}
/// <summary>
/// Say() -> shortcut for .Send(user).AssertReply(Expected)
/// </summary>
/// <param name="userSays"></param>
/// <param name="expected"></param>
/// <param name="description"></param>
/// <param name="timeout"></param>
/// <returns></returns>
/**
* Say() -> shortcut for .Send(user).AssertReply(Expected)
* @param userSays
* @param expected
* @param description
* @param timeout
* @return
*/
public TestFlow Test(String userSays, Function<Activity, String> expected) {
return Test(userSays, expected, null, 3000);
}
@ -396,13 +400,13 @@ public class TestFlow {
.AssertReply(expected, description, timeout);
}
/// <summary>
/// Assert that reply is one of the candidate responses
/// </summary>
/// <param name="candidates"></param>
/// <param name="description"></param>
/// <param name="timeout"></param>
/// <returns></returns>
/**
* Assert that reply is one of the candidate responses
* @param candidates
* @param description
* @param timeout
* @return
*/
public TestFlow AssertReplyOneOf(String[] candidates) {
return AssertReplyOneOf(candidates, null, 3000);
}