diff --git a/Generator/generator-botbuilder-java/generators/app/templates/pom.xml b/Generator/generator-botbuilder-java/generators/app/templates/pom.xml index eaad9195..f519f3db 100644 --- a/Generator/generator-botbuilder-java/generators/app/templates/pom.xml +++ b/Generator/generator-botbuilder-java/generators/app/templates/pom.xml @@ -2,19 +2,19 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.microsoft.bot.connector.sample - bot-connector-sample + com.microsoft.bot + generator-botbuilder-java jar 1.0.0 com.microsoft.bot bot-parent - 4.0.0-a0 - ../../ + 4.0.0 + ../../../../../pom.xml - bot-connector-sample + generator-botbuilder-java http://maven.apache.org @@ -86,4 +86,4 @@ - \ No newline at end of file + diff --git a/libraries/botbuilder/README.md b/libraries/bot-builder/README.md similarity index 98% rename from libraries/botbuilder/README.md rename to libraries/bot-builder/README.md index 72f1506a..29f7ebd6 100644 --- a/libraries/botbuilder/README.md +++ b/libraries/bot-builder/README.md @@ -1,14 +1,14 @@ - -# Contributing - -This project welcomes contributions and suggestions. Most contributions require you to agree to a -Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us -the rights to use your contribution. For details, visit https://cla.microsoft.com. - -When you submit a pull request, a CLA-bot will automatically determine whether you need to provide -a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions -provided by the bot. You will only need to do this once across all repos using our CLA. - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or -contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require you to agree to a +Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us +the rights to use your contribution. For details, visit https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide +a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions +provided by the bot. You will only need to do this once across all repos using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or +contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. diff --git a/libraries/botbuilder/pom.xml b/libraries/bot-builder/pom.xml similarity index 97% rename from libraries/botbuilder/pom.xml rename to libraries/bot-builder/pom.xml index 6aa0c64c..300e984a 100644 --- a/libraries/botbuilder/pom.xml +++ b/libraries/bot-builder/pom.xml @@ -2,8 +2,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.microsoft.bot.builder - botbuilder + com.microsoft.bot + bot-builder jar 4.0-SNAPSHOT @@ -107,12 +107,12 @@ 0.3.0 - com.microsoft.bot.schema - botbuilder-schema + com.microsoft.bot + bot-schema 4.0.0-SNAPSHOT - com.microsoft.bot.connector + com.microsoft.bot bot-connector 4.0.0-SNAPSHOT @@ -174,7 +174,7 @@ cobertura-maven-plugin 2.7 - ../../cobertura-report/botbuilder + ../../cobertura-report/bot-builder xml 256m diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/AnonymousReceiveMiddleware.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/AnonymousReceiveMiddleware.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/AnonymousReceiveMiddleware.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/AnonymousReceiveMiddleware.java index abcabeff..6ad3d416 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/AnonymousReceiveMiddleware.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/AnonymousReceiveMiddleware.java @@ -1,37 +1,37 @@ -package com.microsoft.bot.builder; - -import java.util.concurrent.CompletableFuture; - -/** - * Helper class for defining middleware by using a delegate or anonymous method. - */ -public class AnonymousReceiveMiddleware implements Middleware -{ - private MiddlewareCall _toCall; - - /** - * 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) - throw new NullPointerException("MiddlewareCall anonymousMethod"); - else - _toCall = anonymousMethod; - } - - /** - * 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 void OnTurn(TurnContext context, NextDelegate next) throws Exception { - _toCall.requestHandler(context, next); - } - -} +package com.microsoft.bot.builder; + +import java.util.concurrent.CompletableFuture; + +/** + * Helper class for defining middleware by using a delegate or anonymous method. + */ +public class AnonymousReceiveMiddleware implements Middleware +{ + private MiddlewareCall _toCall; + + /** + * 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) + throw new NullPointerException("MiddlewareCall anonymousMethod"); + else + _toCall = anonymousMethod; + } + + /** + * 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 void OnTurn(TurnContext context, NextDelegate next) throws Exception { + _toCall.requestHandler(context, next); + } + +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/BotAdapter.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotAdapter.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/BotAdapter.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotAdapter.java index 609b8935..ed944c15 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/BotAdapter.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotAdapter.java @@ -1,176 +1,176 @@ -package com.microsoft.bot.builder; - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import com.microsoft.bot.schema.ActivityImpl; -import com.microsoft.bot.schema.models.Activity; -import com.microsoft.bot.schema.models.ConversationReference; -import com.microsoft.bot.schema.models.ConversationReferenceHelper; -import com.microsoft.bot.schema.models.ResourceResponse; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.function.Consumer; -import java.util.function.Function; - -/** - * 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. - *

Use {@link Use(Middleware)} to add {@link Middleware} objects - * to your adapter’s middleware collection. The adapter processes and directs - * incoming activities in through the bot middleware pipeline to your bot’s 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.

- *

- * {@linkalso TurnContext} - * {@linkalso Activity} - * {@linkalso Bot} - * {@linkalso Middleware} - */ -public abstract class BotAdapter { - /** - * The collection of middleware in the adapter's pipeline. - */ - protected final MiddlewareSet _middlewareSet = new MiddlewareSet(); - - /** - * Creates a default adapter. - */ - public BotAdapter() { - super(); - } - - /** - * 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; - } - - /** - * 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 ResourceResponse[] SendActivities(TurnContext context, Activity[] activities) throws InterruptedException; - - /** - * 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. - *

Before calling this, set the ID of the replacement activity to the ID - * of the activity to replace.

- * {@linkalso TurnContext.OnUpdateActivity(UpdateActivityHandler)} - */ - public abstract ResourceResponse UpdateActivity(TurnContext context, Activity activity); - - /** - * 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 void DeleteActivity(TurnContext context, ConversationReference reference) throws ExecutionException, InterruptedException; - - - /** - * 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 doesn’t call - * the next delegate, the adapter does not call any of the subsequent middleware’s - * {@link Middleware.OnTurn(TurnContext, MiddlewareSet.NextDelegate)} - * methods or the callback method, and the pipeline short circuits. - *

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.

- */ - protected void RunPipeline(TurnContext context, Consumer callback) throws Exception { - BotAssert.ContextNotNull(context); - - // Call any registered Middleware Components looking for ReceiveActivity() - if (context.getActivity() != null) { - _middlewareSet.ReceiveActivityWithStatus(context, callback); - } else { - // call back to caller on proactive case - if (callback != null) { - callback.accept(context); - } - } - } - - - /** - * 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 callback) { - throw new UnsupportedOperationException("Adapter does not support CreateConversation with this arguments"); - } - - /** - * 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 void ContinueConversation(String botId, ConversationReference reference, Consumer callback) throws Exception { - - ConversationReferenceHelper conv = new ConversationReferenceHelper(reference); - ActivityImpl activity = conv.GetPostToBotMessage(); - - try (TurnContextImpl context = new TurnContextImpl(this, activity)) { - this.RunPipeline(context, callback); - } - } -} +package com.microsoft.bot.builder; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import com.microsoft.bot.schema.ActivityImpl; +import com.microsoft.bot.schema.models.Activity; +import com.microsoft.bot.schema.models.ConversationReference; +import com.microsoft.bot.schema.models.ConversationReferenceHelper; +import com.microsoft.bot.schema.models.ResourceResponse; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * 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. + *

Use {@link Use(Middleware)} to add {@link Middleware} objects + * to your adapter’s middleware collection. The adapter processes and directs + * incoming activities in through the bot middleware pipeline to your bot’s 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.

+ *

+ * {@linkalso TurnContext} + * {@linkalso Activity} + * {@linkalso Bot} + * {@linkalso Middleware} + */ +public abstract class BotAdapter { + /** + * The collection of middleware in the adapter's pipeline. + */ + protected final MiddlewareSet _middlewareSet = new MiddlewareSet(); + + /** + * Creates a default adapter. + */ + public BotAdapter() { + super(); + } + + /** + * 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; + } + + /** + * 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 ResourceResponse[] SendActivities(TurnContext context, Activity[] activities) throws InterruptedException; + + /** + * 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. + *

Before calling this, set the ID of the replacement activity to the ID + * of the activity to replace.

+ * {@linkalso TurnContext.OnUpdateActivity(UpdateActivityHandler)} + */ + public abstract ResourceResponse UpdateActivity(TurnContext context, Activity activity); + + /** + * 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 void DeleteActivity(TurnContext context, ConversationReference reference) throws ExecutionException, InterruptedException; + + + /** + * 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 doesn’t call + * the next delegate, the adapter does not call any of the subsequent middleware’s + * {@link Middleware.OnTurn(TurnContext, MiddlewareSet.NextDelegate)} + * methods or the callback method, and the pipeline short circuits. + *

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.

+ */ + protected void RunPipeline(TurnContext context, Consumer callback) throws Exception { + BotAssert.ContextNotNull(context); + + // Call any registered Middleware Components looking for ReceiveActivity() + if (context.getActivity() != null) { + _middlewareSet.ReceiveActivityWithStatus(context, callback); + } else { + // call back to caller on proactive case + if (callback != null) { + callback.accept(context); + } + } + } + + + /** + * 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 callback) { + throw new UnsupportedOperationException("Adapter does not support CreateConversation with this arguments"); + } + + /** + * 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 void ContinueConversation(String botId, ConversationReference reference, Consumer callback) throws Exception { + + ConversationReferenceHelper conv = new ConversationReferenceHelper(reference); + ActivityImpl activity = conv.GetPostToBotMessage(); + + try (TurnContextImpl context = new TurnContextImpl(this, activity)) { + this.RunPipeline(context, callback); + } + } +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/BotAssert.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotAssert.java similarity index 96% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/BotAssert.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotAssert.java index 3643c0f1..15a6c15c 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/BotAssert.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotAssert.java @@ -1,99 +1,99 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.microsoft.bot.builder; - -import com.microsoft.bot.schema.ActivityImpl; -import com.microsoft.bot.schema.models.Activity; -import com.microsoft.bot.schema.models.ConversationReference; - -import java.util.ArrayList; - -/** - * Provides methods for debugging Bot Builder code. - */ -public class BotAssert -{ - /** - * 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"); - } - - /** - * 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"); - } - - /** - * 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"); - } - - /** - * 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"); - } - - /** - * 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 activities) - { - if (activities == null) - throw new NullPointerException("List"); - } - - /** - * 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"); - } - - /** - * 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) - { - if (middleware == null) - throw new NullPointerException("List"); - } -} +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.microsoft.bot.builder; + +import com.microsoft.bot.schema.ActivityImpl; +import com.microsoft.bot.schema.models.Activity; +import com.microsoft.bot.schema.models.ConversationReference; + +import java.util.ArrayList; + +/** + * Provides methods for debugging Bot Builder code. + */ +public class BotAssert +{ + /** + * 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"); + } + + /** + * 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"); + } + + /** + * 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"); + } + + /** + * 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"); + } + + /** + * 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 activities) + { + if (activities == null) + throw new NullPointerException("List"); + } + + /** + * 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"); + } + + /** + * 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) + { + if (middleware == null) + throw new NullPointerException("List"); + } +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/BotFrameworkAdapter.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotFrameworkAdapter.java similarity index 98% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/BotFrameworkAdapter.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotFrameworkAdapter.java index 3b30ffa8..2c850e05 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/BotFrameworkAdapter.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotFrameworkAdapter.java @@ -1,779 +1,779 @@ -package com.microsoft.bot.builder; - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import com.microsoft.bot.connector.ConnectorClient; -import com.microsoft.bot.connector.Conversations; -import com.microsoft.bot.connector.authentication.*; -import com.microsoft.bot.connector.implementation.ConnectorClientImpl; -import com.microsoft.bot.connector.implementation.ConversationsImpl; -import com.microsoft.bot.schema.ActivityImpl; -import com.microsoft.bot.schema.models.*; -import com.microsoft.rest.retry.RetryStrategy; -import org.apache.commons.lang3.StringUtils; -import sun.net.www.http.HttpClient; - -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.function.Consumer; -import java.util.function.Function; - -import static java.util.concurrent.CompletableFuture.completedFuture; - -/** - * 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. - *

Use {@link Use(Middleware)} to add {@link Middleware} objects - * to your adapter’s middleware collection. The adapter processes and directs - * incoming activities in through the bot middleware pipeline to your bot’s 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.

- *

- * {@linkalso TurnContext} - * {@linkalso Activity} - * {@linkalso Bot} - * {@linkalso Middleware} - */ -public class BotFrameworkAdapter extends BotAdapter { - private final CredentialProvider _credentialProvider; - - private final RetryStrategy connectorClientRetryStrategy; - private Map appCredentialMap = new HashMap(); - - private final String InvokeReponseKey = "BotFrameworkAdapter.InvokeResponse"; - private boolean isEmulatingOAuthCards = false; - - /** - * 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); - } - - public BotFrameworkAdapter(CredentialProvider credentialProvider, RetryStrategy connectorClientRetryStrategy) { - this(credentialProvider, connectorClientRetryStrategy, null, null); - } - - public BotFrameworkAdapter(CredentialProvider credentialProvider, RetryStrategy connectorClientRetryStrategy, HttpClient httpClient) { - this(credentialProvider, connectorClientRetryStrategy, httpClient, null); - } - - public BotFrameworkAdapter(CredentialProvider credentialProvider, RetryStrategy connectorClientRetryStrategy, HttpClient httpClient, Middleware middleware) { - if (credentialProvider == null) - throw new IllegalArgumentException("credentialProvider"); - _credentialProvider = credentialProvider; - //_httpClient = httpClient ?? new HttpClient(); - this.connectorClientRetryStrategy = connectorClientRetryStrategy; - - if (middleware != null) { - this.Use(middleware); - } - } - - /** - * 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. - *

This method registers the following.services().for the turn. - * {@link ConnectorClient}, the channel connector client to use this turn. - *

- *

- * 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. - *

- *

- * {@linkalso ProcessActivity(String, Activity, Func { TurnContext, Task })} - * {@linkalso BotAdapter.RunPipeline(TurnContext, Func { TurnContext, Task } } - */ - @Override - public void ContinueConversation(String botAppId, ConversationReference reference, Consumer callback) throws Exception { - if (StringUtils.isEmpty(botAppId)) - throw new IllegalArgumentException("botAppId"); - - if (reference == null) - throw new IllegalArgumentException("reference"); - - if (callback == null) - throw new IllegalArgumentException("callback"); - - try (TurnContextImpl context = new TurnContextImpl(this, new ConversationReferenceHelper(reference).GetPostToBotMessage())) { - // Hand craft Claims Identity. - HashMap claims = new HashMap(); - claims.put(AuthenticationConstants.AudienceClaim, botAppId); - claims.put(AuthenticationConstants.AppIdClaim, botAppId); - ClaimsIdentityImpl claimsIdentity = new ClaimsIdentityImpl("ExternalBearer", claims); - - context.getServices().Add("BotIdentity", claimsIdentity); - - ConnectorClient connectorClient = this.CreateConnectorClientAsync(reference.serviceUrl(), claimsIdentity).join(); - context.getServices().Add("ConnectorClient", connectorClient); - RunPipeline(context, callback); - } - return; - } - - /** - * 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); - } - - public BotFrameworkAdapter(String appId, String appPassword, RetryStrategy connectorClientRetryStrategy) { - this(appId, appPassword, connectorClientRetryStrategy, null, null); - } - - public BotFrameworkAdapter(String appId, String appPassword, RetryStrategy connectorClientRetryStrategy, HttpClient httpClient) { - this(appId, appPassword, connectorClientRetryStrategy, httpClient, null); - } - - public BotFrameworkAdapter(String appId, String appPassword, RetryStrategy connectorClientRetryStrategy, HttpClient httpClient, Middleware middleware) { - this(new SimpleCredentialProvider(appId, appPassword), connectorClientRetryStrategy, httpClient, middleware); - } - - /** - * 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; - } - - /** - * 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. - *

This method registers the following.services().for the turn. - * {@link ConnectorClient}, the channel connector client to use this turn. - *

- *

- * {@linkalso ContinueConversation(String, ConversationReference, Func { TurnContext, Task })} - * {@linkalso BotAdapter.RunPipeline(TurnContext, Func { TurnContext, Task })} - */ - public CompletableFuture ProcessActivity(String authHeader, ActivityImpl activity, Function callback) throws Exception { - BotAssert.ActivityNotNull(activity); - - //ClaimsIdentity claimsIdentity = await(JwtTokenValidation.validateAuthHeader(activity, authHeader, _credentialProvider)); - - //return completedFuture(await(ProcessActivity(claimsIdentity, activity, callback))); - return completedFuture(null); - } - - public CompletableFuture ProcessActivity(ClaimsIdentity identity, ActivityImpl activity, Consumer callback) throws Exception { - BotAssert.ActivityNotNull(activity); - - try (TurnContextImpl context = new TurnContextImpl(this, activity)) { - context.getServices().Add("BotIdentity", identity); - - ConnectorClient connectorClient = this.CreateConnectorClientAsync(activity.serviceUrl(), identity).join(); - // TODO: Verify key that C# uses - context.getServices().Add("ConnectorClient", connectorClient); - - super.RunPipeline(context, callback); - - // Handle Invoke scenarios, which deviate from the request/response model in that - // the Bot will return a specific body and return code. - if (activity.type() == ActivityTypes.INVOKE) { - Activity invokeResponse = context.getServices().Get(InvokeReponseKey); - if (invokeResponse == null) { - // ToDo: Trace Here - throw new IllegalStateException("Bot failed to return a valid 'invokeResponse' activity."); - } else { - return completedFuture((InvokeResponse) invokeResponse.value()); - } - } - - // For all non-invoke scenarios, the HTTP layers above don't have to mess - // withthe Body and return codes. - return null; - } - } - - /** - * 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 ResourceResponse[] SendActivities(TurnContext context, Activity[] activities) throws InterruptedException { - if (context == null) { - throw new IllegalArgumentException("context"); - } - - if (activities == null) { - throw new IllegalArgumentException("activities"); - } - - if (activities.length == 0) { - throw new IllegalArgumentException("Expecting one or more activities, but the array was empty."); - } - - ResourceResponse[] responses = new ResourceResponse[activities.length]; - - /* - * NOTE: we're using for here (vs. foreach) because we want to simultaneously index into the - * activities array to get the activity to process as well as use that index to assign - * the response to the responses array and this is the most cost effective way to do that. - */ - for (int index = 0; index < activities.length; index++) { - Activity activity = activities[index]; - ResourceResponse response = new ResourceResponse(); - - if (activity.type().toString().equals("delay")) { - // The Activity Schema doesn't have a delay type build in, so it's simulated - // here in the Bot. This matches the behavior in the Node connector. - int delayMs = (int) activity.value(); - Thread.sleep(delayMs); - //await(Task.Delay(delayMs)); - // No need to create a response. One will be created below. - } else if (activity.type().toString().equals("invokeResponse")) // Aligning name with Node - { - context.getServices().Add(InvokeReponseKey, activity); - // No need to create a response. One will be created below. - } else if (activity.type() == ActivityTypes.TRACE && !activity.channelId().equals("emulator")) { - // if it is a Trace activity we only send to the channel if it's the emulator. - } else if (!StringUtils.isEmpty(activity.replyToId())) { - ConnectorClient connectorClient = context.getServices().Get("ConnectorClient"); - response = connectorClient.conversations().replyToActivity(activity.conversation().id(), activity.id(), activity); - } else { - ConnectorClient connectorClient = context.getServices().Get("ConnectorClient"); - response = connectorClient.conversations().sendToConversation(activity.conversation().id(), activity); - } - - // If No response is set, then defult to a "simple" response. This can't really be done - // above, as there are cases where the ReplyTo/SendTo methods will also return null - // (See below) so the check has to happen here. - - // Note: In addition to the Invoke / Delay / Activity cases, this code also applies - // with Skype and Teams with regards to typing events. When sending a typing event in - // these channels they do not return a RequestResponse which causes the bot to blow up. - // https://github.com/Microsoft/botbuilder-dotnet/issues/460 - // bug report : https://github.com/Microsoft/botbuilder-dotnet/issues/465 - if (response == null) { - response = new ResourceResponse().withId((activity.id() == null) ? "" : activity.id()); - } - - responses[index] = response; - } - - return responses; - } - - /** - * 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. - *

Before calling this, set the ID of the replacement activity to the ID - * of the activity to replace.

- * {@linkalso TurnContext.OnUpdateActivity(UpdateActivityHandler)} - */ - @Override - public ResourceResponse UpdateActivity(TurnContext context, Activity activity) { - ConnectorClient connectorClient = context.getServices().Get("ConnectorClient"); - // TODO String conversationId, String activityId, Activity activity) - return connectorClient.conversations().updateActivity(activity.conversation().id(), activity.id(), activity); - } - - /** - * 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 void DeleteActivity(TurnContext context, ConversationReference reference) { - ConnectorClientImpl connectorClient = context.getServices().Get("ConnectorClient"); - try { - connectorClient.conversations().deleteConversationMemberFuture(reference.conversation().id(), reference.activityId()).join(); - } catch (ExecutionException e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Failed deleting activity (%s)", e.toString())); - } catch (InterruptedException e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Failed deleting activity (%s)", e.toString())); - } - return; - } - - /** - * 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 void DeleteConversationMember(TurnContextImpl context, String memberId) { - if (context.getActivity().conversation() == null) - throw new IllegalArgumentException("BotFrameworkAdapter.deleteConversationMember(): missing conversation"); - - if (StringUtils.isEmpty(context.getActivity().conversation().id())) - throw new IllegalArgumentException("BotFrameworkAdapter.deleteConversationMember(): missing conversation.id"); - - ConnectorClient connectorClient = context.getServices().Get("ConnectorClient"); - - String conversationId = context.getActivity().conversation().id(); - - // TODO: - //await (connectorClient.conversations().DeleteConversationMemberAsync(conversationId, memberId)); - return; - } - - /** - * 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> GetActivityMembers(TurnContextImpl context) { - return GetActivityMembers(context, null); - } - - public CompletableFuture> GetActivityMembers(TurnContextImpl context, String activityId) { - // If no activity was passed in, use the current activity. - if (activityId == null) - activityId = context.getActivity().id(); - - if (context.getActivity().conversation() == null) - throw new IllegalArgumentException("BotFrameworkAdapter.GetActivityMembers(): missing conversation"); - - if (StringUtils.isEmpty((context.getActivity().conversation().id()))) - throw new IllegalArgumentException("BotFrameworkAdapter.GetActivityMembers(): missing conversation.id"); - - ConnectorClient connectorClient = context.getServices().Get("ConnectorClient"); - String conversationId = context.getActivity().conversation().id(); - - // TODO: - //List accounts = await(connectorClient.conversations().GetActivityMembersAsync(conversationId, activityId)); - - return completedFuture(null); - } - - /** - * 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> GetConversationMembers(TurnContextImpl context) { - if (context.getActivity().conversation() == null) - throw new IllegalArgumentException("BotFrameworkAdapter.GetActivityMembers(): missing conversation"); - - if (StringUtils.isEmpty(context.getActivity().conversation().id())) - throw new IllegalArgumentException("BotFrameworkAdapter.GetActivityMembers(): missing conversation.id"); - - ConnectorClient connectorClient = context.getServices().Get("ConnectorClient"); - String conversationId = context.getActivity().conversation().id(); - - // TODO - //List accounts = await(connectorClient.conversations().getConversationMembersAsync(conversationId)); - return completedFuture(null); - } - - /** - * 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 GetConversations(String serviceUrl, MicrosoftAppCredentials credentials) throws MalformedURLException, URISyntaxException { - return GetConversations(serviceUrl, credentials, null); - } - - public CompletableFuture GetConversations(String serviceUrl, MicrosoftAppCredentials credentials, String continuationToken) throws MalformedURLException, URISyntaxException { - if (StringUtils.isEmpty(serviceUrl)) - throw new IllegalArgumentException("serviceUrl"); - - if (credentials == null) - throw new IllegalArgumentException("credentials"); - - ConnectorClient connectorClient = this.CreateConnectorClient(serviceUrl, credentials); - // TODO - //ConversationsResult results = await(connectorClient.conversations().getConversationsAsync(continuationToken)); - return completedFuture(null); - } - - /** - * 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 GetConversations(TurnContextImpl context) { - return GetConversations(context, null); - } - - public CompletableFuture GetConversations(TurnContextImpl context, String continuationToken) { - ConnectorClient connectorClient = context.getServices().Get("ConnectorClient"); - // TODO - //ConversationsResult results = await(connectorClient.conversations().getConversationsAsync()); - return completedFuture(null); - } - - - /** - * 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 GetUserToken(TurnContextImpl context, String connectionName, String magicCode) { - BotAssert.ContextNotNull(context); - if (context.getActivity().from() == null || StringUtils.isEmpty(context.getActivity().from().id())) - throw new IllegalArgumentException("BotFrameworkAdapter.GetuserToken(): missing from or from.id"); - - if (StringUtils.isEmpty(connectionName)) - throw new IllegalArgumentException("connectionName"); - - //OAuthClient client = this.CreateOAuthApiClient(context); - //return await(client.GetUserTokenAsync(context.getActivity().from().id(), connectionName, magicCode)); - return completedFuture(null); - } - - /** - * 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 GetOauthSignInLink(TurnContextImpl context, String connectionName) { - BotAssert.ContextNotNull(context); - if (StringUtils.isEmpty(connectionName)) - throw new IllegalArgumentException("connectionName"); - - //OAuthClient client = this.CreateOAuthApiClient(context); - //return await(client.GetSignInLinkAsync(context.getActivity(), connectionName)); - return completedFuture(null); - } - - /** - * 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)) - throw new IllegalArgumentException("connectionName"); - - //OAuthClient client = this.CreateOAuthApiClient(context); - //await(client.SignOutUserAsync(context.Activity.From.Id, connectionName)); - return completedFuture(null); - } - - /** - * 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. - *

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.

- *

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.

- */ - public CompletableFuture CreateConversation(String channelId, String serviceUrl, MicrosoftAppCredentials - credentials, ConversationParameters conversationParameters, Consumer callback) throws Exception { - // Validate serviceUrl - can throw - URI uri = new URI(serviceUrl); - return CompletableFuture.runAsync(() -> { - ConnectorClient connectorClient = null; - try { - connectorClient = this.CreateConnectorClient(serviceUrl, credentials); - } catch (MalformedURLException e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Bad serviceUrl: %s", serviceUrl)); - } catch (URISyntaxException e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Bad serviceUrl: %s", serviceUrl)); - } - - Conversations conv = connectorClient.conversations(); - List results = null; - if (conv instanceof ConversationsImpl) { - ConversationsImpl convImpl = (ConversationsImpl) conv; - results = convImpl.CreateConversationAsync(conversationParameters).join(); - } else { - results = new ArrayList(); - results.add(conv.createConversation(conversationParameters)); - } - if (results.size() == 1) { - - ConversationResourceResponse result = results.get(0); - // Create a conversation update activity to represent the result. - - ConversationUpdateActivity conversationUpdate = (ConversationUpdateActivity) MessageActivity.CreateConversationUpdateActivity() - .withChannelId(channelId) - .withTopicName(conversationParameters.topicName()) - .withServiceUrl(serviceUrl) - .withMembersAdded(conversationParameters.members()) - .withId((result.activityId() != null) ? result.activityId() : UUID.randomUUID().toString()) - .withConversation(new ConversationAccount().withId(result.id())) - .withRecipient(conversationParameters.bot()); - - try (TurnContextImpl context = new TurnContextImpl(this, conversationUpdate)) { - try { - this.RunPipeline(context, callback); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Running pipeline failed : %s", e)); - } - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Turn Context Error: %s", e)); - } - } else { - // Should never happen - throw new RuntimeException(String.format("Conversations create issue - returned %d conversations", results.size())); - } - }); - - } - - protected CompletableFuture TrySetEmulatingOAuthCards(TurnContext turnContext) { - if (!isEmulatingOAuthCards && - turnContext.getActivity().channelId().equals("emulator") && - (_credentialProvider.isAuthenticationDisabledAsync().join())) { - isEmulatingOAuthCards = true; - } - return completedFuture(isEmulatingOAuthCards); - - } - - protected OAuthClient CreateOAuthApiClient(TurnContext context) throws MalformedURLException, URISyntaxException { - ConnectorClientImpl client = context.getServices().Get("ConnectorClient"); - if (client == null) { - throw new IllegalArgumentException("CreateOAuthApiClient: OAuth requires a valid ConnectorClient instance"); - } - if (isEmulatingOAuthCards) { - return new OAuthClient(client, context.getActivity().serviceUrl()); - } - return new OAuthClient(client, AuthenticationConstants.OAuthUrl); - } - - /** - * 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 CreateConnectorClientAsync(String serviceUrl, ClaimsIdentity claimsIdentity) { - - return CompletableFuture.supplyAsync(() -> { - if (claimsIdentity == null) { - throw new UnsupportedOperationException("ClaimsIdentity cannot be null. Pass Anonymous ClaimsIdentity if authentication is turned off."); - } - - // For requests from channel App Id is in Audience claim of JWT token. For emulator it is in AppId claim. For - // unauthenticated requests we have anonymous identity provided auth is disabled. - if (claimsIdentity.claims() == null) { - try { - return CreateConnectorClient(serviceUrl); - } catch (MalformedURLException e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Invalid Service URL: %s", serviceUrl)); - } catch (URISyntaxException e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Invalid Service URL: %s", serviceUrl)); - } - } - - // For Activities coming from Emulator AppId claim contains the Bot's AAD AppId. - // For anonymous requests (requests with no header) appId is not set in claims. - - Map.Entry botAppIdClaim = claimsIdentity.claims().entrySet().stream() - .filter(claim -> claim.getKey() == AuthenticationConstants.AudienceClaim) - .findFirst() - .orElse(null); - if (botAppIdClaim == null) { - botAppIdClaim = claimsIdentity.claims().entrySet().stream() - .filter(claim -> claim.getKey() == AuthenticationConstants.AppIdClaim) - .findFirst() - .orElse(null); - } - - if (botAppIdClaim != null) { - String botId = botAppIdClaim.getValue(); - MicrosoftAppCredentials appCredentials = this.GetAppCredentialsAsync(botId).join(); - try { - return this.CreateConnectorClient(serviceUrl, appCredentials); - } catch (MalformedURLException e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Bad Service URL: %s", serviceUrl)); - } catch (URISyntaxException e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Bad Service URL: %s", serviceUrl)); - } - } else { - try { - return this.CreateConnectorClient(serviceUrl); - } catch (MalformedURLException e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Bad Service URL: %s", serviceUrl)); - } catch (URISyntaxException e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Bad Service URL: %s", serviceUrl)); - } - } - }); - - } - - /** - * 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); - } - - private ConnectorClient CreateConnectorClient(String serviceUrl, MicrosoftAppCredentials appCredentials) throws MalformedURLException, URISyntaxException { - ConnectorClientImpl connectorClient = null; - if (appCredentials != null) { - connectorClient = new ConnectorClientImpl(new URI(serviceUrl).toURL().toString(), appCredentials); - } - // TODO: Constructor necessary? -// else { -// -// connectorClient = new ConnectorClientImpl(new URI(serviceUrl).toURL().toString()); -// } - - if (this.connectorClientRetryStrategy != null) - connectorClient.withRestRetryStrategy(this.connectorClientRetryStrategy); - - - return connectorClient; - - } - - /** - * 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 GetAppCredentialsAsync(String appId) { - CompletableFuture result = CompletableFuture.supplyAsync(() -> { - if (appId == null) { - return MicrosoftAppCredentials.Empty; - } - if (this.appCredentialMap.containsKey(appId)) - return this.appCredentialMap.get(appId); - String appPassword = this._credentialProvider.getAppPasswordAsync(appId).join(); - MicrosoftAppCredentials appCredentials = new MicrosoftAppCredentials(appId, appPassword); - this.appCredentialMap.put(appId, appCredentials); - return appCredentials; - - }); - return result; - } - -} +package com.microsoft.bot.builder; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import com.microsoft.bot.connector.ConnectorClient; +import com.microsoft.bot.connector.Conversations; +import com.microsoft.bot.connector.authentication.*; +import com.microsoft.bot.connector.implementation.ConnectorClientImpl; +import com.microsoft.bot.connector.implementation.ConversationsImpl; +import com.microsoft.bot.schema.ActivityImpl; +import com.microsoft.bot.schema.models.*; +import com.microsoft.rest.retry.RetryStrategy; +import org.apache.commons.lang3.StringUtils; +import sun.net.www.http.HttpClient; + +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.function.Consumer; +import java.util.function.Function; + +import static java.util.concurrent.CompletableFuture.completedFuture; + +/** + * 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. + *

Use {@link Use(Middleware)} to add {@link Middleware} objects + * to your adapter’s middleware collection. The adapter processes and directs + * incoming activities in through the bot middleware pipeline to your bot’s 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.

+ *

+ * {@linkalso TurnContext} + * {@linkalso Activity} + * {@linkalso Bot} + * {@linkalso Middleware} + */ +public class BotFrameworkAdapter extends BotAdapter { + private final CredentialProvider _credentialProvider; + + private final RetryStrategy connectorClientRetryStrategy; + private Map appCredentialMap = new HashMap(); + + private final String InvokeReponseKey = "BotFrameworkAdapter.InvokeResponse"; + private boolean isEmulatingOAuthCards = false; + + /** + * 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); + } + + public BotFrameworkAdapter(CredentialProvider credentialProvider, RetryStrategy connectorClientRetryStrategy) { + this(credentialProvider, connectorClientRetryStrategy, null, null); + } + + public BotFrameworkAdapter(CredentialProvider credentialProvider, RetryStrategy connectorClientRetryStrategy, HttpClient httpClient) { + this(credentialProvider, connectorClientRetryStrategy, httpClient, null); + } + + public BotFrameworkAdapter(CredentialProvider credentialProvider, RetryStrategy connectorClientRetryStrategy, HttpClient httpClient, Middleware middleware) { + if (credentialProvider == null) + throw new IllegalArgumentException("credentialProvider"); + _credentialProvider = credentialProvider; + //_httpClient = httpClient ?? new HttpClient(); + this.connectorClientRetryStrategy = connectorClientRetryStrategy; + + if (middleware != null) { + this.Use(middleware); + } + } + + /** + * 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. + *

This method registers the following.services().for the turn. + * {@link ConnectorClient}, the channel connector client to use this turn. + *

+ *

+ * 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. + *

+ *

+ * {@linkalso ProcessActivity(String, Activity, Func { TurnContext, Task })} + * {@linkalso BotAdapter.RunPipeline(TurnContext, Func { TurnContext, Task } } + */ + @Override + public void ContinueConversation(String botAppId, ConversationReference reference, Consumer callback) throws Exception { + if (StringUtils.isEmpty(botAppId)) + throw new IllegalArgumentException("botAppId"); + + if (reference == null) + throw new IllegalArgumentException("reference"); + + if (callback == null) + throw new IllegalArgumentException("callback"); + + try (TurnContextImpl context = new TurnContextImpl(this, new ConversationReferenceHelper(reference).GetPostToBotMessage())) { + // Hand craft Claims Identity. + HashMap claims = new HashMap(); + claims.put(AuthenticationConstants.AudienceClaim, botAppId); + claims.put(AuthenticationConstants.AppIdClaim, botAppId); + ClaimsIdentityImpl claimsIdentity = new ClaimsIdentityImpl("ExternalBearer", claims); + + context.getServices().Add("BotIdentity", claimsIdentity); + + ConnectorClient connectorClient = this.CreateConnectorClientAsync(reference.serviceUrl(), claimsIdentity).join(); + context.getServices().Add("ConnectorClient", connectorClient); + RunPipeline(context, callback); + } + return; + } + + /** + * 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); + } + + public BotFrameworkAdapter(String appId, String appPassword, RetryStrategy connectorClientRetryStrategy) { + this(appId, appPassword, connectorClientRetryStrategy, null, null); + } + + public BotFrameworkAdapter(String appId, String appPassword, RetryStrategy connectorClientRetryStrategy, HttpClient httpClient) { + this(appId, appPassword, connectorClientRetryStrategy, httpClient, null); + } + + public BotFrameworkAdapter(String appId, String appPassword, RetryStrategy connectorClientRetryStrategy, HttpClient httpClient, Middleware middleware) { + this(new SimpleCredentialProvider(appId, appPassword), connectorClientRetryStrategy, httpClient, middleware); + } + + /** + * 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; + } + + /** + * 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. + *

This method registers the following.services().for the turn. + * {@link ConnectorClient}, the channel connector client to use this turn. + *

+ *

+ * {@linkalso ContinueConversation(String, ConversationReference, Func { TurnContext, Task })} + * {@linkalso BotAdapter.RunPipeline(TurnContext, Func { TurnContext, Task })} + */ + public CompletableFuture ProcessActivity(String authHeader, ActivityImpl activity, Function callback) throws Exception { + BotAssert.ActivityNotNull(activity); + + //ClaimsIdentity claimsIdentity = await(JwtTokenValidation.validateAuthHeader(activity, authHeader, _credentialProvider)); + + //return completedFuture(await(ProcessActivity(claimsIdentity, activity, callback))); + return completedFuture(null); + } + + public CompletableFuture ProcessActivity(ClaimsIdentity identity, ActivityImpl activity, Consumer callback) throws Exception { + BotAssert.ActivityNotNull(activity); + + try (TurnContextImpl context = new TurnContextImpl(this, activity)) { + context.getServices().Add("BotIdentity", identity); + + ConnectorClient connectorClient = this.CreateConnectorClientAsync(activity.serviceUrl(), identity).join(); + // TODO: Verify key that C# uses + context.getServices().Add("ConnectorClient", connectorClient); + + super.RunPipeline(context, callback); + + // Handle Invoke scenarios, which deviate from the request/response model in that + // the Bot will return a specific body and return code. + if (activity.type() == ActivityTypes.INVOKE) { + Activity invokeResponse = context.getServices().Get(InvokeReponseKey); + if (invokeResponse == null) { + // ToDo: Trace Here + throw new IllegalStateException("Bot failed to return a valid 'invokeResponse' activity."); + } else { + return completedFuture((InvokeResponse) invokeResponse.value()); + } + } + + // For all non-invoke scenarios, the HTTP layers above don't have to mess + // withthe Body and return codes. + return null; + } + } + + /** + * 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 ResourceResponse[] SendActivities(TurnContext context, Activity[] activities) throws InterruptedException { + if (context == null) { + throw new IllegalArgumentException("context"); + } + + if (activities == null) { + throw new IllegalArgumentException("activities"); + } + + if (activities.length == 0) { + throw new IllegalArgumentException("Expecting one or more activities, but the array was empty."); + } + + ResourceResponse[] responses = new ResourceResponse[activities.length]; + + /* + * NOTE: we're using for here (vs. foreach) because we want to simultaneously index into the + * activities array to get the activity to process as well as use that index to assign + * the response to the responses array and this is the most cost effective way to do that. + */ + for (int index = 0; index < activities.length; index++) { + Activity activity = activities[index]; + ResourceResponse response = new ResourceResponse(); + + if (activity.type().toString().equals("delay")) { + // The Activity Schema doesn't have a delay type build in, so it's simulated + // here in the Bot. This matches the behavior in the Node connector. + int delayMs = (int) activity.value(); + Thread.sleep(delayMs); + //await(Task.Delay(delayMs)); + // No need to create a response. One will be created below. + } else if (activity.type().toString().equals("invokeResponse")) // Aligning name with Node + { + context.getServices().Add(InvokeReponseKey, activity); + // No need to create a response. One will be created below. + } else if (activity.type() == ActivityTypes.TRACE && !activity.channelId().equals("emulator")) { + // if it is a Trace activity we only send to the channel if it's the emulator. + } else if (!StringUtils.isEmpty(activity.replyToId())) { + ConnectorClient connectorClient = context.getServices().Get("ConnectorClient"); + response = connectorClient.conversations().replyToActivity(activity.conversation().id(), activity.id(), activity); + } else { + ConnectorClient connectorClient = context.getServices().Get("ConnectorClient"); + response = connectorClient.conversations().sendToConversation(activity.conversation().id(), activity); + } + + // If No response is set, then defult to a "simple" response. This can't really be done + // above, as there are cases where the ReplyTo/SendTo methods will also return null + // (See below) so the check has to happen here. + + // Note: In addition to the Invoke / Delay / Activity cases, this code also applies + // with Skype and Teams with regards to typing events. When sending a typing event in + // these channels they do not return a RequestResponse which causes the bot to blow up. + // https://github.com/Microsoft/botbuilder-dotnet/issues/460 + // bug report : https://github.com/Microsoft/botbuilder-dotnet/issues/465 + if (response == null) { + response = new ResourceResponse().withId((activity.id() == null) ? "" : activity.id()); + } + + responses[index] = response; + } + + return responses; + } + + /** + * 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. + *

Before calling this, set the ID of the replacement activity to the ID + * of the activity to replace.

+ * {@linkalso TurnContext.OnUpdateActivity(UpdateActivityHandler)} + */ + @Override + public ResourceResponse UpdateActivity(TurnContext context, Activity activity) { + ConnectorClient connectorClient = context.getServices().Get("ConnectorClient"); + // TODO String conversationId, String activityId, Activity activity) + return connectorClient.conversations().updateActivity(activity.conversation().id(), activity.id(), activity); + } + + /** + * 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 void DeleteActivity(TurnContext context, ConversationReference reference) { + ConnectorClientImpl connectorClient = context.getServices().Get("ConnectorClient"); + try { + connectorClient.conversations().deleteConversationMemberFuture(reference.conversation().id(), reference.activityId()).join(); + } catch (ExecutionException e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Failed deleting activity (%s)", e.toString())); + } catch (InterruptedException e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Failed deleting activity (%s)", e.toString())); + } + return; + } + + /** + * 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 void DeleteConversationMember(TurnContextImpl context, String memberId) { + if (context.getActivity().conversation() == null) + throw new IllegalArgumentException("BotFrameworkAdapter.deleteConversationMember(): missing conversation"); + + if (StringUtils.isEmpty(context.getActivity().conversation().id())) + throw new IllegalArgumentException("BotFrameworkAdapter.deleteConversationMember(): missing conversation.id"); + + ConnectorClient connectorClient = context.getServices().Get("ConnectorClient"); + + String conversationId = context.getActivity().conversation().id(); + + // TODO: + //await (connectorClient.conversations().DeleteConversationMemberAsync(conversationId, memberId)); + return; + } + + /** + * 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> GetActivityMembers(TurnContextImpl context) { + return GetActivityMembers(context, null); + } + + public CompletableFuture> GetActivityMembers(TurnContextImpl context, String activityId) { + // If no activity was passed in, use the current activity. + if (activityId == null) + activityId = context.getActivity().id(); + + if (context.getActivity().conversation() == null) + throw new IllegalArgumentException("BotFrameworkAdapter.GetActivityMembers(): missing conversation"); + + if (StringUtils.isEmpty((context.getActivity().conversation().id()))) + throw new IllegalArgumentException("BotFrameworkAdapter.GetActivityMembers(): missing conversation.id"); + + ConnectorClient connectorClient = context.getServices().Get("ConnectorClient"); + String conversationId = context.getActivity().conversation().id(); + + // TODO: + //List accounts = await(connectorClient.conversations().GetActivityMembersAsync(conversationId, activityId)); + + return completedFuture(null); + } + + /** + * 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> GetConversationMembers(TurnContextImpl context) { + if (context.getActivity().conversation() == null) + throw new IllegalArgumentException("BotFrameworkAdapter.GetActivityMembers(): missing conversation"); + + if (StringUtils.isEmpty(context.getActivity().conversation().id())) + throw new IllegalArgumentException("BotFrameworkAdapter.GetActivityMembers(): missing conversation.id"); + + ConnectorClient connectorClient = context.getServices().Get("ConnectorClient"); + String conversationId = context.getActivity().conversation().id(); + + // TODO + //List accounts = await(connectorClient.conversations().getConversationMembersAsync(conversationId)); + return completedFuture(null); + } + + /** + * 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 GetConversations(String serviceUrl, MicrosoftAppCredentials credentials) throws MalformedURLException, URISyntaxException { + return GetConversations(serviceUrl, credentials, null); + } + + public CompletableFuture GetConversations(String serviceUrl, MicrosoftAppCredentials credentials, String continuationToken) throws MalformedURLException, URISyntaxException { + if (StringUtils.isEmpty(serviceUrl)) + throw new IllegalArgumentException("serviceUrl"); + + if (credentials == null) + throw new IllegalArgumentException("credentials"); + + ConnectorClient connectorClient = this.CreateConnectorClient(serviceUrl, credentials); + // TODO + //ConversationsResult results = await(connectorClient.conversations().getConversationsAsync(continuationToken)); + return completedFuture(null); + } + + /** + * 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 GetConversations(TurnContextImpl context) { + return GetConversations(context, null); + } + + public CompletableFuture GetConversations(TurnContextImpl context, String continuationToken) { + ConnectorClient connectorClient = context.getServices().Get("ConnectorClient"); + // TODO + //ConversationsResult results = await(connectorClient.conversations().getConversationsAsync()); + return completedFuture(null); + } + + + /** + * 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 GetUserToken(TurnContextImpl context, String connectionName, String magicCode) { + BotAssert.ContextNotNull(context); + if (context.getActivity().from() == null || StringUtils.isEmpty(context.getActivity().from().id())) + throw new IllegalArgumentException("BotFrameworkAdapter.GetuserToken(): missing from or from.id"); + + if (StringUtils.isEmpty(connectionName)) + throw new IllegalArgumentException("connectionName"); + + //OAuthClient client = this.CreateOAuthApiClient(context); + //return await(client.GetUserTokenAsync(context.getActivity().from().id(), connectionName, magicCode)); + return completedFuture(null); + } + + /** + * 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 GetOauthSignInLink(TurnContextImpl context, String connectionName) { + BotAssert.ContextNotNull(context); + if (StringUtils.isEmpty(connectionName)) + throw new IllegalArgumentException("connectionName"); + + //OAuthClient client = this.CreateOAuthApiClient(context); + //return await(client.GetSignInLinkAsync(context.getActivity(), connectionName)); + return completedFuture(null); + } + + /** + * 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)) + throw new IllegalArgumentException("connectionName"); + + //OAuthClient client = this.CreateOAuthApiClient(context); + //await(client.SignOutUserAsync(context.Activity.From.Id, connectionName)); + return completedFuture(null); + } + + /** + * 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. + *

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.

+ *

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.

+ */ + public CompletableFuture CreateConversation(String channelId, String serviceUrl, MicrosoftAppCredentials + credentials, ConversationParameters conversationParameters, Consumer callback) throws Exception { + // Validate serviceUrl - can throw + URI uri = new URI(serviceUrl); + return CompletableFuture.runAsync(() -> { + ConnectorClient connectorClient = null; + try { + connectorClient = this.CreateConnectorClient(serviceUrl, credentials); + } catch (MalformedURLException e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Bad serviceUrl: %s", serviceUrl)); + } catch (URISyntaxException e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Bad serviceUrl: %s", serviceUrl)); + } + + Conversations conv = connectorClient.conversations(); + List results = null; + if (conv instanceof ConversationsImpl) { + ConversationsImpl convImpl = (ConversationsImpl) conv; + results = convImpl.CreateConversationAsync(conversationParameters).join(); + } else { + results = new ArrayList(); + results.add(conv.createConversation(conversationParameters)); + } + if (results.size() == 1) { + + ConversationResourceResponse result = results.get(0); + // Create a conversation update activity to represent the result. + + ConversationUpdateActivity conversationUpdate = (ConversationUpdateActivity) MessageActivity.CreateConversationUpdateActivity() + .withChannelId(channelId) + .withTopicName(conversationParameters.topicName()) + .withServiceUrl(serviceUrl) + .withMembersAdded(conversationParameters.members()) + .withId((result.activityId() != null) ? result.activityId() : UUID.randomUUID().toString()) + .withConversation(new ConversationAccount().withId(result.id())) + .withRecipient(conversationParameters.bot()); + + try (TurnContextImpl context = new TurnContextImpl(this, conversationUpdate)) { + try { + this.RunPipeline(context, callback); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Running pipeline failed : %s", e)); + } + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Turn Context Error: %s", e)); + } + } else { + // Should never happen + throw new RuntimeException(String.format("Conversations create issue - returned %d conversations", results.size())); + } + }); + + } + + protected CompletableFuture TrySetEmulatingOAuthCards(TurnContext turnContext) { + if (!isEmulatingOAuthCards && + turnContext.getActivity().channelId().equals("emulator") && + (_credentialProvider.isAuthenticationDisabledAsync().join())) { + isEmulatingOAuthCards = true; + } + return completedFuture(isEmulatingOAuthCards); + + } + + protected OAuthClient CreateOAuthApiClient(TurnContext context) throws MalformedURLException, URISyntaxException { + ConnectorClientImpl client = context.getServices().Get("ConnectorClient"); + if (client == null) { + throw new IllegalArgumentException("CreateOAuthApiClient: OAuth requires a valid ConnectorClient instance"); + } + if (isEmulatingOAuthCards) { + return new OAuthClient(client, context.getActivity().serviceUrl()); + } + return new OAuthClient(client, AuthenticationConstants.OAuthUrl); + } + + /** + * 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 CreateConnectorClientAsync(String serviceUrl, ClaimsIdentity claimsIdentity) { + + return CompletableFuture.supplyAsync(() -> { + if (claimsIdentity == null) { + throw new UnsupportedOperationException("ClaimsIdentity cannot be null. Pass Anonymous ClaimsIdentity if authentication is turned off."); + } + + // For requests from channel App Id is in Audience claim of JWT token. For emulator it is in AppId claim. For + // unauthenticated requests we have anonymous identity provided auth is disabled. + if (claimsIdentity.claims() == null) { + try { + return CreateConnectorClient(serviceUrl); + } catch (MalformedURLException e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Invalid Service URL: %s", serviceUrl)); + } catch (URISyntaxException e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Invalid Service URL: %s", serviceUrl)); + } + } + + // For Activities coming from Emulator AppId claim contains the Bot's AAD AppId. + // For anonymous requests (requests with no header) appId is not set in claims. + + Map.Entry botAppIdClaim = claimsIdentity.claims().entrySet().stream() + .filter(claim -> claim.getKey() == AuthenticationConstants.AudienceClaim) + .findFirst() + .orElse(null); + if (botAppIdClaim == null) { + botAppIdClaim = claimsIdentity.claims().entrySet().stream() + .filter(claim -> claim.getKey() == AuthenticationConstants.AppIdClaim) + .findFirst() + .orElse(null); + } + + if (botAppIdClaim != null) { + String botId = botAppIdClaim.getValue(); + MicrosoftAppCredentials appCredentials = this.GetAppCredentialsAsync(botId).join(); + try { + return this.CreateConnectorClient(serviceUrl, appCredentials); + } catch (MalformedURLException e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Bad Service URL: %s", serviceUrl)); + } catch (URISyntaxException e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Bad Service URL: %s", serviceUrl)); + } + } else { + try { + return this.CreateConnectorClient(serviceUrl); + } catch (MalformedURLException e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Bad Service URL: %s", serviceUrl)); + } catch (URISyntaxException e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Bad Service URL: %s", serviceUrl)); + } + } + }); + + } + + /** + * 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); + } + + private ConnectorClient CreateConnectorClient(String serviceUrl, MicrosoftAppCredentials appCredentials) throws MalformedURLException, URISyntaxException { + ConnectorClientImpl connectorClient = null; + if (appCredentials != null) { + connectorClient = new ConnectorClientImpl(new URI(serviceUrl).toURL().toString(), appCredentials); + } + // TODO: Constructor necessary? +// else { +// +// connectorClient = new ConnectorClientImpl(new URI(serviceUrl).toURL().toString()); +// } + + if (this.connectorClientRetryStrategy != null) + connectorClient.withRestRetryStrategy(this.connectorClientRetryStrategy); + + + return connectorClient; + + } + + /** + * 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 GetAppCredentialsAsync(String appId) { + CompletableFuture result = CompletableFuture.supplyAsync(() -> { + if (appId == null) { + return MicrosoftAppCredentials.Empty; + } + if (this.appCredentialMap.containsKey(appId)) + return this.appCredentialMap.get(appId); + String appPassword = this._credentialProvider.getAppPasswordAsync(appId).join(); + MicrosoftAppCredentials appCredentials = new MicrosoftAppCredentials(appId, appPassword); + this.appCredentialMap.put(appId, appCredentials); + return appCredentials; + + }); + return result; + } + +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/BotState.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotState.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/BotState.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotState.java index 0f480242..871223f1 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/BotState.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotState.java @@ -1,165 +1,165 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.microsoft.bot.builder; - -import com.fasterxml.jackson.core.JsonProcessingException; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.StreamSupport; - -import static java.util.concurrent.CompletableFuture.completedFuture; - -/** - * 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 : Middleware -// where TState : class, new() -public class BotState implements Middleware { - - private final StateSettings settings; - private final Storage storage; - private final Function keyDelegate; - private final String propertyName; - private final Supplier ctor; - - /** - * 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 keyDelegate, Supplier ctor) { - this(storage, propertyName, keyDelegate, ctor, null); - } - - public BotState(Storage storage, String propertyName, Function keyDelegate, Supplier ctor, StateSettings settings) { - if (null == storage) { - throw new IllegalArgumentException("Storage"); - } - if (null == propertyName) { - throw new IllegalArgumentException("String propertyName"); - } - if (null == keyDelegate) { - throw new IllegalArgumentException("Key Delegate"); - } - if (null == ctor) { - throw new IllegalArgumentException("ctor"); - } - this.ctor = ctor; - this.storage = storage; - this.propertyName = propertyName; - this.keyDelegate = keyDelegate; - if (null == settings) - this.settings = new StateSettings(); - else - this.settings = settings; - } - - - /** - * 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 void OnTurn(TurnContext context, NextDelegate next) throws Exception { - ReadToContextService(context); - next.next(); - WriteFromContextService(context).join(); - return; - } - - protected void ReadToContextService(TurnContext context) throws IllegalArgumentException, JsonProcessingException { - String key = this.keyDelegate.apply(context); - Map items = null; - try { - CompletableFuture> result = storage.Read(new String[]{key}); - items = result.get(); - System.out.println(String.format("BotState:OnTurn(tid:%s) ReadToContextService: Found %s items", Thread.currentThread().getId(), items.size())); - } catch (JsonProcessingException e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Error waiting context storage read: %s", e.toString())); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (ExecutionException e) { - e.printStackTrace(); - } - TState state = StreamSupport.stream(items.entrySet().spliterator(), false) - .filter(entry -> entry.getKey() == key) - .map(Map.Entry::getValue) - .map(entry -> (TState) entry) - .findFirst() - .orElse(null); - - - //var state = items.Where(entry => entry.Key == key).Select(entry => entry.Value).OfType().FirstOrDefault(); - if (state == null) - state = ctor.get(); - context.getServices().Add(this.propertyName, state); - } - - protected CompletableFuture WriteFromContextService(TurnContext context) throws Exception { - TState state = context.getServices().Get(this.propertyName); - return Write(context, state); - } - - /** - * Reads state from storage. - * - * @param TState The type of the bot state object. - * @param context The context object for this turn. - */ - public CompletableFuture Read(TurnContext context) throws JsonProcessingException { - String key = this.keyDelegate.apply(context); - Map items = storage.Read(new String[]{key}).join(); - TState state = StreamSupport.stream(items.entrySet().spliterator(), false) - .filter(item -> item.getKey() == key) - .map(Map.Entry::getValue) - .map(item -> (TState) item) - .findFirst() - .orElse(null); - //var state = items.Where(entry => entry.Key == key).Select(entry => entry.Value).OfType().FirstOrDefault(); - if (state == null) - state = ctor.get(); - return completedFuture(state); - } - - /** - * 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 changes = new HashMap(); - //List> changes = new ArrayList>(); - if (state == null) - state = ctor.get(); - String key = keyDelegate.apply(context); - changes.put(key, state); - - if (this.settings.getLastWriterWins()) { - for (Map.Entry item : changes.entrySet()) { - if (item.getValue() instanceof StoreItem) { - StoreItem valueStoreItem = (StoreItem) item.getValue(); - valueStoreItem.seteTag("*"); - } - } - } - return completedFuture(storage.Write(changes).join()); - } -} - - - +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.microsoft.bot.builder; + +import com.fasterxml.jackson.core.JsonProcessingException; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.StreamSupport; + +import static java.util.concurrent.CompletableFuture.completedFuture; + +/** + * 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 : Middleware +// where TState : class, new() +public class BotState implements Middleware { + + private final StateSettings settings; + private final Storage storage; + private final Function keyDelegate; + private final String propertyName; + private final Supplier ctor; + + /** + * 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 keyDelegate, Supplier ctor) { + this(storage, propertyName, keyDelegate, ctor, null); + } + + public BotState(Storage storage, String propertyName, Function keyDelegate, Supplier ctor, StateSettings settings) { + if (null == storage) { + throw new IllegalArgumentException("Storage"); + } + if (null == propertyName) { + throw new IllegalArgumentException("String propertyName"); + } + if (null == keyDelegate) { + throw new IllegalArgumentException("Key Delegate"); + } + if (null == ctor) { + throw new IllegalArgumentException("ctor"); + } + this.ctor = ctor; + this.storage = storage; + this.propertyName = propertyName; + this.keyDelegate = keyDelegate; + if (null == settings) + this.settings = new StateSettings(); + else + this.settings = settings; + } + + + /** + * 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 void OnTurn(TurnContext context, NextDelegate next) throws Exception { + ReadToContextService(context); + next.next(); + WriteFromContextService(context).join(); + return; + } + + protected void ReadToContextService(TurnContext context) throws IllegalArgumentException, JsonProcessingException { + String key = this.keyDelegate.apply(context); + Map items = null; + try { + CompletableFuture> result = storage.Read(new String[]{key}); + items = result.get(); + System.out.println(String.format("BotState:OnTurn(tid:%s) ReadToContextService: Found %s items", Thread.currentThread().getId(), items.size())); + } catch (JsonProcessingException e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Error waiting context storage read: %s", e.toString())); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } + TState state = StreamSupport.stream(items.entrySet().spliterator(), false) + .filter(entry -> entry.getKey() == key) + .map(Map.Entry::getValue) + .map(entry -> (TState) entry) + .findFirst() + .orElse(null); + + + //var state = items.Where(entry => entry.Key == key).Select(entry => entry.Value).OfType().FirstOrDefault(); + if (state == null) + state = ctor.get(); + context.getServices().Add(this.propertyName, state); + } + + protected CompletableFuture WriteFromContextService(TurnContext context) throws Exception { + TState state = context.getServices().Get(this.propertyName); + return Write(context, state); + } + + /** + * Reads state from storage. + * + * @param TState The type of the bot state object. + * @param context The context object for this turn. + */ + public CompletableFuture Read(TurnContext context) throws JsonProcessingException { + String key = this.keyDelegate.apply(context); + Map items = storage.Read(new String[]{key}).join(); + TState state = StreamSupport.stream(items.entrySet().spliterator(), false) + .filter(item -> item.getKey() == key) + .map(Map.Entry::getValue) + .map(item -> (TState) item) + .findFirst() + .orElse(null); + //var state = items.Where(entry => entry.Key == key).Select(entry => entry.Value).OfType().FirstOrDefault(); + if (state == null) + state = ctor.get(); + return completedFuture(state); + } + + /** + * 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 changes = new HashMap(); + //List> changes = new ArrayList>(); + if (state == null) + state = ctor.get(); + String key = keyDelegate.apply(context); + changes.put(key, state); + + if (this.settings.getLastWriterWins()) { + for (Map.Entry item : changes.entrySet()) { + if (item.getValue() instanceof StoreItem) { + StoreItem valueStoreItem = (StoreItem) item.getValue(); + valueStoreItem.seteTag("*"); + } + } + } + return completedFuture(storage.Write(changes).join()); + } +} + + + diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/CallOnException.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/CallOnException.java similarity index 96% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/CallOnException.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/CallOnException.java index 2ad3ba32..f4ff21ac 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/CallOnException.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/CallOnException.java @@ -1,9 +1,9 @@ -package com.microsoft.bot.builder; - -import com.microsoft.bot.builder.TurnContext; - -import java.util.concurrent.CompletableFuture; - -public interface CallOnException { - CompletableFuture apply(TurnContext context, T t ) throws Exception; -} +package com.microsoft.bot.builder; + +import com.microsoft.bot.builder.TurnContext; + +import java.util.concurrent.CompletableFuture; + +public interface CallOnException { + CompletableFuture apply(TurnContext context, T t ) throws Exception; +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/CatchExceptionMiddleware.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/CatchExceptionMiddleware.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/CatchExceptionMiddleware.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/CatchExceptionMiddleware.java index e684af15..599045cd 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/CatchExceptionMiddleware.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/CatchExceptionMiddleware.java @@ -1,46 +1,46 @@ - - -package com.microsoft.bot.builder; - -/** - * 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 implements Middleware { - private final CallOnException _handler; - private final Class _exceptionType; - - public CatchExceptionMiddleware(CallOnException callOnException, Class exceptionType) { - _handler = callOnException; - _exceptionType = exceptionType; - } - - - @Override - public void OnTurn(TurnContext context, NextDelegate next) throws Exception { - - Class c = _exceptionType.getDeclaringClass(); - - try { - // Continue to route the activity through the pipeline - // any errors further down the pipeline will be caught by - // this try / catch - next.next(); - } catch (Exception ex) { - - if (_exceptionType.isInstance(ex)) - // If an error is thrown and the exception is of type T then invoke the handler - _handler.apply(context, (T) ex); - else - throw ex; - } - return; - } - -} + + +package com.microsoft.bot.builder; + +/** + * 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 implements Middleware { + private final CallOnException _handler; + private final Class _exceptionType; + + public CatchExceptionMiddleware(CallOnException callOnException, Class exceptionType) { + _handler = callOnException; + _exceptionType = exceptionType; + } + + + @Override + public void OnTurn(TurnContext context, NextDelegate next) throws Exception { + + Class c = _exceptionType.getDeclaringClass(); + + try { + // Continue to route the activity through the pipeline + // any errors further down the pipeline will be caught by + // this try / catch + next.next(); + } catch (Exception ex) { + + if (_exceptionType.isInstance(ex)) + // If an error is thrown and the exception is of type T then invoke the handler + _handler.apply(context, (T) ex); + else + throw ex; + } + return; + } + +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/ConversationState.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/ConversationState.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/ConversationState.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/ConversationState.java index 67234b10..a802dd94 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/ConversationState.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/ConversationState.java @@ -1,49 +1,49 @@ -package com.microsoft.bot.builder; - -import com.microsoft.bot.builder.TurnContext; - -import java.util.function.Supplier; - -/** - * 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 extends BotState -{ - /** - * 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).Namespace}.{typeof(ConversationState).Name}" - public static String PropertyName() { - return String.format("ConversationState:Microsoft.Bot.Builder.Core.Extensions.ConversationState`1"); - } - - /** - * 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 ctor) { - this(storage, null, ctor); - } - - public ConversationState(Storage storage, StateSettings settings, Supplier ctor) { - super(storage, PropertyName(), - (context) -> { - return String.format("conversation/%s/%s", context.getActivity().channelId(), context.getActivity().conversation().id()); - }, - ctor, - settings); - } - - /** - * Gets the conversation state object from turn context. - * @param context The context object for this turn. - * @return The coversation state object. - */ - public static TState Get(TurnContext context) throws IllegalArgumentException { - return context.getServices().Get(PropertyName()); - } -} +package com.microsoft.bot.builder; + +import com.microsoft.bot.builder.TurnContext; + +import java.util.function.Supplier; + +/** + * 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 extends BotState +{ + /** + * 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).Namespace}.{typeof(ConversationState).Name}" + public static String PropertyName() { + return String.format("ConversationState:Microsoft.Bot.Builder.Core.Extensions.ConversationState`1"); + } + + /** + * 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 ctor) { + this(storage, null, ctor); + } + + public ConversationState(Storage storage, StateSettings settings, Supplier ctor) { + super(storage, PropertyName(), + (context) -> { + return String.format("conversation/%s/%s", context.getActivity().channelId(), context.getActivity().conversation().id()); + }, + ctor, + settings); + } + + /** + * Gets the conversation state object from turn context. + * @param context The context object for this turn. + * @return The coversation state object. + */ + public static TState Get(TurnContext context) throws IllegalArgumentException { + return context.getServices().Get(PropertyName()); + } +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/DeleteActivityHandler.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/DeleteActivityHandler.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/DeleteActivityHandler.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/DeleteActivityHandler.java index af7820ca..db6c2568 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/DeleteActivityHandler.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/DeleteActivityHandler.java @@ -1,25 +1,25 @@ -package com.microsoft.bot.builder; - -import com.microsoft.bot.schema.models.ConversationReference; - -/** - * 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 doesn’t call the next delegate, - * the adapter does not call any of the subsequent handlers and does not delete the - *activity. - *

The conversation reference's {@link ConversationReference.ActivityId} - * indicates the activity in the conversation to replace.

- * - * {@linkalso BotAdapter} - * {@linkalso SendActivitiesHandler} - * {@linkalso UpdateActivityHandler} - */ -@FunctionalInterface -public interface DeleteActivityHandler { - void handle(TurnContext context, ConversationReference reference, Runnable next) throws Exception; -} +package com.microsoft.bot.builder; + +import com.microsoft.bot.schema.models.ConversationReference; + +/** + * 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 doesn’t call the next delegate, + * the adapter does not call any of the subsequent handlers and does not delete the + *activity. + *

The conversation reference's {@link ConversationReference.ActivityId} + * indicates the activity in the conversation to replace.

+ * + * {@linkalso BotAdapter} + * {@linkalso SendActivitiesHandler} + * {@linkalso UpdateActivityHandler} + */ +@FunctionalInterface +public interface DeleteActivityHandler { + void handle(TurnContext context, ConversationReference reference, Runnable next) throws Exception; +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/InvokeResponse.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/InvokeResponse.java similarity index 96% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/InvokeResponse.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/InvokeResponse.java index accec9cf..d37bae29 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/InvokeResponse.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/InvokeResponse.java @@ -1,37 +1,37 @@ -package com.microsoft.bot.builder; - -/** - * 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 { - /** - * 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() { - return this._status; - } - - public void setStatus(int status) { - this._status = status; - } - - /** - * 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() { - return _body; - } - - public void setBody(Object body) { - this._body = body; - } -} +package com.microsoft.bot.builder; + +/** + * 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 { + /** + * 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() { + return this._status; + } + + public void setStatus(int status) { + this._status = status; + } + + /** + * 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() { + return _body; + } + + public void setBody(Object body) { + this._body = body; + } +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/MemoryTranscriptStore.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/MemoryTranscriptStore.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/MemoryTranscriptStore.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/MemoryTranscriptStore.java index c332058d..cf36ef09 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/MemoryTranscriptStore.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/MemoryTranscriptStore.java @@ -1,310 +1,310 @@ -package com.microsoft.bot.builder; - - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - - -import com.microsoft.bot.schema.models.Activity; -import org.joda.time.DateTime; - -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.ForkJoinWorkerThread; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -/** - * The memory transcript store stores transcripts in volatile memory in a Dictionary. - *

- *

- * Because this uses an unbounded volitile dictionary this should only be used for unit tests or non-production environments. - */ -public class MemoryTranscriptStore implements TranscriptStore { - private HashMap>> channels = new HashMap>>(); - final ForkJoinPool.ForkJoinWorkerThreadFactory factory = new ForkJoinPool.ForkJoinWorkerThreadFactory() { - @Override - public ForkJoinWorkerThread newThread(ForkJoinPool pool) { - final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); - worker.setName("TestFlow-" + worker.getPoolIndex()); - return worker; - } - }; - - final ExecutorService executor = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), factory, null, false); - - - /** - * Logs an activity to the transcript. - * - * @param activity The activity to log. - * @return A CompletableFuture that represents the work queued to execute. - */ - public final void LogActivityAsync(Activity activity) { - if (activity == null) { - throw new NullPointerException("activity cannot be null for LogActivity()"); - } - - synchronized (this.channels) { - HashMap> channel; - if (!this.channels.containsKey(activity.channelId())) { - channel = new HashMap>(); - this.channels.put(activity.channelId(), channel); - } else { - channel = this.channels.get(activity.channelId()); - } - - ArrayList transcript = null; - - - if (!channel.containsKey(activity.conversation().id())) { - transcript = new ArrayList(); - channel.put(activity.conversation().id(), transcript); - } else { - transcript = channel.get(activity.conversation().id()); - } - - transcript.add(activity); - } - - } - - /** - * Gets from the store activities that match a set of criteria. - * - * @param channelId The ID of the channel the conversation is in. - * @param conversationId The ID of the conversation. - * @param continuationToken - * @return A task that represents the work queued to execute. - * If the task completes successfully, the result contains the matching activities. - */ - - public final CompletableFuture> GetTranscriptActivitiesAsync(String channelId, String conversationId, String continuationToken) { - return GetTranscriptActivitiesAsync(channelId, conversationId, continuationToken, null); - } - - /** - * Gets from the store activities that match a set of criteria. - * - * @param channelId The ID of the channel the conversation is in. - * @param conversationId The ID of the conversation. - * @return A task that represents the work queued to execute. - * If the task completes successfully, the result contains the matching activities. - */ - - public final CompletableFuture> GetTranscriptActivitiesAsync(String channelId, String conversationId) { - return GetTranscriptActivitiesAsync(channelId, conversationId, null, null); - } - - /** - * Gets from the store activities that match a set of criteria. - * - * @param channelId The ID of the channel the conversation is in. - * @param conversationId The ID of the conversation. - * @param continuationToken - * @param startDate A cutoff date. Activities older than this date are not included. - * @return A task that represents the work queued to execute. - * If the task completes successfully, the result contains the matching activities. - */ - public final CompletableFuture> GetTranscriptActivitiesAsync(String channelId, String conversationId, String continuationToken, DateTime startDate) { - return CompletableFuture.supplyAsync(() -> { - if (channelId == null) { - throw new NullPointerException(String.format("missing %1$s", "channelId")); - } - - if (conversationId == null) { - throw new NullPointerException(String.format("missing %1$s", "conversationId")); - } - - PagedResult pagedResult = new PagedResult(); - synchronized (channels) { - HashMap> channel; - if (!channels.containsKey(channelId)) { - return pagedResult; - } - channel = channels.get(channelId); - ArrayList transcript; - - if (!channel.containsKey(conversationId)) { - return pagedResult; - } - transcript = channel.get(conversationId); - if (continuationToken != null) { - List items = transcript.stream() - .sorted(Comparator.comparing(Activity::timestamp)) - .filter(a -> a.timestamp().compareTo(startDate) >= 0) - .filter(skipwhile(a -> !a.id().equals(continuationToken))) - .skip(1) - .limit(20) - .collect(Collectors.toList()); - - pagedResult.items(items.toArray(new Activity[items.size()])); - - if (pagedResult.getItems().length == 20) { - pagedResult.withContinuationToken(items.get(items.size() - 1).id()); - } - } else { - List items = transcript.stream() - .sorted(Comparator.comparing(Activity::timestamp)) - .filter(a -> a.timestamp().compareTo((startDate == null) ? new DateTime(Long.MIN_VALUE) : startDate) >= 0) - .limit(20) - .collect(Collectors.toList()); - pagedResult.items(items.toArray(new Activity[items.size()])); - if (items.size() == 20) { - pagedResult.withContinuationToken(items.get(items.size() - 1).id()); - } - } - } - - return pagedResult; - - }, this.executor); - } - - /** - * Deletes conversation data from the store. - * - * @param channelId The ID of the channel the conversation is in. - * @param conversationId The ID of the conversation to delete. - * @return A task that represents the work queued to execute. - */ - public final CompletableFuture DeleteTranscriptAsync(String channelId, String conversationId) { - return CompletableFuture.runAsync(() -> { - if (channelId == null) { - throw new NullPointerException(String.format("%1$s should not be null", "channelId")); - } - - if (conversationId == null) { - throw new NullPointerException(String.format("%1$s should not be null", "conversationId")); - } - - synchronized (this.channels) { - if (!this.channels.containsKey(channelId)) { - return; - } - HashMap> channel = this.channels.get(channelId); - if (channel.containsKey(conversationId)) { - channel.remove(conversationId); - } - } - }, this.executor); - } - - /** - * Gets the conversations on a channel from the store. - * - * @param channelId The ID of the channel. - * @return A task that represents the work queued to execute. - */ - - public final CompletableFuture> ListTranscriptsAsync(String channelId) { - return ListTranscriptsAsync(channelId, null); - } - - /** - * Gets the conversations on a channel from the store. - * - * @param channelId The ID of the channel. - * @param continuationToken - * @return A task that represents the work queued to execute. - */ - - public final CompletableFuture> ListTranscriptsAsync(String channelId, String continuationToken) { - return CompletableFuture.supplyAsync(() -> { - if (channelId == null) { - throw new NullPointerException(String.format("missing %1$s", "channelId")); - } - - PagedResult pagedResult = new PagedResult(); - synchronized (channels) { - - if (!channels.containsKey(channelId)) { - return pagedResult; - } - - HashMap> channel = channels.get(channelId); - if (continuationToken != null) { - List items = channel.entrySet().stream() - .map(c -> { - OffsetDateTime offsetDateTime = null; - if (c.getValue().stream().findFirst().isPresent()) { - DateTime dt = c.getValue().stream().findFirst().get().timestamp(); - // convert to DateTime to OffsetDateTime - Instant instant = Instant.ofEpochMilli(dt.getMillis()); - ZoneOffset offset = ZoneId.of(dt.getZone().getID()).getRules().getOffset(instant); - offsetDateTime = instant.atOffset(offset); - } else { - offsetDateTime = OffsetDateTime.now(); - } - return new Transcript() - .withChannelId(channelId) - .withId(c.getKey()) - .withCreated(offsetDateTime); - } - ) - .sorted(Comparator.comparing(Transcript::getCreated)) - .filter(skipwhile(c -> !c.getId().equals(continuationToken))) - .skip(1) - .limit(20) - .collect(Collectors.toList()); - pagedResult.items(items.toArray(new Transcript[items.size()])); - if (items.size() == 20) { - pagedResult.withContinuationToken(items.get(items.size() - 1).getId()); - } - } else { - - List items = channel.entrySet().stream() - .map(c -> { - OffsetDateTime offsetDateTime = null; - if (c.getValue().stream().findFirst().isPresent()) { - DateTime dt = c.getValue().stream().findFirst().get().timestamp(); - // convert to DateTime to OffsetDateTime - Instant instant = Instant.ofEpochMilli(dt.getMillis()); - ZoneOffset offset = ZoneId.of(dt.getZone().getID()).getRules().getOffset(instant); - offsetDateTime = instant.atOffset(offset); - } else { - offsetDateTime = OffsetDateTime.now(); - } - return new Transcript() - .withChannelId(channelId) - .withId(c.getKey()) - .withCreated(offsetDateTime); - } - ) - .sorted(Comparator.comparing(Transcript::getCreated)) - .limit(20) - .collect(Collectors.toList()); - pagedResult.items(items.toArray(new Transcript[items.size()])); - if (items.size() == 20) { - pagedResult.withContinuationToken(items.get(items.size() - 1).getId()); - } - } - } - return pagedResult; - }, this.executor); - } - - /** - * Emulate C# SkipWhile. - * Stateful - * - * @param func1 predicate to apply - * @param type - * @return if the predicate condition is true - */ - public static Predicate skipwhile(Function func1) { - final boolean[] started = {false}; - return t -> started[0] || (started[0] = (boolean) func1.apply(t)); - } - +package com.microsoft.bot.builder; + + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + + +import com.microsoft.bot.schema.models.Activity; +import org.joda.time.DateTime; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.ForkJoinWorkerThread; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +/** + * The memory transcript store stores transcripts in volatile memory in a Dictionary. + *

+ *

+ * Because this uses an unbounded volitile dictionary this should only be used for unit tests or non-production environments. + */ +public class MemoryTranscriptStore implements TranscriptStore { + private HashMap>> channels = new HashMap>>(); + final ForkJoinPool.ForkJoinWorkerThreadFactory factory = new ForkJoinPool.ForkJoinWorkerThreadFactory() { + @Override + public ForkJoinWorkerThread newThread(ForkJoinPool pool) { + final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); + worker.setName("TestFlow-" + worker.getPoolIndex()); + return worker; + } + }; + + final ExecutorService executor = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), factory, null, false); + + + /** + * Logs an activity to the transcript. + * + * @param activity The activity to log. + * @return A CompletableFuture that represents the work queued to execute. + */ + public final void LogActivityAsync(Activity activity) { + if (activity == null) { + throw new NullPointerException("activity cannot be null for LogActivity()"); + } + + synchronized (this.channels) { + HashMap> channel; + if (!this.channels.containsKey(activity.channelId())) { + channel = new HashMap>(); + this.channels.put(activity.channelId(), channel); + } else { + channel = this.channels.get(activity.channelId()); + } + + ArrayList transcript = null; + + + if (!channel.containsKey(activity.conversation().id())) { + transcript = new ArrayList(); + channel.put(activity.conversation().id(), transcript); + } else { + transcript = channel.get(activity.conversation().id()); + } + + transcript.add(activity); + } + + } + + /** + * Gets from the store activities that match a set of criteria. + * + * @param channelId The ID of the channel the conversation is in. + * @param conversationId The ID of the conversation. + * @param continuationToken + * @return A task that represents the work queued to execute. + * If the task completes successfully, the result contains the matching activities. + */ + + public final CompletableFuture> GetTranscriptActivitiesAsync(String channelId, String conversationId, String continuationToken) { + return GetTranscriptActivitiesAsync(channelId, conversationId, continuationToken, null); + } + + /** + * Gets from the store activities that match a set of criteria. + * + * @param channelId The ID of the channel the conversation is in. + * @param conversationId The ID of the conversation. + * @return A task that represents the work queued to execute. + * If the task completes successfully, the result contains the matching activities. + */ + + public final CompletableFuture> GetTranscriptActivitiesAsync(String channelId, String conversationId) { + return GetTranscriptActivitiesAsync(channelId, conversationId, null, null); + } + + /** + * Gets from the store activities that match a set of criteria. + * + * @param channelId The ID of the channel the conversation is in. + * @param conversationId The ID of the conversation. + * @param continuationToken + * @param startDate A cutoff date. Activities older than this date are not included. + * @return A task that represents the work queued to execute. + * If the task completes successfully, the result contains the matching activities. + */ + public final CompletableFuture> GetTranscriptActivitiesAsync(String channelId, String conversationId, String continuationToken, DateTime startDate) { + return CompletableFuture.supplyAsync(() -> { + if (channelId == null) { + throw new NullPointerException(String.format("missing %1$s", "channelId")); + } + + if (conversationId == null) { + throw new NullPointerException(String.format("missing %1$s", "conversationId")); + } + + PagedResult pagedResult = new PagedResult(); + synchronized (channels) { + HashMap> channel; + if (!channels.containsKey(channelId)) { + return pagedResult; + } + channel = channels.get(channelId); + ArrayList transcript; + + if (!channel.containsKey(conversationId)) { + return pagedResult; + } + transcript = channel.get(conversationId); + if (continuationToken != null) { + List items = transcript.stream() + .sorted(Comparator.comparing(Activity::timestamp)) + .filter(a -> a.timestamp().compareTo(startDate) >= 0) + .filter(skipwhile(a -> !a.id().equals(continuationToken))) + .skip(1) + .limit(20) + .collect(Collectors.toList()); + + pagedResult.items(items.toArray(new Activity[items.size()])); + + if (pagedResult.getItems().length == 20) { + pagedResult.withContinuationToken(items.get(items.size() - 1).id()); + } + } else { + List items = transcript.stream() + .sorted(Comparator.comparing(Activity::timestamp)) + .filter(a -> a.timestamp().compareTo((startDate == null) ? new DateTime(Long.MIN_VALUE) : startDate) >= 0) + .limit(20) + .collect(Collectors.toList()); + pagedResult.items(items.toArray(new Activity[items.size()])); + if (items.size() == 20) { + pagedResult.withContinuationToken(items.get(items.size() - 1).id()); + } + } + } + + return pagedResult; + + }, this.executor); + } + + /** + * Deletes conversation data from the store. + * + * @param channelId The ID of the channel the conversation is in. + * @param conversationId The ID of the conversation to delete. + * @return A task that represents the work queued to execute. + */ + public final CompletableFuture DeleteTranscriptAsync(String channelId, String conversationId) { + return CompletableFuture.runAsync(() -> { + if (channelId == null) { + throw new NullPointerException(String.format("%1$s should not be null", "channelId")); + } + + if (conversationId == null) { + throw new NullPointerException(String.format("%1$s should not be null", "conversationId")); + } + + synchronized (this.channels) { + if (!this.channels.containsKey(channelId)) { + return; + } + HashMap> channel = this.channels.get(channelId); + if (channel.containsKey(conversationId)) { + channel.remove(conversationId); + } + } + }, this.executor); + } + + /** + * Gets the conversations on a channel from the store. + * + * @param channelId The ID of the channel. + * @return A task that represents the work queued to execute. + */ + + public final CompletableFuture> ListTranscriptsAsync(String channelId) { + return ListTranscriptsAsync(channelId, null); + } + + /** + * Gets the conversations on a channel from the store. + * + * @param channelId The ID of the channel. + * @param continuationToken + * @return A task that represents the work queued to execute. + */ + + public final CompletableFuture> ListTranscriptsAsync(String channelId, String continuationToken) { + return CompletableFuture.supplyAsync(() -> { + if (channelId == null) { + throw new NullPointerException(String.format("missing %1$s", "channelId")); + } + + PagedResult pagedResult = new PagedResult(); + synchronized (channels) { + + if (!channels.containsKey(channelId)) { + return pagedResult; + } + + HashMap> channel = channels.get(channelId); + if (continuationToken != null) { + List items = channel.entrySet().stream() + .map(c -> { + OffsetDateTime offsetDateTime = null; + if (c.getValue().stream().findFirst().isPresent()) { + DateTime dt = c.getValue().stream().findFirst().get().timestamp(); + // convert to DateTime to OffsetDateTime + Instant instant = Instant.ofEpochMilli(dt.getMillis()); + ZoneOffset offset = ZoneId.of(dt.getZone().getID()).getRules().getOffset(instant); + offsetDateTime = instant.atOffset(offset); + } else { + offsetDateTime = OffsetDateTime.now(); + } + return new Transcript() + .withChannelId(channelId) + .withId(c.getKey()) + .withCreated(offsetDateTime); + } + ) + .sorted(Comparator.comparing(Transcript::getCreated)) + .filter(skipwhile(c -> !c.getId().equals(continuationToken))) + .skip(1) + .limit(20) + .collect(Collectors.toList()); + pagedResult.items(items.toArray(new Transcript[items.size()])); + if (items.size() == 20) { + pagedResult.withContinuationToken(items.get(items.size() - 1).getId()); + } + } else { + + List items = channel.entrySet().stream() + .map(c -> { + OffsetDateTime offsetDateTime = null; + if (c.getValue().stream().findFirst().isPresent()) { + DateTime dt = c.getValue().stream().findFirst().get().timestamp(); + // convert to DateTime to OffsetDateTime + Instant instant = Instant.ofEpochMilli(dt.getMillis()); + ZoneOffset offset = ZoneId.of(dt.getZone().getID()).getRules().getOffset(instant); + offsetDateTime = instant.atOffset(offset); + } else { + offsetDateTime = OffsetDateTime.now(); + } + return new Transcript() + .withChannelId(channelId) + .withId(c.getKey()) + .withCreated(offsetDateTime); + } + ) + .sorted(Comparator.comparing(Transcript::getCreated)) + .limit(20) + .collect(Collectors.toList()); + pagedResult.items(items.toArray(new Transcript[items.size()])); + if (items.size() == 20) { + pagedResult.withContinuationToken(items.get(items.size() - 1).getId()); + } + } + } + return pagedResult; + }, this.executor); + } + + /** + * Emulate C# SkipWhile. + * Stateful + * + * @param func1 predicate to apply + * @param type + * @return if the predicate condition is true + */ + public static Predicate skipwhile(Function func1) { + final boolean[] started = {false}; + return t -> started[0] || (started[0] = (boolean) func1.apply(t)); + } + } \ No newline at end of file diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/Middleware.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/Middleware.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/Middleware.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/Middleware.java index f76d47ed..fb36c04a 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/Middleware.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/Middleware.java @@ -1,57 +1,57 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.microsoft.bot.builder; - -/** - * 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. - *

You can add middleware objects to your adapter’s middleware collection. The - * adapter processes and directs incoming activities in through the bot middleware - * pipeline to your bot’s 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.

- *

For each activity, the adapter calls middleware in the order in which you - * added it.

- * - * - * This defines middleware that sends "before" and "after" messages - * before and after the adapter calls the bot's - * {@link Bot.OnTurn(TurnContext)} method. - * - * public class SampleMiddleware : Middleware - * { - * public async Task OnTurn(TurnContext context, MiddlewareSet.NextDelegate next) - * { - * context.SendActivity("before"); - * await next().ConfigureAwait(false); - * context.SendActivity("after"); - * } - * } - * - * - * {@linkalso Bot} - */ -public interface Middleware -{ - /** - * 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 doesn’t call the next delegate, - * the adapter does not call any of the subsequent middleware’s request handlers or the - * bot’s receive handler, and the pipeline short circuits. - *

The {@code context} provides information about the - * incoming activity, and other data needed to process the activity.

- * - * {@linkalso TurnContext} - * {@linkalso Bot.Schema.Activity} - */ - void OnTurn(TurnContext context, NextDelegate next) throws Exception; -} - - - +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.microsoft.bot.builder; + +/** + * 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. + *

You can add middleware objects to your adapter’s middleware collection. The + * adapter processes and directs incoming activities in through the bot middleware + * pipeline to your bot’s 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.

+ *

For each activity, the adapter calls middleware in the order in which you + * added it.

+ * + * + * This defines middleware that sends "before" and "after" messages + * before and after the adapter calls the bot's + * {@link Bot.OnTurn(TurnContext)} method. + * + * public class SampleMiddleware : Middleware + * { + * public async Task OnTurn(TurnContext context, MiddlewareSet.NextDelegate next) + * { + * context.SendActivity("before"); + * await next().ConfigureAwait(false); + * context.SendActivity("after"); + * } + * } + * + * + * {@linkalso Bot} + */ +public interface Middleware +{ + /** + * 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 doesn’t call the next delegate, + * the adapter does not call any of the subsequent middleware’s request handlers or the + * bot’s receive handler, and the pipeline short circuits. + *

The {@code context} provides information about the + * incoming activity, and other data needed to process the activity.

+ * + * {@linkalso TurnContext} + * {@linkalso Bot.Schema.Activity} + */ + void OnTurn(TurnContext context, NextDelegate next) throws Exception; +} + + + diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/MiddlewareCall.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/MiddlewareCall.java similarity index 96% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/MiddlewareCall.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/MiddlewareCall.java index 8ed161ca..e440af0f 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/MiddlewareCall.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/MiddlewareCall.java @@ -1,6 +1,6 @@ -package com.microsoft.bot.builder; - -@FunctionalInterface -public interface MiddlewareCall { - void requestHandler(TurnContext tc, NextDelegate nd) throws Exception; -} +package com.microsoft.bot.builder; + +@FunctionalInterface +public interface MiddlewareCall { + void requestHandler(TurnContext tc, NextDelegate nd) throws Exception; +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/MiddlewareSet.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/MiddlewareSet.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/MiddlewareSet.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/MiddlewareSet.java index d0414d7a..e02d7bb2 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/MiddlewareSet.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/MiddlewareSet.java @@ -1,97 +1,97 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.microsoft.bot.builder; - - -import java.util.ArrayList; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.function.Consumer; - -public class MiddlewareSet implements Middleware { - public NextDelegate Next; - - private final ArrayList _middleware = new ArrayList(); - - public MiddlewareSet Use(Middleware middleware) { - BotAssert.MiddlewareNotNull(middleware); - _middleware.add(middleware); - return this; - } - - public void ReceiveActivity(TurnContextImpl context) - throws Exception { - ReceiveActivityInternal(context, null); - } - - @Override - public void OnTurn(TurnContext context, NextDelegate next) throws Exception { - ReceiveActivityInternal((TurnContextImpl) context, null); - try { - next.next(); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(String.format("MiddlewareSet::OnTurn next delegate: %s", e.toString())); - } - } - - - public void OnTurn(TurnContextImpl context, CompletableFuture next) - throws ExecutionException, InterruptedException { - return; - } - - /** - * 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 void ReceiveActivityWithStatus(TurnContext context, Consumer callback) - throws Exception { - ReceiveActivityInternal(context, callback); - } - - private void ReceiveActivityInternal(TurnContext context, Consumer callback) - throws Exception { - ReceiveActivityInternal(context, callback, 0); - } - - private void ReceiveActivityInternal(TurnContext context, Consumer callback, int nextMiddlewareIndex) - throws Exception { - // Check if we're at the end of the middleware list yet - if (nextMiddlewareIndex == _middleware.size()) { - // If all the Middlware ran, the "leading edge" of the tree is now complete. - // This means it's time to run any developer specified callback. - // Once this callback is done, the "trailing edge" calls are then completed. This - // allows code that looks like: - // Trace.TraceInformation("before"); - // await next(); - // Trace.TraceInformation("after"); - // to run as expected. - - // If a callback was provided invoke it now and return its task, otherwise just return the completed task - if (callback == null) { - return ; - } else { - callback.accept(context); - return; - } - } - - // Get the next piece of middleware - Middleware nextMiddleware = _middleware.get(nextMiddlewareIndex); - NextDelegate next = new NextDelegate() { - public void next() throws Exception { - ReceiveActivityInternal(context, callback, nextMiddlewareIndex + 1); - } - }; - - // Execute the next middleware passing a closure that will recurse back into this method at the next piece of middlware as the NextDelegate - nextMiddleware.OnTurn( - context, - next); - } - - -} +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.microsoft.bot.builder; + + +import java.util.ArrayList; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.function.Consumer; + +public class MiddlewareSet implements Middleware { + public NextDelegate Next; + + private final ArrayList _middleware = new ArrayList(); + + public MiddlewareSet Use(Middleware middleware) { + BotAssert.MiddlewareNotNull(middleware); + _middleware.add(middleware); + return this; + } + + public void ReceiveActivity(TurnContextImpl context) + throws Exception { + ReceiveActivityInternal(context, null); + } + + @Override + public void OnTurn(TurnContext context, NextDelegate next) throws Exception { + ReceiveActivityInternal((TurnContextImpl) context, null); + try { + next.next(); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(String.format("MiddlewareSet::OnTurn next delegate: %s", e.toString())); + } + } + + + public void OnTurn(TurnContextImpl context, CompletableFuture next) + throws ExecutionException, InterruptedException { + return; + } + + /** + * 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 void ReceiveActivityWithStatus(TurnContext context, Consumer callback) + throws Exception { + ReceiveActivityInternal(context, callback); + } + + private void ReceiveActivityInternal(TurnContext context, Consumer callback) + throws Exception { + ReceiveActivityInternal(context, callback, 0); + } + + private void ReceiveActivityInternal(TurnContext context, Consumer callback, int nextMiddlewareIndex) + throws Exception { + // Check if we're at the end of the middleware list yet + if (nextMiddlewareIndex == _middleware.size()) { + // If all the Middlware ran, the "leading edge" of the tree is now complete. + // This means it's time to run any developer specified callback. + // Once this callback is done, the "trailing edge" calls are then completed. This + // allows code that looks like: + // Trace.TraceInformation("before"); + // await next(); + // Trace.TraceInformation("after"); + // to run as expected. + + // If a callback was provided invoke it now and return its task, otherwise just return the completed task + if (callback == null) { + return ; + } else { + callback.accept(context); + return; + } + } + + // Get the next piece of middleware + Middleware nextMiddleware = _middleware.get(nextMiddlewareIndex); + NextDelegate next = new NextDelegate() { + public void next() throws Exception { + ReceiveActivityInternal(context, callback, nextMiddlewareIndex + 1); + } + }; + + // Execute the next middleware passing a closure that will recurse back into this method at the next piece of middlware as the NextDelegate + nextMiddleware.OnTurn( + context, + next); + } + + +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/NextDelegate.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/NextDelegate.java similarity index 95% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/NextDelegate.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/NextDelegate.java index d665f4df..8ff4d0f2 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/NextDelegate.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/NextDelegate.java @@ -1,6 +1,6 @@ -package com.microsoft.bot.builder; - -@FunctionalInterface -public interface NextDelegate { - void next() throws Exception; -} +package com.microsoft.bot.builder; + +@FunctionalInterface +public interface NextDelegate { + void next() throws Exception; +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/PagedResult.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/PagedResult.java similarity index 95% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/PagedResult.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/PagedResult.java index 33f0418e..a5783ebd 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/PagedResult.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/PagedResult.java @@ -1,43 +1,43 @@ -package com.microsoft.bot.builder; - - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - Page of results from an enumeration. - - - */ -public class PagedResult -{ - /** - Page of items. - */ - -//C# TO JAVA CONVERTER WARNING: Java does not allow direct instantiation of arrays of generic type parameters: -//ORIGINAL LINE: private T[] Items = new T[0]; - private T[] items = (T[])new Object[0]; - public final T[] getItems() - { - return this.items; - } - public final void items(T[] value) - { - this.items = value; - } - - /** - Token used to page through multiple pages. - */ - private String continuationToken; - public final String continuationToken() - { - return this.continuationToken; - } - public final PagedResult withContinuationToken(String value) - { - this.continuationToken = value; - return this; - } -} +package com.microsoft.bot.builder; + + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + Page of results from an enumeration. + + + */ +public class PagedResult +{ + /** + Page of items. + */ + +//C# TO JAVA CONVERTER WARNING: Java does not allow direct instantiation of arrays of generic type parameters: +//ORIGINAL LINE: private T[] Items = new T[0]; + private T[] items = (T[])new Object[0]; + public final T[] getItems() + { + return this.items; + } + public final void items(T[] value) + { + this.items = value; + } + + /** + Token used to page through multiple pages. + */ + private String continuationToken; + public final String continuationToken() + { + return this.continuationToken; + } + public final PagedResult withContinuationToken(String value) + { + this.continuationToken = value; + return this; + } +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/SendActivitiesHandler.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/SendActivitiesHandler.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/SendActivitiesHandler.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/SendActivitiesHandler.java index b605b2f4..aff09c6f 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/SendActivitiesHandler.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/SendActivitiesHandler.java @@ -1,13 +1,13 @@ -package com.microsoft.bot.builder; - -import com.microsoft.bot.builder.TurnContext; -import com.microsoft.bot.schema.models.Activity; -import com.microsoft.bot.schema.models.ResourceResponse; - -import java.util.List; -import java.util.concurrent.Callable; - -@FunctionalInterface -public interface SendActivitiesHandler { - ResourceResponse[] handle(TurnContext context, List activities, Callable next) throws Exception; -} +package com.microsoft.bot.builder; + +import com.microsoft.bot.builder.TurnContext; +import com.microsoft.bot.schema.models.Activity; +import com.microsoft.bot.schema.models.ResourceResponse; + +import java.util.List; +import java.util.concurrent.Callable; + +@FunctionalInterface +public interface SendActivitiesHandler { + ResourceResponse[] handle(TurnContext context, List activities, Callable next) throws Exception; +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/StateSettings.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/StateSettings.java similarity index 96% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/StateSettings.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/StateSettings.java index 14a7e23f..30b5d06b 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/StateSettings.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/StateSettings.java @@ -1,16 +1,16 @@ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.microsoft.bot.builder; - -public class StateSettings -{ - private boolean lastWriterWins = true; - public boolean getLastWriterWins() { - return this.lastWriterWins; - } - public void setLast(boolean lastWriterWins) { - this.lastWriterWins = lastWriterWins; - } -} +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.microsoft.bot.builder; + +public class StateSettings +{ + private boolean lastWriterWins = true; + public boolean getLastWriterWins() { + return this.lastWriterWins; + } + public void setLast(boolean lastWriterWins) { + this.lastWriterWins = lastWriterWins; + } +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/StateTurnContextExtensions.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/StateTurnContextExtensions.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/StateTurnContextExtensions.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/StateTurnContextExtensions.java index 7d49fe56..45ff7aa2 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/StateTurnContextExtensions.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/StateTurnContextExtensions.java @@ -1,32 +1,32 @@ -package com.microsoft.bot.builder; - -import com.microsoft.bot.builder.ConversationState; -import com.microsoft.bot.builder.TurnContext; -import com.microsoft.bot.builder.UserState; - -/** - * Provides helper methods for getting state objects from the turn context. - */ -public class StateTurnContextExtensions -{ - /** - * 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 GetConversationState(TurnContext context) throws IllegalArgumentException { - - return ConversationState.Get(context); - } - - /** - * 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 GetUserState(TurnContext context) throws IllegalArgumentException { - return UserState.Get(context); - } -} +package com.microsoft.bot.builder; + +import com.microsoft.bot.builder.ConversationState; +import com.microsoft.bot.builder.TurnContext; +import com.microsoft.bot.builder.UserState; + +/** + * Provides helper methods for getting state objects from the turn context. + */ +public class StateTurnContextExtensions +{ + /** + * 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 GetConversationState(TurnContext context) throws IllegalArgumentException { + + return ConversationState.Get(context); + } + + /** + * 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 GetUserState(TurnContext context) throws IllegalArgumentException { + return UserState.Get(context); + } +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/Storage.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/Storage.java similarity index 96% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/Storage.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/Storage.java index c1b8df39..e825604a 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/Storage.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/Storage.java @@ -1,35 +1,35 @@ -package com.microsoft.bot.builder; - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - - -import com.fasterxml.jackson.core.JsonProcessingException; - -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -public interface Storage -{ - /** - * Read StoreItems from storage - * @param keys keys of the storeItems to read - * @return StoreItem dictionary - */ - CompletableFuture> Read(String... keys) throws JsonProcessingException; - - /** - * Write StoreItems to storage - * @param changes - */ - CompletableFuture Write(Map changes) throws Exception; - - /** - * Delete StoreItems from storage - * @param keys keys of the storeItems to delete - */ - CompletableFuture Delete(String... keys); -} - - - +package com.microsoft.bot.builder; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + + +import com.fasterxml.jackson.core.JsonProcessingException; + +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +public interface Storage +{ + /** + * Read StoreItems from storage + * @param keys keys of the storeItems to read + * @return StoreItem dictionary + */ + CompletableFuture> Read(String... keys) throws JsonProcessingException; + + /** + * Write StoreItems to storage + * @param changes + */ + CompletableFuture Write(Map changes) throws Exception; + + /** + * Delete StoreItems from storage + * @param keys keys of the storeItems to delete + */ + CompletableFuture Delete(String... keys); +} + + + diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/StorageExtensions.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/StorageExtensions.java similarity index 96% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/StorageExtensions.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/StorageExtensions.java index 1899bea9..015e151b 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/StorageExtensions.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/StorageExtensions.java @@ -1,37 +1,37 @@ -package com.microsoft.bot.builder; - -import com.fasterxml.jackson.core.JsonProcessingException; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - - -public class StorageExtensions { - - - /** - * Storage extension to Read as strong typed StoreItem objects - * - * @param StoreItemT - * @param storage - * @param keys - * @return - */ - @SuppressWarnings("unchecked") - public static CompletableFuture> Read(Storage storage, String... keys) throws JsonProcessingException { - Map storeItems = storage.Read(keys).join(); - HashMap result = new HashMap(); - for (Map.Entry entry : storeItems.entrySet()) { - StoreItemT tempVal; - try { - tempVal = (StoreItemT) entry.getValue(); - } catch (Exception ex) { - // Skip - not an instance of StoreItemT (ugly) - continue; - } - result.put((String) entry.getKey(), tempVal); - } - return CompletableFuture.completedFuture(result); - } -} +package com.microsoft.bot.builder; + +import com.fasterxml.jackson.core.JsonProcessingException; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + + +public class StorageExtensions { + + + /** + * Storage extension to Read as strong typed StoreItem objects + * + * @param StoreItemT + * @param storage + * @param keys + * @return + */ + @SuppressWarnings("unchecked") + public static CompletableFuture> Read(Storage storage, String... keys) throws JsonProcessingException { + Map storeItems = storage.Read(keys).join(); + HashMap result = new HashMap(); + for (Map.Entry entry : storeItems.entrySet()) { + StoreItemT tempVal; + try { + tempVal = (StoreItemT) entry.getValue(); + } catch (Exception ex) { + // Skip - not an instance of StoreItemT (ugly) + continue; + } + result.put((String) entry.getKey(), tempVal); + } + return CompletableFuture.completedFuture(result); + } +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/StoreItem.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/StoreItem.java similarity index 93% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/StoreItem.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/StoreItem.java index 14a4b24b..fb1a4a94 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/StoreItem.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/StoreItem.java @@ -1,11 +1,11 @@ -package com.microsoft.bot.builder; - -public interface StoreItem -{ - /** - * eTag for concurrency - */ - - String geteTag(); - void seteTag(String eTag); -} +package com.microsoft.bot.builder; + +public interface StoreItem +{ + /** + * eTag for concurrency + */ + + String geteTag(); + void seteTag(String eTag); +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TraceTranscriptLogger.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TraceTranscriptLogger.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TraceTranscriptLogger.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TraceTranscriptLogger.java index 5c884eed..a61cd54e 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TraceTranscriptLogger.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TraceTranscriptLogger.java @@ -1,58 +1,58 @@ -package com.microsoft.bot.builder; - - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.microsoft.bot.schema.models.Activity; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.ForkJoinWorkerThread; - -/** - * Represents a transcript logger that writes activites to a object. - */ -public class TraceTranscriptLogger implements TranscriptLogger { - // https://github.com/FasterXML/jackson-databind/wiki/Serialization-Features - private static ObjectMapper mapper = new ObjectMapper() - .enable(SerializationFeature.INDENT_OUTPUT); - private static final Logger logger = LogManager.getLogger("HelloWorld"); - - ForkJoinPool.ForkJoinWorkerThreadFactory factory = new ForkJoinPool.ForkJoinWorkerThreadFactory() - { - @Override - public ForkJoinWorkerThread newThread(ForkJoinPool pool) - { - final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); - worker.setName("BotTrace-" + worker.getPoolIndex()); - return worker; - } - }; - - ExecutorService executor = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), factory, null, true); - - /** - * Log an activity to the transcript. - * - * @param activity The activity to transcribe. - * @return A task that represents the work queued to execute. - */ - @Override - public void LogActivityAsync(Activity activity) { - BotAssert.ActivityNotNull(activity); - String event = null; - try { - event = mapper.writeValueAsString(activity); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - this.logger.info(event); - } -} +package com.microsoft.bot.builder; + + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.microsoft.bot.schema.models.Activity; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.ForkJoinWorkerThread; + +/** + * Represents a transcript logger that writes activites to a object. + */ +public class TraceTranscriptLogger implements TranscriptLogger { + // https://github.com/FasterXML/jackson-databind/wiki/Serialization-Features + private static ObjectMapper mapper = new ObjectMapper() + .enable(SerializationFeature.INDENT_OUTPUT); + private static final Logger logger = LogManager.getLogger("HelloWorld"); + + ForkJoinPool.ForkJoinWorkerThreadFactory factory = new ForkJoinPool.ForkJoinWorkerThreadFactory() + { + @Override + public ForkJoinWorkerThread newThread(ForkJoinPool pool) + { + final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); + worker.setName("BotTrace-" + worker.getPoolIndex()); + return worker; + } + }; + + ExecutorService executor = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), factory, null, true); + + /** + * Log an activity to the transcript. + * + * @param activity The activity to transcribe. + * @return A task that represents the work queued to execute. + */ + @Override + public void LogActivityAsync(Activity activity) { + BotAssert.ActivityNotNull(activity); + String event = null; + try { + event = mapper.writeValueAsString(activity); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + this.logger.info(event); + } +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/Transcript.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/Transcript.java similarity index 95% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/Transcript.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/Transcript.java index 0601a108..76068a66 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/Transcript.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/Transcript.java @@ -1,54 +1,54 @@ -package com.microsoft.bot.builder; - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - - -import java.time.OffsetDateTime; - -/** - * Transcript store item. - */ -public class Transcript { - /** - * channelId that the transcript was taken from. - */ - private String channelId; - - public String channelId() { - return this.channelId; - } - - public Transcript withChannelId(String value) { - this.channelId = value; - return this; - } - - /** - * Conversation id. - */ - private String id; - - public String getId() { - return this.id; - } - - public Transcript withId(String value) { - this.id = value; - return this; - } - - /** - * Date conversation was started. - */ - private OffsetDateTime created = OffsetDateTime.now(); - - public OffsetDateTime getCreated() { - return this.created; - } - - public Transcript withCreated(OffsetDateTime value) { - this.created = value; - return this; - } -} +package com.microsoft.bot.builder; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + + +import java.time.OffsetDateTime; + +/** + * Transcript store item. + */ +public class Transcript { + /** + * channelId that the transcript was taken from. + */ + private String channelId; + + public String channelId() { + return this.channelId; + } + + public Transcript withChannelId(String value) { + this.channelId = value; + return this; + } + + /** + * Conversation id. + */ + private String id; + + public String getId() { + return this.id; + } + + public Transcript withId(String value) { + this.id = value; + return this; + } + + /** + * Date conversation was started. + */ + private OffsetDateTime created = OffsetDateTime.now(); + + public OffsetDateTime getCreated() { + return this.created; + } + + public Transcript withCreated(OffsetDateTime value) { + this.created = value; + return this; + } +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TranscriptLogger.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TranscriptLogger.java similarity index 96% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TranscriptLogger.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TranscriptLogger.java index fe13afa4..4d4204af 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TranscriptLogger.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TranscriptLogger.java @@ -1,21 +1,21 @@ -package com.microsoft.bot.builder; - - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - - -import com.microsoft.bot.schema.models.Activity; - -/** - * Transcript logger stores activities for conversations for recall. - */ -public interface TranscriptLogger { - /** - * Log an activity to the transcript. - * - * @param activity The activity to transcribe. - * @return A task that represents the work queued to execute. - */ - void LogActivityAsync(Activity activity); -} +package com.microsoft.bot.builder; + + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + + +import com.microsoft.bot.schema.models.Activity; + +/** + * Transcript logger stores activities for conversations for recall. + */ +public interface TranscriptLogger { + /** + * Log an activity to the transcript. + * + * @param activity The activity to transcribe. + * @return A task that represents the work queued to execute. + */ + void LogActivityAsync(Activity activity); +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TranscriptLoggerMiddleware.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TranscriptLoggerMiddleware.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TranscriptLoggerMiddleware.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TranscriptLoggerMiddleware.java index 12895d29..57562e33 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TranscriptLoggerMiddleware.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TranscriptLoggerMiddleware.java @@ -1,191 +1,191 @@ -package com.microsoft.bot.builder; - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.microsoft.bot.schema.ActivityImpl; -import com.microsoft.bot.schema.models.Activity; -import com.microsoft.bot.schema.models.ActivityTypes; -import com.microsoft.bot.schema.models.ResourceResponse; -import org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; - -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; - - -/** - * When added, this middleware will log incoming and outgoing activitites to a ITranscriptStore. - */ -public class TranscriptLoggerMiddleware implements Middleware { - // https://github.com/FasterXML/jackson-databind/wiki/Serialization-Features - private static ObjectMapper mapper; - - static { - mapper = new ObjectMapper() - .enable(SerializationFeature.INDENT_OUTPUT); - mapper.findAndRegisterModules(); - } - - private TranscriptLogger logger; - private static final Logger log4j = LogManager.getLogger("BotFx"); - - private Queue transcript = new ConcurrentLinkedQueue(); - - /** - * Initializes a new instance of the class. - * - * @param transcriptLogger The transcript logger to use. - */ - public TranscriptLoggerMiddleware(TranscriptLogger transcriptLogger) { - if (transcriptLogger == null) - throw new NullPointerException("TranscriptLoggerMiddleware requires a ITranscriptLogger implementation. "); - - this.logger = transcriptLogger; - - } - - /** - * initialization for middleware turn. - * - * @param context - * @param next - * @return - */ - @Override - public void OnTurn(TurnContext context, NextDelegate next) throws Exception { - // log incoming activity at beginning of turn - if (context.getActivity() != null) { - JsonNode role = null; - if (context.getActivity().from() == null) { - throw new RuntimeException("Activity does not contain From field"); - } - if (context.getActivity().from().properties().containsKey("role")) { - role = context.getActivity().from().properties().get("role"); - } - - if (role == null || StringUtils.isBlank(role.asText())) { - context.getActivity().from().properties().put("role", mapper.createObjectNode().with("user")); - } - Activity activityTemp = ActivityImpl.CloneActity(context.getActivity()); - - LogActivity(ActivityImpl.CloneActity(context.getActivity())); - } - - // hook up onSend pipeline - context.OnSendActivities((ctx, activities, nextSend) -> - { - - // run full pipeline - ResourceResponse[] responses = new ResourceResponse[0]; - try { - if (nextSend != null) { - responses = nextSend.call(); - } - } catch (Exception e) { - e.printStackTrace(); - } - - for (Activity activity : activities) { - LogActivity(ActivityImpl.CloneActity(activity)); - } - - return responses; - - - }); - - // hook up update activity pipeline - context.OnUpdateActivity((ctx, activity, nextUpdate) -> - { - - // run full pipeline - ResourceResponse response = null; - try { - if (nextUpdate != null) { - response = nextUpdate.call(); - } - } catch (Exception e) { - e.printStackTrace(); - - - throw new RuntimeException(String.format("Error on Logging.OnUpdateActivity : %s", e.toString())); - } - - // add Message Update activity - Activity updateActivity = ActivityImpl.CloneActity(activity); - updateActivity.withType(ActivityTypes.MESSAGE_UPDATE); - LogActivity(updateActivity); - return response; - - - }); - - // hook up delete activity pipeline - context.OnDeleteActivity((ctxt, reference, nextDel) -> { - // run full pipeline - - try { - if (nextDel != null) { - log4j.error(String.format("Transcript logActivity next delegate: %s)", nextDel)); - nextDel.run(); - } - } catch (Exception e) { - e.printStackTrace(); - log4j.error(String.format("Transcript logActivity failed with %s (next delegate: %s)", e.toString(), nextDel)); - throw new RuntimeException(String.format("Transcript logActivity failed with %s", e.getMessage())); - - } - - // add MessageDelete activity - // log as MessageDelete activity - Activity deleteActivity = new Activity() - .withType(ActivityTypes.MESSAGE_DELETE) - .withId(reference.activityId()) - .applyConversationReference(reference, false); - - LogActivity(deleteActivity); - return; - - }); - - - // process bot logic - try { - next.next(); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Error on Logging.next : %s", e.toString())); - } - - // flush transcript at end of turn - while (!transcript.isEmpty()) { - Activity activity = transcript.poll(); - try { - this.logger.LogActivityAsync(activity); - } catch (RuntimeException err) { - log4j.error(String.format("Transcript poll failed : %1$s", err)); - } - } - - } - - - private void LogActivity(Activity activity) { - if (activity.timestamp() == null) { - activity.withTimestamp(DateTime.now(DateTimeZone.UTC)); - } - transcript.offer(activity); - } - -} - - - +package com.microsoft.bot.builder; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.microsoft.bot.schema.ActivityImpl; +import com.microsoft.bot.schema.models.Activity; +import com.microsoft.bot.schema.models.ActivityTypes; +import com.microsoft.bot.schema.models.ResourceResponse; +import org.apache.commons.lang3.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; + +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; + + +/** + * When added, this middleware will log incoming and outgoing activitites to a ITranscriptStore. + */ +public class TranscriptLoggerMiddleware implements Middleware { + // https://github.com/FasterXML/jackson-databind/wiki/Serialization-Features + private static ObjectMapper mapper; + + static { + mapper = new ObjectMapper() + .enable(SerializationFeature.INDENT_OUTPUT); + mapper.findAndRegisterModules(); + } + + private TranscriptLogger logger; + private static final Logger log4j = LogManager.getLogger("BotFx"); + + private Queue transcript = new ConcurrentLinkedQueue(); + + /** + * Initializes a new instance of the class. + * + * @param transcriptLogger The transcript logger to use. + */ + public TranscriptLoggerMiddleware(TranscriptLogger transcriptLogger) { + if (transcriptLogger == null) + throw new NullPointerException("TranscriptLoggerMiddleware requires a ITranscriptLogger implementation. "); + + this.logger = transcriptLogger; + + } + + /** + * initialization for middleware turn. + * + * @param context + * @param next + * @return + */ + @Override + public void OnTurn(TurnContext context, NextDelegate next) throws Exception { + // log incoming activity at beginning of turn + if (context.getActivity() != null) { + JsonNode role = null; + if (context.getActivity().from() == null) { + throw new RuntimeException("Activity does not contain From field"); + } + if (context.getActivity().from().properties().containsKey("role")) { + role = context.getActivity().from().properties().get("role"); + } + + if (role == null || StringUtils.isBlank(role.asText())) { + context.getActivity().from().properties().put("role", mapper.createObjectNode().with("user")); + } + Activity activityTemp = ActivityImpl.CloneActity(context.getActivity()); + + LogActivity(ActivityImpl.CloneActity(context.getActivity())); + } + + // hook up onSend pipeline + context.OnSendActivities((ctx, activities, nextSend) -> + { + + // run full pipeline + ResourceResponse[] responses = new ResourceResponse[0]; + try { + if (nextSend != null) { + responses = nextSend.call(); + } + } catch (Exception e) { + e.printStackTrace(); + } + + for (Activity activity : activities) { + LogActivity(ActivityImpl.CloneActity(activity)); + } + + return responses; + + + }); + + // hook up update activity pipeline + context.OnUpdateActivity((ctx, activity, nextUpdate) -> + { + + // run full pipeline + ResourceResponse response = null; + try { + if (nextUpdate != null) { + response = nextUpdate.call(); + } + } catch (Exception e) { + e.printStackTrace(); + + + throw new RuntimeException(String.format("Error on Logging.OnUpdateActivity : %s", e.toString())); + } + + // add Message Update activity + Activity updateActivity = ActivityImpl.CloneActity(activity); + updateActivity.withType(ActivityTypes.MESSAGE_UPDATE); + LogActivity(updateActivity); + return response; + + + }); + + // hook up delete activity pipeline + context.OnDeleteActivity((ctxt, reference, nextDel) -> { + // run full pipeline + + try { + if (nextDel != null) { + log4j.error(String.format("Transcript logActivity next delegate: %s)", nextDel)); + nextDel.run(); + } + } catch (Exception e) { + e.printStackTrace(); + log4j.error(String.format("Transcript logActivity failed with %s (next delegate: %s)", e.toString(), nextDel)); + throw new RuntimeException(String.format("Transcript logActivity failed with %s", e.getMessage())); + + } + + // add MessageDelete activity + // log as MessageDelete activity + Activity deleteActivity = new Activity() + .withType(ActivityTypes.MESSAGE_DELETE) + .withId(reference.activityId()) + .applyConversationReference(reference, false); + + LogActivity(deleteActivity); + return; + + }); + + + // process bot logic + try { + next.next(); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Error on Logging.next : %s", e.toString())); + } + + // flush transcript at end of turn + while (!transcript.isEmpty()) { + Activity activity = transcript.poll(); + try { + this.logger.LogActivityAsync(activity); + } catch (RuntimeException err) { + log4j.error(String.format("Transcript poll failed : %1$s", err)); + } + } + + } + + + private void LogActivity(Activity activity) { + if (activity.timestamp() == null) { + activity.withTimestamp(DateTime.now(DateTimeZone.UTC)); + } + transcript.offer(activity); + } + +} + + + diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TranscriptStore.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TranscriptStore.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TranscriptStore.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TranscriptStore.java index 0852735b..085a294f 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TranscriptStore.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TranscriptStore.java @@ -1,57 +1,57 @@ -package com.microsoft.bot.builder; - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - - -import com.microsoft.bot.schema.models.Activity; -import org.joda.time.DateTime; - -import java.util.concurrent.CompletableFuture; - -/** - * Transcript logger stores activities for conversations for recall. - */ -public interface TranscriptStore extends TranscriptLogger { - /** - * Gets from the store activities that match a set of criteria. - * - * @param channelId The ID of the channel the conversation is in. - * @param conversationId The ID of the conversation. - * @param continuationToken - * @param startDate A cutoff date. Activities older than this date are not included. - * @return A task that represents the work queued to execute. - * If the task completes successfully, the result contains the matching activities. - */ - - CompletableFuture> GetTranscriptActivitiesAsync(String channelId, String conversationId, String continuationToken); - - CompletableFuture> GetTranscriptActivitiesAsync(String channelId, String conversationId); - - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: -//ORIGINAL LINE: Task> GetTranscriptActivitiesAsync(string channelId, string conversationId, string continuationToken = null, DateTime startDate = default(DateTime)); - CompletableFuture> GetTranscriptActivitiesAsync(String channelId, String conversationId, String continuationToken, DateTime localStartDate); - - /** - * Gets the conversations on a channel from the store. - * - * @param channelId The ID of the channel. - * @param continuationToken - * @return A task that represents the work queued to execute. - */ - - CompletableFuture> ListTranscriptsAsync(String channelId); - - //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: -//ORIGINAL LINE: Task> ListTranscriptsAsync(string channelId, string continuationToken = null); - CompletableFuture> ListTranscriptsAsync(String channelId, String continuationToken); - - /** - * Deletes conversation data from the store. - * - * @param channelId The ID of the channel the conversation is in. - * @param conversationId The ID of the conversation to delete. - * @return A task that represents the work queued to execute. - */ - CompletableFuture DeleteTranscriptAsync(String channelId, String conversationId); -} +package com.microsoft.bot.builder; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + + +import com.microsoft.bot.schema.models.Activity; +import org.joda.time.DateTime; + +import java.util.concurrent.CompletableFuture; + +/** + * Transcript logger stores activities for conversations for recall. + */ +public interface TranscriptStore extends TranscriptLogger { + /** + * Gets from the store activities that match a set of criteria. + * + * @param channelId The ID of the channel the conversation is in. + * @param conversationId The ID of the conversation. + * @param continuationToken + * @param startDate A cutoff date. Activities older than this date are not included. + * @return A task that represents the work queued to execute. + * If the task completes successfully, the result contains the matching activities. + */ + + CompletableFuture> GetTranscriptActivitiesAsync(String channelId, String conversationId, String continuationToken); + + CompletableFuture> GetTranscriptActivitiesAsync(String channelId, String conversationId); + + //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: +//ORIGINAL LINE: Task> GetTranscriptActivitiesAsync(string channelId, string conversationId, string continuationToken = null, DateTime startDate = default(DateTime)); + CompletableFuture> GetTranscriptActivitiesAsync(String channelId, String conversationId, String continuationToken, DateTime localStartDate); + + /** + * Gets the conversations on a channel from the store. + * + * @param channelId The ID of the channel. + * @param continuationToken + * @return A task that represents the work queued to execute. + */ + + CompletableFuture> ListTranscriptsAsync(String channelId); + + //C# TO JAVA CONVERTER NOTE: Java does not support optional parameters. Overloaded method(s) are created above: +//ORIGINAL LINE: Task> ListTranscriptsAsync(string channelId, string continuationToken = null); + CompletableFuture> ListTranscriptsAsync(String channelId, String continuationToken); + + /** + * Deletes conversation data from the store. + * + * @param channelId The ID of the channel the conversation is in. + * @param conversationId The ID of the conversation to delete. + * @return A task that represents the work queued to execute. + */ + CompletableFuture DeleteTranscriptAsync(String channelId, String conversationId); +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TurnContext.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnContext.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TurnContext.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnContext.java index 957db6c8..edf6ced6 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TurnContext.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnContext.java @@ -1,182 +1,182 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.microsoft.bot.builder; - -/** - * 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 doesn’t 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.models.Activity; -import com.microsoft.bot.schema.models.ConversationReference; -import com.microsoft.bot.schema.models.ResourceResponse; - -import java.util.concurrent.CompletableFuture; - -//public delegate Task DeleteActivityHandler(TurnContext context, ConversationReference reference, Func next); - -/** - * 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 -{ - /** - * Gets the bot adapter that created this context object. - */ - BotAdapter getAdapter(); - - /** - * Gets the services registered on this context object. - */ - TurnContextServiceCollection getServices(); - - /** - * Incoming request - */ - Activity getActivity(); - - - - /** - * 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); - - /** - * 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. - *

See the channel's documentation for limits imposed upon the contents of - * {@code textReplyToSend}.

- *

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.

- * - */ - ResourceResponse SendActivity(String textReplyToSend) throws Exception; - ResourceResponse SendActivity(String textReplyToSend, String speak) throws Exception; - //CompletableFuture SendActivity(String textReplyToSend, String speak = null, String inputHint = InputHints.AcceptingInput); - ResourceResponse SendActivity(String textReplyToSend, String speak, String inputHint) throws Exception; - - /** - * 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. - */ - ResourceResponse SendActivity(Activity activity) throws Exception; - - /** - * 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. - */ - ResourceResponse[] SendActivities(Activity[] activities) throws Exception; - - /** - * 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. - *

Before calling this, set the ID of the replacement activity to the ID - * of the activity to replace.

- */ - ResourceResponse UpdateActivity(Activity activity) throws Exception; - - /** - * 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. - *

Before calling this, set the ID of the replacement activity to the ID - * of the activity to replace.

- */ - //CompletableFuture UpdateActivityAsync(Activity activity) throws Exception; - - /** - * 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; - - /** - * 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. - */ - void DeleteActivity(ConversationReference conversationReference) throws Exception; - - /** - * 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); - - /** - * 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); - - /** - * 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); -} +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.microsoft.bot.builder; + +/** + * 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 doesn’t 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.models.Activity; +import com.microsoft.bot.schema.models.ConversationReference; +import com.microsoft.bot.schema.models.ResourceResponse; + +import java.util.concurrent.CompletableFuture; + +//public delegate Task DeleteActivityHandler(TurnContext context, ConversationReference reference, Func next); + +/** + * 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 +{ + /** + * Gets the bot adapter that created this context object. + */ + BotAdapter getAdapter(); + + /** + * Gets the services registered on this context object. + */ + TurnContextServiceCollection getServices(); + + /** + * Incoming request + */ + Activity getActivity(); + + + + /** + * 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); + + /** + * 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. + *

See the channel's documentation for limits imposed upon the contents of + * {@code textReplyToSend}.

+ *

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.

+ * + */ + ResourceResponse SendActivity(String textReplyToSend) throws Exception; + ResourceResponse SendActivity(String textReplyToSend, String speak) throws Exception; + //CompletableFuture SendActivity(String textReplyToSend, String speak = null, String inputHint = InputHints.AcceptingInput); + ResourceResponse SendActivity(String textReplyToSend, String speak, String inputHint) throws Exception; + + /** + * 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. + */ + ResourceResponse SendActivity(Activity activity) throws Exception; + + /** + * 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. + */ + ResourceResponse[] SendActivities(Activity[] activities) throws Exception; + + /** + * 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. + *

Before calling this, set the ID of the replacement activity to the ID + * of the activity to replace.

+ */ + ResourceResponse UpdateActivity(Activity activity) throws Exception; + + /** + * 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. + *

Before calling this, set the ID of the replacement activity to the ID + * of the activity to replace.

+ */ + //CompletableFuture UpdateActivityAsync(Activity activity) throws Exception; + + /** + * 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; + + /** + * 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. + */ + void DeleteActivity(ConversationReference conversationReference) throws Exception; + + /** + * 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); + + /** + * 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); + + /** + * 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); +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TurnContextImpl.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnContextImpl.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TurnContextImpl.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnContextImpl.java index 58d4ed20..c955db95 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TurnContextImpl.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnContextImpl.java @@ -1,615 +1,615 @@ -package com.microsoft.bot.builder; - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import com.microsoft.bot.schema.ActivityImpl; -import com.microsoft.bot.schema.models.Activity; -import com.microsoft.bot.schema.models.ConversationReference; -import com.microsoft.bot.schema.models.InputHints; -import com.microsoft.bot.schema.models.ResourceResponse; -import org.apache.commons.lang3.StringUtils; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.*; - -import static com.microsoft.bot.schema.models.ActivityTypes.MESSAGE; -import static com.microsoft.bot.schema.models.ActivityTypes.TRACE; -import static java.util.stream.Collectors.toList; - -/** - * 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; - private Boolean responded = false; - - private final List onSendActivities = new ArrayList(); - private final List onUpdateActivity = new ArrayList(); - private final List onDeleteActivity = new ArrayList(); - - private final TurnContextServiceCollection turnServices; - ForkJoinPool.ForkJoinWorkerThreadFactory factory = new ForkJoinPool.ForkJoinWorkerThreadFactory() - { - @Override - public ForkJoinWorkerThread newThread(ForkJoinPool pool) - { - final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); - worker.setName("TestFlow-" + worker.getPoolIndex()); - return worker; - } - }; - - ExecutorService executor = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), factory, null, true); - - - - /** - * 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"); - this.adapter = adapter; - if (activity == null) - throw new IllegalArgumentException("activity"); - this.activity = activity; - - turnServices = new TurnContextServiceCollectionImpl(); - } - - - /** - * 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"); - - this.onSendActivities.add(handler); - return this; - } - - /** - * 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"); - - this.onUpdateActivity.add(handler); - return this; - } - - /** - * 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"); - - this.onDeleteActivity.add(handler); - return this; - } - - /** - * Gets the bot adapter that created this context object. - */ - public BotAdapter getAdapter() { - return this.adapter; - } - - /** - * Gets the services registered on this context object. - */ - public TurnContextServiceCollection getServices() { - return this.turnServices; - } - - /** - * Gets the activity associated with this turn; or {@code null} when processing - * a proactive message. - */ - @Override - public Activity getActivity() { - return this.activity; - } - - /** - * 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; - } - - public void setResponded(boolean responded) { - if (responded == false) { - throw new IllegalArgumentException("TurnContext: cannot set 'responded' to a value of 'false'."); - } - this.responded = true; - } - - /** - * 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. - *

See the channel's documentation for limits imposed upon the contents of - * {@code textReplyToSend}.

- *

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.

- */ - @Override - public ResourceResponse SendActivity(String textReplyToSend) throws Exception { - return SendActivity(textReplyToSend, null, null); - } - - @Override - public ResourceResponse SendActivity(String textReplyToSend, String speak) throws Exception { - return SendActivity(textReplyToSend, speak, null); - } - - @Override - public ResourceResponse SendActivity(String textReplyToSend, String speak, String inputHint) throws Exception { - if (StringUtils.isEmpty(textReplyToSend)) - throw new IllegalArgumentException("textReplyToSend"); - - ActivityImpl activityToSend = (ActivityImpl) new ActivityImpl() - .withType(MESSAGE) - .withText(textReplyToSend); - if (speak != null) - activityToSend.withSpeak(speak); - - if (StringUtils.isNotEmpty(inputHint)) - activityToSend.withInputHint(InputHints.fromString(inputHint)); - - return SendActivity(activityToSend); - } - - /** - * 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 ResourceResponse SendActivity(Activity activity) throws Exception { - if (activity == null) - throw new IllegalArgumentException("activity"); - - System.out.printf("In SENDEACTIVITYASYNC:"); - System.out.flush(); - Activity[] activities = {activity}; - ResourceResponse[] responses; - try { - responses = SendActivities(activities); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(String.format("TurnContext:SendActivity fail %s", e.toString())); - } - if (responses == null || responses.length == 0) { - // It's possible an interceptor prevented the activity from having been sent. - // Just return an empty response in that case. - return null; - } else { - return responses[0]; - } - - } - - /** - * 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 ResourceResponse[] SendActivities(Activity[] activities) throws Exception { - // Bind the relevant Conversation Reference properties, such as URLs and - // ChannelId's, to the activities we're about to send. - ConversationReference cr = GetConversationReference(this.activity); - for (Activity a : activities) { - ApplyConversationReference(a, cr); - } - - // Convert the IActivities to Activies. - // Activity[] activityArray = Array.ConvertAll(activities, (input) => (Activity)input); - List activityArray = Arrays.stream(activities).map(input -> (Activity) input).collect(toList()); - - - // Create the list used by the recursive methods. - List activityList = new ArrayList(activityArray); - - Callable ActuallySendStuff = () -> { - // Are the any non-trace activities to send? - // The thinking here is that a Trace event isn't user relevant data - // so the "Responded" flag should not be set by Trace messages being - // sent out. - boolean sentNonTraceActivities = false; - if (!activityList.stream().anyMatch((a) -> a.type() == TRACE)) { - sentNonTraceActivities = true; - } - // Send from the list, which may have been manipulated via the event handlers. - // Note that 'responses' was captured from the root of the call, and will be - // returned to the original caller. - ResourceResponse[] responses = new ResourceResponse[0]; - responses = this.getAdapter().SendActivities(this, activityList.toArray(new ActivityImpl[activityList.size()])); - if (responses != null && responses.length == activityList.size()) { - // stitch up activity ids - for (int i = 0; i < responses.length; i++) { - ResourceResponse response = responses[i]; - Activity activity = activityList.get(i); - activity.withId(response.id()); - } - } - - // If we actually sent something (that's not Trace), set the flag. - if (sentNonTraceActivities) { - this.setResponded(true); - } - return responses; - }; - - List act_list = new ArrayList<>(activityList); - return SendActivitiesInternal(act_list, onSendActivities.iterator(), ActuallySendStuff); - } - - /** - * 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. - *

Before calling this, set the ID of the replacement activity to the ID - * of the activity to replace.

- */ - @Override - public ResourceResponse UpdateActivity(Activity activity) throws Exception { - - - Callable ActuallyUpdateStuff = () -> { - return this.getAdapter().UpdateActivity(this, activity); - }; - - return UpdateActivityInternal(activity, onUpdateActivity.iterator(), ActuallyUpdateStuff); - } - - - - /** - * Deletes an existing activity. - * - * @param activityId The ID of the activity to delete. - * @return A task that represents the work queued to execute. - * @throws Exception 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"); - - return CompletableFuture.runAsync(() -> { - ConversationReference cr = this.GetConversationReference(this.getActivity()); - cr.withActivityId(activityId); - - Runnable ActuallyDeleteStuff = () -> { - try { - this.getAdapter().DeleteActivity(this, cr); - } catch (ExecutionException e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Failed to delete activity %s", e.toString())); - } catch (InterruptedException e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Failed to delete activity %s", e.toString())); - } - return; - }; - - try { - DeleteActivityInternal(cr, onDeleteActivity.iterator(), ActuallyDeleteStuff); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Failed to delete activity %s", e.getMessage())); - } - return; - - }, executor); - - } - - /** - * 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 void DeleteActivity(ConversationReference conversationReference) throws Exception { - if (conversationReference == null) - throw new IllegalArgumentException("conversationReference"); - - Runnable ActuallyDeleteStuff = () -> { - try { - this.getAdapter().DeleteActivity(this, conversationReference); - return; - } catch (ExecutionException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - throw new RuntimeException("DeleteActivity failed"); - }; - - DeleteActivityInternal(conversationReference, onDeleteActivity.iterator(), ActuallyDeleteStuff); - return ; - } - - private ResourceResponse[] SendActivitiesInternal(List activities, Iterator sendHandlers, Callable callAtBottom) throws Exception { - if (activities == null) - throw new IllegalArgumentException("activities"); - if (sendHandlers == null) - throw new IllegalArgumentException("sendHandlers"); - - if (false == sendHandlers.hasNext()) { // No middleware to run. - if (callAtBottom != null) - return callAtBottom.call(); - return new ResourceResponse[0]; - } - - // Default to "No more Middleware after this". - Callable 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. - //Iterable remaining = sendHandlers.Skip(1); - //Iterator remaining = sendHandlers.iterator(); - if (sendHandlers.hasNext()) - sendHandlers.next(); - return SendActivitiesInternal(activities, sendHandlers, callAtBottom); - }; - - // Grab the current middleware, which is the 1st element in the array, and execute it - SendActivitiesHandler caller = sendHandlers.next(); - return caller.handle(this, activities, next); - } - - // private async Task UpdateActivityInternal(Activity activity, - // IEnumerable updateHandlers, - // Func> callAtBottom) - // { - // BotAssert.ActivityNotNull(activity); - // if (updateHandlers == null) - // throw new ArgumentException(nameof(updateHandlers)); - // - // if (updateHandlers.Count() == 0) // No middleware to run. - // { - // if (callAtBottom != null) - // { - // return await callAtBottom(); - // } - // - // return null; - // } - // - // /** - // */ Default to "No more Middleware after this". - // */ - // async Task 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. - // */ - // IEnumerable 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 - // */ - // UpdateActivityHandler toCall = updateHandlers.First(); - // return await toCall(this, activity, next); - // } - private ResourceResponse UpdateActivityInternal(Activity activity, - Iterator updateHandlers, - Callable callAtBottom) throws Exception { - BotAssert.ActivityNotNull(activity); - if (updateHandlers == null) - throw new IllegalArgumentException("updateHandlers"); - - if (false == updateHandlers.hasNext()) { // No middleware to run. - if (callAtBottom != null) { - return callAtBottom.call(); - } - return null; - } - - // Default to "No more Middleware after this". - Callable 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. - if (updateHandlers.hasNext()) - updateHandlers.next(); - ResourceResponse result = null; - try { - result = UpdateActivityInternal(activity, updateHandlers, callAtBottom); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Error updating activity: %s", e.toString())); - } - activity.withId(result.id()); - return result; - }; - - // Grab the current middleware, which is the 1st element in the array, and execute it - UpdateActivityHandler toCall = updateHandlers.next(); - return toCall.handle(this, activity, next); - } - - - private void DeleteActivityInternal(ConversationReference cr, - Iterator deleteHandlers, - Runnable callAtBottom) throws Exception { - BotAssert.ConversationReferenceNotNull(cr); - if (deleteHandlers == null) - throw new IllegalArgumentException("deleteHandlers"); - - if (deleteHandlers.hasNext() == false) { // No middleware to run. - if (callAtBottom != null) { - callAtBottom.run(); - } - return; - } - - // Default to "No more Middleware after this". - Runnable 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. - - //Iterator remaining = (deleteHandlers.hasNext()) ? deleteHandlers.next() : null; - if (deleteHandlers.hasNext()) - deleteHandlers.next(); - - - try { - DeleteActivityInternal(cr, deleteHandlers, callAtBottom); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("DeleteActivityInternal failed"); - } - return; - }; - - // Grab the current middleware, which is the 1st element in the array, and execute it. - DeleteActivityHandler toCall = deleteHandlers.next(); - toCall.handle(this, cr, next); - } - - /** - * 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); - - ConversationReference r = new ConversationReference() - .withActivityId(activity.id()) - .withUser(activity.from()) - .withBot(activity.recipient()) - .withConversation(activity.conversation()) - .withChannelId(activity.channelId()) - .withServiceUrl(activity.serviceUrl()); - - return r; - } - - /** - * 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. - *

The {@link SendActivity(Activity)} and {@link SendActivities(Activity[])} - * methods do this for you.

- */ - public static Activity ApplyConversationReference(Activity activity, ConversationReference reference) { - return ApplyConversationReference(activity, reference, false); - } - - public static Activity ApplyConversationReference(Activity activity, ConversationReference reference, boolean isIncoming) { - activity.withChannelId(reference.channelId()); - activity.withServiceUrl(reference.serviceUrl()); - activity.withConversation(reference.conversation()); - - if (isIncoming) { - activity.withFrom(reference.user()); - activity.withRecipient(reference.bot()); - if (reference.activityId() != null) - activity.withId(reference.activityId()); - } else { // Outgoing - activity.withFrom(reference.bot()); - activity.withRecipient(reference.user()); - if (reference.activityId() != null) - activity.withReplyToId(reference.activityId()); - } - return activity; - } - - public void close() throws Exception { - turnServices.close(); - } -} +package com.microsoft.bot.builder; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import com.microsoft.bot.schema.ActivityImpl; +import com.microsoft.bot.schema.models.Activity; +import com.microsoft.bot.schema.models.ConversationReference; +import com.microsoft.bot.schema.models.InputHints; +import com.microsoft.bot.schema.models.ResourceResponse; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.*; + +import static com.microsoft.bot.schema.models.ActivityTypes.MESSAGE; +import static com.microsoft.bot.schema.models.ActivityTypes.TRACE; +import static java.util.stream.Collectors.toList; + +/** + * 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; + private Boolean responded = false; + + private final List onSendActivities = new ArrayList(); + private final List onUpdateActivity = new ArrayList(); + private final List onDeleteActivity = new ArrayList(); + + private final TurnContextServiceCollection turnServices; + ForkJoinPool.ForkJoinWorkerThreadFactory factory = new ForkJoinPool.ForkJoinWorkerThreadFactory() + { + @Override + public ForkJoinWorkerThread newThread(ForkJoinPool pool) + { + final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); + worker.setName("TestFlow-" + worker.getPoolIndex()); + return worker; + } + }; + + ExecutorService executor = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), factory, null, true); + + + + /** + * 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"); + this.adapter = adapter; + if (activity == null) + throw new IllegalArgumentException("activity"); + this.activity = activity; + + turnServices = new TurnContextServiceCollectionImpl(); + } + + + /** + * 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"); + + this.onSendActivities.add(handler); + return this; + } + + /** + * 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"); + + this.onUpdateActivity.add(handler); + return this; + } + + /** + * 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"); + + this.onDeleteActivity.add(handler); + return this; + } + + /** + * Gets the bot adapter that created this context object. + */ + public BotAdapter getAdapter() { + return this.adapter; + } + + /** + * Gets the services registered on this context object. + */ + public TurnContextServiceCollection getServices() { + return this.turnServices; + } + + /** + * Gets the activity associated with this turn; or {@code null} when processing + * a proactive message. + */ + @Override + public Activity getActivity() { + return this.activity; + } + + /** + * 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; + } + + public void setResponded(boolean responded) { + if (responded == false) { + throw new IllegalArgumentException("TurnContext: cannot set 'responded' to a value of 'false'."); + } + this.responded = true; + } + + /** + * 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. + *

See the channel's documentation for limits imposed upon the contents of + * {@code textReplyToSend}.

+ *

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.

+ */ + @Override + public ResourceResponse SendActivity(String textReplyToSend) throws Exception { + return SendActivity(textReplyToSend, null, null); + } + + @Override + public ResourceResponse SendActivity(String textReplyToSend, String speak) throws Exception { + return SendActivity(textReplyToSend, speak, null); + } + + @Override + public ResourceResponse SendActivity(String textReplyToSend, String speak, String inputHint) throws Exception { + if (StringUtils.isEmpty(textReplyToSend)) + throw new IllegalArgumentException("textReplyToSend"); + + ActivityImpl activityToSend = (ActivityImpl) new ActivityImpl() + .withType(MESSAGE) + .withText(textReplyToSend); + if (speak != null) + activityToSend.withSpeak(speak); + + if (StringUtils.isNotEmpty(inputHint)) + activityToSend.withInputHint(InputHints.fromString(inputHint)); + + return SendActivity(activityToSend); + } + + /** + * 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 ResourceResponse SendActivity(Activity activity) throws Exception { + if (activity == null) + throw new IllegalArgumentException("activity"); + + System.out.printf("In SENDEACTIVITYASYNC:"); + System.out.flush(); + Activity[] activities = {activity}; + ResourceResponse[] responses; + try { + responses = SendActivities(activities); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(String.format("TurnContext:SendActivity fail %s", e.toString())); + } + if (responses == null || responses.length == 0) { + // It's possible an interceptor prevented the activity from having been sent. + // Just return an empty response in that case. + return null; + } else { + return responses[0]; + } + + } + + /** + * 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 ResourceResponse[] SendActivities(Activity[] activities) throws Exception { + // Bind the relevant Conversation Reference properties, such as URLs and + // ChannelId's, to the activities we're about to send. + ConversationReference cr = GetConversationReference(this.activity); + for (Activity a : activities) { + ApplyConversationReference(a, cr); + } + + // Convert the IActivities to Activies. + // Activity[] activityArray = Array.ConvertAll(activities, (input) => (Activity)input); + List activityArray = Arrays.stream(activities).map(input -> (Activity) input).collect(toList()); + + + // Create the list used by the recursive methods. + List activityList = new ArrayList(activityArray); + + Callable ActuallySendStuff = () -> { + // Are the any non-trace activities to send? + // The thinking here is that a Trace event isn't user relevant data + // so the "Responded" flag should not be set by Trace messages being + // sent out. + boolean sentNonTraceActivities = false; + if (!activityList.stream().anyMatch((a) -> a.type() == TRACE)) { + sentNonTraceActivities = true; + } + // Send from the list, which may have been manipulated via the event handlers. + // Note that 'responses' was captured from the root of the call, and will be + // returned to the original caller. + ResourceResponse[] responses = new ResourceResponse[0]; + responses = this.getAdapter().SendActivities(this, activityList.toArray(new ActivityImpl[activityList.size()])); + if (responses != null && responses.length == activityList.size()) { + // stitch up activity ids + for (int i = 0; i < responses.length; i++) { + ResourceResponse response = responses[i]; + Activity activity = activityList.get(i); + activity.withId(response.id()); + } + } + + // If we actually sent something (that's not Trace), set the flag. + if (sentNonTraceActivities) { + this.setResponded(true); + } + return responses; + }; + + List act_list = new ArrayList<>(activityList); + return SendActivitiesInternal(act_list, onSendActivities.iterator(), ActuallySendStuff); + } + + /** + * 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. + *

Before calling this, set the ID of the replacement activity to the ID + * of the activity to replace.

+ */ + @Override + public ResourceResponse UpdateActivity(Activity activity) throws Exception { + + + Callable ActuallyUpdateStuff = () -> { + return this.getAdapter().UpdateActivity(this, activity); + }; + + return UpdateActivityInternal(activity, onUpdateActivity.iterator(), ActuallyUpdateStuff); + } + + + + /** + * Deletes an existing activity. + * + * @param activityId The ID of the activity to delete. + * @return A task that represents the work queued to execute. + * @throws Exception 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"); + + return CompletableFuture.runAsync(() -> { + ConversationReference cr = this.GetConversationReference(this.getActivity()); + cr.withActivityId(activityId); + + Runnable ActuallyDeleteStuff = () -> { + try { + this.getAdapter().DeleteActivity(this, cr); + } catch (ExecutionException e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Failed to delete activity %s", e.toString())); + } catch (InterruptedException e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Failed to delete activity %s", e.toString())); + } + return; + }; + + try { + DeleteActivityInternal(cr, onDeleteActivity.iterator(), ActuallyDeleteStuff); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Failed to delete activity %s", e.getMessage())); + } + return; + + }, executor); + + } + + /** + * 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 void DeleteActivity(ConversationReference conversationReference) throws Exception { + if (conversationReference == null) + throw new IllegalArgumentException("conversationReference"); + + Runnable ActuallyDeleteStuff = () -> { + try { + this.getAdapter().DeleteActivity(this, conversationReference); + return; + } catch (ExecutionException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + throw new RuntimeException("DeleteActivity failed"); + }; + + DeleteActivityInternal(conversationReference, onDeleteActivity.iterator(), ActuallyDeleteStuff); + return ; + } + + private ResourceResponse[] SendActivitiesInternal(List activities, Iterator sendHandlers, Callable callAtBottom) throws Exception { + if (activities == null) + throw new IllegalArgumentException("activities"); + if (sendHandlers == null) + throw new IllegalArgumentException("sendHandlers"); + + if (false == sendHandlers.hasNext()) { // No middleware to run. + if (callAtBottom != null) + return callAtBottom.call(); + return new ResourceResponse[0]; + } + + // Default to "No more Middleware after this". + Callable 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. + //Iterable remaining = sendHandlers.Skip(1); + //Iterator remaining = sendHandlers.iterator(); + if (sendHandlers.hasNext()) + sendHandlers.next(); + return SendActivitiesInternal(activities, sendHandlers, callAtBottom); + }; + + // Grab the current middleware, which is the 1st element in the array, and execute it + SendActivitiesHandler caller = sendHandlers.next(); + return caller.handle(this, activities, next); + } + + // private async Task UpdateActivityInternal(Activity activity, + // IEnumerable updateHandlers, + // Func> callAtBottom) + // { + // BotAssert.ActivityNotNull(activity); + // if (updateHandlers == null) + // throw new ArgumentException(nameof(updateHandlers)); + // + // if (updateHandlers.Count() == 0) // No middleware to run. + // { + // if (callAtBottom != null) + // { + // return await callAtBottom(); + // } + // + // return null; + // } + // + // /** + // */ Default to "No more Middleware after this". + // */ + // async Task 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. + // */ + // IEnumerable 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 + // */ + // UpdateActivityHandler toCall = updateHandlers.First(); + // return await toCall(this, activity, next); + // } + private ResourceResponse UpdateActivityInternal(Activity activity, + Iterator updateHandlers, + Callable callAtBottom) throws Exception { + BotAssert.ActivityNotNull(activity); + if (updateHandlers == null) + throw new IllegalArgumentException("updateHandlers"); + + if (false == updateHandlers.hasNext()) { // No middleware to run. + if (callAtBottom != null) { + return callAtBottom.call(); + } + return null; + } + + // Default to "No more Middleware after this". + Callable 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. + if (updateHandlers.hasNext()) + updateHandlers.next(); + ResourceResponse result = null; + try { + result = UpdateActivityInternal(activity, updateHandlers, callAtBottom); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Error updating activity: %s", e.toString())); + } + activity.withId(result.id()); + return result; + }; + + // Grab the current middleware, which is the 1st element in the array, and execute it + UpdateActivityHandler toCall = updateHandlers.next(); + return toCall.handle(this, activity, next); + } + + + private void DeleteActivityInternal(ConversationReference cr, + Iterator deleteHandlers, + Runnable callAtBottom) throws Exception { + BotAssert.ConversationReferenceNotNull(cr); + if (deleteHandlers == null) + throw new IllegalArgumentException("deleteHandlers"); + + if (deleteHandlers.hasNext() == false) { // No middleware to run. + if (callAtBottom != null) { + callAtBottom.run(); + } + return; + } + + // Default to "No more Middleware after this". + Runnable 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. + + //Iterator remaining = (deleteHandlers.hasNext()) ? deleteHandlers.next() : null; + if (deleteHandlers.hasNext()) + deleteHandlers.next(); + + + try { + DeleteActivityInternal(cr, deleteHandlers, callAtBottom); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("DeleteActivityInternal failed"); + } + return; + }; + + // Grab the current middleware, which is the 1st element in the array, and execute it. + DeleteActivityHandler toCall = deleteHandlers.next(); + toCall.handle(this, cr, next); + } + + /** + * 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); + + ConversationReference r = new ConversationReference() + .withActivityId(activity.id()) + .withUser(activity.from()) + .withBot(activity.recipient()) + .withConversation(activity.conversation()) + .withChannelId(activity.channelId()) + .withServiceUrl(activity.serviceUrl()); + + return r; + } + + /** + * 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. + *

The {@link SendActivity(Activity)} and {@link SendActivities(Activity[])} + * methods do this for you.

+ */ + public static Activity ApplyConversationReference(Activity activity, ConversationReference reference) { + return ApplyConversationReference(activity, reference, false); + } + + public static Activity ApplyConversationReference(Activity activity, ConversationReference reference, boolean isIncoming) { + activity.withChannelId(reference.channelId()); + activity.withServiceUrl(reference.serviceUrl()); + activity.withConversation(reference.conversation()); + + if (isIncoming) { + activity.withFrom(reference.user()); + activity.withRecipient(reference.bot()); + if (reference.activityId() != null) + activity.withId(reference.activityId()); + } else { // Outgoing + activity.withFrom(reference.bot()); + activity.withRecipient(reference.user()); + if (reference.activityId() != null) + activity.withReplyToId(reference.activityId()); + } + return activity; + } + + public void close() throws Exception { + turnServices.close(); + } +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TurnContextServiceCollection.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnContextServiceCollection.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TurnContextServiceCollection.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnContextServiceCollection.java index 6c75869a..b2ec6dec 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TurnContextServiceCollection.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnContextServiceCollection.java @@ -1,32 +1,32 @@ -package com.microsoft.bot.builder; - -import java.util.Map; - -/** - * 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>, AutoCloseable { - /** - * 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} - */ - void Add(String key, TService service) throws IllegalArgumentException; - - /** - * 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 Get(String key) throws IllegalArgumentException; - -} - - - +package com.microsoft.bot.builder; + +import java.util.Map; + +/** + * 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>, AutoCloseable { + /** + * 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} + */ + void Add(String key, TService service) throws IllegalArgumentException; + + /** + * 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 Get(String key) throws IllegalArgumentException; + +} + + + diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TurnContextServiceCollectionImpl.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnContextServiceCollectionImpl.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TurnContextServiceCollectionImpl.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnContextServiceCollectionImpl.java index acd1afa9..c20ef1cb 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TurnContextServiceCollectionImpl.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnContextServiceCollectionImpl.java @@ -1,67 +1,67 @@ -package com.microsoft.bot.builder; - - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -public final class TurnContextServiceCollectionImpl implements TurnContextServiceCollection, AutoCloseable -{ - private final HashMap _services = new HashMap(); - - public TurnContextServiceCollectionImpl() throws IllegalArgumentException { - } - - - - public TService Get(String key) throws IllegalArgumentException { - if (key == null) - throw new IllegalArgumentException("key"); - - TService service = (TService) _services.get(key); - // TODO: log that we didn't find the requested service - return (TService) service; - } - /** - * 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 Get(Class type) throws IllegalArgumentException { - return this.Get(type.getName()); - } - - @Override - public void Add(String key, TService service) throws IllegalArgumentException { - if (key == null) throw new IllegalArgumentException("key"); - if (service == null) throw new IllegalArgumentException("service"); - - if (_services.containsKey(key)) - throw new IllegalArgumentException (String.format("Key %s already exists", key)); - _services.put(key, service); - } - /** - * 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 void Add(TService service, Class type) throws IllegalArgumentException { - Add(type.getName(), service); - } - - - public Iterator> iterator() { - return _services.entrySet().iterator(); - } - - @Override - public void close() throws Exception { - for (Map.Entry entry : this._services.entrySet()) { - if (entry.getValue() instanceof AutoCloseable) { - ((AutoCloseable) entry.getValue()).close(); - } - } - } -} - +package com.microsoft.bot.builder; + + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public final class TurnContextServiceCollectionImpl implements TurnContextServiceCollection, AutoCloseable +{ + private final HashMap _services = new HashMap(); + + public TurnContextServiceCollectionImpl() throws IllegalArgumentException { + } + + + + public TService Get(String key) throws IllegalArgumentException { + if (key == null) + throw new IllegalArgumentException("key"); + + TService service = (TService) _services.get(key); + // TODO: log that we didn't find the requested service + return (TService) service; + } + /** + * 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 Get(Class type) throws IllegalArgumentException { + return this.Get(type.getName()); + } + + @Override + public void Add(String key, TService service) throws IllegalArgumentException { + if (key == null) throw new IllegalArgumentException("key"); + if (service == null) throw new IllegalArgumentException("service"); + + if (_services.containsKey(key)) + throw new IllegalArgumentException (String.format("Key %s already exists", key)); + _services.put(key, service); + } + /** + * 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 void Add(TService service, Class type) throws IllegalArgumentException { + Add(type.getName(), service); + } + + + public Iterator> iterator() { + return _services.entrySet().iterator(); + } + + @Override + public void close() throws Exception { + for (Map.Entry entry : this._services.entrySet()) { + if (entry.getValue() instanceof AutoCloseable) { + ((AutoCloseable) entry.getValue()).close(); + } + } + } +} + diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TurnTask.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnTask.java similarity index 95% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TurnTask.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnTask.java index 926ffe3a..0d5c79b8 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/TurnTask.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/TurnTask.java @@ -1,8 +1,8 @@ -package com.microsoft.bot.builder; - -import java.util.concurrent.CompletableFuture; - -@FunctionalInterface -public interface TurnTask { - CompletableFuture invoke(TurnContext context); -} +package com.microsoft.bot.builder; + +import java.util.concurrent.CompletableFuture; + +@FunctionalInterface +public interface TurnTask { + CompletableFuture invoke(TurnContext context); +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/UpdateActivityHandler.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/UpdateActivityHandler.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/UpdateActivityHandler.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/UpdateActivityHandler.java index c8291dd3..fc62d63d 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/UpdateActivityHandler.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/UpdateActivityHandler.java @@ -1,30 +1,30 @@ -package com.microsoft.bot.builder; - -import com.microsoft.bot.builder.TurnContext; -import com.microsoft.bot.schema.models.Activity; -import com.microsoft.bot.schema.models.ResourceResponse; - -import java.util.concurrent.Callable; - -/** - * 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 doesn’t call the next delegate, - * the adapter does not call any of the subsequent handlers and does not update the - * activity. - *

The activity's {@link Activity.Id} indicates the activity in the - * conversation to replace.

- * - * {@linkalso BotAdapter} - * {@linkalso SendActivitiesHandler} - * {@linkalso DeleteActivityHandler} - */ - -@FunctionalInterface -public interface UpdateActivityHandler { - ResourceResponse handle(TurnContext context, Activity activity, Callable next); -} +package com.microsoft.bot.builder; + +import com.microsoft.bot.builder.TurnContext; +import com.microsoft.bot.schema.models.Activity; +import com.microsoft.bot.schema.models.ResourceResponse; + +import java.util.concurrent.Callable; + +/** + * 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 doesn’t call the next delegate, + * the adapter does not call any of the subsequent handlers and does not update the + * activity. + *

The activity's {@link Activity.Id} indicates the activity in the + * conversation to replace.

+ * + * {@linkalso BotAdapter} + * {@linkalso SendActivitiesHandler} + * {@linkalso DeleteActivityHandler} + */ + +@FunctionalInterface +public interface UpdateActivityHandler { + ResourceResponse handle(TurnContext context, Activity activity, Callable next); +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/UserState.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/UserState.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/UserState.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/UserState.java index 659128aa..1b37447a 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/UserState.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/UserState.java @@ -1,50 +1,50 @@ -package com.microsoft.bot.builder; - -import com.microsoft.bot.builder.StateSettings; -import com.microsoft.bot.builder.Storage; -import com.microsoft.bot.builder.TurnContext; - - -import java.util.function.Supplier; - -/** - * 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 extends BotState -{ - /** - * 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).Namespace}.{typeof(UserState).Name}" - public static String PropertyName() { - return String.format("UserState:Microsoft.Bot.Builder.Core.Extensions.UserState`1"); - } - - /** - * 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 ctor) { - this(storage, ctor, null); - } - public UserState(Storage storage, Supplier ctor, StateSettings settings) { - super(storage, PropertyName(), - (context) -> { - return String.format("user/%s/%s", context.getActivity().channelId(), context.getActivity().conversation().id()); - }, - ctor, - settings); - } - - /** - * Gets the user state object from turn context. - * @param context The context object for this turn. - * @return The user state object. - */ - public static TState Get(TurnContext context) throws IllegalArgumentException { - return context.getServices().Get(PropertyName()); - } -} +package com.microsoft.bot.builder; + +import com.microsoft.bot.builder.StateSettings; +import com.microsoft.bot.builder.Storage; +import com.microsoft.bot.builder.TurnContext; + + +import java.util.function.Supplier; + +/** + * 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 extends BotState +{ + /** + * 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).Namespace}.{typeof(UserState).Name}" + public static String PropertyName() { + return String.format("UserState:Microsoft.Bot.Builder.Core.Extensions.UserState`1"); + } + + /** + * 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 ctor) { + this(storage, ctor, null); + } + public UserState(Storage storage, Supplier ctor, StateSettings settings) { + super(storage, PropertyName(), + (context) -> { + return String.format("user/%s/%s", context.getActivity().channelId(), context.getActivity().conversation().id()); + }, + ctor, + settings); + } + + /** + * Gets the user state object from turn context. + * @param context The context object for this turn. + * @return The user state object. + */ + public static TState Get(TurnContext context) throws IllegalArgumentException { + return context.getServices().Get(PropertyName()); + } +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/adapters/TestAdapter.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/adapters/TestAdapter.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/adapters/TestAdapter.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/adapters/TestAdapter.java index d6516a53..7b2ea993 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/adapters/TestAdapter.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/adapters/TestAdapter.java @@ -1,234 +1,234 @@ -package com.microsoft.bot.builder.adapters; - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import com.microsoft.bot.builder.BotAdapter; -import com.microsoft.bot.builder.Middleware; -import com.microsoft.bot.builder.TurnContext; -import com.microsoft.bot.builder.TurnContextImpl; -import com.microsoft.bot.schema.ActivityImpl; -import com.microsoft.bot.schema.models.*; -import org.apache.commons.lang3.StringUtils; -import org.joda.time.DateTime; - -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.function.Consumer; -import java.util.function.Function; - -public class TestAdapter extends BotAdapter { - private int nextId = 0; - private final Queue botReplies = new LinkedList<>(); - private ConversationReference conversationReference; - - public TestAdapter() { - this(null); - } - - - public TestAdapter(ConversationReference reference) { - if (reference != null) { - this.withConversationReference(reference); - } else { - this.withConversationReference(new ConversationReference() - .withChannelId("test") - .withServiceUrl("https://test.com")); - - this.conversationReference().withUser(new ChannelAccount() - .withId("user1") - .withName("User1")); - this.conversationReference().withBot(new ChannelAccount() - .withId("bot") - .withName("Bot")); - this.conversationReference().withConversation(new ConversationAccount() - .withIsGroup(Boolean.FALSE) - .withConversationType("convo1") - .withId("Conversation1")); - } - } - - public Queue activeQueue() { - return botReplies; - } - - public TestAdapter Use(Middleware middleware) { - super.Use(middleware); - return this; - } - - public void ProcessActivity(ActivityImpl activity, - Consumer callback - ) throws Exception { - synchronized (this.conversationReference()) { - // ready for next reply - if (activity.type() == null) - activity.withType(ActivityTypes.MESSAGE); - activity.withChannelId(this.conversationReference().channelId()); - activity.withFrom(this.conversationReference().user()); - activity.withRecipient(this.conversationReference().bot()); - activity.withConversation(this.conversationReference().conversation()); - activity.withServiceUrl(this.conversationReference().serviceUrl()); - Integer next = this.nextId++; - activity.withId(next.toString()); - } - // Assume Default DateTime : DateTime(0) - if (activity.timestamp() == null || activity.timestamp() == new DateTime(0)) - activity.withTimestamp(DateTime.now()); - - try (TurnContextImpl context = new TurnContextImpl(this, activity)) { - super.RunPipeline(context, callback); - } - return; - } - - public ConversationReference conversationReference() { - return conversationReference; - } - - public void withConversationReference(ConversationReference conversationReference) { - this.conversationReference = conversationReference; - } - - @Override - public ResourceResponse[] SendActivities(TurnContext context, Activity[] activities) throws InterruptedException { - List responses = new LinkedList(); - - for (Activity activity : activities) { - if (StringUtils.isEmpty(activity.id())) - activity.withId(UUID.randomUUID().toString()); - - if (activity.timestamp() == null) - activity.withTimestamp(DateTime.now()); - - responses.add(new ResourceResponse().withId(activity.id())); - // This is simulating DELAY - - System.out.println(String.format("TestAdapter:SendActivities(tid:%s):Count:%s", Thread.currentThread().getId(), activities.length)); - for (Activity act : activities) { - System.out.printf(":--------\n: To:%s\n", act.recipient().name()); - System.out.printf(": From:%s\n", (act.from() == null) ? "No from set" : act.from().name()); - System.out.printf(": Text:%s\n:---------", (act.text() == null) ? "No text set" : act.text()); - } - if (activity.type().toString().equals("delay")) { - // The BotFrameworkAdapter and Console adapter implement this - // hack directly in the POST method. Replicating that here - // to keep the behavior as close as possible to facillitate - // more realistic tests. - int delayMs = (int) activity.value(); - Thread.sleep(delayMs); - } else { - synchronized (this.botReplies) { - this.botReplies.add(activity); - } - } - } - return responses.toArray(new ResourceResponse[responses.size()]); - } - - - @Override - public ResourceResponse UpdateActivity(TurnContext context, Activity activity) { - synchronized (this.botReplies) { - List replies = new ArrayList<>(botReplies); - for (int i = 0; i < this.botReplies.size(); i++) { - if (replies.get(i).id().equals(activity.id())) { - replies.set(i, activity); - this.botReplies.clear(); - - for (Activity item : replies) { - this.botReplies.add(item); - } - return new ResourceResponse().withId(activity.id()); - } - } - } - return new ResourceResponse(); - } - - @Override - public void DeleteActivity(TurnContext context, ConversationReference reference) { - synchronized (this.botReplies) { - ArrayList replies = new ArrayList<>(this.botReplies); - for (int i = 0; i < this.botReplies.size(); i++) { - if (replies.get(i).id().equals(reference.activityId())) { - replies.remove(i); - this.botReplies.clear(); - for (Activity item : replies) { - this.botReplies.add(item); - } - break; - } - } - } - return; - } - - /** - * 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 callback) { - this.activeQueue().clear(); - MessageActivity update = MessageActivity.CreateConversationUpdateActivity(); - - update.withConversation(new ConversationAccount().withId(UUID.randomUUID().toString())); - TurnContextImpl context = new TurnContextImpl(this, (ActivityImpl) update); - return callback.apply(context); - } - - /** - * Called by TestFlow to check next reply - * - * @return - */ - public Activity GetNextReply() { - synchronized (this.botReplies) { - if (this.botReplies.size() > 0) { - return this.botReplies.remove(); - } - } - return null; - } - - /** - * Called by TestFlow to get appropriate activity for conversationReference of testbot - * - * @param text - * @return - */ - public Activity MakeActivity() { - return MakeActivity(null); - } - - public ActivityImpl MakeActivity(String text) { - Integer next = nextId++; - ActivityImpl activity = (ActivityImpl) new ActivityImpl() - .withType(ActivityTypes.MESSAGE) - .withFrom(conversationReference().user()) - .withRecipient(conversationReference().bot()) - .withConversation(conversationReference().conversation()) - .withServiceUrl(conversationReference().serviceUrl()) - .withId(next.toString()) - .withText(text); - - return activity; - } - - - /** - * Called by TestFlow to send text to the bot - * - * @param userSays - * @return - */ - public void SendTextToBot(String userSays, Consumer callback) throws Exception { - this.ProcessActivity(this.MakeActivity(userSays), callback); - } -} - - +package com.microsoft.bot.builder.adapters; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +import com.microsoft.bot.builder.BotAdapter; +import com.microsoft.bot.builder.Middleware; +import com.microsoft.bot.builder.TurnContext; +import com.microsoft.bot.builder.TurnContextImpl; +import com.microsoft.bot.schema.ActivityImpl; +import com.microsoft.bot.schema.models.*; +import org.apache.commons.lang3.StringUtils; +import org.joda.time.DateTime; + +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.function.Consumer; +import java.util.function.Function; + +public class TestAdapter extends BotAdapter { + private int nextId = 0; + private final Queue botReplies = new LinkedList<>(); + private ConversationReference conversationReference; + + public TestAdapter() { + this(null); + } + + + public TestAdapter(ConversationReference reference) { + if (reference != null) { + this.withConversationReference(reference); + } else { + this.withConversationReference(new ConversationReference() + .withChannelId("test") + .withServiceUrl("https://test.com")); + + this.conversationReference().withUser(new ChannelAccount() + .withId("user1") + .withName("User1")); + this.conversationReference().withBot(new ChannelAccount() + .withId("bot") + .withName("Bot")); + this.conversationReference().withConversation(new ConversationAccount() + .withIsGroup(Boolean.FALSE) + .withConversationType("convo1") + .withId("Conversation1")); + } + } + + public Queue activeQueue() { + return botReplies; + } + + public TestAdapter Use(Middleware middleware) { + super.Use(middleware); + return this; + } + + public void ProcessActivity(ActivityImpl activity, + Consumer callback + ) throws Exception { + synchronized (this.conversationReference()) { + // ready for next reply + if (activity.type() == null) + activity.withType(ActivityTypes.MESSAGE); + activity.withChannelId(this.conversationReference().channelId()); + activity.withFrom(this.conversationReference().user()); + activity.withRecipient(this.conversationReference().bot()); + activity.withConversation(this.conversationReference().conversation()); + activity.withServiceUrl(this.conversationReference().serviceUrl()); + Integer next = this.nextId++; + activity.withId(next.toString()); + } + // Assume Default DateTime : DateTime(0) + if (activity.timestamp() == null || activity.timestamp() == new DateTime(0)) + activity.withTimestamp(DateTime.now()); + + try (TurnContextImpl context = new TurnContextImpl(this, activity)) { + super.RunPipeline(context, callback); + } + return; + } + + public ConversationReference conversationReference() { + return conversationReference; + } + + public void withConversationReference(ConversationReference conversationReference) { + this.conversationReference = conversationReference; + } + + @Override + public ResourceResponse[] SendActivities(TurnContext context, Activity[] activities) throws InterruptedException { + List responses = new LinkedList(); + + for (Activity activity : activities) { + if (StringUtils.isEmpty(activity.id())) + activity.withId(UUID.randomUUID().toString()); + + if (activity.timestamp() == null) + activity.withTimestamp(DateTime.now()); + + responses.add(new ResourceResponse().withId(activity.id())); + // This is simulating DELAY + + System.out.println(String.format("TestAdapter:SendActivities(tid:%s):Count:%s", Thread.currentThread().getId(), activities.length)); + for (Activity act : activities) { + System.out.printf(":--------\n: To:%s\n", act.recipient().name()); + System.out.printf(": From:%s\n", (act.from() == null) ? "No from set" : act.from().name()); + System.out.printf(": Text:%s\n:---------", (act.text() == null) ? "No text set" : act.text()); + } + if (activity.type().toString().equals("delay")) { + // The BotFrameworkAdapter and Console adapter implement this + // hack directly in the POST method. Replicating that here + // to keep the behavior as close as possible to facillitate + // more realistic tests. + int delayMs = (int) activity.value(); + Thread.sleep(delayMs); + } else { + synchronized (this.botReplies) { + this.botReplies.add(activity); + } + } + } + return responses.toArray(new ResourceResponse[responses.size()]); + } + + + @Override + public ResourceResponse UpdateActivity(TurnContext context, Activity activity) { + synchronized (this.botReplies) { + List replies = new ArrayList<>(botReplies); + for (int i = 0; i < this.botReplies.size(); i++) { + if (replies.get(i).id().equals(activity.id())) { + replies.set(i, activity); + this.botReplies.clear(); + + for (Activity item : replies) { + this.botReplies.add(item); + } + return new ResourceResponse().withId(activity.id()); + } + } + } + return new ResourceResponse(); + } + + @Override + public void DeleteActivity(TurnContext context, ConversationReference reference) { + synchronized (this.botReplies) { + ArrayList replies = new ArrayList<>(this.botReplies); + for (int i = 0; i < this.botReplies.size(); i++) { + if (replies.get(i).id().equals(reference.activityId())) { + replies.remove(i); + this.botReplies.clear(); + for (Activity item : replies) { + this.botReplies.add(item); + } + break; + } + } + } + return; + } + + /** + * 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 callback) { + this.activeQueue().clear(); + MessageActivity update = MessageActivity.CreateConversationUpdateActivity(); + + update.withConversation(new ConversationAccount().withId(UUID.randomUUID().toString())); + TurnContextImpl context = new TurnContextImpl(this, (ActivityImpl) update); + return callback.apply(context); + } + + /** + * Called by TestFlow to check next reply + * + * @return + */ + public Activity GetNextReply() { + synchronized (this.botReplies) { + if (this.botReplies.size() > 0) { + return this.botReplies.remove(); + } + } + return null; + } + + /** + * Called by TestFlow to get appropriate activity for conversationReference of testbot + * + * @param text + * @return + */ + public Activity MakeActivity() { + return MakeActivity(null); + } + + public ActivityImpl MakeActivity(String text) { + Integer next = nextId++; + ActivityImpl activity = (ActivityImpl) new ActivityImpl() + .withType(ActivityTypes.MESSAGE) + .withFrom(conversationReference().user()) + .withRecipient(conversationReference().bot()) + .withConversation(conversationReference().conversation()) + .withServiceUrl(conversationReference().serviceUrl()) + .withId(next.toString()) + .withText(text); + + return activity; + } + + + /** + * Called by TestFlow to send text to the bot + * + * @param userSays + * @return + */ + public void SendTextToBot(String userSays, Consumer callback) throws Exception { + this.ProcessActivity(this.MakeActivity(userSays), callback); + } +} + + diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/Dialog.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/Dialog.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/Dialog.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/Dialog.java index 8f706f83..729367b7 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/Dialog.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/Dialog.java @@ -1,111 +1,111 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.microsoft.bot.builder.dialogs; - - -import com.microsoft.bot.builder.BotAssert; -import com.microsoft.bot.builder.TurnContext; - -import java.util.HashMap; -import java.util.concurrent.CompletableFuture; - -/** - * Base class for controls - */ -public abstract class Dialog -{ - /** - * 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 Begin(TurnContext context, HashMap state) - { - return Begin(context, state, null); - } - public CompletableFuture Begin(TurnContext context, HashMap state, HashMap options) - { - BotAssert.ContextNotNull(context); - if (state == null) - throw new NullPointerException("HashMap state"); - - // Create empty dialog set and ourselves to it - // TODO: Complete - //DialogSet dialogs = new DialogSet(); - //dialogs.Add("dialog", (IDialog)this); - - // Start the control - //HashMap result = null; - - /* - // TODO Complete - - await dc.Begin("dialog", options); - */ - CompletableFuture result = null; - /* - if (dc.ActiveDialog != null) { - result = new DialogCompletion(); - result.setIsActive(true); - result.setIsCompleted(false); - } - else{ - result = new DialogCompletion(); - result.setIsActive(false); - result.setIsCompleted(true); - result.setResult(result); - } - */ - return result; - } - - /** - * 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 Continue(TurnContext context, HashMap state) - { - BotAssert.ContextNotNull(context); - if (state == null) - throw new NullPointerException("HashMap"); - - // Create empty dialog set and ourselves to it - // TODO: daveta - //DialogSet dialogs = new DialogSet(); - //dialogs.Add("dialog", (IDialog)this); - - // Continue the dialog - //HashMap result = null; - CompletableFuture result = null; - /* - TODO: daveta - var dc = new DialogContext(dialogs, context, state, (r) => { result = r; }); - if (dc.ActiveDialog != null) - { - await dc.Continue(); - return dc.ActiveDialog != null - ? - new DialogCompletion { IsActive = true, IsCompleted = false } - : - new DialogCompletion { IsActive = false, IsCompleted = true, Result = result }; - } - else - { - return new DialogCompletion { IsActive = false, IsCompleted = false }; - } - */ - - return result; - - } -} - +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.microsoft.bot.builder.dialogs; + + +import com.microsoft.bot.builder.BotAssert; +import com.microsoft.bot.builder.TurnContext; + +import java.util.HashMap; +import java.util.concurrent.CompletableFuture; + +/** + * Base class for controls + */ +public abstract class Dialog +{ + /** + * 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 Begin(TurnContext context, HashMap state) + { + return Begin(context, state, null); + } + public CompletableFuture Begin(TurnContext context, HashMap state, HashMap options) + { + BotAssert.ContextNotNull(context); + if (state == null) + throw new NullPointerException("HashMap state"); + + // Create empty dialog set and ourselves to it + // TODO: Complete + //DialogSet dialogs = new DialogSet(); + //dialogs.Add("dialog", (IDialog)this); + + // Start the control + //HashMap result = null; + + /* + // TODO Complete + + await dc.Begin("dialog", options); + */ + CompletableFuture result = null; + /* + if (dc.ActiveDialog != null) { + result = new DialogCompletion(); + result.setIsActive(true); + result.setIsCompleted(false); + } + else{ + result = new DialogCompletion(); + result.setIsActive(false); + result.setIsCompleted(true); + result.setResult(result); + } + */ + return result; + } + + /** + * 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 Continue(TurnContext context, HashMap state) + { + BotAssert.ContextNotNull(context); + if (state == null) + throw new NullPointerException("HashMap"); + + // Create empty dialog set and ourselves to it + // TODO: daveta + //DialogSet dialogs = new DialogSet(); + //dialogs.Add("dialog", (IDialog)this); + + // Continue the dialog + //HashMap result = null; + CompletableFuture result = null; + /* + TODO: daveta + var dc = new DialogContext(dialogs, context, state, (r) => { result = r; }); + if (dc.ActiveDialog != null) + { + await dc.Continue(); + return dc.ActiveDialog != null + ? + new DialogCompletion { IsActive = true, IsCompleted = false } + : + new DialogCompletion { IsActive = false, IsCompleted = true, Result = result }; + } + else + { + return new DialogCompletion { IsActive = false, IsCompleted = false }; + } + */ + + return result; + + } +} + diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/DialogCompletion.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/DialogCompletion.java similarity index 96% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/DialogCompletion.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/DialogCompletion.java index d5cc31ac..a978effc 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/DialogCompletion.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/DialogCompletion.java @@ -1,54 +1,54 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.microsoft.bot.builder.dialogs; - -import java.util.HashMap; - -/** - * 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 -{ - - - /** - * If 'true' the dialog is still active. - */ - boolean _isActive; - public void setIsActive(boolean isActive) { - this._isActive = isActive; - } - public boolean getIsActive() { - return this._isActive; - } - - /** - * If 'true' the dialog just completed and the final [result](#result) can be retrieved. - */ - boolean _isCompleted; - public void setIsCompleted(boolean isCompleted) - { - this._isCompleted = isCompleted; - } - public boolean getIsCompleted() - { - return this._isCompleted; - } - - /** - * 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 _result; - public HashMap getResult() { - return _result; - } - public void setResult(HashMap result) { - this._result = result; - } -} +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.microsoft.bot.builder.dialogs; + +import java.util.HashMap; + +/** + * 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 +{ + + + /** + * If 'true' the dialog is still active. + */ + boolean _isActive; + public void setIsActive(boolean isActive) { + this._isActive = isActive; + } + public boolean getIsActive() { + return this._isActive; + } + + /** + * If 'true' the dialog just completed and the final [result](#result) can be retrieved. + */ + boolean _isCompleted; + public void setIsCompleted(boolean isCompleted) + { + this._isCompleted = isCompleted; + } + public boolean getIsCompleted() + { + return this._isCompleted; + } + + /** + * 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 _result; + public HashMap getResult() { + return _result; + } + public void setResult(HashMap result) { + this._result = result; + } +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/DialogContainer.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/DialogContainer.java similarity index 96% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/DialogContainer.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/DialogContainer.java index c7618129..51d0f50d 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/DialogContainer.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/DialogContainer.java @@ -1,50 +1,50 @@ -/* -public class DialogContainer implements IDialogContinue - - -{ - protected DialogSet Dialogs { get; set; } - protected string DialogId { get; set; } - - public DialogContainer(string dialogId, DialogSet dialogs = null) - { - if (string.IsNullOrEmpty(dialogId)) - throw new ArgumentNullException(nameof(dialogId)); - - Dialogs dialogs = (dialogs != null) ? dialogs : new DialogSet(); - DialogId = dialogId; - } - - public async Task DialogBegin(DialogContext dc, IDictionary dialogArgs = null) - { - if (dc == null) - throw new ArgumentNullException(nameof(dc)); - - // Start the controls entry point dialog. - IDictionary result = null; - var cdc = new DialogContext(this.Dialogs, dc.Context, dc.ActiveDialog.State, (r) => { result = r; }); - await cdc.Begin(DialogId, dialogArgs); - // End if the controls dialog ends. - if (cdc.ActiveDialog == null) - { - await dc.End(result); - } - } - - public async Task DialogContinue(DialogContext dc) - { - if (dc == null) - throw new ArgumentNullException(nameof(dc)); - - // Continue controls dialog stack. - IDictionary result = null; - var cdc = new DialogContext(this.Dialogs, dc.Context, dc.ActiveDialog.State, (r) => { result = r; }); - await cdc.Continue(); - // End if the controls dialog ends. - if (cdc.ActiveDialog == null) - { - await dc.End(result); - } - } -} -*/ +/* +public class DialogContainer implements IDialogContinue + + +{ + protected DialogSet Dialogs { get; set; } + protected string DialogId { get; set; } + + public DialogContainer(string dialogId, DialogSet dialogs = null) + { + if (string.IsNullOrEmpty(dialogId)) + throw new ArgumentNullException(nameof(dialogId)); + + Dialogs dialogs = (dialogs != null) ? dialogs : new DialogSet(); + DialogId = dialogId; + } + + public async Task DialogBegin(DialogContext dc, IDictionary dialogArgs = null) + { + if (dc == null) + throw new ArgumentNullException(nameof(dc)); + + // Start the controls entry point dialog. + IDictionary result = null; + var cdc = new DialogContext(this.Dialogs, dc.Context, dc.ActiveDialog.State, (r) => { result = r; }); + await cdc.Begin(DialogId, dialogArgs); + // End if the controls dialog ends. + if (cdc.ActiveDialog == null) + { + await dc.End(result); + } + } + + public async Task DialogContinue(DialogContext dc) + { + if (dc == null) + throw new ArgumentNullException(nameof(dc)); + + // Continue controls dialog stack. + IDictionary result = null; + var cdc = new DialogContext(this.Dialogs, dc.Context, dc.ActiveDialog.State, (r) => { result = r; }); + await cdc.Continue(); + // End if the controls dialog ends. + if (cdc.ActiveDialog == null) + { + await dc.End(result); + } + } +} +*/ diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/DialogContext.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/DialogContext.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/DialogContext.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/DialogContext.java index 0c791981..53531a32 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/DialogContext.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/DialogContext.java @@ -1,167 +1,167 @@ -package com.microsoft.bot.builder.dialogs; - -// -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. -// -// Microsoft Bot Framework: http://botframework.com -// -// Bot Builder SDK GitHub: -// https://github.com/Microsoft/BotBuilder -// -// Copyright (c) Microsoft Corporation -// All rights reserved. -// -// MIT License: -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -/** - * 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 -{ - CompletableFuture invoke(DialogContext contenxt, Available) -} - -public delegate Task ResumeAfter(IDialogContext context, IAwaitable result); -*/ - -/** - * 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); - - - -/** - * The context for the execution of a dialog's conversational process. - */ -// DAVETA: TODO -// public interface DialogContext extends -public interface DialogContext { - } - - -/** - * Helper methods. - */ -/* -public static partial class Extensions -{*/ - /** - * 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; - - if (!string.IsNullOrEmpty(locale)) - { - message.Locale = locale; - } - - await botToUser.PostAsync(message); - } -*/ - - - /** - * 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(); - - message.Text = text; - message.Speak = speak; - - if (!string.IsNullOrEmpty(locale)) - { - message.Locale = locale; - } - - if (options != null) - { - message.InputHint = options.InputHint; - message.TextFormat = options.TextFormat; - message.AttachmentLayout = options.AttachmentLayout; - message.Attachments = options.Attachments; - message.Entities = options.Entities; - } - - await botToUser.PostAsync(message); - }*/ - - /** - * 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 resume) - { - stack.Wait(resume); - } -*/ - - /** - * 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(this IDialogStack stack, IDialog child, ResumeAfter resume, MessageActivity message) - { - await stack.Forward(child, resume, message, token); - } -}*/ +package com.microsoft.bot.builder.dialogs; + +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. +// +// Microsoft Bot Framework: http://botframework.com +// +// Bot Builder SDK GitHub: +// https://github.com/Microsoft/BotBuilder +// +// Copyright (c) Microsoft Corporation +// All rights reserved. +// +// MIT License: +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +/** + * 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 +{ + CompletableFuture invoke(DialogContext contenxt, Available) +} + +public delegate Task ResumeAfter(IDialogContext context, IAwaitable result); +*/ + +/** + * 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); + + + +/** + * The context for the execution of a dialog's conversational process. + */ +// DAVETA: TODO +// public interface DialogContext extends +public interface DialogContext { + } + + +/** + * Helper methods. + */ +/* +public static partial class Extensions +{*/ + /** + * 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; + + if (!string.IsNullOrEmpty(locale)) + { + message.Locale = locale; + } + + await botToUser.PostAsync(message); + } +*/ + + + /** + * 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(); + + message.Text = text; + message.Speak = speak; + + if (!string.IsNullOrEmpty(locale)) + { + message.Locale = locale; + } + + if (options != null) + { + message.InputHint = options.InputHint; + message.TextFormat = options.TextFormat; + message.AttachmentLayout = options.AttachmentLayout; + message.Attachments = options.Attachments; + message.Entities = options.Entities; + } + + await botToUser.PostAsync(message); + }*/ + + /** + * 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 resume) + { + stack.Wait(resume); + } +*/ + + /** + * 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(this IDialogStack stack, IDialog child, ResumeAfter resume, MessageActivity message) + { + await stack.Forward(child, resume, message, token); + } +}*/ diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/IDialog.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/IDialog.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/IDialog.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/IDialog.java index f4c3872a..8cb58b52 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/IDialog.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/IDialog.java @@ -1,19 +1,19 @@ -package com.microsoft.bot.builder.dialogs; - -// TODO: daveta remove this - not sure where this came from -/** - * 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 -{ - /** - * 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 dialogArgs = null); - //CompleteableFuture DialogBegin(DialogContext dc, HashMap dialogArgs); - //CompleteableFuture DialogBegin(DialogContext dc); -} +package com.microsoft.bot.builder.dialogs; + +// TODO: daveta remove this - not sure where this came from +/** + * 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 +{ + /** + * 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 dialogArgs = null); + //CompleteableFuture DialogBegin(DialogContext dc, HashMap dialogArgs); + //CompleteableFuture DialogBegin(DialogContext dc); +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/IDialogContinue.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/IDialogContinue.java similarity index 97% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/IDialogContinue.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/IDialogContinue.java index 1fb250aa..0abb6879 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/IDialogContinue.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/IDialogContinue.java @@ -1,21 +1,21 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.microsoft.bot.builder.dialogs; - - -import java.util.concurrent.CompletableFuture; - -/** - * Interface Dialog objects that can be continued. - */ -public interface IDialogContinue extends IDialog -{ - /** - * 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); -} +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.microsoft.bot.builder.dialogs; + + +import java.util.concurrent.CompletableFuture; + +/** + * Interface Dialog objects that can be continued. + */ +public interface IDialogContinue extends IDialog +{ + /** + * 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); +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/MessageOptions.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/MessageOptions.java similarity index 96% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/MessageOptions.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/MessageOptions.java index 3a452da1..e56b74c2 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/dialogs/MessageOptions.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/dialogs/MessageOptions.java @@ -1,57 +1,57 @@ -package com.microsoft.bot.builder.dialogs; - -import com.microsoft.bot.schema.models.AttachmentLayoutTypes; -import com.microsoft.bot.schema.models.TextFormatTypes; - -/** - * Optional message properties that can be sent {@link Extensions.SayAsync(BotToUser, String MessageOptions,)} - */ -public class MessageOptions -{ - public MessageOptions() - { - this.setTextFormat(TextFormatTypes.MARKDOWN.toString()); - this.setAttachmentLayout(AttachmentLayoutTypes.LIST.toString()); - // this.Attachments = new ArrayList(); - // this.Entities = new ArrayList(); - } - - /** - * Indicates whether the bot is accepting, expecting, or ignoring input - */ - //public string InputHint { get; set; } - - /** - * Format of text fields [plain|markdown] Default:markdown - */ - String textFormat; - public String getTextFormat() { - return this.textFormat; - } - public void setTextFormat(String textFormat) { - this.textFormat = textFormat; - } - - - - /** - * Hint for how to deal with multiple attachments: [list|carousel] Default:list - */ - String attachmentLayout; - public String getAttachmentLayout() { - return this.attachmentLayout; - } - public void setAttachmentLayout(String attachmentLayout) { - this.attachmentLayout = attachmentLayout; - } - - /** - * Attachments - */ - //public IList Attachments { get; set; } - - /** - * Collection of Entity objects, each of which contains metadata about this activity. Each Entity object is typed. - */ - //public IList Entities { get; set; } -} +package com.microsoft.bot.builder.dialogs; + +import com.microsoft.bot.schema.models.AttachmentLayoutTypes; +import com.microsoft.bot.schema.models.TextFormatTypes; + +/** + * Optional message properties that can be sent {@link Extensions.SayAsync(BotToUser, String MessageOptions,)} + */ +public class MessageOptions +{ + public MessageOptions() + { + this.setTextFormat(TextFormatTypes.MARKDOWN.toString()); + this.setAttachmentLayout(AttachmentLayoutTypes.LIST.toString()); + // this.Attachments = new ArrayList(); + // this.Entities = new ArrayList(); + } + + /** + * Indicates whether the bot is accepting, expecting, or ignoring input + */ + //public string InputHint { get; set; } + + /** + * Format of text fields [plain|markdown] Default:markdown + */ + String textFormat; + public String getTextFormat() { + return this.textFormat; + } + public void setTextFormat(String textFormat) { + this.textFormat = textFormat; + } + + + + /** + * Hint for how to deal with multiple attachments: [list|carousel] Default:list + */ + String attachmentLayout; + public String getAttachmentLayout() { + return this.attachmentLayout; + } + public void setAttachmentLayout(String attachmentLayout) { + this.attachmentLayout = attachmentLayout; + } + + /** + * Attachments + */ + //public IList Attachments { get; set; } + + /** + * Collection of Entity objects, each of which contains metadata about this activity. Each Entity object is typed. + */ + //public IList Entities { get; set; } +} diff --git a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/prompts/Choice.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/prompts/Choice.java similarity index 96% rename from libraries/botbuilder/src/main/java/com/microsoft/bot/builder/prompts/Choice.java rename to libraries/bot-builder/src/main/java/com/microsoft/bot/builder/prompts/Choice.java index b7e0d0cd..92ab0f55 100644 --- a/libraries/botbuilder/src/main/java/com/microsoft/bot/builder/prompts/Choice.java +++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/prompts/Choice.java @@ -1,43 +1,43 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.microsoft.bot.builder.prompts; - -import com.microsoft.bot.schema.models.CardAction; - -import java.util.ArrayList; - -public class Choice -{ - /** - * Value to return when selected. - */ - String _value; - public void setValue(String value) { - this._value = value; - } - public String getValue() { - return this._value; - } - - /** - * (Optional) action to use when rendering the choice as a suggested action. - */ - CardAction _action; - public CardAction getAction() { - return this._action; - } - public void setAction(CardAction action) { - this._action = action; - } - - /** - * (Optional) list of synonyms to recognize in addition to the value. - */ - ArrayList _synonyms; - public ArrayList getSynonyms() { - return _synonyms; - } - public void setSynonyms(ArrayList synonyms) { - this._synonyms = synonyms; - } -} +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.microsoft.bot.builder.prompts; + +import com.microsoft.bot.schema.models.CardAction; + +import java.util.ArrayList; + +public class Choice +{ + /** + * Value to return when selected. + */ + String _value; + public void setValue(String value) { + this._value = value; + } + public String getValue() { + return this._value; + } + + /** + * (Optional) action to use when rendering the choice as a suggested action. + */ + CardAction _action; + public CardAction getAction() { + return this._action; + } + public void setAction(CardAction action) { + this._action = action; + } + + /** + * (Optional) list of synonyms to recognize in addition to the value. + */ + ArrayList _synonyms; + public ArrayList getSynonyms() { + return _synonyms; + } + public void setSynonyms(ArrayList synonyms) { + this._synonyms = synonyms; + } +} diff --git a/libraries/botbuilder/src/main/resources/log4j2.json b/libraries/bot-builder/src/main/resources/log4j2.json similarity index 96% rename from libraries/botbuilder/src/main/resources/log4j2.json rename to libraries/bot-builder/src/main/resources/log4j2.json index 9161234d..b183e4d9 100644 --- a/libraries/botbuilder/src/main/resources/log4j2.json +++ b/libraries/bot-builder/src/main/resources/log4j2.json @@ -1,25 +1,25 @@ -{ - "configuration": { - "name": "Default", - "appenders": { - "Console": { - "name": "Console-Appender", - "target": "SYSTEM_OUT", - "PatternLayout": {"pattern": "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"} - } - }, - "loggers": { - "logger": [ - { - "name": "com.microsoft.bot.builder", - "level": "debug", - "appender-ref": [{"ref": "Console-Appender", "level": "debug"}] - } - ], - "root": { - "level": "warn", - "appender-ref": {"ref": "Console-Appender","level": "warn"} - } - } - } -} +{ + "configuration": { + "name": "Default", + "appenders": { + "Console": { + "name": "Console-Appender", + "target": "SYSTEM_OUT", + "PatternLayout": {"pattern": "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"} + } + }, + "loggers": { + "logger": [ + { + "name": "com.microsoft.bot.builder", + "level": "debug", + "appender-ref": [{"ref": "Console-Appender", "level": "debug"}] + } + ], + "root": { + "level": "warn", + "appender-ref": {"ref": "Console-Appender","level": "warn"} + } + } + } +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/ActionDel.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/ActionDel.java similarity index 96% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/ActionDel.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/ActionDel.java index 532dda15..3283583f 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/ActionDel.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/ActionDel.java @@ -1,7 +1,7 @@ -package com.microsoft.bot.builder; - -// This is a proxy for some previous tests using Action bindings -@FunctionalInterface -public interface ActionDel { - void CallMe(); -} +package com.microsoft.bot.builder; + +// This is a proxy for some previous tests using Action bindings +@FunctionalInterface +public interface ActionDel { + void CallMe(); +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/BotFrameworkAdapterTest.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/BotFrameworkAdapterTest.java similarity index 96% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/BotFrameworkAdapterTest.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/BotFrameworkAdapterTest.java index 514c88bb..1fe82f7c 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/BotFrameworkAdapterTest.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/BotFrameworkAdapterTest.java @@ -1,42 +1,42 @@ -package com.microsoft.bot.builder; - -import com.microsoft.bot.schema.ActivityImpl; -import com.microsoft.bot.schema.models.*; -import org.junit.Assert; -import org.junit.Test; - -import java.util.UUID; -import java.util.function.Consumer; - -public class BotFrameworkAdapterTest { - @Test - public void AdapterSingleUse() - { - SimpleAdapter a = new SimpleAdapter(); - a.Use(new CallCountingMiddleware()); - } - - @Test - public void AdapterUseChaining() - { - SimpleAdapter a = new SimpleAdapter(); - a.Use(new CallCountingMiddleware()).Use(new CallCountingMiddleware()); - } - - @Test - public void PassResourceResponsesThrough() throws Exception { - Consumer validateResponse = (activities) -> { - // no need to do anything. - }; - - SimpleAdapter a = new SimpleAdapter(validateResponse); - TurnContextImpl c = new TurnContextImpl(a, new ActivityImpl()); - - String activityId = UUID.randomUUID().toString(); - ActivityImpl activity = TestMessage.Message() - .withId(activityId); - - ResourceResponse resourceResponse = c.SendActivity(activity); - Assert.assertTrue("Incorrect response Id returned", resourceResponse.id() == activityId); - } -} +package com.microsoft.bot.builder; + +import com.microsoft.bot.schema.ActivityImpl; +import com.microsoft.bot.schema.models.*; +import org.junit.Assert; +import org.junit.Test; + +import java.util.UUID; +import java.util.function.Consumer; + +public class BotFrameworkAdapterTest { + @Test + public void AdapterSingleUse() + { + SimpleAdapter a = new SimpleAdapter(); + a.Use(new CallCountingMiddleware()); + } + + @Test + public void AdapterUseChaining() + { + SimpleAdapter a = new SimpleAdapter(); + a.Use(new CallCountingMiddleware()).Use(new CallCountingMiddleware()); + } + + @Test + public void PassResourceResponsesThrough() throws Exception { + Consumer validateResponse = (activities) -> { + // no need to do anything. + }; + + SimpleAdapter a = new SimpleAdapter(validateResponse); + TurnContextImpl c = new TurnContextImpl(a, new ActivityImpl()); + + String activityId = UUID.randomUUID().toString(); + ActivityImpl activity = TestMessage.Message() + .withId(activityId); + + ResourceResponse resourceResponse = c.SendActivity(activity); + Assert.assertTrue("Incorrect response Id returned", resourceResponse.id() == activityId); + } +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/BotStateTest.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/BotStateTest.java similarity index 97% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/BotStateTest.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/BotStateTest.java index f8849c65..8b858784 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/BotStateTest.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/BotStateTest.java @@ -1,379 +1,379 @@ - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.microsoft.bot.builder; - - - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.microsoft.bot.builder.adapters.TestAdapter; -import com.microsoft.bot.builder.adapters.TestFlow; -import com.microsoft.bot.connector.implementation.ConnectorClientImpl; -import com.microsoft.bot.schema.models.ChannelAccount; -import com.microsoft.bot.schema.models.ResourceResponse; -import com.microsoft.rest.RestClient; -import org.apache.commons.lang3.StringUtils; -import org.junit.Assert; -import org.junit.Test; - -import java.util.UUID; -import java.util.concurrent.ExecutionException; -import java.util.function.Consumer; - - -// [TestClass] -// [TestCategory("State Management")] -public class BotStateTest { - protected ConnectorClientImpl connector; - protected ChannelAccount bot; - protected ChannelAccount user; - - - protected void initializeClients(RestClient restClient, String botId, String userId) { - - connector = new ConnectorClientImpl(restClient); - bot = new ChannelAccount().withId(botId); - user = new ChannelAccount().withId(userId); - - } - - - protected void cleanUpResources() { - } - - @Test - public void State_DoNOTRememberContextState() throws ExecutionException, InterruptedException { - - TestAdapter adapter = new TestAdapter(); - - new TestFlow(adapter, (context) -> { - TestPocoState obj = StateTurnContextExtensions.GetConversationState(context); - Assert.assertNull("context.state should not exist", obj); } - ) - .Send("set value") - .StartTest(); - - } - - //@Test - public void State_RememberIStoreItemUserState() throws ExecutionException, InterruptedException { - TestAdapter adapter = new TestAdapter() - .Use(new UserState(new MemoryStorage(), TestState::new)); - - - Consumer callback = (context) -> { - System.out.print(String.format("State_RememberIStoreItemUserState CALLBACK called..")); - System.out.flush(); - TestState userState = StateTurnContextExtensions.GetUserState(context); - Assert.assertNotNull("user state should exist", userState); - switch (context.getActivity().text()) { - case "set value": - userState.withValue("test"); - try { - ((TurnContextImpl)context).SendActivity("value saved"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(String.format("Error sending activity! - set value")); - } - break; - case "get value": - try { - Assert.assertFalse(StringUtils.isBlank(userState.value())); - ((TurnContextImpl)context).SendActivity(userState.value()); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(String.format("Error sending activity! - get value")); - } - break; - } - - }; - - new TestFlow(adapter, callback) - .Test("set value", "value saved") - .Test("get value", "test") - .StartTest(); - - } - - @Test - public void State_RememberPocoUserState() throws ExecutionException, InterruptedException { - TestAdapter adapter = new TestAdapter() - .Use(new UserState(new MemoryStorage(), TestPocoState::new)); - new TestFlow(adapter, - (context) -> - { - TestPocoState userState = StateTurnContextExtensions.GetUserState(context); - - Assert.assertNotNull("user state should exist", userState); - switch (context.getActivity().text()) { - case "set value": - userState.setValue("test"); - try { - context.SendActivity("value saved"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(String.format("Error sending activity! - set value")); - } - break; - case "get value": - try { - Assert.assertFalse(StringUtils.isBlank(userState.getValue())); - context.SendActivity(userState.getValue()); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(String.format("Error sending activity! - get value")); - } - break; - } - }) - .Test("set value", "value saved") - .Test("get value", "test") - .StartTest(); - } - - //@Test - public void State_RememberIStoreItemConversationState() throws ExecutionException, InterruptedException { - TestAdapter adapter = new TestAdapter() - .Use(new ConversationState(new MemoryStorage(), TestState::new)); - new TestFlow(adapter, - (context) -> - { - TestState conversationState = StateTurnContextExtensions.GetConversationState(context); - Assert.assertNotNull("state.conversation should exist", conversationState); - switch (context.getActivity().text()) { - case "set value": - conversationState.withValue("test"); - try { - context.SendActivity("value saved"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(String.format("Error sending activity! - set value")); - } - break; - case "get value": - try { - Assert.assertFalse(StringUtils.isBlank(conversationState.value())); - context.SendActivity(conversationState.value()); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(String.format("Error sending activity! - get value")); - } - break; - } - }) - .Test("set value", "value saved") - .Test("get value", "test") - .StartTest(); - } - - //@Test - public void State_RememberPocoConversationState() throws ExecutionException, InterruptedException { - TestAdapter adapter = new TestAdapter() - .Use(new ConversationState(new MemoryStorage(), TestPocoState::new)); - new TestFlow(adapter, - (context) -> - { - TestPocoState conversationState = StateTurnContextExtensions.GetConversationState(context); - Assert.assertNotNull("state.conversation should exist", conversationState); - switch (context.getActivity().text()) { - case "set value": - conversationState.setValue("test"); - try { - context.SendActivity("value saved"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(String.format("Error sending activity! - set value")); - } - break; - case "get value": - try { - Assert.assertFalse(StringUtils.isBlank(conversationState.getValue())); - context.SendActivity(conversationState.getValue()); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(String.format("Error sending activity! - get value")); - } - break; - } - }) - - .Test("set value", "value saved") - .Test("get value", "test") - .StartTest(); - } - - @Test - public void State_CustomStateManagerTest() throws ExecutionException, InterruptedException { - - String testGuid = UUID.randomUUID().toString(); - TestAdapter adapter = new TestAdapter() - .Use(new CustomKeyState(new MemoryStorage())); - new TestFlow(adapter, - (context) -> - { - CustomState customState = CustomKeyState.Get(context); - - switch (context.getActivity().text()) { - case "set value": - customState.setCustomString(testGuid); - try { - context.SendActivity("value saved"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(String.format("Error sending activity! - set value")); - } - break; - case "get value": - try { - Assert.assertFalse(StringUtils.isBlank(customState.getCustomString())); - context.SendActivity(customState.getCustomString()); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(String.format("Error sending activity! - get value")); - } - break; - } - }) - .Test("set value", "value saved") - .Test("get value", testGuid.toString()) - .StartTest(); - } - @Test - public void State_RoundTripTypedObjectwTrace() throws ExecutionException, InterruptedException { - TestAdapter adapter = new TestAdapter() - .Use(new ConversationState(new MemoryStorage(), TypedObject::new)); - new TestFlow(adapter, - (context) -> - { - System.out.println(String.format(">>Test Callback(tid:%s): STARTING : %s", Thread.currentThread().getId(), context.getActivity().text())); - System.out.flush(); - TypedObject conversation = StateTurnContextExtensions.GetConversationState(context); - Assert.assertNotNull("conversationstate should exist", conversation); - System.out.println(String.format(">>Test Callback(tid:%s): Text is : %s", Thread.currentThread().getId(), context.getActivity().text())); - System.out.flush(); - switch (context.getActivity().text()) { - case "set value": - conversation.withName("test"); - try { - System.out.println(String.format(">>Test Callback(tid:%s): Send activity : %s", Thread.currentThread().getId(), - "value saved")); - System.out.flush(); - ResourceResponse response = context.SendActivity("value saved"); - System.out.println(String.format(">>Test Callback(tid:%s): Response Id: %s", Thread.currentThread().getId(), - response.id())); - System.out.flush(); - - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(String.format("Error sending activity! - set value")); - } - break; - case "get value": - try { - System.out.println(String.format(">>Test Callback(tid:%s): Send activity : %s", Thread.currentThread().getId(), - "TypedObject")); - System.out.flush(); - context.SendActivity("TypedObject"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(String.format("Error sending activity! - get value")); - } - break; - } - }) - .Turn("set value", "value saved", "Description", 50000) - .Turn("get value", "TypedObject", "Description", 50000) - .StartTest(); - - } - - - @Test - public void State_RoundTripTypedObject() throws ExecutionException, InterruptedException { - TestAdapter adapter = new TestAdapter() - .Use(new ConversationState(new MemoryStorage(), TypedObject::new)); - - new TestFlow(adapter, - (context) -> - { - TypedObject conversation = StateTurnContextExtensions.GetConversationState(context); - Assert.assertNotNull("conversationstate should exist", conversation); - switch (context.getActivity().text()) { - case "set value": - conversation.withName("test"); - try { - context.SendActivity("value saved"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(String.format("Error sending activity! - set value")); - } - break; - case "get value": - try { - context.SendActivity("TypedObject"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(String.format("Error sending activity! - get value")); - } - break; - } - }) - .Test("set value", "value saved") - .Test("get value", "TypedObject") - .StartTest(); - - } - - @Test - public void State_UseBotStateDirectly() throws ExecutionException, InterruptedException { - TestAdapter adapter = new TestAdapter(); - - new TestFlow(adapter, - (context) -> - { - BotState botStateManager = new BotState(new MemoryStorage(), "BotState:com.microsoft.bot.builder.core.extensions.BotState", - (ctx) -> String.format("botstate/%s/%s/com.microsoft.bot.builder.core.extensions.BotState", - ctx.getActivity().channelId(), ctx.getActivity().conversation().id()), CustomState::new); - - // read initial state object - CustomState customState = null; - try { - customState = (CustomState) botStateManager.Read(context).join(); - } catch (JsonProcessingException e) { - e.printStackTrace(); - Assert.fail("Error reading custom state"); - } - - // this should be a 'new CustomState' as nothing is currently stored in storage - Assert.assertEquals(customState, new CustomState()); - - // amend property and write to storage - customState.setCustomString("test"); - try { - botStateManager.Write(context, customState).join(); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail("Could not write customstate"); - } - - // set customState to null before reading from storage - customState = null; - try { - customState = (CustomState) botStateManager.Read(context).join(); - } catch (JsonProcessingException e) { - e.printStackTrace(); - Assert.fail("Could not read customstate back"); - } - - // check object read from value has the correct value for CustomString - Assert.assertEquals(customState.getCustomString(), "test"); - } - ) - .StartTest(); - } - - -} - + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.microsoft.bot.builder; + + + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.microsoft.bot.builder.adapters.TestAdapter; +import com.microsoft.bot.builder.adapters.TestFlow; +import com.microsoft.bot.connector.implementation.ConnectorClientImpl; +import com.microsoft.bot.schema.models.ChannelAccount; +import com.microsoft.bot.schema.models.ResourceResponse; +import com.microsoft.rest.RestClient; +import org.apache.commons.lang3.StringUtils; +import org.junit.Assert; +import org.junit.Test; + +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import java.util.function.Consumer; + + +// [TestClass] +// [TestCategory("State Management")] +public class BotStateTest { + protected ConnectorClientImpl connector; + protected ChannelAccount bot; + protected ChannelAccount user; + + + protected void initializeClients(RestClient restClient, String botId, String userId) { + + connector = new ConnectorClientImpl(restClient); + bot = new ChannelAccount().withId(botId); + user = new ChannelAccount().withId(userId); + + } + + + protected void cleanUpResources() { + } + + @Test + public void State_DoNOTRememberContextState() throws ExecutionException, InterruptedException { + + TestAdapter adapter = new TestAdapter(); + + new TestFlow(adapter, (context) -> { + TestPocoState obj = StateTurnContextExtensions.GetConversationState(context); + Assert.assertNull("context.state should not exist", obj); } + ) + .Send("set value") + .StartTest(); + + } + + //@Test + public void State_RememberIStoreItemUserState() throws ExecutionException, InterruptedException { + TestAdapter adapter = new TestAdapter() + .Use(new UserState(new MemoryStorage(), TestState::new)); + + + Consumer callback = (context) -> { + System.out.print(String.format("State_RememberIStoreItemUserState CALLBACK called..")); + System.out.flush(); + TestState userState = StateTurnContextExtensions.GetUserState(context); + Assert.assertNotNull("user state should exist", userState); + switch (context.getActivity().text()) { + case "set value": + userState.withValue("test"); + try { + ((TurnContextImpl)context).SendActivity("value saved"); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(String.format("Error sending activity! - set value")); + } + break; + case "get value": + try { + Assert.assertFalse(StringUtils.isBlank(userState.value())); + ((TurnContextImpl)context).SendActivity(userState.value()); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(String.format("Error sending activity! - get value")); + } + break; + } + + }; + + new TestFlow(adapter, callback) + .Test("set value", "value saved") + .Test("get value", "test") + .StartTest(); + + } + + @Test + public void State_RememberPocoUserState() throws ExecutionException, InterruptedException { + TestAdapter adapter = new TestAdapter() + .Use(new UserState(new MemoryStorage(), TestPocoState::new)); + new TestFlow(adapter, + (context) -> + { + TestPocoState userState = StateTurnContextExtensions.GetUserState(context); + + Assert.assertNotNull("user state should exist", userState); + switch (context.getActivity().text()) { + case "set value": + userState.setValue("test"); + try { + context.SendActivity("value saved"); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(String.format("Error sending activity! - set value")); + } + break; + case "get value": + try { + Assert.assertFalse(StringUtils.isBlank(userState.getValue())); + context.SendActivity(userState.getValue()); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(String.format("Error sending activity! - get value")); + } + break; + } + }) + .Test("set value", "value saved") + .Test("get value", "test") + .StartTest(); + } + + //@Test + public void State_RememberIStoreItemConversationState() throws ExecutionException, InterruptedException { + TestAdapter adapter = new TestAdapter() + .Use(new ConversationState(new MemoryStorage(), TestState::new)); + new TestFlow(adapter, + (context) -> + { + TestState conversationState = StateTurnContextExtensions.GetConversationState(context); + Assert.assertNotNull("state.conversation should exist", conversationState); + switch (context.getActivity().text()) { + case "set value": + conversationState.withValue("test"); + try { + context.SendActivity("value saved"); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(String.format("Error sending activity! - set value")); + } + break; + case "get value": + try { + Assert.assertFalse(StringUtils.isBlank(conversationState.value())); + context.SendActivity(conversationState.value()); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(String.format("Error sending activity! - get value")); + } + break; + } + }) + .Test("set value", "value saved") + .Test("get value", "test") + .StartTest(); + } + + //@Test + public void State_RememberPocoConversationState() throws ExecutionException, InterruptedException { + TestAdapter adapter = new TestAdapter() + .Use(new ConversationState(new MemoryStorage(), TestPocoState::new)); + new TestFlow(adapter, + (context) -> + { + TestPocoState conversationState = StateTurnContextExtensions.GetConversationState(context); + Assert.assertNotNull("state.conversation should exist", conversationState); + switch (context.getActivity().text()) { + case "set value": + conversationState.setValue("test"); + try { + context.SendActivity("value saved"); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(String.format("Error sending activity! - set value")); + } + break; + case "get value": + try { + Assert.assertFalse(StringUtils.isBlank(conversationState.getValue())); + context.SendActivity(conversationState.getValue()); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(String.format("Error sending activity! - get value")); + } + break; + } + }) + + .Test("set value", "value saved") + .Test("get value", "test") + .StartTest(); + } + + @Test + public void State_CustomStateManagerTest() throws ExecutionException, InterruptedException { + + String testGuid = UUID.randomUUID().toString(); + TestAdapter adapter = new TestAdapter() + .Use(new CustomKeyState(new MemoryStorage())); + new TestFlow(adapter, + (context) -> + { + CustomState customState = CustomKeyState.Get(context); + + switch (context.getActivity().text()) { + case "set value": + customState.setCustomString(testGuid); + try { + context.SendActivity("value saved"); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(String.format("Error sending activity! - set value")); + } + break; + case "get value": + try { + Assert.assertFalse(StringUtils.isBlank(customState.getCustomString())); + context.SendActivity(customState.getCustomString()); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(String.format("Error sending activity! - get value")); + } + break; + } + }) + .Test("set value", "value saved") + .Test("get value", testGuid.toString()) + .StartTest(); + } + @Test + public void State_RoundTripTypedObjectwTrace() throws ExecutionException, InterruptedException { + TestAdapter adapter = new TestAdapter() + .Use(new ConversationState(new MemoryStorage(), TypedObject::new)); + new TestFlow(adapter, + (context) -> + { + System.out.println(String.format(">>Test Callback(tid:%s): STARTING : %s", Thread.currentThread().getId(), context.getActivity().text())); + System.out.flush(); + TypedObject conversation = StateTurnContextExtensions.GetConversationState(context); + Assert.assertNotNull("conversationstate should exist", conversation); + System.out.println(String.format(">>Test Callback(tid:%s): Text is : %s", Thread.currentThread().getId(), context.getActivity().text())); + System.out.flush(); + switch (context.getActivity().text()) { + case "set value": + conversation.withName("test"); + try { + System.out.println(String.format(">>Test Callback(tid:%s): Send activity : %s", Thread.currentThread().getId(), + "value saved")); + System.out.flush(); + ResourceResponse response = context.SendActivity("value saved"); + System.out.println(String.format(">>Test Callback(tid:%s): Response Id: %s", Thread.currentThread().getId(), + response.id())); + System.out.flush(); + + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(String.format("Error sending activity! - set value")); + } + break; + case "get value": + try { + System.out.println(String.format(">>Test Callback(tid:%s): Send activity : %s", Thread.currentThread().getId(), + "TypedObject")); + System.out.flush(); + context.SendActivity("TypedObject"); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(String.format("Error sending activity! - get value")); + } + break; + } + }) + .Turn("set value", "value saved", "Description", 50000) + .Turn("get value", "TypedObject", "Description", 50000) + .StartTest(); + + } + + + @Test + public void State_RoundTripTypedObject() throws ExecutionException, InterruptedException { + TestAdapter adapter = new TestAdapter() + .Use(new ConversationState(new MemoryStorage(), TypedObject::new)); + + new TestFlow(adapter, + (context) -> + { + TypedObject conversation = StateTurnContextExtensions.GetConversationState(context); + Assert.assertNotNull("conversationstate should exist", conversation); + switch (context.getActivity().text()) { + case "set value": + conversation.withName("test"); + try { + context.SendActivity("value saved"); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(String.format("Error sending activity! - set value")); + } + break; + case "get value": + try { + context.SendActivity("TypedObject"); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(String.format("Error sending activity! - get value")); + } + break; + } + }) + .Test("set value", "value saved") + .Test("get value", "TypedObject") + .StartTest(); + + } + + @Test + public void State_UseBotStateDirectly() throws ExecutionException, InterruptedException { + TestAdapter adapter = new TestAdapter(); + + new TestFlow(adapter, + (context) -> + { + BotState botStateManager = new BotState(new MemoryStorage(), "BotState:com.microsoft.bot.builder.core.extensions.BotState", + (ctx) -> String.format("botstate/%s/%s/com.microsoft.bot.builder.core.extensions.BotState", + ctx.getActivity().channelId(), ctx.getActivity().conversation().id()), CustomState::new); + + // read initial state object + CustomState customState = null; + try { + customState = (CustomState) botStateManager.Read(context).join(); + } catch (JsonProcessingException e) { + e.printStackTrace(); + Assert.fail("Error reading custom state"); + } + + // this should be a 'new CustomState' as nothing is currently stored in storage + Assert.assertEquals(customState, new CustomState()); + + // amend property and write to storage + customState.setCustomString("test"); + try { + botStateManager.Write(context, customState).join(); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("Could not write customstate"); + } + + // set customState to null before reading from storage + customState = null; + try { + customState = (CustomState) botStateManager.Read(context).join(); + } catch (JsonProcessingException e) { + e.printStackTrace(); + Assert.fail("Could not read customstate back"); + } + + // check object read from value has the correct value for CustomString + Assert.assertEquals(customState.getCustomString(), "test"); + } + ) + .StartTest(); + } + + +} + diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/CallCountingMiddleware.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/CallCountingMiddleware.java similarity index 95% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/CallCountingMiddleware.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/CallCountingMiddleware.java index b0dcf759..5b2f6786 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/CallCountingMiddleware.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/CallCountingMiddleware.java @@ -1,28 +1,28 @@ -package com.microsoft.bot.builder; - -public class CallCountingMiddleware implements Middleware { - private int calls = 0; - - public int calls() { - return this.calls; - } - - public CallCountingMiddleware withCalls(int calls) { - this.calls = calls; - return this; - } - - - @Override - public void OnTurn(TurnContext context, NextDelegate next) throws Exception { - this.calls++; - try { - next.next(); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(String.format("CallCountingMiddleWare: %s", e.toString())); - } - - - } -} +package com.microsoft.bot.builder; + +public class CallCountingMiddleware implements Middleware { + private int calls = 0; + + public int calls() { + return this.calls; + } + + public CallCountingMiddleware withCalls(int calls) { + this.calls = calls; + return this; + } + + + @Override + public void OnTurn(TurnContext context, NextDelegate next) throws Exception { + this.calls++; + try { + next.next(); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(String.format("CallCountingMiddleWare: %s", e.toString())); + } + + + } +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/CallMeMiddlware.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/CallMeMiddlware.java similarity index 95% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/CallMeMiddlware.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/CallMeMiddlware.java index ab54c61d..2f4b8fc3 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/CallMeMiddlware.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/CallMeMiddlware.java @@ -1,21 +1,21 @@ -package com.microsoft.bot.builder; - -public class CallMeMiddlware implements Middleware { - private ActionDel callMe; - - public CallMeMiddlware(ActionDel callme) { - this.callMe = callme; - } - - @Override - public void OnTurn(TurnContext context, NextDelegate next) throws Exception { - - this.callMe.CallMe(); - try { - next.next(); - } catch (Exception e) { - e.printStackTrace(); - - } - } -} +package com.microsoft.bot.builder; + +public class CallMeMiddlware implements Middleware { + private ActionDel callMe; + + public CallMeMiddlware(ActionDel callme) { + this.callMe = callme; + } + + @Override + public void OnTurn(TurnContext context, NextDelegate next) throws Exception { + + this.callMe.CallMe(); + try { + next.next(); + } catch (Exception e) { + e.printStackTrace(); + + } + } +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/CatchException_MiddlewareTest.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/CatchException_MiddlewareTest.java similarity index 97% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/CatchException_MiddlewareTest.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/CatchException_MiddlewareTest.java index 5618f000..16d3029f 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/CatchException_MiddlewareTest.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/CatchException_MiddlewareTest.java @@ -1,109 +1,109 @@ -package com.microsoft.bot.builder; - -import com.microsoft.bot.builder.adapters.TestAdapter; -import com.microsoft.bot.builder.adapters.TestFlow; -import com.microsoft.bot.schema.ActivityImpl; -import com.microsoft.bot.schema.models.Activity; -import org.junit.Assert; -import org.junit.Test; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; - -public class CatchException_MiddlewareTest { - - @Test - public void CatchException_TestMiddleware_TestStackedErrorMiddleware() throws ExecutionException, InterruptedException { - - TestAdapter adapter = new TestAdapter() - .Use(new CatchExceptionMiddleware(new CallOnException() { - @Override - public CompletableFuture apply(TurnContext context, T t) throws Exception { - return CompletableFuture.runAsync(() -> { - Activity activity = context.getActivity(); - if (activity instanceof ActivityImpl) { - try { - context.SendActivity(((ActivityImpl) activity).CreateReply(t.toString())); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(String.format("CatchException_TestMiddleware_TestStackedErrorMiddleware:SendActivity failed %s", e.toString())); - } - } else - Assert.assertTrue("Test was built for ActivityImpl", false); - - }); - - } - }, Exception.class)) - // Add middleware to catch NullReferenceExceptions before throwing up to the general exception instance - .Use(new CatchExceptionMiddleware(new CallOnException() { - @Override - public CompletableFuture apply(TurnContext context, T t) throws Exception { - context.SendActivity("Sorry - Null Reference Exception"); - return CompletableFuture.completedFuture(null); - } - }, NullPointerException.class)); - - - new TestFlow(adapter, (context) -> - { - - if (context.getActivity().text() == "foo") { - try { - context.SendActivity(context.getActivity().text()); - } catch (Exception e) { - e.printStackTrace(); - } - } - if (context.getActivity().text() == "UnsupportedOperationException") { - throw new UnsupportedOperationException("Test"); - } - - } - ) - .Send("foo") - .AssertReply("foo", "passthrough") - .Send("UnsupportedOperationException") - .AssertReply("Test") - .StartTest(); - - } - -/* @Test - // [TestCategory("Middleware")] - public void CatchException_TestMiddleware_SpecificExceptionType() -{ - TestAdapter adapter = new TestAdapter() - .Use(new CatchExceptionMiddleware((context, exception) => - { - context.SendActivity("Generic Exception Caught"); - return CompletableFuture.CompletedTask; - })) - .Use(new CatchExceptionMiddleware((context, exception) => - { - context.SendActivity(exception.Message); - return CompletableFuture.CompletedTask; - })); - - - await new TestFlow(adapter, (context) => - { - if (context.Activity.AsMessageActivity().Text == "foo") - { - context.SendActivity(context.Activity.AsMessageActivity().Text); - } - - if (context.Activity.AsMessageActivity().Text == "NullReferenceException") - { - throw new NullReferenceException("Test"); - } - - return CompletableFuture.CompletedTask; - }) - .Send("foo") - .AssertReply("foo", "passthrough") - .Send("NullReferenceException") - .AssertReply("Test") - .StartTest(); -}*/ -} +package com.microsoft.bot.builder; + +import com.microsoft.bot.builder.adapters.TestAdapter; +import com.microsoft.bot.builder.adapters.TestFlow; +import com.microsoft.bot.schema.ActivityImpl; +import com.microsoft.bot.schema.models.Activity; +import org.junit.Assert; +import org.junit.Test; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +public class CatchException_MiddlewareTest { + + @Test + public void CatchException_TestMiddleware_TestStackedErrorMiddleware() throws ExecutionException, InterruptedException { + + TestAdapter adapter = new TestAdapter() + .Use(new CatchExceptionMiddleware(new CallOnException() { + @Override + public CompletableFuture apply(TurnContext context, T t) throws Exception { + return CompletableFuture.runAsync(() -> { + Activity activity = context.getActivity(); + if (activity instanceof ActivityImpl) { + try { + context.SendActivity(((ActivityImpl) activity).CreateReply(t.toString())); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(String.format("CatchException_TestMiddleware_TestStackedErrorMiddleware:SendActivity failed %s", e.toString())); + } + } else + Assert.assertTrue("Test was built for ActivityImpl", false); + + }); + + } + }, Exception.class)) + // Add middleware to catch NullReferenceExceptions before throwing up to the general exception instance + .Use(new CatchExceptionMiddleware(new CallOnException() { + @Override + public CompletableFuture apply(TurnContext context, T t) throws Exception { + context.SendActivity("Sorry - Null Reference Exception"); + return CompletableFuture.completedFuture(null); + } + }, NullPointerException.class)); + + + new TestFlow(adapter, (context) -> + { + + if (context.getActivity().text() == "foo") { + try { + context.SendActivity(context.getActivity().text()); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (context.getActivity().text() == "UnsupportedOperationException") { + throw new UnsupportedOperationException("Test"); + } + + } + ) + .Send("foo") + .AssertReply("foo", "passthrough") + .Send("UnsupportedOperationException") + .AssertReply("Test") + .StartTest(); + + } + +/* @Test + // [TestCategory("Middleware")] + public void CatchException_TestMiddleware_SpecificExceptionType() +{ + TestAdapter adapter = new TestAdapter() + .Use(new CatchExceptionMiddleware((context, exception) => + { + context.SendActivity("Generic Exception Caught"); + return CompletableFuture.CompletedTask; + })) + .Use(new CatchExceptionMiddleware((context, exception) => + { + context.SendActivity(exception.Message); + return CompletableFuture.CompletedTask; + })); + + + await new TestFlow(adapter, (context) => + { + if (context.Activity.AsMessageActivity().Text == "foo") + { + context.SendActivity(context.Activity.AsMessageActivity().Text); + } + + if (context.Activity.AsMessageActivity().Text == "NullReferenceException") + { + throw new NullReferenceException("Test"); + } + + return CompletableFuture.CompletedTask; + }) + .Send("foo") + .AssertReply("foo", "passthrough") + .Send("NullReferenceException") + .AssertReply("Test") + .StartTest(); +}*/ +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/CustomKeyState.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/CustomKeyState.java similarity index 96% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/CustomKeyState.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/CustomKeyState.java index 335690c7..138079c3 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/CustomKeyState.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/CustomKeyState.java @@ -1,15 +1,15 @@ -package com.microsoft.bot.builder; - - -public class CustomKeyState extends BotState { - public static final String PropertyName = "Microsoft.Bot.Builder.Tests.CustomKeyState"; - - public CustomKeyState(Storage storage) { - super(storage, CustomKeyState.PropertyName, (context) -> "CustomKey", CustomState::new); - } - - public static CustomState Get(TurnContext context) { - return context.getServices().Get(PropertyName); - } -} - +package com.microsoft.bot.builder; + + +public class CustomKeyState extends BotState { + public static final String PropertyName = "Microsoft.Bot.Builder.Tests.CustomKeyState"; + + public CustomKeyState(Storage storage) { + super(storage, CustomKeyState.PropertyName, (context) -> "CustomKey", CustomState::new); + } + + public static CustomState Get(TurnContext context) { + return context.getServices().Get(PropertyName); + } +} + diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/CustomState.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/CustomState.java similarity index 94% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/CustomState.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/CustomState.java index f7825720..c169e56f 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/CustomState.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/CustomState.java @@ -1,29 +1,29 @@ -package com.microsoft.bot.builder; - -import com.microsoft.bot.builder.StoreItem; - -public class CustomState implements StoreItem - -{ - private String _customString; - - public String getCustomString() { - return _customString; - } - - public void setCustomString(String customString) { - this._customString = customString; - } - - private String _eTag; - - public String geteTag() - - { - return _eTag; - } - - public void seteTag(String eTag) { - this._eTag = eTag; - } -} +package com.microsoft.bot.builder; + +import com.microsoft.bot.builder.StoreItem; + +public class CustomState implements StoreItem + +{ + private String _customString; + + public String getCustomString() { + return _customString; + } + + public void setCustomString(String customString) { + this._customString = customString; + } + + private String _eTag; + + public String geteTag() + + { + return _eTag; + } + + public void seteTag(String eTag) { + this._eTag = eTag; + } +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/DictionaryStorage.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/DictionaryStorage.java similarity index 97% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/DictionaryStorage.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/DictionaryStorage.java index 697f4278..289ced22 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/DictionaryStorage.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/DictionaryStorage.java @@ -1,129 +1,129 @@ -package com.microsoft.bot.builder; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -import static java.util.concurrent.CompletableFuture.completedFuture; - -/** - * Models IStorage around a dictionary - */ -public class DictionaryStorage implements Storage { - private static ObjectMapper objectMapper; - - // TODO: Object needs to be defined - private final Map memory; - private final Object syncroot = new Object(); - private int _eTag = 0; - private final String typeNameForNonEntity = "__type_name_"; - - public DictionaryStorage() { - this(null); - } - public DictionaryStorage(Map dictionary ) { - DictionaryStorage.objectMapper = new ObjectMapper() - .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) - .findAndRegisterModules(); - this.memory = (dictionary != null) ? dictionary : new HashMap(); - } - - public CompletableFuture Delete(String[] keys) { - synchronized (this.syncroot) { - for (String key : keys) { - Object o = this.memory.get(key); - this.memory.remove(o); - } - } - return completedFuture(null); - } - - @Override - public CompletableFuture> Read(String[] keys) throws JsonProcessingException { - return CompletableFuture.supplyAsync(() -> { - Map storeItems = new HashMap(keys.length); - synchronized (this.syncroot) { - for (String key : keys) { - if (this.memory.containsKey(key)) { - Object state = this.memory.get(key); - if (state != null) { - try { - if (!(state instanceof JsonNode)) - throw new RuntimeException("DictionaryRead failed: entry not JsonNode"); - JsonNode stateNode = (JsonNode) state; - // Check if type info is set for the class - if (!(stateNode.hasNonNull(this.typeNameForNonEntity))) { - throw new RuntimeException(String.format("DictionaryRead failed: Type info not present")); - } - String clsName = stateNode.get(this.typeNameForNonEntity).textValue(); - - // Load the class info - Class cls; - try { - cls = Class.forName(clsName); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - throw new RuntimeException(String.format("DictionaryRead failed: Could not load class %s", clsName)); - } - - // Populate dictionary - storeItems.put(key,DictionaryStorage.objectMapper.treeToValue(stateNode, cls )); - } catch (JsonProcessingException e) { - e.printStackTrace(); - throw new RuntimeException(String.format("DictionaryRead failed: %s", e.toString())); - } - } - } - - } - } - - return storeItems; - }); - } - - @Override - public CompletableFuture Write(Map changes) throws Exception { - synchronized (this.syncroot) { - for (Map.Entry change : changes.entrySet()) { - Object newValue = change.getValue(); - - String oldStateETag = null; // default(string); - if (this.memory.containsValue(change.getKey())) { - Map oldState = (Map) this.memory.get(change.getKey()); - if (oldState.containsValue("eTag")) { - Map.Entry eTagToken = (Map.Entry) oldState.get("eTag"); - oldStateETag = (String) eTagToken.getValue(); - } - - } - // Dictionary stores Key:JsonNode (with type information held within the JsonNode) - JsonNode newState = DictionaryStorage.objectMapper.valueToTree(newValue); - ((ObjectNode)newState).put(this.typeNameForNonEntity, newValue.getClass().getTypeName()); - - // Set ETag if applicable - if (newValue instanceof StoreItem) { - StoreItem newStoreItem = (StoreItem) newValue; - if(oldStateETag != null && newStoreItem.geteTag() != "*" && - newStoreItem.geteTag() != oldStateETag) { - throw new Exception(String.format("Etag conflict.\r\n\r\nOriginal: %s\r\nCurrent: %s", - newStoreItem.geteTag(), oldStateETag)); - } - Integer newTag = _eTag++; - ((ObjectNode)newState).put("eTag", newTag.toString()); - } - - this.memory.put((String)change.getKey(), newState); - } - } - return completedFuture(null); - } - -} - +package com.microsoft.bot.builder; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +import static java.util.concurrent.CompletableFuture.completedFuture; + +/** + * Models IStorage around a dictionary + */ +public class DictionaryStorage implements Storage { + private static ObjectMapper objectMapper; + + // TODO: Object needs to be defined + private final Map memory; + private final Object syncroot = new Object(); + private int _eTag = 0; + private final String typeNameForNonEntity = "__type_name_"; + + public DictionaryStorage() { + this(null); + } + public DictionaryStorage(Map dictionary ) { + DictionaryStorage.objectMapper = new ObjectMapper() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .findAndRegisterModules(); + this.memory = (dictionary != null) ? dictionary : new HashMap(); + } + + public CompletableFuture Delete(String[] keys) { + synchronized (this.syncroot) { + for (String key : keys) { + Object o = this.memory.get(key); + this.memory.remove(o); + } + } + return completedFuture(null); + } + + @Override + public CompletableFuture> Read(String[] keys) throws JsonProcessingException { + return CompletableFuture.supplyAsync(() -> { + Map storeItems = new HashMap(keys.length); + synchronized (this.syncroot) { + for (String key : keys) { + if (this.memory.containsKey(key)) { + Object state = this.memory.get(key); + if (state != null) { + try { + if (!(state instanceof JsonNode)) + throw new RuntimeException("DictionaryRead failed: entry not JsonNode"); + JsonNode stateNode = (JsonNode) state; + // Check if type info is set for the class + if (!(stateNode.hasNonNull(this.typeNameForNonEntity))) { + throw new RuntimeException(String.format("DictionaryRead failed: Type info not present")); + } + String clsName = stateNode.get(this.typeNameForNonEntity).textValue(); + + // Load the class info + Class cls; + try { + cls = Class.forName(clsName); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + throw new RuntimeException(String.format("DictionaryRead failed: Could not load class %s", clsName)); + } + + // Populate dictionary + storeItems.put(key,DictionaryStorage.objectMapper.treeToValue(stateNode, cls )); + } catch (JsonProcessingException e) { + e.printStackTrace(); + throw new RuntimeException(String.format("DictionaryRead failed: %s", e.toString())); + } + } + } + + } + } + + return storeItems; + }); + } + + @Override + public CompletableFuture Write(Map changes) throws Exception { + synchronized (this.syncroot) { + for (Map.Entry change : changes.entrySet()) { + Object newValue = change.getValue(); + + String oldStateETag = null; // default(string); + if (this.memory.containsValue(change.getKey())) { + Map oldState = (Map) this.memory.get(change.getKey()); + if (oldState.containsValue("eTag")) { + Map.Entry eTagToken = (Map.Entry) oldState.get("eTag"); + oldStateETag = (String) eTagToken.getValue(); + } + + } + // Dictionary stores Key:JsonNode (with type information held within the JsonNode) + JsonNode newState = DictionaryStorage.objectMapper.valueToTree(newValue); + ((ObjectNode)newState).put(this.typeNameForNonEntity, newValue.getClass().getTypeName()); + + // Set ETag if applicable + if (newValue instanceof StoreItem) { + StoreItem newStoreItem = (StoreItem) newValue; + if(oldStateETag != null && newStoreItem.geteTag() != "*" && + newStoreItem.geteTag() != oldStateETag) { + throw new Exception(String.format("Etag conflict.\r\n\r\nOriginal: %s\r\nCurrent: %s", + newStoreItem.geteTag(), oldStateETag)); + } + Integer newTag = _eTag++; + ((ObjectNode)newState).put("eTag", newTag.toString()); + } + + this.memory.put((String)change.getKey(), newState); + } + } + return completedFuture(null); + } + +} + diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/DoNotCallNextMiddleware.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/DoNotCallNextMiddleware.java similarity index 96% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/DoNotCallNextMiddleware.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/DoNotCallNextMiddleware.java index a7938303..a680c09f 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/DoNotCallNextMiddleware.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/DoNotCallNextMiddleware.java @@ -1,14 +1,14 @@ -package com.microsoft.bot.builder; - -public class DoNotCallNextMiddleware implements Middleware { - private final ActionDel _callMe; - - public DoNotCallNextMiddleware(ActionDel callMe) { - _callMe = callMe; - } - - public void OnTurn(TurnContext context, NextDelegate next) { - _callMe.CallMe(); - // DO NOT call NEXT - } -} +package com.microsoft.bot.builder; + +public class DoNotCallNextMiddleware implements Middleware { + private final ActionDel _callMe; + + public DoNotCallNextMiddleware(ActionDel callMe) { + _callMe = callMe; + } + + public void OnTurn(TurnContext context, NextDelegate next) { + _callMe.CallMe(); + // DO NOT call NEXT + } +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/MemoryStorage.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/MemoryStorage.java similarity index 95% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/MemoryStorage.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/MemoryStorage.java index 40ca5811..403d90c9 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/MemoryStorage.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/MemoryStorage.java @@ -1,13 +1,13 @@ -package com.microsoft.bot.builder; - -import com.microsoft.bot.builder.DictionaryStorage; - -/** - * RamStorage stores data in volative dictionary - */ -public class MemoryStorage extends DictionaryStorage { - - public MemoryStorage() { - super(null); - } -} +package com.microsoft.bot.builder; + +import com.microsoft.bot.builder.DictionaryStorage; + +/** + * RamStorage stores data in volative dictionary + */ +public class MemoryStorage extends DictionaryStorage { + + public MemoryStorage() { + super(null); + } +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/MiddlewareSetTest.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/MiddlewareSetTest.java similarity index 97% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/MiddlewareSetTest.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/MiddlewareSetTest.java index 2c58b0d6..d289200d 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/MiddlewareSetTest.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/MiddlewareSetTest.java @@ -1,534 +1,534 @@ -package com.microsoft.bot.builder; - - -import com.microsoft.bot.builder.ActionDel; -import com.microsoft.bot.builder.base.TestBase; -import com.microsoft.bot.connector.implementation.ConnectorClientImpl; -import com.microsoft.bot.schema.models.ChannelAccount; -import com.microsoft.rest.RestClient; -import org.junit.Assert; -import org.junit.Test; - -import java.util.concurrent.ExecutionException; -import java.util.function.Consumer; - - -// [TestCategory("Russian Doll Middleware, Nested Middleware sets")] -public class MiddlewareSetTest extends TestBase -{ - protected ConnectorClientImpl connector; - protected ChannelAccount bot; - protected ChannelAccount user; - private boolean innerOnreceiveCalled; - - public MiddlewareSetTest() { - super(RunCondition.BOTH); - } - - @Override - protected void initializeClients(RestClient restClient, String botId, String userId) { - - connector = new ConnectorClientImpl(restClient); - bot = new ChannelAccount().withId(botId); - user = new ChannelAccount().withId(userId); - - // Test-specific stuff - innerOnreceiveCalled = false; - } - - @Override - protected void cleanUpResources() { - } - - - @Test - public void NoMiddleware() throws Exception { - MiddlewareSet m = new MiddlewareSet(); - // No middleware. Should not explode. - try { - m.ReceiveActivity(null); - Assert.assertTrue(true); - } catch (ExecutionException e) { - e.printStackTrace(); - Assert.fail("No exception expected" + e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - Assert.fail("No exception expected" + e.getMessage()); - } - } - - - @Test - public void NestedSet_OnReceive() throws Exception { - final boolean[] wasCalled = {false}; - MiddlewareSet inner = new MiddlewareSet(); - inner.Use(new AnonymousReceiveMiddleware(new MiddlewareCall() { - public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { - wasCalled[0] = true; - nd.next(); - } - })); - MiddlewareSet outer = new MiddlewareSet(); - outer.Use(inner); - try { - outer.ReceiveActivity(null); - } catch (ExecutionException e) { - Assert.fail(e.getMessage()); - return; - } catch (InterruptedException e) { - Assert.fail(e.getMessage()); - return; - } - - Assert.assertTrue("Inner Middleware Receive was not called.", wasCalled[0]); - } - - - @Test - public void NoMiddlewareWithDelegate() throws Exception { - MiddlewareSet m = new MiddlewareSet(); - final boolean wasCalled[] = {false}; - Consumer cb = context -> { - wasCalled[0] = true; - }; - // No middleware. Should not explode. - m.ReceiveActivityWithStatus(null, cb); - Assert.assertTrue("Delegate was not called", wasCalled[0]); - } - - @Test - public void OneMiddlewareItem() throws Exception { - WasCalledMiddlware simple = new WasCalledMiddlware(); - - final boolean wasCalled[] = {false}; - Consumer cb = context -> { - wasCalled[0] = true; - }; - - MiddlewareSet m = new MiddlewareSet(); - m.Use(simple); - - Assert.assertFalse(simple.getCalled()); - m.ReceiveActivityWithStatus(null, cb); - Assert.assertTrue(simple.getCalled()); - Assert.assertTrue( "Delegate was not called", wasCalled[0]); - } - - @Test - public void OneMiddlewareItemWithDelegate() throws Exception { - WasCalledMiddlware simple = new WasCalledMiddlware(); - - MiddlewareSet m = new MiddlewareSet(); - m.Use(simple); - - Assert.assertFalse(simple.getCalled()); - m.ReceiveActivity(null); - Assert.assertTrue(simple.getCalled()); - } - - @Test(expected = IllegalStateException.class) - //[ExpectedException(typeof(InvalidOperationException))] - public void BubbleUncaughtException() throws Exception { - MiddlewareSet m = new MiddlewareSet(); - m.Use(new AnonymousReceiveMiddleware(new MiddlewareCall() { - public void requestHandler(TurnContext tc, NextDelegate nd) throws IllegalStateException { - throw new IllegalStateException("test"); - }} - )); - - m.ReceiveActivity(null); - Assert.assertFalse("Should never have gotten here", true); - } - - @Test - public void TwoMiddlewareItems() throws Exception { - WasCalledMiddlware one = new WasCalledMiddlware(); - WasCalledMiddlware two = new WasCalledMiddlware(); - - MiddlewareSet m = new MiddlewareSet(); - m.Use(one); - m.Use(two); - - m.ReceiveActivity(null); - Assert.assertTrue(one.getCalled()); - Assert.assertTrue(two.getCalled()); - } - - @Test - public void TwoMiddlewareItemsWithDelegate() throws Exception { - WasCalledMiddlware one = new WasCalledMiddlware(); - WasCalledMiddlware two = new WasCalledMiddlware(); - - final int called[] = {0}; - Consumer cb = (context) -> { - called[0]++; - }; - - MiddlewareSet m = new MiddlewareSet(); - m.Use(one); - m.Use(two); - - m.ReceiveActivityWithStatus(null, cb); - Assert.assertTrue(one.getCalled()); - Assert.assertTrue(two.getCalled()); - Assert.assertTrue("Incorrect number of calls to Delegate", called[0] == 1 ); - } - - @Test - public void TwoMiddlewareItemsInOrder() throws Exception { - final boolean called1[] = {false}; - final boolean called2[] = {false}; - - CallMeMiddlware one = new CallMeMiddlware(new ActionDel() { - @Override - public void CallMe() { - Assert.assertFalse( "Second Middleware was called", called2[0]); - called1[0] = true; - } - }); - - CallMeMiddlware two = new CallMeMiddlware(new ActionDel() { - @Override - public void CallMe() { - Assert.assertTrue("First Middleware was not called", called1[0]); - called2[0] = true; - } - }); - - MiddlewareSet m = new MiddlewareSet(); - m.Use(one); - m.Use(two); - - m.ReceiveActivity(null); - Assert.assertTrue(called1[0]); - Assert.assertTrue(called2[0]); - } - - @Test - public void Status_OneMiddlewareRan() throws Exception { - final boolean called1[] = {false}; - - CallMeMiddlware one = new CallMeMiddlware(new ActionDel() { - @Override - public void CallMe() { - called1[0] = true; - } - }); - - MiddlewareSet m = new MiddlewareSet(); - m.Use(one); - - // The middlware in this pipeline calls next(), so the delegate should be called - final boolean didAllRun[] = {false}; - Consumer cb = (context) -> { - didAllRun[0] = true; - }; - m.ReceiveActivityWithStatus(null, cb); - - Assert.assertTrue(called1[0]); - Assert.assertTrue(didAllRun[0]); - } - - @Test - public void Status_RunAtEndEmptyPipeline() throws Exception { - MiddlewareSet m = new MiddlewareSet(); - final boolean didAllRun[] = {false}; - Consumer cb = (context)-> { - didAllRun[0] = true; - }; - - // This middlware pipeline has no entries. This should result in - // the status being TRUE. - m.ReceiveActivityWithStatus(null, cb); - Assert.assertTrue(didAllRun[0]); - - } - - @Test - public void Status_TwoItemsOneDoesNotCallNext() throws Exception { - final boolean called1[] = {false}; - final boolean called2[] = {false}; - - CallMeMiddlware one = new CallMeMiddlware(new ActionDel() { - @Override - public void CallMe() { - Assert.assertFalse("Second Middleware was called", called2[0]); - called1[0] = true; - } - }); - - DoNotCallNextMiddleware two = new DoNotCallNextMiddleware(new ActionDel() { - @Override - public void CallMe() { - Assert.assertTrue("First Middleware was not called", called1[0]); - called2[0] = true; - }}); - - MiddlewareSet m = new MiddlewareSet(); - m.Use(one); - m.Use(two); - - boolean didAllRun[] = {false}; - Consumer cb= (context) -> { - didAllRun[0] = true; - }; - m.ReceiveActivityWithStatus(null, cb); - Assert.assertTrue(called1[0]); - Assert.assertTrue(called2[0]); - - // The 2nd middleware did not call next, so the "final" action should not have run. - Assert.assertFalse(didAllRun[0]); - } - - @Test - public void Status_OneEntryThatDoesNotCallNext() throws Exception { - final boolean called1[] = {false}; - - DoNotCallNextMiddleware one = new DoNotCallNextMiddleware(new ActionDel() { - @Override - public void CallMe() { - called1[0] = true; - } - }); - - MiddlewareSet m = new MiddlewareSet(); - m.Use(one); - - // The middleware in this pipeline DOES NOT call next(), so this must not be called - boolean didAllRun[] = {false}; - Consumer cb = (context) -> { - didAllRun[0] = true; - }; - m.ReceiveActivityWithStatus(null, cb); - - Assert.assertTrue(called1[0]); - - // Our "Final" action MUST NOT have been called, as the Middlware Pipeline - // didn't complete. - Assert.assertFalse(didAllRun[0]); - } - - @Test - public void AnonymousMiddleware() throws Exception { - final boolean didRun[] = {false}; - - MiddlewareSet m = new MiddlewareSet(); - MiddlewareCall mwc = new MiddlewareCall() { - public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { - didRun[0] = true; - nd.next(); - return; - } - }; - m.Use(new AnonymousReceiveMiddleware(mwc)); - - Assert.assertFalse(didRun[0]); - m.ReceiveActivity(null); - Assert.assertTrue(didRun[0]); - } - - @Test - public void TwoAnonymousMiddleware() throws Exception { - final boolean didRun1[] = {false}; - final boolean didRun2[] = {false}; - - MiddlewareSet m = new MiddlewareSet(); - MiddlewareCall mwc1 = new MiddlewareCall() { - public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { - didRun1[0] = true; - nd.next(); - return; - } - }; - - m.Use(new AnonymousReceiveMiddleware(mwc1)); - MiddlewareCall mwc2 = new MiddlewareCall() { - public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { - didRun2[0] = true; - nd.next(); - return; - } - }; - - m.Use(new AnonymousReceiveMiddleware(mwc2)); - - m.ReceiveActivity(null); - Assert.assertTrue(didRun1[0]); - Assert.assertTrue(didRun2[0]); - } - - @Test - public void TwoAnonymousMiddlewareInOrder() throws Exception { - final boolean didRun1[] = {false}; - final boolean didRun2[] = {false}; - - MiddlewareSet m = new MiddlewareSet(); - MiddlewareCall mwc1 = new MiddlewareCall() { - public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { - Assert.assertFalse("Looks like the 2nd one has already run", didRun2[0]); - didRun1[0] = true; - nd.next(); - return; - } - }; - m.Use(new AnonymousReceiveMiddleware(mwc1)); - - MiddlewareCall mwc2 = new MiddlewareCall() { - public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { - Assert.assertTrue("Looks like the 1nd one has not yet run", didRun1[0]); - didRun2[0] = true; - nd.next(); - return ; - } - }; - - m.Use(new AnonymousReceiveMiddleware(mwc2)); - - m.ReceiveActivity(null); - Assert.assertTrue(didRun1[0]); - Assert.assertTrue(didRun2[0]); - } - - @Test - public void MixedMiddlewareInOrderAnonymousFirst() throws Exception { - final boolean didRun1[] = {false}; - final boolean didRun2[] = {false}; - - MiddlewareSet m = new MiddlewareSet(); - MiddlewareCall mwc1 = new MiddlewareCall() { - public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { - Assert.assertFalse("First middleware already ran", didRun1[0]); - Assert.assertFalse("Looks like the second middleware was already run", didRun2[0]); - didRun1[0] = true; - nd.next(); - Assert.assertTrue("Second middleware should have completed running", didRun2[0]); - return ; - } - }; - m.Use(new AnonymousReceiveMiddleware(mwc1)); - - ActionDel act = new ActionDel() { - @Override - public void CallMe() { - Assert.assertTrue("First middleware should have already been called", didRun1[0]); - Assert.assertFalse("Second middleware should not have been invoked yet", didRun2[0]); - didRun2[0] = true; - } - }; - m.Use(new CallMeMiddlware(act)); - - m.ReceiveActivity(null); - Assert.assertTrue(didRun1[0]); - Assert.assertTrue(didRun2[0]); - } - - @Test - public void MixedMiddlewareInOrderAnonymousLast() throws Exception { - final boolean didRun1[] = {false}; - final boolean didRun2[] = {false}; - - MiddlewareSet m = new MiddlewareSet(); - - ActionDel act = new ActionDel() { - @Override - public void CallMe() { - Assert.assertFalse("First middleware should not have already been called", didRun1[0]); - Assert.assertFalse("Second middleware should not have been invoked yet", didRun2[0]); - didRun1[0] = true; - } - }; - m.Use(new CallMeMiddlware(act)); - - MiddlewareCall mwc1 = new MiddlewareCall() { - public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { - Assert.assertTrue("First middleware has not been run yet", didRun1[0]); - didRun2[0] = true; - nd.next(); - return; - } - }; - m.Use(new AnonymousReceiveMiddleware(mwc1)); - - m.ReceiveActivity(null); - Assert.assertTrue(didRun1[0]); - Assert.assertTrue(didRun2[0]); - } - - @Test - public void RunCodeBeforeAndAfter() throws Exception { - final boolean didRun1[] = {false}; - final boolean codeafter2run[] = {false}; - final boolean didRun2[] = {false}; - - MiddlewareSet m = new MiddlewareSet(); - - MiddlewareCall mwc1 = new MiddlewareCall() { - public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { - Assert.assertFalse("Looks like the 1st middleware has already run", didRun1[0]); - didRun1[0] = true; - nd.next(); - Assert.assertTrue("The 2nd middleware should have run now.", didRun1[0]); - codeafter2run[0] = true; - return ; - } - }; - m.Use(new AnonymousReceiveMiddleware(mwc1)); - - MiddlewareCall mwc2 = new MiddlewareCall() { - public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { - Assert.assertTrue("Looks like the 1st middleware has not been run", didRun1[0]); - Assert.assertFalse("The code that runs after middleware 2 is complete has already run.", codeafter2run[0]); - didRun2[0] = true; - nd.next(); - return ; - } - }; - m.Use(new AnonymousReceiveMiddleware(mwc2)); - - m.ReceiveActivity(null); - Assert.assertTrue(didRun1[0]); - Assert.assertTrue(didRun2[0]); - Assert.assertTrue(codeafter2run[0]); - } - - @Test - public void CatchAnExceptionViaMiddlware() throws Exception { - MiddlewareSet m = new MiddlewareSet(); - final boolean caughtException[] = {false}; - - MiddlewareCall mwc1 = new MiddlewareCall() { - public void requestHandler(TurnContext tc, NextDelegate nd) throws ExecutionException, InterruptedException { - try { - nd.next(); - Assert.assertTrue("Should not get here", false); - - } - catch (InterruptedException ex) { - System.out.println("Here isi the exception message" + ex.getMessage()); - System.out.flush(); - Assert.assertTrue(ex.getMessage() == "test"); - - caughtException[0] = true; - } catch (Exception e) { - Assert.assertTrue("Should not get here" + e.getMessage(), false); - } - return ; - }}; - - m.Use(new AnonymousReceiveMiddleware(mwc1)); - - MiddlewareCall mwc2 = new MiddlewareCall() { - public void requestHandler(TurnContext tc, NextDelegate nd) throws InterruptedException { - throw new InterruptedException("test"); - } - }; - - m.Use(new AnonymousReceiveMiddleware(mwc2)); - - m.ReceiveActivity(null); - Assert.assertTrue(caughtException[0]); - } - - - -} +package com.microsoft.bot.builder; + + +import com.microsoft.bot.builder.ActionDel; +import com.microsoft.bot.builder.base.TestBase; +import com.microsoft.bot.connector.implementation.ConnectorClientImpl; +import com.microsoft.bot.schema.models.ChannelAccount; +import com.microsoft.rest.RestClient; +import org.junit.Assert; +import org.junit.Test; + +import java.util.concurrent.ExecutionException; +import java.util.function.Consumer; + + +// [TestCategory("Russian Doll Middleware, Nested Middleware sets")] +public class MiddlewareSetTest extends TestBase +{ + protected ConnectorClientImpl connector; + protected ChannelAccount bot; + protected ChannelAccount user; + private boolean innerOnreceiveCalled; + + public MiddlewareSetTest() { + super(RunCondition.BOTH); + } + + @Override + protected void initializeClients(RestClient restClient, String botId, String userId) { + + connector = new ConnectorClientImpl(restClient); + bot = new ChannelAccount().withId(botId); + user = new ChannelAccount().withId(userId); + + // Test-specific stuff + innerOnreceiveCalled = false; + } + + @Override + protected void cleanUpResources() { + } + + + @Test + public void NoMiddleware() throws Exception { + MiddlewareSet m = new MiddlewareSet(); + // No middleware. Should not explode. + try { + m.ReceiveActivity(null); + Assert.assertTrue(true); + } catch (ExecutionException e) { + e.printStackTrace(); + Assert.fail("No exception expected" + e.getMessage()); + } catch (InterruptedException e) { + e.printStackTrace(); + Assert.fail("No exception expected" + e.getMessage()); + } + } + + + @Test + public void NestedSet_OnReceive() throws Exception { + final boolean[] wasCalled = {false}; + MiddlewareSet inner = new MiddlewareSet(); + inner.Use(new AnonymousReceiveMiddleware(new MiddlewareCall() { + public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { + wasCalled[0] = true; + nd.next(); + } + })); + MiddlewareSet outer = new MiddlewareSet(); + outer.Use(inner); + try { + outer.ReceiveActivity(null); + } catch (ExecutionException e) { + Assert.fail(e.getMessage()); + return; + } catch (InterruptedException e) { + Assert.fail(e.getMessage()); + return; + } + + Assert.assertTrue("Inner Middleware Receive was not called.", wasCalled[0]); + } + + + @Test + public void NoMiddlewareWithDelegate() throws Exception { + MiddlewareSet m = new MiddlewareSet(); + final boolean wasCalled[] = {false}; + Consumer cb = context -> { + wasCalled[0] = true; + }; + // No middleware. Should not explode. + m.ReceiveActivityWithStatus(null, cb); + Assert.assertTrue("Delegate was not called", wasCalled[0]); + } + + @Test + public void OneMiddlewareItem() throws Exception { + WasCalledMiddlware simple = new WasCalledMiddlware(); + + final boolean wasCalled[] = {false}; + Consumer cb = context -> { + wasCalled[0] = true; + }; + + MiddlewareSet m = new MiddlewareSet(); + m.Use(simple); + + Assert.assertFalse(simple.getCalled()); + m.ReceiveActivityWithStatus(null, cb); + Assert.assertTrue(simple.getCalled()); + Assert.assertTrue( "Delegate was not called", wasCalled[0]); + } + + @Test + public void OneMiddlewareItemWithDelegate() throws Exception { + WasCalledMiddlware simple = new WasCalledMiddlware(); + + MiddlewareSet m = new MiddlewareSet(); + m.Use(simple); + + Assert.assertFalse(simple.getCalled()); + m.ReceiveActivity(null); + Assert.assertTrue(simple.getCalled()); + } + + @Test(expected = IllegalStateException.class) + //[ExpectedException(typeof(InvalidOperationException))] + public void BubbleUncaughtException() throws Exception { + MiddlewareSet m = new MiddlewareSet(); + m.Use(new AnonymousReceiveMiddleware(new MiddlewareCall() { + public void requestHandler(TurnContext tc, NextDelegate nd) throws IllegalStateException { + throw new IllegalStateException("test"); + }} + )); + + m.ReceiveActivity(null); + Assert.assertFalse("Should never have gotten here", true); + } + + @Test + public void TwoMiddlewareItems() throws Exception { + WasCalledMiddlware one = new WasCalledMiddlware(); + WasCalledMiddlware two = new WasCalledMiddlware(); + + MiddlewareSet m = new MiddlewareSet(); + m.Use(one); + m.Use(two); + + m.ReceiveActivity(null); + Assert.assertTrue(one.getCalled()); + Assert.assertTrue(two.getCalled()); + } + + @Test + public void TwoMiddlewareItemsWithDelegate() throws Exception { + WasCalledMiddlware one = new WasCalledMiddlware(); + WasCalledMiddlware two = new WasCalledMiddlware(); + + final int called[] = {0}; + Consumer cb = (context) -> { + called[0]++; + }; + + MiddlewareSet m = new MiddlewareSet(); + m.Use(one); + m.Use(two); + + m.ReceiveActivityWithStatus(null, cb); + Assert.assertTrue(one.getCalled()); + Assert.assertTrue(two.getCalled()); + Assert.assertTrue("Incorrect number of calls to Delegate", called[0] == 1 ); + } + + @Test + public void TwoMiddlewareItemsInOrder() throws Exception { + final boolean called1[] = {false}; + final boolean called2[] = {false}; + + CallMeMiddlware one = new CallMeMiddlware(new ActionDel() { + @Override + public void CallMe() { + Assert.assertFalse( "Second Middleware was called", called2[0]); + called1[0] = true; + } + }); + + CallMeMiddlware two = new CallMeMiddlware(new ActionDel() { + @Override + public void CallMe() { + Assert.assertTrue("First Middleware was not called", called1[0]); + called2[0] = true; + } + }); + + MiddlewareSet m = new MiddlewareSet(); + m.Use(one); + m.Use(two); + + m.ReceiveActivity(null); + Assert.assertTrue(called1[0]); + Assert.assertTrue(called2[0]); + } + + @Test + public void Status_OneMiddlewareRan() throws Exception { + final boolean called1[] = {false}; + + CallMeMiddlware one = new CallMeMiddlware(new ActionDel() { + @Override + public void CallMe() { + called1[0] = true; + } + }); + + MiddlewareSet m = new MiddlewareSet(); + m.Use(one); + + // The middlware in this pipeline calls next(), so the delegate should be called + final boolean didAllRun[] = {false}; + Consumer cb = (context) -> { + didAllRun[0] = true; + }; + m.ReceiveActivityWithStatus(null, cb); + + Assert.assertTrue(called1[0]); + Assert.assertTrue(didAllRun[0]); + } + + @Test + public void Status_RunAtEndEmptyPipeline() throws Exception { + MiddlewareSet m = new MiddlewareSet(); + final boolean didAllRun[] = {false}; + Consumer cb = (context)-> { + didAllRun[0] = true; + }; + + // This middlware pipeline has no entries. This should result in + // the status being TRUE. + m.ReceiveActivityWithStatus(null, cb); + Assert.assertTrue(didAllRun[0]); + + } + + @Test + public void Status_TwoItemsOneDoesNotCallNext() throws Exception { + final boolean called1[] = {false}; + final boolean called2[] = {false}; + + CallMeMiddlware one = new CallMeMiddlware(new ActionDel() { + @Override + public void CallMe() { + Assert.assertFalse("Second Middleware was called", called2[0]); + called1[0] = true; + } + }); + + DoNotCallNextMiddleware two = new DoNotCallNextMiddleware(new ActionDel() { + @Override + public void CallMe() { + Assert.assertTrue("First Middleware was not called", called1[0]); + called2[0] = true; + }}); + + MiddlewareSet m = new MiddlewareSet(); + m.Use(one); + m.Use(two); + + boolean didAllRun[] = {false}; + Consumer cb= (context) -> { + didAllRun[0] = true; + }; + m.ReceiveActivityWithStatus(null, cb); + Assert.assertTrue(called1[0]); + Assert.assertTrue(called2[0]); + + // The 2nd middleware did not call next, so the "final" action should not have run. + Assert.assertFalse(didAllRun[0]); + } + + @Test + public void Status_OneEntryThatDoesNotCallNext() throws Exception { + final boolean called1[] = {false}; + + DoNotCallNextMiddleware one = new DoNotCallNextMiddleware(new ActionDel() { + @Override + public void CallMe() { + called1[0] = true; + } + }); + + MiddlewareSet m = new MiddlewareSet(); + m.Use(one); + + // The middleware in this pipeline DOES NOT call next(), so this must not be called + boolean didAllRun[] = {false}; + Consumer cb = (context) -> { + didAllRun[0] = true; + }; + m.ReceiveActivityWithStatus(null, cb); + + Assert.assertTrue(called1[0]); + + // Our "Final" action MUST NOT have been called, as the Middlware Pipeline + // didn't complete. + Assert.assertFalse(didAllRun[0]); + } + + @Test + public void AnonymousMiddleware() throws Exception { + final boolean didRun[] = {false}; + + MiddlewareSet m = new MiddlewareSet(); + MiddlewareCall mwc = new MiddlewareCall() { + public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { + didRun[0] = true; + nd.next(); + return; + } + }; + m.Use(new AnonymousReceiveMiddleware(mwc)); + + Assert.assertFalse(didRun[0]); + m.ReceiveActivity(null); + Assert.assertTrue(didRun[0]); + } + + @Test + public void TwoAnonymousMiddleware() throws Exception { + final boolean didRun1[] = {false}; + final boolean didRun2[] = {false}; + + MiddlewareSet m = new MiddlewareSet(); + MiddlewareCall mwc1 = new MiddlewareCall() { + public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { + didRun1[0] = true; + nd.next(); + return; + } + }; + + m.Use(new AnonymousReceiveMiddleware(mwc1)); + MiddlewareCall mwc2 = new MiddlewareCall() { + public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { + didRun2[0] = true; + nd.next(); + return; + } + }; + + m.Use(new AnonymousReceiveMiddleware(mwc2)); + + m.ReceiveActivity(null); + Assert.assertTrue(didRun1[0]); + Assert.assertTrue(didRun2[0]); + } + + @Test + public void TwoAnonymousMiddlewareInOrder() throws Exception { + final boolean didRun1[] = {false}; + final boolean didRun2[] = {false}; + + MiddlewareSet m = new MiddlewareSet(); + MiddlewareCall mwc1 = new MiddlewareCall() { + public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { + Assert.assertFalse("Looks like the 2nd one has already run", didRun2[0]); + didRun1[0] = true; + nd.next(); + return; + } + }; + m.Use(new AnonymousReceiveMiddleware(mwc1)); + + MiddlewareCall mwc2 = new MiddlewareCall() { + public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { + Assert.assertTrue("Looks like the 1nd one has not yet run", didRun1[0]); + didRun2[0] = true; + nd.next(); + return ; + } + }; + + m.Use(new AnonymousReceiveMiddleware(mwc2)); + + m.ReceiveActivity(null); + Assert.assertTrue(didRun1[0]); + Assert.assertTrue(didRun2[0]); + } + + @Test + public void MixedMiddlewareInOrderAnonymousFirst() throws Exception { + final boolean didRun1[] = {false}; + final boolean didRun2[] = {false}; + + MiddlewareSet m = new MiddlewareSet(); + MiddlewareCall mwc1 = new MiddlewareCall() { + public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { + Assert.assertFalse("First middleware already ran", didRun1[0]); + Assert.assertFalse("Looks like the second middleware was already run", didRun2[0]); + didRun1[0] = true; + nd.next(); + Assert.assertTrue("Second middleware should have completed running", didRun2[0]); + return ; + } + }; + m.Use(new AnonymousReceiveMiddleware(mwc1)); + + ActionDel act = new ActionDel() { + @Override + public void CallMe() { + Assert.assertTrue("First middleware should have already been called", didRun1[0]); + Assert.assertFalse("Second middleware should not have been invoked yet", didRun2[0]); + didRun2[0] = true; + } + }; + m.Use(new CallMeMiddlware(act)); + + m.ReceiveActivity(null); + Assert.assertTrue(didRun1[0]); + Assert.assertTrue(didRun2[0]); + } + + @Test + public void MixedMiddlewareInOrderAnonymousLast() throws Exception { + final boolean didRun1[] = {false}; + final boolean didRun2[] = {false}; + + MiddlewareSet m = new MiddlewareSet(); + + ActionDel act = new ActionDel() { + @Override + public void CallMe() { + Assert.assertFalse("First middleware should not have already been called", didRun1[0]); + Assert.assertFalse("Second middleware should not have been invoked yet", didRun2[0]); + didRun1[0] = true; + } + }; + m.Use(new CallMeMiddlware(act)); + + MiddlewareCall mwc1 = new MiddlewareCall() { + public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { + Assert.assertTrue("First middleware has not been run yet", didRun1[0]); + didRun2[0] = true; + nd.next(); + return; + } + }; + m.Use(new AnonymousReceiveMiddleware(mwc1)); + + m.ReceiveActivity(null); + Assert.assertTrue(didRun1[0]); + Assert.assertTrue(didRun2[0]); + } + + @Test + public void RunCodeBeforeAndAfter() throws Exception { + final boolean didRun1[] = {false}; + final boolean codeafter2run[] = {false}; + final boolean didRun2[] = {false}; + + MiddlewareSet m = new MiddlewareSet(); + + MiddlewareCall mwc1 = new MiddlewareCall() { + public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { + Assert.assertFalse("Looks like the 1st middleware has already run", didRun1[0]); + didRun1[0] = true; + nd.next(); + Assert.assertTrue("The 2nd middleware should have run now.", didRun1[0]); + codeafter2run[0] = true; + return ; + } + }; + m.Use(new AnonymousReceiveMiddleware(mwc1)); + + MiddlewareCall mwc2 = new MiddlewareCall() { + public void requestHandler(TurnContext tc, NextDelegate nd) throws Exception { + Assert.assertTrue("Looks like the 1st middleware has not been run", didRun1[0]); + Assert.assertFalse("The code that runs after middleware 2 is complete has already run.", codeafter2run[0]); + didRun2[0] = true; + nd.next(); + return ; + } + }; + m.Use(new AnonymousReceiveMiddleware(mwc2)); + + m.ReceiveActivity(null); + Assert.assertTrue(didRun1[0]); + Assert.assertTrue(didRun2[0]); + Assert.assertTrue(codeafter2run[0]); + } + + @Test + public void CatchAnExceptionViaMiddlware() throws Exception { + MiddlewareSet m = new MiddlewareSet(); + final boolean caughtException[] = {false}; + + MiddlewareCall mwc1 = new MiddlewareCall() { + public void requestHandler(TurnContext tc, NextDelegate nd) throws ExecutionException, InterruptedException { + try { + nd.next(); + Assert.assertTrue("Should not get here", false); + + } + catch (InterruptedException ex) { + System.out.println("Here isi the exception message" + ex.getMessage()); + System.out.flush(); + Assert.assertTrue(ex.getMessage() == "test"); + + caughtException[0] = true; + } catch (Exception e) { + Assert.assertTrue("Should not get here" + e.getMessage(), false); + } + return ; + }}; + + m.Use(new AnonymousReceiveMiddleware(mwc1)); + + MiddlewareCall mwc2 = new MiddlewareCall() { + public void requestHandler(TurnContext tc, NextDelegate nd) throws InterruptedException { + throw new InterruptedException("test"); + } + }; + + m.Use(new AnonymousReceiveMiddleware(mwc2)); + + m.ReceiveActivity(null); + Assert.assertTrue(caughtException[0]); + } + + + +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/SimpleAdapter.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/SimpleAdapter.java similarity index 97% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/SimpleAdapter.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/SimpleAdapter.java index b6574ac5..d2c339f3 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/SimpleAdapter.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/SimpleAdapter.java @@ -1,90 +1,90 @@ -package com.microsoft.bot.builder; - -import com.microsoft.bot.schema.ActivityImpl; -import com.microsoft.bot.schema.models.Activity; -import com.microsoft.bot.schema.models.ConversationReference; -import com.microsoft.bot.schema.models.ResourceResponse; -import org.junit.Assert; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.function.Consumer; - -public class SimpleAdapter extends BotAdapter { - private Consumer callOnSend = null; - private Consumer callOnUpdate = null; - private Consumer callOnDelete = null; - - // Callback Function but doesn't need to be. Avoid java legacy type erasure - public SimpleAdapter(Consumer callOnSend) { - this(callOnSend, null, null); - } - - public SimpleAdapter(Consumer callOnSend, Consumer callOnUpdate) { - this(callOnSend, callOnUpdate, null); - } - - public SimpleAdapter(Consumer callOnSend, Consumer callOnUpdate, Consumer callOnDelete) { - this.callOnSend = callOnSend; - this.callOnUpdate = callOnUpdate; - this.callOnDelete = callOnDelete; - } - - public SimpleAdapter() { - - } - - - @Override - public ResourceResponse[] SendActivities(TurnContext context, Activity[] activities) throws InterruptedException { - Assert.assertNotNull("SimpleAdapter.deleteActivity: missing reference", activities); - Assert.assertTrue("SimpleAdapter.sendActivities: empty activities array.", activities.length > 0); - - if (this.callOnSend != null) - this.callOnSend.accept(activities); - - List responses = new ArrayList(); - for (Activity activity : activities) { - responses.add(new ResourceResponse().withId(activity.id())); - } - ResourceResponse[] result = new ResourceResponse[responses.size()]; - return responses.toArray(result); - - - } - - @Override - public ResourceResponse UpdateActivity(TurnContext context, Activity activity) { - - Assert.assertNotNull("SimpleAdapter.updateActivity: missing activity", activity); - if (this.callOnUpdate != null) - this.callOnUpdate.accept(activity); - return new ResourceResponse() - .withId(activity.id()); - - - } - - @Override - public void DeleteActivity(TurnContext context, ConversationReference reference) throws ExecutionException, InterruptedException { - Assert.assertNotNull("SimpleAdapter.deleteActivity: missing reference", reference); - if (callOnDelete != null) - this.callOnDelete.accept(reference); - - - } - - - public void ProcessRequest(ActivityImpl activty, Consumer callback) throws Exception { - - try (TurnContextImpl ctx = new TurnContextImpl(this, activty)) { - this.RunPipeline(ctx, callback); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(String.format("Error running pipeline: %s", e.toString())); - } - - } -} - +package com.microsoft.bot.builder; + +import com.microsoft.bot.schema.ActivityImpl; +import com.microsoft.bot.schema.models.Activity; +import com.microsoft.bot.schema.models.ConversationReference; +import com.microsoft.bot.schema.models.ResourceResponse; +import org.junit.Assert; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.function.Consumer; + +public class SimpleAdapter extends BotAdapter { + private Consumer callOnSend = null; + private Consumer callOnUpdate = null; + private Consumer callOnDelete = null; + + // Callback Function but doesn't need to be. Avoid java legacy type erasure + public SimpleAdapter(Consumer callOnSend) { + this(callOnSend, null, null); + } + + public SimpleAdapter(Consumer callOnSend, Consumer callOnUpdate) { + this(callOnSend, callOnUpdate, null); + } + + public SimpleAdapter(Consumer callOnSend, Consumer callOnUpdate, Consumer callOnDelete) { + this.callOnSend = callOnSend; + this.callOnUpdate = callOnUpdate; + this.callOnDelete = callOnDelete; + } + + public SimpleAdapter() { + + } + + + @Override + public ResourceResponse[] SendActivities(TurnContext context, Activity[] activities) throws InterruptedException { + Assert.assertNotNull("SimpleAdapter.deleteActivity: missing reference", activities); + Assert.assertTrue("SimpleAdapter.sendActivities: empty activities array.", activities.length > 0); + + if (this.callOnSend != null) + this.callOnSend.accept(activities); + + List responses = new ArrayList(); + for (Activity activity : activities) { + responses.add(new ResourceResponse().withId(activity.id())); + } + ResourceResponse[] result = new ResourceResponse[responses.size()]; + return responses.toArray(result); + + + } + + @Override + public ResourceResponse UpdateActivity(TurnContext context, Activity activity) { + + Assert.assertNotNull("SimpleAdapter.updateActivity: missing activity", activity); + if (this.callOnUpdate != null) + this.callOnUpdate.accept(activity); + return new ResourceResponse() + .withId(activity.id()); + + + } + + @Override + public void DeleteActivity(TurnContext context, ConversationReference reference) throws ExecutionException, InterruptedException { + Assert.assertNotNull("SimpleAdapter.deleteActivity: missing reference", reference); + if (callOnDelete != null) + this.callOnDelete.accept(reference); + + + } + + + public void ProcessRequest(ActivityImpl activty, Consumer callback) throws Exception { + + try (TurnContextImpl ctx = new TurnContextImpl(this, activty)) { + this.RunPipeline(ctx, callback); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(String.format("Error running pipeline: %s", e.toString())); + } + + } +} + diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/StateSettings.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/StateSettings.java similarity index 96% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/StateSettings.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/StateSettings.java index a3382d4f..d54f58b4 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/StateSettings.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/StateSettings.java @@ -1,15 +1,15 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.microsoft.bot.builder; - -public class StateSettings -{ - private boolean lastWriterWins = true; - public boolean getLastWriterWins() { - return this.lastWriterWins; - } - public void setLast(boolean lastWriterWins) { - this.lastWriterWins = lastWriterWins; - } -} +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.microsoft.bot.builder; + +public class StateSettings +{ + private boolean lastWriterWins = true; + public boolean getLastWriterWins() { + return this.lastWriterWins; + } + public void setLast(boolean lastWriterWins) { + this.lastWriterWins = lastWriterWins; + } +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TestMessage.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TestMessage.java similarity index 97% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TestMessage.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TestMessage.java index 4b10b9c7..94f3fb0e 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TestMessage.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TestMessage.java @@ -1,32 +1,32 @@ -package com.microsoft.bot.builder; - -import com.microsoft.bot.schema.ActivityImpl; -import com.microsoft.bot.schema.models.ActivityTypes; -import com.microsoft.bot.schema.models.ChannelAccount; -import com.microsoft.bot.schema.models.ConversationAccount; - -public class TestMessage { - public static ActivityImpl Message() { - return TestMessage.Message("1234"); - } - - public static ActivityImpl Message(String id) { - ActivityImpl a = new ActivityImpl() - .withType(ActivityTypes.MESSAGE) - .withId(id) - .withText("test") - .withFrom(new ChannelAccount() - .withId("user") - .withName("User Name")) - .withRecipient(new ChannelAccount() - .withId("bot") - .withName("Bot Name")) - .withConversation(new ConversationAccount() - .withId("convo") - .withName("Convo Name")) - .withChannelId("UnitTest") - .withServiceUrl("https://example.org"); - return a; - } - -} +package com.microsoft.bot.builder; + +import com.microsoft.bot.schema.ActivityImpl; +import com.microsoft.bot.schema.models.ActivityTypes; +import com.microsoft.bot.schema.models.ChannelAccount; +import com.microsoft.bot.schema.models.ConversationAccount; + +public class TestMessage { + public static ActivityImpl Message() { + return TestMessage.Message("1234"); + } + + public static ActivityImpl Message(String id) { + ActivityImpl a = new ActivityImpl() + .withType(ActivityTypes.MESSAGE) + .withId(id) + .withText("test") + .withFrom(new ChannelAccount() + .withId("user") + .withName("User Name")) + .withRecipient(new ChannelAccount() + .withId("bot") + .withName("Bot Name")) + .withConversation(new ConversationAccount() + .withId("convo") + .withName("Convo Name")) + .withChannelId("UnitTest") + .withServiceUrl("https://example.org"); + return a; + } + +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TestPocoState.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TestPocoState.java similarity index 94% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TestPocoState.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TestPocoState.java index 3064a934..324c70ba 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TestPocoState.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TestPocoState.java @@ -1,14 +1,14 @@ -package com.microsoft.bot.builder; - - -public class TestPocoState -{ - private String value; - public String getValue() { - return this.value; - } - public void setValue(String value) { - this.value = value; - } -} - +package com.microsoft.bot.builder; + + +public class TestPocoState +{ + private String value; + public String getValue() { + return this.value; + } + public void setValue(String value) { + this.value = value; + } +} + diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TestState.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TestState.java similarity index 94% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TestState.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TestState.java index 7f62c3c1..0238dd5a 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TestState.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TestState.java @@ -1,28 +1,28 @@ -package com.microsoft.bot.builder; - -import com.microsoft.bot.builder.StoreItem; - -public class TestState implements StoreItem { - private String etag; - - @Override - public String geteTag() { - return this.etag; - } - - @Override - public void seteTag(String etag) { - this.etag = etag; - } - - private String value; - - public String value() { - return this.value; - } - - public void withValue(String value) { - this.value = value; - } -} - +package com.microsoft.bot.builder; + +import com.microsoft.bot.builder.StoreItem; + +public class TestState implements StoreItem { + private String etag; + + @Override + public String geteTag() { + return this.etag; + } + + @Override + public void seteTag(String etag) { + this.etag = etag; + } + + private String value; + + public String value() { + return this.value; + } + + public void withValue(String value) { + this.value = value; + } +} + diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TranscriptMiddlewareTest.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TranscriptMiddlewareTest.java similarity index 97% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TranscriptMiddlewareTest.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TranscriptMiddlewareTest.java index 080b1ccd..e9cbb3ec 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TranscriptMiddlewareTest.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TranscriptMiddlewareTest.java @@ -1,267 +1,267 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.microsoft.bot.builder; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.joda.JodaModule; -import com.microsoft.bot.builder.adapters.TestAdapter; -import com.microsoft.bot.builder.adapters.TestFlow; -import com.microsoft.bot.builder.dialogs.Dialog; -import com.microsoft.bot.schema.ActivityImpl; -import com.microsoft.bot.schema.models.*; -import org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.junit.Assert; -import org.junit.Test; - -import java.util.concurrent.ExecutionException; - - -public class TranscriptMiddlewareTest { - - @Test - public final void Transcript_SimpleReceive() throws Exception { - MemoryTranscriptStore transcriptStore = new MemoryTranscriptStore(); - TestAdapter adapter = (new TestAdapter()).Use(new TranscriptLoggerMiddleware(transcriptStore)); - final String[] conversationId = {null}; - - - new TestFlow(adapter, (ctxt) -> - { - - TurnContextImpl context = (TurnContextImpl) ctxt; - conversationId[0] = context.getActivity().conversation().id(); - ActivityImpl typingActivity = new ActivityImpl() - .withType(ActivityTypes.TYPING) - .withRelatesTo(context.getActivity().relatesTo()); - try { - ResourceResponse response = context.SendActivity(typingActivity); - System.out.printf("Here's the response:"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(); - } - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - Assert.fail(); - } - try { - context.SendActivity("echo:" + context.getActivity().text()); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(); - } - - }).Send("foo") - .AssertReply((activity) -> { - Assert.assertEquals(activity.type(), ActivityTypes.TYPING); - return null; - }).StartTest(); - //.AssertReply("echo:foo").StartTest(); - - - } - - @Test - public final void Transcript_MiddlewareTest() throws Exception { - MemoryTranscriptStore transcriptStore = new MemoryTranscriptStore(); - TranscriptLoggerMiddleware logger = new TranscriptLoggerMiddleware(transcriptStore); - TestAdapter adapter = new TestAdapter(); - ActivityImpl activity = ActivityImpl.CreateMessageActivity() - .withFrom(new ChannelAccount().withName("MyAccount").withId("acctid").withRole(RoleTypes.USER)); - TurnContextImpl context = new TurnContextImpl(adapter, activity); - NextDelegate nd = new NextDelegate() { - @Override - public void next() throws Exception { - System.out.printf("Delegate called!"); - System.out.flush(); - return ; - } - }; - ActivityImpl typingActivity = new ActivityImpl() - .withType(ActivityTypes.TYPING) - .withRelatesTo(context.getActivity().relatesTo()); - try { - context.SendActivity(typingActivity); - System.out.printf("HI"); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(); - } - - - //logger.OnTurn(context, nd).get(); - } - - @Test - public final void Transcript_LogActivities() throws ExecutionException, InterruptedException { - Logger logger = LogManager.getLogger(Dialog.class); - MemoryTranscriptStore transcriptStore = new MemoryTranscriptStore(); - TestAdapter adapter = (new TestAdapter()).Use(new TranscriptLoggerMiddleware(transcriptStore)); - final String[] conversationId = {null}; - - - String result = new TestFlow(adapter, (context) -> - { - - //TurnContextImpl context = (TurnContextImpl) ctxt; - conversationId[0] = context.getActivity().conversation().id(); - ActivityImpl typingActivity = new ActivityImpl() - .withType(ActivityTypes.TYPING) - .withRelatesTo(context.getActivity().relatesTo()); - try { - context.SendActivity((Activity)typingActivity); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(); - } - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - Assert.fail(); - } - try { - context.SendActivity("echo:" + context.getActivity().text()); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(); - } - }).Send("foo") - .AssertReply((activity) -> { - Assert.assertEquals(activity.type(), ActivityTypes.TYPING); - return null; - }) - .AssertReply("echo:foo") - .Send("bar") - .AssertReply((activity) -> { - Assert.assertEquals(activity.type(), ActivityTypes.TYPING); - return null; - }) - .AssertReply("echo:bar") - .StartTest(); - - - PagedResult pagedResult = transcriptStore.GetTranscriptActivitiesAsync("test", conversationId[0]).join(); - Assert.assertEquals(6, pagedResult.getItems().length); - Assert.assertEquals( "foo", ((Activity)pagedResult.getItems()[0]).text()); - Assert.assertNotEquals(((Activity)pagedResult.getItems()[1]), null); - Assert.assertEquals("echo:foo", ((Activity) pagedResult.getItems()[2]).text()); - Assert.assertEquals("bar", ((Activity)pagedResult.getItems()[3]).text()); - - Assert.assertTrue(pagedResult.getItems()[4] != null); - Assert.assertEquals("echo:bar", ((Activity)pagedResult.getItems()[5]).text()); - for (Object activity : pagedResult.getItems()) - { - Assert.assertFalse(StringUtils.isBlank(((Activity) activity).id())); - Assert.assertTrue(((Activity)activity).timestamp().isAfter(Long.MIN_VALUE)); - } - System.out.printf("Complete"); - } - - @Test - public void Transcript_LogUpdateActivities() throws InterruptedException, ExecutionException { - MemoryTranscriptStore transcriptStore = new MemoryTranscriptStore(); - TestAdapter adapter = (new TestAdapter()).Use(new TranscriptLoggerMiddleware(transcriptStore)); - final String[] conversationId = {null}; - final Activity[] activityToUpdate = {null}; - ObjectMapper mapper = new ObjectMapper(); - mapper.registerModule(new JodaModule()); - new TestFlow(adapter, (context) -> - { - - conversationId[0] = context.getActivity().conversation().id(); - if (context.getActivity().text().equals("update")) { - activityToUpdate[0].withText("new response"); - try { - context.UpdateActivity(activityToUpdate[0]); - } catch (Exception e) { - e.printStackTrace(); - } - } else { - ActivityImpl activity = ((ActivityImpl) context.getActivity()).CreateReply("response"); - ResourceResponse response = null; - try { - response = context.SendActivity(activity); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(); - } - activity.withId(response.id()); - - // clone the activity, so we can use it to do an update - activityToUpdate[0] = ActivityImpl.CloneActity(activity); - //JsonConvert.DeserializeObject(JsonConvert.SerializeObject(activity)); - } - }).Send("foo") - .Send("update") - .AssertReply("new response") - .StartTest(); - Thread.sleep(500); - PagedResult pagedResult = transcriptStore.GetTranscriptActivitiesAsync("test", conversationId[0]).join(); - Assert.assertEquals(4, pagedResult.getItems().length); - Assert.assertEquals("foo", ((Activity)pagedResult.getItems()[0]).text()); - Assert.assertEquals( "response", ((Activity)pagedResult.getItems()[1]).text()); - // TODO: Fix the following 3 asserts so they work correctly. They succeed in the travis builds and fail in the - // BotBuilder-Java 4.0 master build. - //Assert.assertEquals( "new response", ((Activity)pagedResult.getItems()[2]).text()); - //Assert.assertEquals("update", ((Activity)pagedResult.getItems()[3]).text()); - //Assert.assertEquals( ((Activity)pagedResult.getItems()[1]).id(), ((Activity) pagedResult.getItems()[2]).id()); - } - - @Test - public final void Transcript_LogDeleteActivities() throws InterruptedException, ExecutionException { - MemoryTranscriptStore transcriptStore = new MemoryTranscriptStore(); - TestAdapter adapter = (new TestAdapter()).Use(new TranscriptLoggerMiddleware(transcriptStore)); - final String[] conversationId = {null}; - final String[] activityId = {null}; - new TestFlow(adapter, (context) -> - { - - conversationId[0] = context.getActivity().conversation().id(); - if (context.getActivity().text().equals("deleteIt")) { - try { - context.DeleteActivity(activityId[0]).join(); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(); - } - } else { - ActivityImpl activity = ((ActivityImpl) context.getActivity()).CreateReply("response"); - ResourceResponse response = null; - try { - response = context.SendActivity(activity); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(); - } - activityId[0] = response.id(); - } - - - }).Send("foo") - .AssertReply("response") - .Send("deleteIt") - .StartTest(); - Thread.sleep(1500); - PagedResult pagedResult = transcriptStore.GetTranscriptActivitiesAsync("test", conversationId[0]).join(); - for (Object act : pagedResult.getItems()) { - System.out.printf("Here is the object: %s : Type: %s\n", act.getClass().getTypeName(), ((Activity)act).type()); - } - - for (Object activity : pagedResult.getItems() ) { - System.out.printf("Recipient: %s\nText: %s\n", ((Activity) activity).recipient().name(), ((Activity)activity).text()); - } - Assert.assertEquals(4, pagedResult.getItems().length); - Assert.assertEquals("foo", ((Activity)pagedResult.getItems()[0]).text()); - Assert.assertEquals("response", ((Activity)pagedResult.getItems()[1]).text()); - Assert.assertEquals("deleteIt", ((Activity)pagedResult.getItems()[2]).text()); - Assert.assertEquals(ActivityTypes.MESSAGE_DELETE, ((Activity)pagedResult.getItems()[3]).type()); - Assert.assertEquals(((Activity)pagedResult.getItems()[1]).id(), ((Activity) pagedResult.getItems()[3]).id()); - } -} - +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.microsoft.bot.builder; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.joda.JodaModule; +import com.microsoft.bot.builder.adapters.TestAdapter; +import com.microsoft.bot.builder.adapters.TestFlow; +import com.microsoft.bot.builder.dialogs.Dialog; +import com.microsoft.bot.schema.ActivityImpl; +import com.microsoft.bot.schema.models.*; +import org.apache.commons.lang3.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.junit.Assert; +import org.junit.Test; + +import java.util.concurrent.ExecutionException; + + +public class TranscriptMiddlewareTest { + + @Test + public final void Transcript_SimpleReceive() throws Exception { + MemoryTranscriptStore transcriptStore = new MemoryTranscriptStore(); + TestAdapter adapter = (new TestAdapter()).Use(new TranscriptLoggerMiddleware(transcriptStore)); + final String[] conversationId = {null}; + + + new TestFlow(adapter, (ctxt) -> + { + + TurnContextImpl context = (TurnContextImpl) ctxt; + conversationId[0] = context.getActivity().conversation().id(); + ActivityImpl typingActivity = new ActivityImpl() + .withType(ActivityTypes.TYPING) + .withRelatesTo(context.getActivity().relatesTo()); + try { + ResourceResponse response = context.SendActivity(typingActivity); + System.out.printf("Here's the response:"); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(); + } + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + Assert.fail(); + } + try { + context.SendActivity("echo:" + context.getActivity().text()); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(); + } + + }).Send("foo") + .AssertReply((activity) -> { + Assert.assertEquals(activity.type(), ActivityTypes.TYPING); + return null; + }).StartTest(); + //.AssertReply("echo:foo").StartTest(); + + + } + + @Test + public final void Transcript_MiddlewareTest() throws Exception { + MemoryTranscriptStore transcriptStore = new MemoryTranscriptStore(); + TranscriptLoggerMiddleware logger = new TranscriptLoggerMiddleware(transcriptStore); + TestAdapter adapter = new TestAdapter(); + ActivityImpl activity = ActivityImpl.CreateMessageActivity() + .withFrom(new ChannelAccount().withName("MyAccount").withId("acctid").withRole(RoleTypes.USER)); + TurnContextImpl context = new TurnContextImpl(adapter, activity); + NextDelegate nd = new NextDelegate() { + @Override + public void next() throws Exception { + System.out.printf("Delegate called!"); + System.out.flush(); + return ; + } + }; + ActivityImpl typingActivity = new ActivityImpl() + .withType(ActivityTypes.TYPING) + .withRelatesTo(context.getActivity().relatesTo()); + try { + context.SendActivity(typingActivity); + System.out.printf("HI"); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(); + } + + + //logger.OnTurn(context, nd).get(); + } + + @Test + public final void Transcript_LogActivities() throws ExecutionException, InterruptedException { + Logger logger = LogManager.getLogger(Dialog.class); + MemoryTranscriptStore transcriptStore = new MemoryTranscriptStore(); + TestAdapter adapter = (new TestAdapter()).Use(new TranscriptLoggerMiddleware(transcriptStore)); + final String[] conversationId = {null}; + + + String result = new TestFlow(adapter, (context) -> + { + + //TurnContextImpl context = (TurnContextImpl) ctxt; + conversationId[0] = context.getActivity().conversation().id(); + ActivityImpl typingActivity = new ActivityImpl() + .withType(ActivityTypes.TYPING) + .withRelatesTo(context.getActivity().relatesTo()); + try { + context.SendActivity((Activity)typingActivity); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(); + } + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + Assert.fail(); + } + try { + context.SendActivity("echo:" + context.getActivity().text()); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(); + } + }).Send("foo") + .AssertReply((activity) -> { + Assert.assertEquals(activity.type(), ActivityTypes.TYPING); + return null; + }) + .AssertReply("echo:foo") + .Send("bar") + .AssertReply((activity) -> { + Assert.assertEquals(activity.type(), ActivityTypes.TYPING); + return null; + }) + .AssertReply("echo:bar") + .StartTest(); + + + PagedResult pagedResult = transcriptStore.GetTranscriptActivitiesAsync("test", conversationId[0]).join(); + Assert.assertEquals(6, pagedResult.getItems().length); + Assert.assertEquals( "foo", ((Activity)pagedResult.getItems()[0]).text()); + Assert.assertNotEquals(((Activity)pagedResult.getItems()[1]), null); + Assert.assertEquals("echo:foo", ((Activity) pagedResult.getItems()[2]).text()); + Assert.assertEquals("bar", ((Activity)pagedResult.getItems()[3]).text()); + + Assert.assertTrue(pagedResult.getItems()[4] != null); + Assert.assertEquals("echo:bar", ((Activity)pagedResult.getItems()[5]).text()); + for (Object activity : pagedResult.getItems()) + { + Assert.assertFalse(StringUtils.isBlank(((Activity) activity).id())); + Assert.assertTrue(((Activity)activity).timestamp().isAfter(Long.MIN_VALUE)); + } + System.out.printf("Complete"); + } + + @Test + public void Transcript_LogUpdateActivities() throws InterruptedException, ExecutionException { + MemoryTranscriptStore transcriptStore = new MemoryTranscriptStore(); + TestAdapter adapter = (new TestAdapter()).Use(new TranscriptLoggerMiddleware(transcriptStore)); + final String[] conversationId = {null}; + final Activity[] activityToUpdate = {null}; + ObjectMapper mapper = new ObjectMapper(); + mapper.registerModule(new JodaModule()); + new TestFlow(adapter, (context) -> + { + + conversationId[0] = context.getActivity().conversation().id(); + if (context.getActivity().text().equals("update")) { + activityToUpdate[0].withText("new response"); + try { + context.UpdateActivity(activityToUpdate[0]); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + ActivityImpl activity = ((ActivityImpl) context.getActivity()).CreateReply("response"); + ResourceResponse response = null; + try { + response = context.SendActivity(activity); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(); + } + activity.withId(response.id()); + + // clone the activity, so we can use it to do an update + activityToUpdate[0] = ActivityImpl.CloneActity(activity); + //JsonConvert.DeserializeObject(JsonConvert.SerializeObject(activity)); + } + }).Send("foo") + .Send("update") + .AssertReply("new response") + .StartTest(); + Thread.sleep(500); + PagedResult pagedResult = transcriptStore.GetTranscriptActivitiesAsync("test", conversationId[0]).join(); + Assert.assertEquals(4, pagedResult.getItems().length); + Assert.assertEquals("foo", ((Activity)pagedResult.getItems()[0]).text()); + Assert.assertEquals( "response", ((Activity)pagedResult.getItems()[1]).text()); + // TODO: Fix the following 3 asserts so they work correctly. They succeed in the travis builds and fail in the + // BotBuilder-Java 4.0 master build. + //Assert.assertEquals( "new response", ((Activity)pagedResult.getItems()[2]).text()); + //Assert.assertEquals("update", ((Activity)pagedResult.getItems()[3]).text()); + //Assert.assertEquals( ((Activity)pagedResult.getItems()[1]).id(), ((Activity) pagedResult.getItems()[2]).id()); + } + + @Test + public final void Transcript_LogDeleteActivities() throws InterruptedException, ExecutionException { + MemoryTranscriptStore transcriptStore = new MemoryTranscriptStore(); + TestAdapter adapter = (new TestAdapter()).Use(new TranscriptLoggerMiddleware(transcriptStore)); + final String[] conversationId = {null}; + final String[] activityId = {null}; + new TestFlow(adapter, (context) -> + { + + conversationId[0] = context.getActivity().conversation().id(); + if (context.getActivity().text().equals("deleteIt")) { + try { + context.DeleteActivity(activityId[0]).join(); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(); + } + } else { + ActivityImpl activity = ((ActivityImpl) context.getActivity()).CreateReply("response"); + ResourceResponse response = null; + try { + response = context.SendActivity(activity); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(); + } + activityId[0] = response.id(); + } + + + }).Send("foo") + .AssertReply("response") + .Send("deleteIt") + .StartTest(); + Thread.sleep(1500); + PagedResult pagedResult = transcriptStore.GetTranscriptActivitiesAsync("test", conversationId[0]).join(); + for (Object act : pagedResult.getItems()) { + System.out.printf("Here is the object: %s : Type: %s\n", act.getClass().getTypeName(), ((Activity)act).type()); + } + + for (Object activity : pagedResult.getItems() ) { + System.out.printf("Recipient: %s\nText: %s\n", ((Activity) activity).recipient().name(), ((Activity)activity).text()); + } + Assert.assertEquals(4, pagedResult.getItems().length); + Assert.assertEquals("foo", ((Activity)pagedResult.getItems()[0]).text()); + Assert.assertEquals("response", ((Activity)pagedResult.getItems()[1]).text()); + Assert.assertEquals("deleteIt", ((Activity)pagedResult.getItems()[2]).text()); + Assert.assertEquals(ActivityTypes.MESSAGE_DELETE, ((Activity)pagedResult.getItems()[3]).type()); + Assert.assertEquals(((Activity)pagedResult.getItems()[1]).id(), ((Activity) pagedResult.getItems()[3]).id()); + } +} + diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TurnContextTests.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TurnContextTests.java similarity index 96% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TurnContextTests.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TurnContextTests.java index 839f33b3..d7676c9c 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TurnContextTests.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TurnContextTests.java @@ -1,509 +1,509 @@ -package com.microsoft.bot.builder; - -//[TestClass] -//[TestCategory("Middleware")] -//public class TurnContextTests extends BotConnectorTestBase { -public class TurnContextTests { -/* - @Test - public CompletableFuture ConstructorNullAdapter() - { - //TurnContext c = new TurnContext(null, new Activity()); - //Assert.Fail("Should Fail due to null Adapter"); - } - - @Test - public CompletableFuture ConstructorNullActivity() - { - //TestAdapter a = new TestAdapter(); - //TurnContext c = new TurnContext(a, null); - //Assert.Fail("Should Fail due to null Activty"); - } - - [TestMethod] - public async Task Constructor() - { - TurnContext c = new TurnContext(new TestAdapter(), new Activity()); - Assert.IsNotNull(c); - } - - [TestMethod] - public async Task RespondedIsFalse() - { - TurnContext c = new TurnContext(new TestAdapter(), new Activity()); - Assert.IsFalse(c.Responded); - } - - [TestMethod] - [ExpectedException(typeof(ArgumentException))] - public async Task UnableToSetRespondedToFalse() - { - TurnContext c = new TurnContext(new TestAdapter(), new Activity()) - { - Responded = false // should throw - }; - Assert.Fail("Should have thrown"); - } - - [TestMethod] - public async Task CacheValueUsingSetAndGet() - { - var adapter = new TestAdapter(); - await new TestFlow(adapter, MyBotLogic) - .Send("TestResponded") - .StartTest(); - } - - [TestMethod] - [ExpectedException(typeof(ArgumentNullException))] - public async Task GetThrowsOnNullKey() - { - TurnContext c = new TurnContext(new SimpleAdapter(), new Activity()); - c.Services.Get(null); - } - - [TestMethod] - public async Task GetReturnsNullOnEmptyKey() - { - TurnContext c = new TurnContext(new SimpleAdapter(), new Activity()); - object service = c.Services.Get(string.Empty); // empty key - Assert.IsNull(service, "Should not have found a service under an empty key"); - } - - - [TestMethod] - public async Task GetReturnsNullWithUnknownKey() - { - TurnContext c = new TurnContext(new SimpleAdapter(), new Activity()); - object o = c.Services.Get("test"); - Assert.IsNull(o); - } - - [TestMethod] - public async Task CacheValueUsingGetAndSet() - { - TurnContext c = new TurnContext(new SimpleAdapter(), new Activity()); - - c.Services.Add("bar", "foo"); - var result = c.Services.Get("bar"); - - Assert.AreEqual("foo", result); - } - [TestMethod] - public async Task CacheValueUsingGetAndSetGenericWithTypeAsKeyName() - { - TurnContext c = new TurnContext(new SimpleAdapter(), new Activity()); - - c.Services.Add("foo"); - string result = c.Services.Get(); - - Assert.AreEqual("foo", result); - } - - [TestMethod] - public async Task RequestIsSet() - { - TurnContext c = new TurnContext(new SimpleAdapter(), TestMessage.Message()); - Assert.IsTrue(c.Activity.Id == "1234"); - } - - [TestMethod] - public async Task SendAndSetResponded() - { - SimpleAdapter a = new SimpleAdapter(); - TurnContext c = new TurnContext(a, new Activity()); - Assert.IsFalse(c.Responded); - var response = await c.SendActivity(TestMessage.Message("testtest")); - - Assert.IsTrue(c.Responded); - Assert.IsTrue(response.Id == "testtest"); - } - - [TestMethod] - public async Task SendBatchOfActivities() - { - SimpleAdapter a = new SimpleAdapter(); - TurnContext c = new TurnContext(a, new Activity()); - Assert.IsFalse(c.Responded); - - var message1 = TestMessage.Message("message1"); - var message2 = TestMessage.Message("message2"); - - var response = await c.SendActivities(new Activity[] { message1, message2 } ); - - Assert.IsTrue(c.Responded); - Assert.IsTrue(response.Length == 2); - Assert.IsTrue(response[0].Id == "message1"); - Assert.IsTrue(response[1].Id == "message2"); - } - - [TestMethod] - public async Task SendAndSetRespondedUsingMessageActivity() - { - SimpleAdapter a = new SimpleAdapter(); - TurnContext c = new TurnContext(a, new Activity()); - Assert.IsFalse(c.Responded); - - MessageActivity msg = TestMessage.Message().AsMessageActivity(); - await c.SendActivity(msg); - Assert.IsTrue(c.Responded); - } - - [TestMethod] - public async Task TraceActivitiesDoNoSetResponded() - { - SimpleAdapter a = new SimpleAdapter(); - TurnContext c = new TurnContext(a, new Activity()); - Assert.IsFalse(c.Responded); - - // Send a Trace Activity, and make sure responded is NOT set. - ITraceActivity trace = Activity.CreateTraceActivity("trace"); - await c.SendActivity(trace); - Assert.IsFalse(c.Responded); - - // Just to sanity check everything, send a Message and verify the - // responded flag IS set. - MessageActivity msg = TestMessage.Message().AsMessageActivity(); - await c.SendActivity(msg); - Assert.IsTrue(c.Responded); - } - - [TestMethod] - public async Task SendOneActivityToAdapter() - { - bool foundActivity = false; - - void ValidateResponses(Activity[] activities) - { - Assert.IsTrue(activities.Count() == 1, "Incorrect Count"); - Assert.IsTrue(activities[0].Id == "1234"); - foundActivity = true; - } - - SimpleAdapter a = new SimpleAdapter(ValidateResponses); - TurnContext c = new TurnContext(a, new Activity()); - await c.SendActivity(TestMessage.Message()); - Assert.IsTrue(foundActivity); - } - - [TestMethod] - public async Task CallOnSendBeforeDelivery() - { - SimpleAdapter a = new SimpleAdapter(); - TurnContext c = new TurnContext(a, new Activity()); - - int count = 0; - c.OnSendActivities(async (context, activities, next) => - { - Assert.IsNotNull(activities, "Null Array passed in"); - count = activities.Count(); - return await next(); - }); - - await c.SendActivity(TestMessage.Message()); - - Assert.IsTrue(count == 1); - } - - [TestMethod] - public async Task AllowInterceptionOfDeliveryOnSend() - { - bool responsesSent = false; - void ValidateResponses(Activity[] activities) - { - responsesSent = true; - Assert.Fail("Should not be called. Interceptor did not work"); - } - - SimpleAdapter a = new SimpleAdapter(ValidateResponses); - TurnContext c = new TurnContext(a, new Activity()); - - int count = 0; - c.OnSendActivities(async (context, activities, next) => - { - Assert.IsNotNull(activities, "Null Array passed in"); - count = activities.Count(); - // Do not call next. - return null; - }); - - await c.SendActivity(TestMessage.Message()); - - Assert.IsTrue(count == 1); - Assert.IsFalse(responsesSent, "Responses made it to the adapter."); - } - - [TestMethod] - public async Task InterceptAndMutateOnSend() - { - bool foundIt = false; - void ValidateResponses(Activity[] activities) - { - Assert.IsNotNull(activities); - Assert.IsTrue(activities.Length == 1); - Assert.IsTrue(activities[0].Id == "changed"); - foundIt = true; - } - - SimpleAdapter a = new SimpleAdapter(ValidateResponses); - TurnContext c = new TurnContext(a, new Activity()); - - c.OnSendActivities(async (context, activities, next) => - { - Assert.IsNotNull(activities, "Null Array passed in"); - Assert.IsTrue(activities.Count() == 1); - Assert.IsTrue(activities[0].Id == "1234", "Unknown Id Passed In"); - activities[0].Id = "changed"; - return await next(); - }); - - await c.SendActivity(TestMessage.Message()); - - // Intercepted the message, changed it, and sent it on to the Adapter - Assert.IsTrue(foundIt); - } - - [TestMethod] - public async Task UpdateOneActivityToAdapter() - { - bool foundActivity = false; - - void ValidateUpdate(Activity activity) - { - Assert.IsNotNull(activity); - Assert.IsTrue(activity.Id == "test"); - foundActivity = true; - } - - SimpleAdapter a = new SimpleAdapter(ValidateUpdate); - TurnContext c = new TurnContext(a, new Activity()); - - var message = TestMessage.Message("test"); - var updateResult = await c.UpdateActivity(message); - - Assert.IsTrue(foundActivity); - Assert.IsTrue(updateResult.Id == "test"); - } - - [TestMethod] - public async Task CallOnUpdateBeforeDelivery() - { - bool foundActivity = false; - - void ValidateUpdate(Activity activity) - { - Assert.IsNotNull(activity); - Assert.IsTrue(activity.Id == "1234"); - foundActivity = true; - } - - SimpleAdapter a = new SimpleAdapter(ValidateUpdate); - TurnContext c = new TurnContext(a, new Activity()); - - bool wasCalled = false; - c.OnUpdateActivity(async (context, activity, next) => - { - Assert.IsNotNull(activity, "Null activity passed in"); - wasCalled = true; - return await next(); - }); - await c.UpdateActivity(TestMessage.Message()); - Assert.IsTrue(wasCalled); - Assert.IsTrue(foundActivity); - } - - [TestMethod] - public async Task InterceptOnUpdate() - { - bool adapterCalled = false; - void ValidateUpdate(Activity activity) - { - adapterCalled = true; - Assert.Fail("Should not be called."); - } - - SimpleAdapter a = new SimpleAdapter(ValidateUpdate); - TurnContext c = new TurnContext(a, new Activity()); - - bool wasCalled = false; - c.OnUpdateActivity(async (context, activity, next) => - { - Assert.IsNotNull(activity, "Null activity passed in"); - wasCalled = true; - // Do Not Call Next - return null; - }); - - await c.UpdateActivity(TestMessage.Message()); - Assert.IsTrue(wasCalled); // Interceptor was called - Assert.IsFalse(adapterCalled); // Adapter was not - } - - [TestMethod] - public async Task InterceptAndMutateOnUpdate() - { - bool adapterCalled = false; - void ValidateUpdate(Activity activity) - { - Assert.IsTrue(activity.Id == "mutated"); - adapterCalled = true; - } - - SimpleAdapter a = new SimpleAdapter(ValidateUpdate); - TurnContext c = new TurnContext(a, new Activity()); - - c.OnUpdateActivity(async (context, activity, next) => - { - Assert.IsNotNull(activity, "Null activity passed in"); - Assert.IsTrue(activity.Id == "1234"); - activity.Id = "mutated"; - return await next(); - }); - - await c.UpdateActivity(TestMessage.Message()); - Assert.IsTrue(adapterCalled); // Adapter was not - } - - [TestMethod] - public async Task DeleteOneActivityToAdapter() - { - bool deleteCalled = false; - - void ValidateDelete(ConversationReference r) - { - Assert.IsNotNull(r); - Assert.IsTrue(r.ActivityId == "12345"); - deleteCalled = true; - } - - SimpleAdapter a = new SimpleAdapter(ValidateDelete); - TurnContext c = new TurnContext(a, TestMessage.Message()); - await c.DeleteActivity("12345"); - Assert.IsTrue(deleteCalled); - } - - [TestMethod] - public async Task DeleteConversationReferenceToAdapter() - { - bool deleteCalled = false; - - void ValidateDelete(ConversationReference r) - { - Assert.IsNotNull(r); - Assert.IsTrue(r.ActivityId == "12345"); - deleteCalled = true; - } - - SimpleAdapter a = new SimpleAdapter(ValidateDelete); - TurnContext c = new TurnContext(a, TestMessage.Message()); - - var reference = new ConversationReference("12345"); - - await c.DeleteActivity(reference); - Assert.IsTrue(deleteCalled); - } - - [TestMethod] - public async Task InterceptOnDelete() - { - bool adapterCalled = false; - - void ValidateDelete(ConversationReference r) - { - adapterCalled = true; - Assert.Fail("Should not be called."); - } - - SimpleAdapter a = new SimpleAdapter(ValidateDelete); - TurnContext c = new TurnContext(a, new Activity()); - - bool wasCalled = false; - c.OnDeleteActivity(async (context, convRef, next) => - { - Assert.IsNotNull(convRef, "Null activity passed in"); - wasCalled = true; - // Do Not Call Next - }); - - await c.DeleteActivity("1234"); - Assert.IsTrue(wasCalled); // Interceptor was called - Assert.IsFalse(adapterCalled); // Adapter was not - } - - [TestMethod] - public async Task InterceptAndMutateOnDelete() - { - bool adapterCalled = false; - - void ValidateDelete(ConversationReference r) - { - Assert.IsTrue(r.ActivityId == "mutated"); - adapterCalled = true; - } - - SimpleAdapter a = new SimpleAdapter(ValidateDelete); - TurnContext c = new TurnContext(a, new Activity()); - - c.OnDeleteActivity(async (context, convRef, next) => - { - Assert.IsNotNull(convRef, "Null activity passed in"); - Assert.IsTrue(convRef.ActivityId == "1234", "Incorrect Activity Id"); - convRef.ActivityId = "mutated"; - await next(); - }); - - await c.DeleteActivity("1234"); - Assert.IsTrue(adapterCalled); // Adapter was called + valided the change - } - - [TestMethod] - public async Task ThrowExceptionInOnSend() - { - SimpleAdapter a = new SimpleAdapter(); - TurnContext c = new TurnContext(a, new Activity()); - - c.OnSendActivities(async (context, activities, next) => - { - throw new Exception("test"); - }); - - try - { - await c.SendActivity(TestMessage.Message()); - Assert.Fail("Should not get here"); - } - catch(Exception ex) - { - Assert.IsTrue(ex.Message == "test"); - } - } - - public async Task MyBotLogic(TurnContext context) - { - switch (context.Activity.AsMessageActivity().Text) - { - case "count": - await context.SendActivity(context.Activity.CreateReply("one")); - await context.SendActivity(context.Activity.CreateReply("two")); - await context.SendActivity(context.Activity.CreateReply("three")); - break; - case "ignore": - break; - case "TestResponded": - if (context.Responded == true) - throw new InvalidOperationException("Responded Is True"); - - await context.SendActivity(context.Activity.CreateReply("one")); - - if (context.Responded == false) - throw new InvalidOperationException("Responded Is True"); - break; - default: - await context.SendActivity( - context.Activity.CreateReply($"echo:{context.Activity.Text}")); - break; - } - } -*/ -} - +package com.microsoft.bot.builder; + +//[TestClass] +//[TestCategory("Middleware")] +//public class TurnContextTests extends BotConnectorTestBase { +public class TurnContextTests { +/* + @Test + public CompletableFuture ConstructorNullAdapter() + { + //TurnContext c = new TurnContext(null, new Activity()); + //Assert.Fail("Should Fail due to null Adapter"); + } + + @Test + public CompletableFuture ConstructorNullActivity() + { + //TestAdapter a = new TestAdapter(); + //TurnContext c = new TurnContext(a, null); + //Assert.Fail("Should Fail due to null Activty"); + } + + [TestMethod] + public async Task Constructor() + { + TurnContext c = new TurnContext(new TestAdapter(), new Activity()); + Assert.IsNotNull(c); + } + + [TestMethod] + public async Task RespondedIsFalse() + { + TurnContext c = new TurnContext(new TestAdapter(), new Activity()); + Assert.IsFalse(c.Responded); + } + + [TestMethod] + [ExpectedException(typeof(ArgumentException))] + public async Task UnableToSetRespondedToFalse() + { + TurnContext c = new TurnContext(new TestAdapter(), new Activity()) + { + Responded = false // should throw + }; + Assert.Fail("Should have thrown"); + } + + [TestMethod] + public async Task CacheValueUsingSetAndGet() + { + var adapter = new TestAdapter(); + await new TestFlow(adapter, MyBotLogic) + .Send("TestResponded") + .StartTest(); + } + + [TestMethod] + [ExpectedException(typeof(ArgumentNullException))] + public async Task GetThrowsOnNullKey() + { + TurnContext c = new TurnContext(new SimpleAdapter(), new Activity()); + c.Services.Get(null); + } + + [TestMethod] + public async Task GetReturnsNullOnEmptyKey() + { + TurnContext c = new TurnContext(new SimpleAdapter(), new Activity()); + object service = c.Services.Get(string.Empty); // empty key + Assert.IsNull(service, "Should not have found a service under an empty key"); + } + + + [TestMethod] + public async Task GetReturnsNullWithUnknownKey() + { + TurnContext c = new TurnContext(new SimpleAdapter(), new Activity()); + object o = c.Services.Get("test"); + Assert.IsNull(o); + } + + [TestMethod] + public async Task CacheValueUsingGetAndSet() + { + TurnContext c = new TurnContext(new SimpleAdapter(), new Activity()); + + c.Services.Add("bar", "foo"); + var result = c.Services.Get("bar"); + + Assert.AreEqual("foo", result); + } + [TestMethod] + public async Task CacheValueUsingGetAndSetGenericWithTypeAsKeyName() + { + TurnContext c = new TurnContext(new SimpleAdapter(), new Activity()); + + c.Services.Add("foo"); + string result = c.Services.Get(); + + Assert.AreEqual("foo", result); + } + + [TestMethod] + public async Task RequestIsSet() + { + TurnContext c = new TurnContext(new SimpleAdapter(), TestMessage.Message()); + Assert.IsTrue(c.Activity.Id == "1234"); + } + + [TestMethod] + public async Task SendAndSetResponded() + { + SimpleAdapter a = new SimpleAdapter(); + TurnContext c = new TurnContext(a, new Activity()); + Assert.IsFalse(c.Responded); + var response = await c.SendActivity(TestMessage.Message("testtest")); + + Assert.IsTrue(c.Responded); + Assert.IsTrue(response.Id == "testtest"); + } + + [TestMethod] + public async Task SendBatchOfActivities() + { + SimpleAdapter a = new SimpleAdapter(); + TurnContext c = new TurnContext(a, new Activity()); + Assert.IsFalse(c.Responded); + + var message1 = TestMessage.Message("message1"); + var message2 = TestMessage.Message("message2"); + + var response = await c.SendActivities(new Activity[] { message1, message2 } ); + + Assert.IsTrue(c.Responded); + Assert.IsTrue(response.Length == 2); + Assert.IsTrue(response[0].Id == "message1"); + Assert.IsTrue(response[1].Id == "message2"); + } + + [TestMethod] + public async Task SendAndSetRespondedUsingMessageActivity() + { + SimpleAdapter a = new SimpleAdapter(); + TurnContext c = new TurnContext(a, new Activity()); + Assert.IsFalse(c.Responded); + + MessageActivity msg = TestMessage.Message().AsMessageActivity(); + await c.SendActivity(msg); + Assert.IsTrue(c.Responded); + } + + [TestMethod] + public async Task TraceActivitiesDoNoSetResponded() + { + SimpleAdapter a = new SimpleAdapter(); + TurnContext c = new TurnContext(a, new Activity()); + Assert.IsFalse(c.Responded); + + // Send a Trace Activity, and make sure responded is NOT set. + ITraceActivity trace = Activity.CreateTraceActivity("trace"); + await c.SendActivity(trace); + Assert.IsFalse(c.Responded); + + // Just to sanity check everything, send a Message and verify the + // responded flag IS set. + MessageActivity msg = TestMessage.Message().AsMessageActivity(); + await c.SendActivity(msg); + Assert.IsTrue(c.Responded); + } + + [TestMethod] + public async Task SendOneActivityToAdapter() + { + bool foundActivity = false; + + void ValidateResponses(Activity[] activities) + { + Assert.IsTrue(activities.Count() == 1, "Incorrect Count"); + Assert.IsTrue(activities[0].Id == "1234"); + foundActivity = true; + } + + SimpleAdapter a = new SimpleAdapter(ValidateResponses); + TurnContext c = new TurnContext(a, new Activity()); + await c.SendActivity(TestMessage.Message()); + Assert.IsTrue(foundActivity); + } + + [TestMethod] + public async Task CallOnSendBeforeDelivery() + { + SimpleAdapter a = new SimpleAdapter(); + TurnContext c = new TurnContext(a, new Activity()); + + int count = 0; + c.OnSendActivities(async (context, activities, next) => + { + Assert.IsNotNull(activities, "Null Array passed in"); + count = activities.Count(); + return await next(); + }); + + await c.SendActivity(TestMessage.Message()); + + Assert.IsTrue(count == 1); + } + + [TestMethod] + public async Task AllowInterceptionOfDeliveryOnSend() + { + bool responsesSent = false; + void ValidateResponses(Activity[] activities) + { + responsesSent = true; + Assert.Fail("Should not be called. Interceptor did not work"); + } + + SimpleAdapter a = new SimpleAdapter(ValidateResponses); + TurnContext c = new TurnContext(a, new Activity()); + + int count = 0; + c.OnSendActivities(async (context, activities, next) => + { + Assert.IsNotNull(activities, "Null Array passed in"); + count = activities.Count(); + // Do not call next. + return null; + }); + + await c.SendActivity(TestMessage.Message()); + + Assert.IsTrue(count == 1); + Assert.IsFalse(responsesSent, "Responses made it to the adapter."); + } + + [TestMethod] + public async Task InterceptAndMutateOnSend() + { + bool foundIt = false; + void ValidateResponses(Activity[] activities) + { + Assert.IsNotNull(activities); + Assert.IsTrue(activities.Length == 1); + Assert.IsTrue(activities[0].Id == "changed"); + foundIt = true; + } + + SimpleAdapter a = new SimpleAdapter(ValidateResponses); + TurnContext c = new TurnContext(a, new Activity()); + + c.OnSendActivities(async (context, activities, next) => + { + Assert.IsNotNull(activities, "Null Array passed in"); + Assert.IsTrue(activities.Count() == 1); + Assert.IsTrue(activities[0].Id == "1234", "Unknown Id Passed In"); + activities[0].Id = "changed"; + return await next(); + }); + + await c.SendActivity(TestMessage.Message()); + + // Intercepted the message, changed it, and sent it on to the Adapter + Assert.IsTrue(foundIt); + } + + [TestMethod] + public async Task UpdateOneActivityToAdapter() + { + bool foundActivity = false; + + void ValidateUpdate(Activity activity) + { + Assert.IsNotNull(activity); + Assert.IsTrue(activity.Id == "test"); + foundActivity = true; + } + + SimpleAdapter a = new SimpleAdapter(ValidateUpdate); + TurnContext c = new TurnContext(a, new Activity()); + + var message = TestMessage.Message("test"); + var updateResult = await c.UpdateActivity(message); + + Assert.IsTrue(foundActivity); + Assert.IsTrue(updateResult.Id == "test"); + } + + [TestMethod] + public async Task CallOnUpdateBeforeDelivery() + { + bool foundActivity = false; + + void ValidateUpdate(Activity activity) + { + Assert.IsNotNull(activity); + Assert.IsTrue(activity.Id == "1234"); + foundActivity = true; + } + + SimpleAdapter a = new SimpleAdapter(ValidateUpdate); + TurnContext c = new TurnContext(a, new Activity()); + + bool wasCalled = false; + c.OnUpdateActivity(async (context, activity, next) => + { + Assert.IsNotNull(activity, "Null activity passed in"); + wasCalled = true; + return await next(); + }); + await c.UpdateActivity(TestMessage.Message()); + Assert.IsTrue(wasCalled); + Assert.IsTrue(foundActivity); + } + + [TestMethod] + public async Task InterceptOnUpdate() + { + bool adapterCalled = false; + void ValidateUpdate(Activity activity) + { + adapterCalled = true; + Assert.Fail("Should not be called."); + } + + SimpleAdapter a = new SimpleAdapter(ValidateUpdate); + TurnContext c = new TurnContext(a, new Activity()); + + bool wasCalled = false; + c.OnUpdateActivity(async (context, activity, next) => + { + Assert.IsNotNull(activity, "Null activity passed in"); + wasCalled = true; + // Do Not Call Next + return null; + }); + + await c.UpdateActivity(TestMessage.Message()); + Assert.IsTrue(wasCalled); // Interceptor was called + Assert.IsFalse(adapterCalled); // Adapter was not + } + + [TestMethod] + public async Task InterceptAndMutateOnUpdate() + { + bool adapterCalled = false; + void ValidateUpdate(Activity activity) + { + Assert.IsTrue(activity.Id == "mutated"); + adapterCalled = true; + } + + SimpleAdapter a = new SimpleAdapter(ValidateUpdate); + TurnContext c = new TurnContext(a, new Activity()); + + c.OnUpdateActivity(async (context, activity, next) => + { + Assert.IsNotNull(activity, "Null activity passed in"); + Assert.IsTrue(activity.Id == "1234"); + activity.Id = "mutated"; + return await next(); + }); + + await c.UpdateActivity(TestMessage.Message()); + Assert.IsTrue(adapterCalled); // Adapter was not + } + + [TestMethod] + public async Task DeleteOneActivityToAdapter() + { + bool deleteCalled = false; + + void ValidateDelete(ConversationReference r) + { + Assert.IsNotNull(r); + Assert.IsTrue(r.ActivityId == "12345"); + deleteCalled = true; + } + + SimpleAdapter a = new SimpleAdapter(ValidateDelete); + TurnContext c = new TurnContext(a, TestMessage.Message()); + await c.DeleteActivity("12345"); + Assert.IsTrue(deleteCalled); + } + + [TestMethod] + public async Task DeleteConversationReferenceToAdapter() + { + bool deleteCalled = false; + + void ValidateDelete(ConversationReference r) + { + Assert.IsNotNull(r); + Assert.IsTrue(r.ActivityId == "12345"); + deleteCalled = true; + } + + SimpleAdapter a = new SimpleAdapter(ValidateDelete); + TurnContext c = new TurnContext(a, TestMessage.Message()); + + var reference = new ConversationReference("12345"); + + await c.DeleteActivity(reference); + Assert.IsTrue(deleteCalled); + } + + [TestMethod] + public async Task InterceptOnDelete() + { + bool adapterCalled = false; + + void ValidateDelete(ConversationReference r) + { + adapterCalled = true; + Assert.Fail("Should not be called."); + } + + SimpleAdapter a = new SimpleAdapter(ValidateDelete); + TurnContext c = new TurnContext(a, new Activity()); + + bool wasCalled = false; + c.OnDeleteActivity(async (context, convRef, next) => + { + Assert.IsNotNull(convRef, "Null activity passed in"); + wasCalled = true; + // Do Not Call Next + }); + + await c.DeleteActivity("1234"); + Assert.IsTrue(wasCalled); // Interceptor was called + Assert.IsFalse(adapterCalled); // Adapter was not + } + + [TestMethod] + public async Task InterceptAndMutateOnDelete() + { + bool adapterCalled = false; + + void ValidateDelete(ConversationReference r) + { + Assert.IsTrue(r.ActivityId == "mutated"); + adapterCalled = true; + } + + SimpleAdapter a = new SimpleAdapter(ValidateDelete); + TurnContext c = new TurnContext(a, new Activity()); + + c.OnDeleteActivity(async (context, convRef, next) => + { + Assert.IsNotNull(convRef, "Null activity passed in"); + Assert.IsTrue(convRef.ActivityId == "1234", "Incorrect Activity Id"); + convRef.ActivityId = "mutated"; + await next(); + }); + + await c.DeleteActivity("1234"); + Assert.IsTrue(adapterCalled); // Adapter was called + valided the change + } + + [TestMethod] + public async Task ThrowExceptionInOnSend() + { + SimpleAdapter a = new SimpleAdapter(); + TurnContext c = new TurnContext(a, new Activity()); + + c.OnSendActivities(async (context, activities, next) => + { + throw new Exception("test"); + }); + + try + { + await c.SendActivity(TestMessage.Message()); + Assert.Fail("Should not get here"); + } + catch(Exception ex) + { + Assert.IsTrue(ex.Message == "test"); + } + } + + public async Task MyBotLogic(TurnContext context) + { + switch (context.Activity.AsMessageActivity().Text) + { + case "count": + await context.SendActivity(context.Activity.CreateReply("one")); + await context.SendActivity(context.Activity.CreateReply("two")); + await context.SendActivity(context.Activity.CreateReply("three")); + break; + case "ignore": + break; + case "TestResponded": + if (context.Responded == true) + throw new InvalidOperationException("Responded Is True"); + + await context.SendActivity(context.Activity.CreateReply("one")); + + if (context.Responded == false) + throw new InvalidOperationException("Responded Is True"); + break; + default: + await context.SendActivity( + context.Activity.CreateReply($"echo:{context.Activity.Text}")); + break; + } + } +*/ +} + diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TypedObject.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TypedObject.java similarity index 95% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TypedObject.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TypedObject.java index bc189243..12978076 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/TypedObject.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TypedObject.java @@ -1,17 +1,17 @@ -package com.microsoft.bot.builder; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class TypedObject { - @JsonProperty - private String name; - - public String name() { - return this.name; - } - - public TypedObject withName(String name) { - this.name = name; - return this; - } -} +package com.microsoft.bot.builder; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class TypedObject { + @JsonProperty + private String name; + + public String name() { + return this.name; + } + + public TypedObject withName(String name) { + this.name = name; + return this; + } +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/WasCalledMiddlware.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/WasCalledMiddlware.java similarity index 96% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/WasCalledMiddlware.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/WasCalledMiddlware.java index a54b4e08..5242ad38 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/WasCalledMiddlware.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/WasCalledMiddlware.java @@ -1,16 +1,16 @@ -package com.microsoft.bot.builder; - -public class WasCalledMiddlware implements Middleware { - boolean called = false; - public boolean getCalled() { - return this.called; - } - public void setCalled(boolean called) { - this.called = called; - } - - public void OnTurn(TurnContext context, NextDelegate next) throws Exception { - setCalled(true); - next.next(); - } -} +package com.microsoft.bot.builder; + +public class WasCalledMiddlware implements Middleware { + boolean called = false; + public boolean getCalled() { + return this.called; + } + public void setCalled(boolean called) { + this.called = called; + } + + public void OnTurn(TurnContext context, NextDelegate next) throws Exception { + setCalled(true); + next.next(); + } +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/adapters/TestFlow.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/adapters/TestFlow.java similarity index 97% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/adapters/TestFlow.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/adapters/TestFlow.java index f8617882..c68956c8 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/adapters/TestFlow.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/adapters/TestFlow.java @@ -1,468 +1,468 @@ -package com.microsoft.bot.builder.adapters; - -import com.microsoft.bot.builder.TurnContext; -import com.microsoft.bot.schema.ActivityImpl; -import com.microsoft.bot.schema.models.Activity; -import org.joda.time.DateTime; -import org.junit.Assert; - -import java.lang.management.ManagementFactory; -import java.util.ArrayList; -import java.util.concurrent.*; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Supplier; - -import static java.util.concurrent.CompletableFuture.completedFuture; - -public class TestFlow { - final TestAdapter adapter; - CompletableFuture testTask; - Consumer callback; - - ArrayList> tasks = new ArrayList>(); - ForkJoinPool.ForkJoinWorkerThreadFactory factory = new ForkJoinPool.ForkJoinWorkerThreadFactory() - { - @Override - public ForkJoinWorkerThread newThread(ForkJoinPool pool) - { - final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); - worker.setName("TestFlow-" + worker.getPoolIndex()); - return worker; - } - }; - - ExecutorService executor = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), factory, null, true); - - - public TestFlow(TestAdapter adapter) { - this(adapter, null); - } - - public TestFlow(TestAdapter adapter, Consumer callback) { - this.adapter = adapter; - this.callback = callback; - this.testTask = completedFuture(null); - } - - - public TestFlow(Supplier testTask, TestFlow flow) { - this.tasks = flow.tasks; - if (testTask != null) - this.tasks.add(testTask); - this.callback = flow.callback; - this.adapter = flow.adapter; - } - - - /** - * Start the execution of the test flow - * - * @return - */ - public String StartTest() throws ExecutionException, InterruptedException { - - System.out.printf("+------------------------------------------+\n"); - int count = 0; - for (Supplier task : this.tasks) { - System.out.printf("| Running task %s of %s\n", count++, this.tasks.size()); - String result = null; - result = task.get(); - System.out.printf("| --> Result: %s", result); - System.out.flush(); - } - System.out.printf("+------------------------------------------+\n"); - return "Completed"; - - } - - /** - * 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"); - - // Function - return new TestFlow((() -> { - System.out.print(String.format("USER SAYS: %s (Thread Id: %s)\n", userSays, Thread.currentThread().getId())); - System.out.flush(); - try { - this.adapter.SendTextToBot(userSays, this.callback); - return "Successfully sent " + userSays; - } catch (Exception e) { - Assert.fail(e.getMessage()); - return e.getMessage(); - } - }), this); - } - - /** - * 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"); - - return new TestFlow((() -> { - System.out.printf("TestFlow(%s): Send with User Activity! %s", Thread.currentThread().getId(), userActivity.text()); - System.out.flush(); - - - try { - this.adapter.ProcessActivity((ActivityImpl) userActivity, this.callback); - return "TestFlow: Send() -> ProcessActivity: " + userActivity.text(); - } catch (Exception e) { - return e.getMessage(); - - } - - }), this); - } - - /** - * Delay for time period - * - * @param ms - * @return - */ - public TestFlow Delay(int ms) { - return new TestFlow(() -> - { - System.out.printf("TestFlow(%s): Delay(%s ms) called. ", Thread.currentThread().getId(), ms); - System.out.flush(); - try { - Thread.sleep((int) ms); - } catch (InterruptedException e) { - return e.getMessage(); - } - return null; - }, this); - } - - /** - * Assert that reply is expected text - * - * @param expected - * @param description - * @param timeout - * @return - */ - public TestFlow AssertReply(String expected) { - return this.AssertReply(expected, null, 3000); - } - - public TestFlow AssertReply(String expected, String description) { - return this.AssertReply(expected, description, 3000); - } - - public TestFlow AssertReply(String expected, String description, int timeout) { - return this.AssertReply(this.adapter.MakeActivity(expected), description, timeout); - } - - /** - * 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); - } - - public TestFlow AssertReply(Activity expected, String description, int timeout) { - if (description == null) - description = Thread.currentThread().getStackTrace()[1].getMethodName(); - String finalDescription = description; - return this.AssertReply((reply) -> { - if (expected.type() != reply.type()) - return String.format("%s: Type should match", finalDescription); - if (expected.text().equals(reply.text())) { - if (finalDescription == null) - return String.format("Expected:%s\nReceived:{reply.AsMessageActivity().Text}", expected.text()); - else - return String.format("%s: Text should match", finalDescription); - } - // TODO, expand this to do all properties set on expected - return null; - }, description, timeout); - } - - /** - * Assert that the reply matches a custom validation routine - * - * @param validateActivity - * @param description - * @param timeout - * @return - */ - public TestFlow AssertReply(Function validateActivity) { - String description = Thread.currentThread().getStackTrace()[1].getMethodName(); - return AssertReply(validateActivity, description, 3000); - } - - public TestFlow AssertReply(Function validateActivity, String description) { - return AssertReply(validateActivity, description, 3000); - } - - public TestFlow AssertReply(Function validateActivity, String description, int timeout) { - return new TestFlow(() -> { - System.out.println(String.format("AssertReply: Starting loop : %s (Thread:%s)", description, Thread.currentThread().getId())); - System.out.flush(); - - int finalTimeout = Integer.MAX_VALUE; - if (isDebug()) - finalTimeout = Integer.MAX_VALUE; - - DateTime start = DateTime.now(); - while (true) { - DateTime current = DateTime.now(); - - if ((current.getMillis() - start.getMillis()) > (long) finalTimeout) { - System.out.println("AssertReply: Timeout!\n"); - System.out.flush(); - return String.format("%d ms Timed out waiting for:'%s'", finalTimeout, description); - } - -// System.out.println("Before GetNextReply\n"); -// System.out.flush(); - - Activity replyActivity = this.adapter.GetNextReply(); -// System.out.println("After GetNextReply\n"); -// System.out.flush(); - - if (replyActivity != null) { - System.out.printf("AssertReply(tid:%s): Received Reply: %s ", Thread.currentThread().getId(), (replyActivity.text() == null) ? "No Text set" : replyActivity.text()); - System.out.flush(); - System.out.printf("=============\n From: %s\n To:%s\n ==========\n", (replyActivity.from() == null) ? "No from set" : replyActivity.from().name(), - (replyActivity.recipient() == null) ? "No recipient set" : replyActivity.recipient().name()); - System.out.flush(); - - // if we have a reply - return validateActivity.apply(replyActivity); - } else { - System.out.printf("AssertReply(tid:%s): Waiting..\n", Thread.currentThread().getId()); - System.out.flush(); - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - }, this); - } - - // Hack to determine if debugger attached.. - public boolean isDebug() { - for (String arg : ManagementFactory.getRuntimeMXBean().getInputArguments()) { - if (arg.contains("jdwp=")) { - return true; - } - } - return false; - } - - - /** - * @param userSays - * @param expected - * @return - */ - public TestFlow Turn(String userSays, String expected, String description, int timeout) { - String result = null; - try { - - result = CompletableFuture.supplyAsync(() -> { // Send the message - - if (userSays == null) - throw new IllegalArgumentException("You have to pass a userSays parameter"); - - System.out.print(String.format("TestTurn(%s): USER SAYS: %s \n", Thread.currentThread().getId(), userSays)); - System.out.flush(); - - try { - this.adapter.SendTextToBot(userSays, this.callback); - return null; - } catch (Exception e) { - return e.getMessage(); - } - - }) - .thenApply(arg -> { // Assert Reply - int finalTimeout = Integer.MAX_VALUE; - if (isDebug()) - finalTimeout = Integer.MAX_VALUE; - Function validateActivity = activity -> { - if (activity.text().equals(expected)) { - System.out.println(String.format("TestTurn(tid:%s): Validated text is: %s", Thread.currentThread().getId(), expected)); - System.out.flush(); - - return "SUCCESS"; - } - System.out.println(String.format("TestTurn(tid:%s): Failed validate text is: %s", Thread.currentThread().getId(), expected)); - System.out.flush(); - - return String.format("FAIL: %s received in Activity.text (%s expected)", activity.text(), expected); - }; - - - System.out.println(String.format("TestTurn(tid:%s): Started receive loop: %s", Thread.currentThread().getId(), description)); - System.out.flush(); - DateTime start = DateTime.now(); - while (true) { - DateTime current = DateTime.now(); - - if ((current.getMillis() - start.getMillis()) > (long) finalTimeout) - return String.format("TestTurn: %d ms Timed out waiting for:'%s'", finalTimeout, description); - - - Activity replyActivity = this.adapter.GetNextReply(); - - - if (replyActivity != null) { - // if we have a reply - System.out.println(String.format("TestTurn(tid:%s): Received Reply: %s", - Thread.currentThread().getId(), - String.format("\n========\n To:%s\n From:%s\n Msg:%s\n=======", replyActivity.recipient().name(), replyActivity.from().name(), replyActivity.text()) - )); - System.out.flush(); - return validateActivity.apply(replyActivity); - } else { - System.out.println(String.format("TestTurn(tid:%s): No reply..", Thread.currentThread().getId())); - System.out.flush(); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - } - }) - .get(timeout, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (ExecutionException e) { - e.printStackTrace(); - } catch (TimeoutException e) { - e.printStackTrace(); - } - return this; - - } - - /** - * 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); - } - - public TestFlow Test(String userSays, String expected, String description) { - return Test(userSays, expected, description, 3000); - } - - public TestFlow Test(String userSays, String expected, String description, int timeout) { - if (expected == null) - throw new IllegalArgumentException("expected"); - - return this.Send(userSays) - .AssertReply(expected, description, timeout); - } - - /** - * 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); - } - - public TestFlow Test(String userSays, Activity expected, String description) { - return Test(userSays, expected, description, 3000); - } - - public TestFlow Test(String userSays, Activity expected, String description, int timeout) { - if (expected == null) - throw new IllegalArgumentException("expected"); - - return this.Send(userSays) - .AssertReply(expected, description, timeout); - } - - /** - * Say() -> shortcut for .Send(user).AssertReply(Expected) - * - * @param userSays - * @param expected - * @param description - * @param timeout - * @return - */ - public TestFlow Test(String userSays, Function expected) { - return Test(userSays, expected, null, 3000); - } - - public TestFlow Test(String userSays, Function expected, String description) { - return Test(userSays, expected, description, 3000); - } - - public TestFlow Test(String userSays, Function expected, String description, int timeout) { - if (expected == null) - throw new IllegalArgumentException("expected"); - - return this.Send(userSays) - .AssertReply(expected, description, timeout); - } - - /** - * 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); - } - - public TestFlow AssertReplyOneOf(String[] candidates, String description) { - return AssertReplyOneOf(candidates, description, 3000); - } - - public TestFlow AssertReplyOneOf(String[] candidates, String description, int timeout) { - if (candidates == null) - throw new IllegalArgumentException("candidates"); - - return this.AssertReply((reply) -> { - for (String candidate : candidates) { - if (reply.text() == candidate) - return null; - } - return String.format("%s: Not one of candidates: %s", description, String.join("\n ", candidates)); - }, description, timeout); - } - -} +package com.microsoft.bot.builder.adapters; + +import com.microsoft.bot.builder.TurnContext; +import com.microsoft.bot.schema.ActivityImpl; +import com.microsoft.bot.schema.models.Activity; +import org.joda.time.DateTime; +import org.junit.Assert; + +import java.lang.management.ManagementFactory; +import java.util.ArrayList; +import java.util.concurrent.*; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; + +import static java.util.concurrent.CompletableFuture.completedFuture; + +public class TestFlow { + final TestAdapter adapter; + CompletableFuture testTask; + Consumer callback; + + ArrayList> tasks = new ArrayList>(); + ForkJoinPool.ForkJoinWorkerThreadFactory factory = new ForkJoinPool.ForkJoinWorkerThreadFactory() + { + @Override + public ForkJoinWorkerThread newThread(ForkJoinPool pool) + { + final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool); + worker.setName("TestFlow-" + worker.getPoolIndex()); + return worker; + } + }; + + ExecutorService executor = new ForkJoinPool(Runtime.getRuntime().availableProcessors(), factory, null, true); + + + public TestFlow(TestAdapter adapter) { + this(adapter, null); + } + + public TestFlow(TestAdapter adapter, Consumer callback) { + this.adapter = adapter; + this.callback = callback; + this.testTask = completedFuture(null); + } + + + public TestFlow(Supplier testTask, TestFlow flow) { + this.tasks = flow.tasks; + if (testTask != null) + this.tasks.add(testTask); + this.callback = flow.callback; + this.adapter = flow.adapter; + } + + + /** + * Start the execution of the test flow + * + * @return + */ + public String StartTest() throws ExecutionException, InterruptedException { + + System.out.printf("+------------------------------------------+\n"); + int count = 0; + for (Supplier task : this.tasks) { + System.out.printf("| Running task %s of %s\n", count++, this.tasks.size()); + String result = null; + result = task.get(); + System.out.printf("| --> Result: %s", result); + System.out.flush(); + } + System.out.printf("+------------------------------------------+\n"); + return "Completed"; + + } + + /** + * 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"); + + // Function + return new TestFlow((() -> { + System.out.print(String.format("USER SAYS: %s (Thread Id: %s)\n", userSays, Thread.currentThread().getId())); + System.out.flush(); + try { + this.adapter.SendTextToBot(userSays, this.callback); + return "Successfully sent " + userSays; + } catch (Exception e) { + Assert.fail(e.getMessage()); + return e.getMessage(); + } + }), this); + } + + /** + * 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"); + + return new TestFlow((() -> { + System.out.printf("TestFlow(%s): Send with User Activity! %s", Thread.currentThread().getId(), userActivity.text()); + System.out.flush(); + + + try { + this.adapter.ProcessActivity((ActivityImpl) userActivity, this.callback); + return "TestFlow: Send() -> ProcessActivity: " + userActivity.text(); + } catch (Exception e) { + return e.getMessage(); + + } + + }), this); + } + + /** + * Delay for time period + * + * @param ms + * @return + */ + public TestFlow Delay(int ms) { + return new TestFlow(() -> + { + System.out.printf("TestFlow(%s): Delay(%s ms) called. ", Thread.currentThread().getId(), ms); + System.out.flush(); + try { + Thread.sleep((int) ms); + } catch (InterruptedException e) { + return e.getMessage(); + } + return null; + }, this); + } + + /** + * Assert that reply is expected text + * + * @param expected + * @param description + * @param timeout + * @return + */ + public TestFlow AssertReply(String expected) { + return this.AssertReply(expected, null, 3000); + } + + public TestFlow AssertReply(String expected, String description) { + return this.AssertReply(expected, description, 3000); + } + + public TestFlow AssertReply(String expected, String description, int timeout) { + return this.AssertReply(this.adapter.MakeActivity(expected), description, timeout); + } + + /** + * 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); + } + + public TestFlow AssertReply(Activity expected, String description, int timeout) { + if (description == null) + description = Thread.currentThread().getStackTrace()[1].getMethodName(); + String finalDescription = description; + return this.AssertReply((reply) -> { + if (expected.type() != reply.type()) + return String.format("%s: Type should match", finalDescription); + if (expected.text().equals(reply.text())) { + if (finalDescription == null) + return String.format("Expected:%s\nReceived:{reply.AsMessageActivity().Text}", expected.text()); + else + return String.format("%s: Text should match", finalDescription); + } + // TODO, expand this to do all properties set on expected + return null; + }, description, timeout); + } + + /** + * Assert that the reply matches a custom validation routine + * + * @param validateActivity + * @param description + * @param timeout + * @return + */ + public TestFlow AssertReply(Function validateActivity) { + String description = Thread.currentThread().getStackTrace()[1].getMethodName(); + return AssertReply(validateActivity, description, 3000); + } + + public TestFlow AssertReply(Function validateActivity, String description) { + return AssertReply(validateActivity, description, 3000); + } + + public TestFlow AssertReply(Function validateActivity, String description, int timeout) { + return new TestFlow(() -> { + System.out.println(String.format("AssertReply: Starting loop : %s (Thread:%s)", description, Thread.currentThread().getId())); + System.out.flush(); + + int finalTimeout = Integer.MAX_VALUE; + if (isDebug()) + finalTimeout = Integer.MAX_VALUE; + + DateTime start = DateTime.now(); + while (true) { + DateTime current = DateTime.now(); + + if ((current.getMillis() - start.getMillis()) > (long) finalTimeout) { + System.out.println("AssertReply: Timeout!\n"); + System.out.flush(); + return String.format("%d ms Timed out waiting for:'%s'", finalTimeout, description); + } + +// System.out.println("Before GetNextReply\n"); +// System.out.flush(); + + Activity replyActivity = this.adapter.GetNextReply(); +// System.out.println("After GetNextReply\n"); +// System.out.flush(); + + if (replyActivity != null) { + System.out.printf("AssertReply(tid:%s): Received Reply: %s ", Thread.currentThread().getId(), (replyActivity.text() == null) ? "No Text set" : replyActivity.text()); + System.out.flush(); + System.out.printf("=============\n From: %s\n To:%s\n ==========\n", (replyActivity.from() == null) ? "No from set" : replyActivity.from().name(), + (replyActivity.recipient() == null) ? "No recipient set" : replyActivity.recipient().name()); + System.out.flush(); + + // if we have a reply + return validateActivity.apply(replyActivity); + } else { + System.out.printf("AssertReply(tid:%s): Waiting..\n", Thread.currentThread().getId()); + System.out.flush(); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + }, this); + } + + // Hack to determine if debugger attached.. + public boolean isDebug() { + for (String arg : ManagementFactory.getRuntimeMXBean().getInputArguments()) { + if (arg.contains("jdwp=")) { + return true; + } + } + return false; + } + + + /** + * @param userSays + * @param expected + * @return + */ + public TestFlow Turn(String userSays, String expected, String description, int timeout) { + String result = null; + try { + + result = CompletableFuture.supplyAsync(() -> { // Send the message + + if (userSays == null) + throw new IllegalArgumentException("You have to pass a userSays parameter"); + + System.out.print(String.format("TestTurn(%s): USER SAYS: %s \n", Thread.currentThread().getId(), userSays)); + System.out.flush(); + + try { + this.adapter.SendTextToBot(userSays, this.callback); + return null; + } catch (Exception e) { + return e.getMessage(); + } + + }) + .thenApply(arg -> { // Assert Reply + int finalTimeout = Integer.MAX_VALUE; + if (isDebug()) + finalTimeout = Integer.MAX_VALUE; + Function validateActivity = activity -> { + if (activity.text().equals(expected)) { + System.out.println(String.format("TestTurn(tid:%s): Validated text is: %s", Thread.currentThread().getId(), expected)); + System.out.flush(); + + return "SUCCESS"; + } + System.out.println(String.format("TestTurn(tid:%s): Failed validate text is: %s", Thread.currentThread().getId(), expected)); + System.out.flush(); + + return String.format("FAIL: %s received in Activity.text (%s expected)", activity.text(), expected); + }; + + + System.out.println(String.format("TestTurn(tid:%s): Started receive loop: %s", Thread.currentThread().getId(), description)); + System.out.flush(); + DateTime start = DateTime.now(); + while (true) { + DateTime current = DateTime.now(); + + if ((current.getMillis() - start.getMillis()) > (long) finalTimeout) + return String.format("TestTurn: %d ms Timed out waiting for:'%s'", finalTimeout, description); + + + Activity replyActivity = this.adapter.GetNextReply(); + + + if (replyActivity != null) { + // if we have a reply + System.out.println(String.format("TestTurn(tid:%s): Received Reply: %s", + Thread.currentThread().getId(), + String.format("\n========\n To:%s\n From:%s\n Msg:%s\n=======", replyActivity.recipient().name(), replyActivity.from().name(), replyActivity.text()) + )); + System.out.flush(); + return validateActivity.apply(replyActivity); + } else { + System.out.println(String.format("TestTurn(tid:%s): No reply..", Thread.currentThread().getId())); + System.out.flush(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + } + }) + .get(timeout, TimeUnit.MILLISECONDS); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } catch (TimeoutException e) { + e.printStackTrace(); + } + return this; + + } + + /** + * 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); + } + + public TestFlow Test(String userSays, String expected, String description) { + return Test(userSays, expected, description, 3000); + } + + public TestFlow Test(String userSays, String expected, String description, int timeout) { + if (expected == null) + throw new IllegalArgumentException("expected"); + + return this.Send(userSays) + .AssertReply(expected, description, timeout); + } + + /** + * 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); + } + + public TestFlow Test(String userSays, Activity expected, String description) { + return Test(userSays, expected, description, 3000); + } + + public TestFlow Test(String userSays, Activity expected, String description, int timeout) { + if (expected == null) + throw new IllegalArgumentException("expected"); + + return this.Send(userSays) + .AssertReply(expected, description, timeout); + } + + /** + * Say() -> shortcut for .Send(user).AssertReply(Expected) + * + * @param userSays + * @param expected + * @param description + * @param timeout + * @return + */ + public TestFlow Test(String userSays, Function expected) { + return Test(userSays, expected, null, 3000); + } + + public TestFlow Test(String userSays, Function expected, String description) { + return Test(userSays, expected, description, 3000); + } + + public TestFlow Test(String userSays, Function expected, String description, int timeout) { + if (expected == null) + throw new IllegalArgumentException("expected"); + + return this.Send(userSays) + .AssertReply(expected, description, timeout); + } + + /** + * 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); + } + + public TestFlow AssertReplyOneOf(String[] candidates, String description) { + return AssertReplyOneOf(candidates, description, 3000); + } + + public TestFlow AssertReplyOneOf(String[] candidates, String description, int timeout) { + if (candidates == null) + throw new IllegalArgumentException("candidates"); + + return this.AssertReply((reply) -> { + for (String candidate : candidates) { + if (reply.text() == candidate) + return null; + } + return String.format("%s: Not one of candidates: %s", description, String.join("\n ", candidates)); + }, description, timeout); + } + +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/base/InterceptorManager.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/InterceptorManager.java similarity index 97% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/base/InterceptorManager.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/InterceptorManager.java index 24294b3f..52bde0ea 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/base/InterceptorManager.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/InterceptorManager.java @@ -1,327 +1,327 @@ -package com.microsoft.bot.builder.base; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.google.common.io.BaseEncoding; -import okhttp3.*; -import okhttp3.internal.Util; -import okio.Buffer; -import okio.BufferedSource; - -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.net.URL; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.zip.GZIPInputStream; - -public class InterceptorManager { - - private final static String RECORD_FOLDER = "session-records/"; - - private Map textReplacementRules = new HashMap(); - // Stores a map of all the HTTP properties in a session - // A state machine ensuring a test is always reset before another one is setup - - protected RecordedData recordedData; - - private final String testName; - - private final TestBase.TestMode testMode; - - private InterceptorManager(String testName, TestBase.TestMode testMode) { - this.testName = testName; - this.testMode = testMode; - } - - public void addTextReplacementRule(String regex, String replacement) { - textReplacementRules.put(regex, replacement); - } - - // factory method - public static InterceptorManager create(String testName, TestBase.TestMode testMode) throws IOException { - InterceptorManager interceptorManager = new InterceptorManager(testName, testMode); - - return interceptorManager; - } - - public boolean isRecordMode() { - return testMode == TestBase.TestMode.RECORD; - } - - public boolean isPlaybackMode() { - return testMode == TestBase.TestMode.PLAYBACK; - } - - public Interceptor initInterceptor() throws IOException { - switch (testMode) { - case RECORD: - recordedData = new RecordedData(); - return new Interceptor() { - @Override - public Response intercept(Chain chain) throws IOException { - return record(chain); - } - }; - case PLAYBACK: - readDataFromFile(); - return new Interceptor() { - @Override - public Response intercept(Chain chain) throws IOException { - return playback(chain); - } - }; - default: - System.out.println("==> Unknown AZURE_TEST_MODE: " + testMode); - }; - return null; - } - - public void finalizeInterceptor() throws IOException { - switch (testMode) { - case RECORD: - writeDataToFile(); - break; - case PLAYBACK: - // Do nothing - break; - default: - System.out.println("==> Unknown AZURE_TEST_MODE: " + testMode); - }; - } - - private Response record(Interceptor.Chain chain) throws IOException { - Request request = chain.request(); - NetworkCallRecord networkCallRecord = new NetworkCallRecord(); - - networkCallRecord.Headers = new HashMap<>(); - - if (request.header("Content-Type") != null) { - networkCallRecord.Headers.put("Content-Type", request.header("Content-Type")); - } - if (request.header("x-ms-version") != null) { - networkCallRecord.Headers.put("x-ms-version", request.header("x-ms-version")); - } - if (request.header("User-Agent") != null) { - networkCallRecord.Headers.put("User-Agent", request.header("User-Agent")); - } - - networkCallRecord.Method = request.method(); - networkCallRecord.Uri = applyReplacementRule(request.url().toString().replaceAll("\\?$", "")); - - networkCallRecord.Body = bodyToString(request); - - Response response = chain.proceed(request); - - networkCallRecord.Response = new HashMap<>(); - networkCallRecord.Response.put("StatusCode", Integer.toString(response.code())); - extractResponseData(networkCallRecord.Response, response); - - // remove pre-added header if this is a waiting or redirection - if (networkCallRecord.Response.get("Body") != null) { - if (networkCallRecord.Response.get("Body").contains("InProgress") - || Integer.parseInt(networkCallRecord.Response.get("StatusCode")) == 307) { - // Do nothing - } else { - synchronized (recordedData.getNetworkCallRecords()) { - recordedData.getNetworkCallRecords().add(networkCallRecord); - } - } - } - - return response; - } - - private String bodyToString(final Request request) { - try { - final Buffer buffer = new Buffer(); - - request.newBuilder().build().body().writeTo(buffer); - return buffer.readUtf8(); - } catch (final Exception e) { - return ""; - } - } - - private Response playback(Interceptor.Chain chain) throws IOException { - Request request = chain.request(); - String incomingUrl = applyReplacementRule(request.url().toString()); - String incomingMethod = request.method(); - - incomingUrl = removeHost(incomingUrl); - NetworkCallRecord networkCallRecord = null; - synchronized (recordedData) { - for (Iterator iterator = recordedData.getNetworkCallRecords().iterator(); iterator.hasNext(); ) { - NetworkCallRecord record = iterator.next(); - if (record.Method.equalsIgnoreCase(incomingMethod) && removeHost(record.Uri).equalsIgnoreCase(incomingUrl)) { - networkCallRecord = record; - iterator.remove(); - break; - } - } - } - - if (networkCallRecord == null) { - System.out.println("NOT FOUND - " + incomingMethod + " " + incomingUrl); - System.out.println("Remaining records " + recordedData.getNetworkCallRecords().size()); - throw new IOException("==> Unexpected request: " + incomingMethod + " " + incomingUrl); - } - - int recordStatusCode = Integer.parseInt(networkCallRecord.Response.get("StatusCode")); - - //Response originalResponse = chain.proceed(request); - //originalResponse.body().close(); - - Response.Builder responseBuilder = new Response.Builder() - .request(request.newBuilder().build()) - .protocol(Protocol.HTTP_2) - .code(recordStatusCode).message("-"); - - for (Map.Entry pair : networkCallRecord.Response.entrySet()) { - if (!pair.getKey().equals("StatusCode") && !pair.getKey().equals("Body") && !pair.getKey().equals("Content-Length")) { - String rawHeader = pair.getValue(); - for (Map.Entry rule : textReplacementRules.entrySet()) { - if (rule.getValue() != null) { - rawHeader = rawHeader.replaceAll(rule.getKey(), rule.getValue()); - } - } - responseBuilder.addHeader(pair.getKey(), rawHeader); - } - } - - String rawBody = networkCallRecord.Response.get("Body"); - if (rawBody != null) { - for (Map.Entry rule : textReplacementRules.entrySet()) { - if (rule.getValue() != null) { - rawBody = rawBody.replaceAll(rule.getKey(), rule.getValue()); - } - } - - String rawContentType = networkCallRecord.Response.get("content-type"); - String contentType = rawContentType == null - ? "application/json; charset=utf-8" - : rawContentType; - - ResponseBody responseBody; - - if (contentType.toLowerCase().contains("application/json")) { - responseBody = ResponseBody.create(MediaType.parse(contentType), rawBody.getBytes()); - } else { - responseBody = ResponseBody.create(MediaType.parse(contentType), BaseEncoding.base64().decode(rawBody)); - } - - responseBuilder.body(responseBody); - responseBuilder.addHeader("Content-Length", String.valueOf(rawBody.getBytes("UTF-8").length)); - } - - Response newResponse = responseBuilder.build(); - - return newResponse; - } - - private void extractResponseData(Map responseData, Response response) throws IOException { - Map> headers = response.headers().toMultimap(); - boolean addedRetryAfter = false; - for (Map.Entry> header : headers.entrySet()) { - String headerValueToStore = header.getValue().get(0); - - if (header.getKey().equalsIgnoreCase("location") || header.getKey().equalsIgnoreCase("azure-asyncoperation")) { - headerValueToStore = applyReplacementRule(headerValueToStore); - } - if (header.getKey().equalsIgnoreCase("retry-after")) { - headerValueToStore = "0"; - addedRetryAfter = true; - } - responseData.put(header.getKey().toLowerCase(), headerValueToStore); - } - - if (!addedRetryAfter) { - responseData.put("retry-after", "0"); - } - - BufferedSource bufferedSource = response.body().source(); - bufferedSource.request(9223372036854775807L); - Buffer buffer = bufferedSource.buffer().clone(); - String content = null; - - if (response.header("Content-Encoding") == null) { - String contentType = response.header("Content-Type"); - if (contentType != null) { - if (contentType.startsWith("application/json")) - { - content = buffer.readString(Util.UTF_8); - } else { - content = BaseEncoding.base64().encode(buffer.readByteArray()); - } - } - } else if (response.header("Content-Encoding").equalsIgnoreCase("gzip")) { - GZIPInputStream gis = new GZIPInputStream(buffer.inputStream()); - content = ""; - responseData.remove("Content-Encoding".toLowerCase()); - responseData.put("Content-Length".toLowerCase(), Integer.toString(content.length())); - } - - if (content != null) { - content = applyReplacementRule(content); - responseData.put("Body", content); - } - } - - private void readDataFromFile() throws IOException { - File recordFile = getRecordFile(testName); - ObjectMapper mapper = new ObjectMapper(); - mapper.enable(SerializationFeature.INDENT_OUTPUT); - recordedData = mapper.readValue(recordFile, RecordedData.class); - System.out.println("Total records " + recordedData.getNetworkCallRecords().size()); - } - - private void writeDataToFile() throws IOException { - ObjectMapper mapper = new ObjectMapper(); - mapper.enable(SerializationFeature.INDENT_OUTPUT); - File recordFile = getRecordFile(testName); - recordFile.createNewFile(); - mapper.writeValue(recordFile, recordedData); - } - - private File getRecordFile(String testName) { - URL folderUrl = InterceptorManager.class.getClassLoader().getResource("."); - File folderFile = new File(folderUrl.getPath() + RECORD_FOLDER); - if (!folderFile.exists()) { - folderFile.mkdir(); - } - String filePath = folderFile.getPath() + "/" + testName + ".json"; - System.out.println("==> Playback file path: " + filePath); - return new File(filePath); - } - - private String applyReplacementRule(String text) { - for (Map.Entry rule : textReplacementRules.entrySet()) { - if (rule.getValue() != null) { - text = text.replaceAll(rule.getKey(), rule.getValue()); - } - } - return text; - } - - private String removeHost(String url) { - URI uri = URI.create(url); - return String.format("%s?%s", uri.getPath(), uri.getQuery()); - } - - public void pushVariable(String variable) { - if (isRecordMode()) { - synchronized (recordedData.getVariables()) { - recordedData.getVariables().add(variable); - } - } - } - - public String popVariable() { - synchronized (recordedData.getVariables()) { - return recordedData.getVariables().remove(); - } - } -} +package com.microsoft.bot.builder.base; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.google.common.io.BaseEncoding; +import okhttp3.*; +import okhttp3.internal.Util; +import okio.Buffer; +import okio.BufferedSource; + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URL; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.zip.GZIPInputStream; + +public class InterceptorManager { + + private final static String RECORD_FOLDER = "session-records/"; + + private Map textReplacementRules = new HashMap(); + // Stores a map of all the HTTP properties in a session + // A state machine ensuring a test is always reset before another one is setup + + protected RecordedData recordedData; + + private final String testName; + + private final TestBase.TestMode testMode; + + private InterceptorManager(String testName, TestBase.TestMode testMode) { + this.testName = testName; + this.testMode = testMode; + } + + public void addTextReplacementRule(String regex, String replacement) { + textReplacementRules.put(regex, replacement); + } + + // factory method + public static InterceptorManager create(String testName, TestBase.TestMode testMode) throws IOException { + InterceptorManager interceptorManager = new InterceptorManager(testName, testMode); + + return interceptorManager; + } + + public boolean isRecordMode() { + return testMode == TestBase.TestMode.RECORD; + } + + public boolean isPlaybackMode() { + return testMode == TestBase.TestMode.PLAYBACK; + } + + public Interceptor initInterceptor() throws IOException { + switch (testMode) { + case RECORD: + recordedData = new RecordedData(); + return new Interceptor() { + @Override + public Response intercept(Chain chain) throws IOException { + return record(chain); + } + }; + case PLAYBACK: + readDataFromFile(); + return new Interceptor() { + @Override + public Response intercept(Chain chain) throws IOException { + return playback(chain); + } + }; + default: + System.out.println("==> Unknown AZURE_TEST_MODE: " + testMode); + }; + return null; + } + + public void finalizeInterceptor() throws IOException { + switch (testMode) { + case RECORD: + writeDataToFile(); + break; + case PLAYBACK: + // Do nothing + break; + default: + System.out.println("==> Unknown AZURE_TEST_MODE: " + testMode); + }; + } + + private Response record(Interceptor.Chain chain) throws IOException { + Request request = chain.request(); + NetworkCallRecord networkCallRecord = new NetworkCallRecord(); + + networkCallRecord.Headers = new HashMap<>(); + + if (request.header("Content-Type") != null) { + networkCallRecord.Headers.put("Content-Type", request.header("Content-Type")); + } + if (request.header("x-ms-version") != null) { + networkCallRecord.Headers.put("x-ms-version", request.header("x-ms-version")); + } + if (request.header("User-Agent") != null) { + networkCallRecord.Headers.put("User-Agent", request.header("User-Agent")); + } + + networkCallRecord.Method = request.method(); + networkCallRecord.Uri = applyReplacementRule(request.url().toString().replaceAll("\\?$", "")); + + networkCallRecord.Body = bodyToString(request); + + Response response = chain.proceed(request); + + networkCallRecord.Response = new HashMap<>(); + networkCallRecord.Response.put("StatusCode", Integer.toString(response.code())); + extractResponseData(networkCallRecord.Response, response); + + // remove pre-added header if this is a waiting or redirection + if (networkCallRecord.Response.get("Body") != null) { + if (networkCallRecord.Response.get("Body").contains("InProgress") + || Integer.parseInt(networkCallRecord.Response.get("StatusCode")) == 307) { + // Do nothing + } else { + synchronized (recordedData.getNetworkCallRecords()) { + recordedData.getNetworkCallRecords().add(networkCallRecord); + } + } + } + + return response; + } + + private String bodyToString(final Request request) { + try { + final Buffer buffer = new Buffer(); + + request.newBuilder().build().body().writeTo(buffer); + return buffer.readUtf8(); + } catch (final Exception e) { + return ""; + } + } + + private Response playback(Interceptor.Chain chain) throws IOException { + Request request = chain.request(); + String incomingUrl = applyReplacementRule(request.url().toString()); + String incomingMethod = request.method(); + + incomingUrl = removeHost(incomingUrl); + NetworkCallRecord networkCallRecord = null; + synchronized (recordedData) { + for (Iterator iterator = recordedData.getNetworkCallRecords().iterator(); iterator.hasNext(); ) { + NetworkCallRecord record = iterator.next(); + if (record.Method.equalsIgnoreCase(incomingMethod) && removeHost(record.Uri).equalsIgnoreCase(incomingUrl)) { + networkCallRecord = record; + iterator.remove(); + break; + } + } + } + + if (networkCallRecord == null) { + System.out.println("NOT FOUND - " + incomingMethod + " " + incomingUrl); + System.out.println("Remaining records " + recordedData.getNetworkCallRecords().size()); + throw new IOException("==> Unexpected request: " + incomingMethod + " " + incomingUrl); + } + + int recordStatusCode = Integer.parseInt(networkCallRecord.Response.get("StatusCode")); + + //Response originalResponse = chain.proceed(request); + //originalResponse.body().close(); + + Response.Builder responseBuilder = new Response.Builder() + .request(request.newBuilder().build()) + .protocol(Protocol.HTTP_2) + .code(recordStatusCode).message("-"); + + for (Map.Entry pair : networkCallRecord.Response.entrySet()) { + if (!pair.getKey().equals("StatusCode") && !pair.getKey().equals("Body") && !pair.getKey().equals("Content-Length")) { + String rawHeader = pair.getValue(); + for (Map.Entry rule : textReplacementRules.entrySet()) { + if (rule.getValue() != null) { + rawHeader = rawHeader.replaceAll(rule.getKey(), rule.getValue()); + } + } + responseBuilder.addHeader(pair.getKey(), rawHeader); + } + } + + String rawBody = networkCallRecord.Response.get("Body"); + if (rawBody != null) { + for (Map.Entry rule : textReplacementRules.entrySet()) { + if (rule.getValue() != null) { + rawBody = rawBody.replaceAll(rule.getKey(), rule.getValue()); + } + } + + String rawContentType = networkCallRecord.Response.get("content-type"); + String contentType = rawContentType == null + ? "application/json; charset=utf-8" + : rawContentType; + + ResponseBody responseBody; + + if (contentType.toLowerCase().contains("application/json")) { + responseBody = ResponseBody.create(MediaType.parse(contentType), rawBody.getBytes()); + } else { + responseBody = ResponseBody.create(MediaType.parse(contentType), BaseEncoding.base64().decode(rawBody)); + } + + responseBuilder.body(responseBody); + responseBuilder.addHeader("Content-Length", String.valueOf(rawBody.getBytes("UTF-8").length)); + } + + Response newResponse = responseBuilder.build(); + + return newResponse; + } + + private void extractResponseData(Map responseData, Response response) throws IOException { + Map> headers = response.headers().toMultimap(); + boolean addedRetryAfter = false; + for (Map.Entry> header : headers.entrySet()) { + String headerValueToStore = header.getValue().get(0); + + if (header.getKey().equalsIgnoreCase("location") || header.getKey().equalsIgnoreCase("azure-asyncoperation")) { + headerValueToStore = applyReplacementRule(headerValueToStore); + } + if (header.getKey().equalsIgnoreCase("retry-after")) { + headerValueToStore = "0"; + addedRetryAfter = true; + } + responseData.put(header.getKey().toLowerCase(), headerValueToStore); + } + + if (!addedRetryAfter) { + responseData.put("retry-after", "0"); + } + + BufferedSource bufferedSource = response.body().source(); + bufferedSource.request(9223372036854775807L); + Buffer buffer = bufferedSource.buffer().clone(); + String content = null; + + if (response.header("Content-Encoding") == null) { + String contentType = response.header("Content-Type"); + if (contentType != null) { + if (contentType.startsWith("application/json")) + { + content = buffer.readString(Util.UTF_8); + } else { + content = BaseEncoding.base64().encode(buffer.readByteArray()); + } + } + } else if (response.header("Content-Encoding").equalsIgnoreCase("gzip")) { + GZIPInputStream gis = new GZIPInputStream(buffer.inputStream()); + content = ""; + responseData.remove("Content-Encoding".toLowerCase()); + responseData.put("Content-Length".toLowerCase(), Integer.toString(content.length())); + } + + if (content != null) { + content = applyReplacementRule(content); + responseData.put("Body", content); + } + } + + private void readDataFromFile() throws IOException { + File recordFile = getRecordFile(testName); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationFeature.INDENT_OUTPUT); + recordedData = mapper.readValue(recordFile, RecordedData.class); + System.out.println("Total records " + recordedData.getNetworkCallRecords().size()); + } + + private void writeDataToFile() throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationFeature.INDENT_OUTPUT); + File recordFile = getRecordFile(testName); + recordFile.createNewFile(); + mapper.writeValue(recordFile, recordedData); + } + + private File getRecordFile(String testName) { + URL folderUrl = InterceptorManager.class.getClassLoader().getResource("."); + File folderFile = new File(folderUrl.getPath() + RECORD_FOLDER); + if (!folderFile.exists()) { + folderFile.mkdir(); + } + String filePath = folderFile.getPath() + "/" + testName + ".json"; + System.out.println("==> Playback file path: " + filePath); + return new File(filePath); + } + + private String applyReplacementRule(String text) { + for (Map.Entry rule : textReplacementRules.entrySet()) { + if (rule.getValue() != null) { + text = text.replaceAll(rule.getKey(), rule.getValue()); + } + } + return text; + } + + private String removeHost(String url) { + URI uri = URI.create(url); + return String.format("%s?%s", uri.getPath(), uri.getQuery()); + } + + public void pushVariable(String variable) { + if (isRecordMode()) { + synchronized (recordedData.getVariables()) { + recordedData.getVariables().add(variable); + } + } + } + + public String popVariable() { + synchronized (recordedData.getVariables()) { + return recordedData.getVariables().remove(); + } + } +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/base/NetworkCallRecord.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/NetworkCallRecord.java similarity index 95% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/base/NetworkCallRecord.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/NetworkCallRecord.java index 201be568..6401faf7 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/base/NetworkCallRecord.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/NetworkCallRecord.java @@ -1,12 +1,12 @@ -package com.microsoft.bot.builder.base; - -import java.util.Map; - -public class NetworkCallRecord { - public String Method; - public String Uri; - public String Body; - - public Map Headers; - public Map Response; -} +package com.microsoft.bot.builder.base; + +import java.util.Map; + +public class NetworkCallRecord { + public String Method; + public String Uri; + public String Body; + + public Map Headers; + public Map Response; +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/base/RecordedData.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/RecordedData.java similarity index 95% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/base/RecordedData.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/RecordedData.java index f178b9cd..2b2417af 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/base/RecordedData.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/RecordedData.java @@ -1,22 +1,22 @@ -package com.microsoft.bot.builder.base; - -import java.util.LinkedList; - -public class RecordedData { - private LinkedList networkCallRecords; - - private LinkedList variables; - - public RecordedData() { - networkCallRecords = new LinkedList<>(); - variables = new LinkedList<>(); - } - - public LinkedList getNetworkCallRecords() { - return networkCallRecords; - } - - public LinkedList getVariables() { - return variables; - } -} +package com.microsoft.bot.builder.base; + +import java.util.LinkedList; + +public class RecordedData { + private LinkedList networkCallRecords; + + private LinkedList variables; + + public RecordedData() { + networkCallRecords = new LinkedList<>(); + variables = new LinkedList<>(); + } + + public LinkedList getNetworkCallRecords() { + return networkCallRecords; + } + + public LinkedList getVariables() { + return variables; + } +} diff --git a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/base/TestBase.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/TestBase.java similarity index 97% rename from libraries/botbuilder/src/test/java/com/microsoft/bot/builder/base/TestBase.java rename to libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/TestBase.java index 6136078c..656a6adb 100644 --- a/libraries/botbuilder/src/test/java/com/microsoft/bot/builder/base/TestBase.java +++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/TestBase.java @@ -1,212 +1,212 @@ -package com.microsoft.bot.builder.base; - -import com.microsoft.bot.connector.authentication.MicrosoftAppCredentials; -import com.microsoft.rest.LogLevel; -import com.microsoft.rest.RestClient; -import com.microsoft.rest.ServiceResponseBuilder; -import com.microsoft.rest.credentials.ServiceClientCredentials; -import com.microsoft.rest.credentials.TokenCredentials; -import com.microsoft.rest.interceptors.LoggingInterceptor; -import com.microsoft.rest.serializer.JacksonAdapter; -import org.junit.*; -import org.junit.rules.TestName; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintStream; -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -public abstract class TestBase { - - private PrintStream out; - - protected enum RunCondition { - MOCK_ONLY, - LIVE_ONLY, - BOTH - } - - public enum TestMode { - PLAYBACK, - RECORD - } - - private final RunCondition runCondition; - - protected TestBase() { - this(RunCondition.BOTH); - } - - protected TestBase(RunCondition runCondition) { - this.runCondition = runCondition; - } - - private String shouldCancelTest(boolean isPlaybackMode) { - // Determine whether to run the test based on the condition the test has been configured with - switch (this.runCondition) { - case MOCK_ONLY: - return (!isPlaybackMode) ? "Test configured to run only as mocked, not live." : null; - case LIVE_ONLY: - return (isPlaybackMode) ? "Test configured to run only as live, not mocked." : null; - default: - return null; - } - } - - private static TestMode testMode = null; - - protected final static String ZERO_CLIENT_ID = "00000000-0000-0000-0000-000000000000"; - protected final static String ZERO_CLIENT_SECRET = "00000000000000000000000"; - protected final static String ZERO_USER_ID = "<--dummy-user-id-->"; - protected final static String ZERO_BOT_ID = "<--dummy-bot-id-->"; - protected final static String ZERO_TOKEN = "<--dummy-token-->"; - - private static final String PLAYBACK_URI = "http://localhost:1234"; - - protected static String hostUri = null; - protected static String clientId = null; - protected static String clientSecret = null; - protected static String userId = null; - protected static String botId = null; - - private static void initTestMode() throws IOException { - String azureTestMode = System.getenv("AZURE_TEST_MODE"); - if (azureTestMode != null) { - if (azureTestMode.equalsIgnoreCase("Record")) { - testMode = TestMode.RECORD; - } else if (azureTestMode.equalsIgnoreCase("Playback")) { - testMode = TestMode.PLAYBACK; - } else { - throw new IOException("Unknown AZURE_TEST_MODE: " + azureTestMode); - } - } else { - System.out.print("Environment variable 'AZURE_TEST_MODE' has not been set yet. Using 'PLAYBACK' mode."); - testMode = TestMode.RECORD; - } - } - - private static void initParams() { - try { - Properties mavenProps = new Properties(); - InputStream in = TestBase.class.getResourceAsStream("/maven.properties"); - if (in == null) { - throw new IOException("The file \"maven.properties\" has not been generated yet. Please execute \"mvn compile\" to generate the file."); - } - mavenProps.load(in); - - clientId = mavenProps.getProperty("clientId"); - clientSecret = mavenProps.getProperty("clientSecret"); - hostUri = mavenProps.getProperty("hostUrl"); - userId = mavenProps.getProperty("userId"); - botId = mavenProps.getProperty("botId"); - } catch (IOException e) { - clientId = ZERO_CLIENT_ID; - clientSecret = ZERO_CLIENT_SECRET; - hostUri = PLAYBACK_URI; - userId = ZERO_USER_ID; - botId = ZERO_BOT_ID; - } - } - - public static boolean isPlaybackMode() { - if (testMode == null) try { - initTestMode(); - } catch (IOException e) { - e.printStackTrace(); - throw new RuntimeException("Can't init test mode."); - } - return testMode == TestMode.PLAYBACK; - } - - public static boolean isRecordMode() { - return !isPlaybackMode(); - } - - @Rule - public TestName testName = new TestName(); - - protected InterceptorManager interceptorManager = null; - - private static void printThreadInfo(String what) { - long id = Thread.currentThread().getId(); - String name = Thread.currentThread().getName(); - System.out.println(String.format("\n***\n*** [%s:%s] - %s\n***\n", name, id, what)); - } - - @BeforeClass - public static void beforeClass() throws IOException { - printThreadInfo("beforeClass"); - initTestMode(); - initParams(); - } - - @Before - public void beforeTest() throws IOException { - printThreadInfo(String.format("%s: %s", "beforeTest", testName.getMethodName())); - final String skipMessage = shouldCancelTest(isPlaybackMode()); - Assume.assumeTrue(skipMessage, skipMessage == null); - - interceptorManager = InterceptorManager.create(testName.getMethodName(), testMode); - - ServiceClientCredentials credentials; - RestClient restClient; - - if (isPlaybackMode()) { - credentials = new TokenCredentials(null, ZERO_TOKEN); - restClient = buildRestClient(new RestClient.Builder() - .withBaseUrl(hostUri + "/") - .withSerializerAdapter(new JacksonAdapter()) - .withResponseBuilderFactory(new ServiceResponseBuilder.Factory()) - .withCredentials(credentials) - .withLogLevel(LogLevel.NONE) - .withNetworkInterceptor(new LoggingInterceptor(LogLevel.BODY_AND_HEADERS)) - .withInterceptor(interceptorManager.initInterceptor()) - ,true); - - out = System.out; - System.setOut(new PrintStream(new OutputStream() { - public void write(int b) { - //DO NOTHING - } - })); - } - else { // Record mode - credentials = new MicrosoftAppCredentials(clientId, clientSecret); - restClient = buildRestClient(new RestClient.Builder() - .withBaseUrl(hostUri + "/") - .withSerializerAdapter(new JacksonAdapter()) - .withResponseBuilderFactory(new ServiceResponseBuilder.Factory()) - .withCredentials(credentials) - .withLogLevel(LogLevel.NONE) - .withReadTimeout(3, TimeUnit.MINUTES) - .withNetworkInterceptor(new LoggingInterceptor(LogLevel.BODY_AND_HEADERS)) - .withInterceptor(interceptorManager.initInterceptor()) - ,false); - - //interceptorManager.addTextReplacementRule(hostUri, PLAYBACK_URI); - } - initializeClients(restClient, botId, userId); - } - - @After - public void afterTest() throws IOException { - if(shouldCancelTest(isPlaybackMode()) != null) { - return; - } - cleanUpResources(); - interceptorManager.finalizeInterceptor(); - } - - protected void addTextReplacementRule(String from, String to ) { - interceptorManager.addTextReplacementRule(from, to); - } - - protected RestClient buildRestClient(RestClient.Builder builder, boolean isMocked) { - return builder.build(); - } - - protected abstract void initializeClients(RestClient restClient, String botId, String userId) throws IOException; - protected abstract void cleanUpResources(); -} +package com.microsoft.bot.builder.base; + +import com.microsoft.bot.connector.authentication.MicrosoftAppCredentials; +import com.microsoft.rest.LogLevel; +import com.microsoft.rest.RestClient; +import com.microsoft.rest.ServiceResponseBuilder; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.credentials.TokenCredentials; +import com.microsoft.rest.interceptors.LoggingInterceptor; +import com.microsoft.rest.serializer.JacksonAdapter; +import org.junit.*; +import org.junit.rules.TestName; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +public abstract class TestBase { + + private PrintStream out; + + protected enum RunCondition { + MOCK_ONLY, + LIVE_ONLY, + BOTH + } + + public enum TestMode { + PLAYBACK, + RECORD + } + + private final RunCondition runCondition; + + protected TestBase() { + this(RunCondition.BOTH); + } + + protected TestBase(RunCondition runCondition) { + this.runCondition = runCondition; + } + + private String shouldCancelTest(boolean isPlaybackMode) { + // Determine whether to run the test based on the condition the test has been configured with + switch (this.runCondition) { + case MOCK_ONLY: + return (!isPlaybackMode) ? "Test configured to run only as mocked, not live." : null; + case LIVE_ONLY: + return (isPlaybackMode) ? "Test configured to run only as live, not mocked." : null; + default: + return null; + } + } + + private static TestMode testMode = null; + + protected final static String ZERO_CLIENT_ID = "00000000-0000-0000-0000-000000000000"; + protected final static String ZERO_CLIENT_SECRET = "00000000000000000000000"; + protected final static String ZERO_USER_ID = "<--dummy-user-id-->"; + protected final static String ZERO_BOT_ID = "<--dummy-bot-id-->"; + protected final static String ZERO_TOKEN = "<--dummy-token-->"; + + private static final String PLAYBACK_URI = "http://localhost:1234"; + + protected static String hostUri = null; + protected static String clientId = null; + protected static String clientSecret = null; + protected static String userId = null; + protected static String botId = null; + + private static void initTestMode() throws IOException { + String azureTestMode = System.getenv("AZURE_TEST_MODE"); + if (azureTestMode != null) { + if (azureTestMode.equalsIgnoreCase("Record")) { + testMode = TestMode.RECORD; + } else if (azureTestMode.equalsIgnoreCase("Playback")) { + testMode = TestMode.PLAYBACK; + } else { + throw new IOException("Unknown AZURE_TEST_MODE: " + azureTestMode); + } + } else { + System.out.print("Environment variable 'AZURE_TEST_MODE' has not been set yet. Using 'PLAYBACK' mode."); + testMode = TestMode.RECORD; + } + } + + private static void initParams() { + try { + Properties mavenProps = new Properties(); + InputStream in = TestBase.class.getResourceAsStream("/maven.properties"); + if (in == null) { + throw new IOException("The file \"maven.properties\" has not been generated yet. Please execute \"mvn compile\" to generate the file."); + } + mavenProps.load(in); + + clientId = mavenProps.getProperty("clientId"); + clientSecret = mavenProps.getProperty("clientSecret"); + hostUri = mavenProps.getProperty("hostUrl"); + userId = mavenProps.getProperty("userId"); + botId = mavenProps.getProperty("botId"); + } catch (IOException e) { + clientId = ZERO_CLIENT_ID; + clientSecret = ZERO_CLIENT_SECRET; + hostUri = PLAYBACK_URI; + userId = ZERO_USER_ID; + botId = ZERO_BOT_ID; + } + } + + public static boolean isPlaybackMode() { + if (testMode == null) try { + initTestMode(); + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException("Can't init test mode."); + } + return testMode == TestMode.PLAYBACK; + } + + public static boolean isRecordMode() { + return !isPlaybackMode(); + } + + @Rule + public TestName testName = new TestName(); + + protected InterceptorManager interceptorManager = null; + + private static void printThreadInfo(String what) { + long id = Thread.currentThread().getId(); + String name = Thread.currentThread().getName(); + System.out.println(String.format("\n***\n*** [%s:%s] - %s\n***\n", name, id, what)); + } + + @BeforeClass + public static void beforeClass() throws IOException { + printThreadInfo("beforeClass"); + initTestMode(); + initParams(); + } + + @Before + public void beforeTest() throws IOException { + printThreadInfo(String.format("%s: %s", "beforeTest", testName.getMethodName())); + final String skipMessage = shouldCancelTest(isPlaybackMode()); + Assume.assumeTrue(skipMessage, skipMessage == null); + + interceptorManager = InterceptorManager.create(testName.getMethodName(), testMode); + + ServiceClientCredentials credentials; + RestClient restClient; + + if (isPlaybackMode()) { + credentials = new TokenCredentials(null, ZERO_TOKEN); + restClient = buildRestClient(new RestClient.Builder() + .withBaseUrl(hostUri + "/") + .withSerializerAdapter(new JacksonAdapter()) + .withResponseBuilderFactory(new ServiceResponseBuilder.Factory()) + .withCredentials(credentials) + .withLogLevel(LogLevel.NONE) + .withNetworkInterceptor(new LoggingInterceptor(LogLevel.BODY_AND_HEADERS)) + .withInterceptor(interceptorManager.initInterceptor()) + ,true); + + out = System.out; + System.setOut(new PrintStream(new OutputStream() { + public void write(int b) { + //DO NOTHING + } + })); + } + else { // Record mode + credentials = new MicrosoftAppCredentials(clientId, clientSecret); + restClient = buildRestClient(new RestClient.Builder() + .withBaseUrl(hostUri + "/") + .withSerializerAdapter(new JacksonAdapter()) + .withResponseBuilderFactory(new ServiceResponseBuilder.Factory()) + .withCredentials(credentials) + .withLogLevel(LogLevel.NONE) + .withReadTimeout(3, TimeUnit.MINUTES) + .withNetworkInterceptor(new LoggingInterceptor(LogLevel.BODY_AND_HEADERS)) + .withInterceptor(interceptorManager.initInterceptor()) + ,false); + + //interceptorManager.addTextReplacementRule(hostUri, PLAYBACK_URI); + } + initializeClients(restClient, botId, userId); + } + + @After + public void afterTest() throws IOException { + if(shouldCancelTest(isPlaybackMode()) != null) { + return; + } + cleanUpResources(); + interceptorManager.finalizeInterceptor(); + } + + protected void addTextReplacementRule(String from, String to ) { + interceptorManager.addTextReplacementRule(from, to); + } + + protected RestClient buildRestClient(RestClient.Builder builder, boolean isMocked) { + return builder.build(); + } + + protected abstract void initializeClients(RestClient restClient, String botId, String userId) throws IOException; + protected abstract void cleanUpResources(); +} diff --git a/libraries/bot-connector/pom.xml b/libraries/bot-connector/pom.xml index 61d5c4e4..f85a02fb 100644 --- a/libraries/bot-connector/pom.xml +++ b/libraries/bot-connector/pom.xml @@ -2,7 +2,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.microsoft.bot.connector + com.microsoft.bot bot-connector jar 4.0.0-SNAPSHOT @@ -87,8 +87,8 @@ 0.3.0 - com.microsoft.bot.schema - botbuilder-schema + com.microsoft.bot + bot-schema 4.0.0-SNAPSHOT diff --git a/libraries/botbuilder-schema/pom.xml b/libraries/bot-schema/pom.xml similarity index 97% rename from libraries/botbuilder-schema/pom.xml rename to libraries/bot-schema/pom.xml index 98aa8bc7..b8490b90 100644 --- a/libraries/botbuilder-schema/pom.xml +++ b/libraries/bot-schema/pom.xml @@ -2,8 +2,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.microsoft.bot.schema - botbuilder-schema + com.microsoft.bot + bot-schema jar 4.0.0-SNAPSHOT @@ -118,7 +118,7 @@ cobertura-maven-plugin 2.7 - ../../cobertura-report/botbuilder-schema + ../../cobertura-report/bot-schema xml 256m diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/ActivityImpl.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/ActivityImpl.java similarity index 97% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/ActivityImpl.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/ActivityImpl.java index 17bff8ca..ef673d84 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/ActivityImpl.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/ActivityImpl.java @@ -1,782 +1,782 @@ -package com.microsoft.bot.schema; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.TreeNode; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.bot.schema.models.Activity; -import com.microsoft.bot.schema.models.ActivityTypes; -import com.microsoft.bot.schema.models.Attachment; -import com.microsoft.bot.schema.models.ChannelAccount; -import com.microsoft.bot.schema.models.ConversationAccount; -import com.microsoft.bot.schema.models.ConversationReference; -import com.microsoft.bot.schema.models.ConversationUpdateActivity; -import com.microsoft.bot.schema.models.EndOfConversationCodes; -import com.microsoft.bot.schema.models.InputHints; -import com.microsoft.bot.schema.models.Mention; -import com.microsoft.bot.schema.models.MessageActivity; -import com.microsoft.bot.schema.models.SuggestedActions; -import com.microsoft.bot.schema.models.TextHighlight; - -import org.apache.commons.lang3.StringUtils; -import org.joda.time.DateTime; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * 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 { - /** - * Content-type for an Activity - */ - public final String ContentType = "application/vnd.microsoft.activity"; - private static final ObjectMapper mapper = new ObjectMapper(); - - void CustomInit() { - } - - /** - * 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); - } - - public ActivityImpl CreateReply(String text) { - return CreateReply(text, null); - } - - public ActivityImpl CreateReply(String text, String locale) { - ActivityImpl reply = new ActivityImpl(); - reply.withType(ActivityTypes.MESSAGE); - reply.withTimestamp(DateTime.now()); - reply.withFrom(new ChannelAccount() - .withId(recipient().id()) - .withName(recipient().name())); - reply.withRecipient(new ChannelAccount() - .withId(from().id()) - .withName(from().name())); - reply.withReplyToId(this.id()); - reply.withServiceUrl(this.serviceUrl()); - reply.withChannelId(channelId()); - reply.withConversation(new ConversationAccount() - .withIsGroup(conversation().isGroup()) - .withId(conversation().id()) - .withName(conversation().name())); - reply.withText((text == null) ? "" : text); - reply.withLocale((locale == null) ? "" : locale); - reply.withAttachments(new ArrayList()); - reply.withEntities(new ArrayList()); - return reply; - } - - /** - * 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); - } - - public TraceActivity CreateTrace(String name, Object value) { - return CreateTrace(name, value, null, null); - - } - - public TraceActivity CreateTrace(String name, Object value, String valueType) { - return CreateTrace(name, value, valueType, null); - } - - // public TraceActivity CreateTrace(String name, Object value, String valueType, [CallerMemberName] String label) - public TraceActivity CreateTrace(String name, Object value, String valueType, String label) { - TraceActivity reply = new TraceActivity(); - reply.withType(ActivityTypes.TRACE); - reply.withTimestamp(DateTime.now()); - reply.withFrom(new ChannelAccount() - .withId(recipient().id()) - .withName(recipient().name())); - reply.withRecipient(new ChannelAccount() - .withId(from().id()) - .withName(from().name())); - reply.withReplyToId(this.id()); - reply.withServiceUrl(this.serviceUrl()); - reply.withChannelId(channelId()); - reply.withConversation(new ConversationAccount() - .withIsGroup(conversation().isGroup()) - .withId(conversation().id()) - .withName(conversation().name())); - reply.withName(name); - reply.withLabel(label); - reply.withValueType((valueType == null) ? value.getClass().getTypeName() : valueType); - reply.withValue(value); - return reply; - } - - /** - * 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); - } - - public static TraceActivity CreateTraceActivity(String name, String valueType, Object value) { - return CreateTraceActivity(name, valueType, value, null); - } - - // public static TraceActivity CreateTraceActivity(String name, String valueType, Object value, [CallerMemberName] String label=null) - public static TraceActivity CreateTraceActivity(String name, String valueType, Object value, String label) { - TraceActivity reply = (TraceActivity) new TraceActivity(); - reply.withType(ActivityTypes.TRACE); - reply.withName(name); - reply.withLabel(label); - reply.withValueType((valueType == null) ? value.getClass().getTypeName() : valueType); - reply.withValue(value); - return reply; - - } - - /** - * Extension data for overflow of properties - */ - // [JsonExtensionData(ReadData = true, WriteData = true)] - //public JObject Properties { get; set; } = new JObject(); - - /** - * Create an instance of the Activity class with MessageActivity masking - */ - public static MessageActivity CreateMessageActivity() { - MessageActivity reply = new MessageActivity(); - reply.withType(ActivityTypes.TRACE); - reply.withTimestamp(DateTime.now()); - reply.withAttachments(new ArrayList()); - reply.withEntities(new ArrayList()); - return reply; - } - - /** - * 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; - } - - /** - * Create an instance of the Activity class with IConversationUpdateActivity masking - */ - public static ConversationUpdateActivity CreateConversationUpdateActivity() { - ConversationUpdateActivity reply = new ConversationUpdateActivity(); - reply.withType(ActivityTypes.CONVERSATION_UPDATE); - reply.withMembersAdded(new ArrayList()); - reply.withMembersRemoved(new ArrayList()); - return reply; - } - - /** - * Create an instance of the Activity class with ITypingActivity masking - */ - //public static TypingActivity CreateTypingActivity() { return new Activity(ActivityTypes.Typing); } - - /** - * Create an instance of the Activity class with IEndOfConversationActivity masking - */ - //public static IEndOfConversationActivity CreateEndOfConversationActivity() { return new Activity(ActivityTypes.EndOfConversation); } - - /** - * Create an instance of the Activity class with an IEventActivity masking - */ - //public static IEventActivity CreateEventActivity() { return new Activity(ActivityTypes.Event); } - - /** - * Create an instance of the Activity class with IInvokeActivity masking - */ - //public static IInvokeActivity CreateInvokeActivity() { return new Activity(ActivityTypes.Invoke); } - - - /** - * 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 - * this problem, this code is purposefully more verbose due to optimizations. - * - * This main goal of the optimizations was to make zero allocations because it is called - * by all of the .AsXXXActivity methods which are used in a pattern heavily upstream to - * "pseudo-cast" the activity based on its type. - */ - - ActivityTypes type = this.type(); - - // If there's no type set then we can't tell if it's the type they're looking for - if (type == null) { - return false; - } - - // Check if the full type value starts with the type they're looking for - - - boolean result = StringUtils.startsWith(type.toString().toLowerCase(), activityType.toLowerCase()); - - // If the full type value starts with the type they're looking for, then we need to check a little further to check if it's definitely the right type - if (result) { - // If the lengths are equal, then it's the exact type they're looking for - result = type.toString().length() == activityType.length(); - - if (!result) { - // Finally, if the type is longer than the type they're looking for then we need to check if there's a / separator right after the type they're looking for - result = type.toString().length() > activityType.length() - && - type.toString().indexOf(activityType.length()) == '/'; - } - } - - return result; - } - - /** - * Set the type value. - * - * @param type the type value to set - * @return the Activity object itself. - */ - public ActivityImpl withType(ActivityTypes type) { - super.withType(type); - return this; - } - - /** - * Set the id value. - * - * @param id the id value to set - * @return the Activity object itself. - */ - public ActivityImpl withId(String id) { - super.withId(id); - return this; - } - - /** - * Set the timestamp value. - * - * @param timestamp the timestamp value to set - * @return the Activity object itself. - */ - public ActivityImpl withTimestamp(DateTime timestamp) { - super.withTimestamp(timestamp); - return this; - } - /** - * Set the localTimestamp value. - * - * @param localTimestamp the localTimestamp value to set - * @return the Activity object itself. - */ - public ActivityImpl withLocalTimestamp(DateTime localTimestamp) { - super.withLocalTimestamp(localTimestamp); - return this; - } - - /** - * Set the serviceUrl value. - * - * @param serviceUrl the serviceUrl value to set - * @return the Activity object itself. - */ - public ActivityImpl withServiceUrl(String serviceUrl) { - super.withServiceUrl(serviceUrl); - return this; - } - - /** - * Set the channelId value. - * - * @param channelId the channelId value to set - * @return the Activity object itself. - */ - public ActivityImpl withChannelId(String channelId) { - super.withChannelId(channelId); - return this; - } - /** - * Set the from value. - * - * @param from the from value to set - * @return the Activity object itself. - */ - public ActivityImpl withFrom(ChannelAccount from) { - super.withFrom(from); - return this; - } - /** - * Set the conversation value. - * - * @param conversation the conversation value to set - * @return the Activity object itself. - */ - public ActivityImpl withConversation(ConversationAccount conversation) { - super.withConversation(conversation); - return this; - } - /** - * Set the recipient value. - * - * @param recipient the recipient value to set - * @return the Activity object itself. - */ - public ActivityImpl withRecipient(ChannelAccount recipient) { - super.withRecipient(recipient); - return this; - } - - /** - * Set the text value. - * - * @param text the text value to set - * @return the Activity object itself. - */ - public ActivityImpl withText(String text) { - super.withText(text); - return this; - } - - /** - * Set the speak value. - * - * @param speak the speak value to set - * @return the Activity object itself. - */ - public ActivityImpl withSpeak(String speak) { - super.withSpeak(speak); - return this; - } - - - /** - * Set the inputHint value. - * - * @param inputHint the inputHint value to set - * @return the Activity object itself. - */ - public ActivityImpl withInputHint(InputHints inputHint) { - super.withInputHint(inputHint); - return this; - } - - /** - * Set the summary value. - * - * @param summary the summary value to set - * @return the Activity object itself. - */ - public ActivityImpl withSummary(String summary) { - super.withSummary(summary); - return this; - } - - - /** - * Set the suggestedActions value. - * - * @param suggestedActions the suggestedActions value to set - * @return the Activity object itself. - */ - public ActivityImpl withSuggestedActions(SuggestedActions suggestedActions) { - super.withSuggestedActions(suggestedActions); - return this; - } - - - /** - * Set the attachments value. - * - * @param attachments the attachments value to set - * @return the Activity object itself. - */ - public ActivityImpl withAttachments(List attachments) { - super.withAttachments(attachments); - return this; - } - - - /** - * Set the entities value. - * - * @param entities the entities value to set - * @return the Activity object itself. - */ - public ActivityImpl withEntities(List entities) { - super.withEntities(entities); - return this; - } - - - /** - * Set the channelData value. - * - * @param channelData the channelData value to set - * @return the Activity object itself. - */ - public ActivityImpl withChannelData(Object channelData) { - super.withChannelData(channelData); - return this; - } - - - /** - * Set the action value. - * - * @param action the action value to set - * @return the Activity object itself. - */ - public ActivityImpl withAction(String action) { - super.withAction(action); - return this; - } - - /** - * Set the replyToId value. - * - * @param replyToId the replyToId value to set - * @return the Activity object itself. - */ - public ActivityImpl withReplyToId(String replyToId) { - super.withReplyToId(replyToId); - return this; - } - - /** - * Set the label value. - * - * @param label the label value to set - * @return the Activity object itself. - */ - public ActivityImpl withLabel(String label) { - super.withLabel(label); - return this; - } - - /** - * Set the valueType value. - * - * @param valueType the valueType value to set - * @return the Activity object itself. - */ - public ActivityImpl withValueType(String valueType) { - super.withValueType(valueType); - return this; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the Activity object itself. - */ - public ActivityImpl withValue(Object value) { - super.withValue(value); - return this; - } - - - /** - * Set the name value. - * - * @param name the name value to set - * @return the Activity object itself. - */ - public ActivityImpl withName(String name) { - super.withName(name); - return this; - } - - - /** - * Set the relatesTo value. - * - * @param relatesTo the relatesTo value to set - * @return the Activity object itself. - */ - public ActivityImpl withRelatesTo(ConversationReference relatesTo) { - super.withRelatesTo(relatesTo); - return this; - } - - /** - * Set the code value. - * - * @param code the code value to set - * @return the Activity object itself. - */ - public ActivityImpl withCode(EndOfConversationCodes code) { - super.withCode(code); - return this; - } - - /** - * Set the expiration value. - * - * @param expiration the expiration value to set - * @return the Activity object itself. - */ - public ActivityImpl withExpiration(DateTime expiration) { - super.withExpiration(expiration); - return this; - } - - /** - * Set the importance value. - * - * @param importance the importance value to set - * @return the Activity object itself. - */ - public ActivityImpl withImportance(String importance) { - super.withImportance(importance); - return this; - } - - /** - * Set the deliveryMode value. - * - * @param deliveryMode the deliveryMode value to set - * @return the Activity object itself. - */ - public ActivityImpl withDeliveryMode(String deliveryMode) { - super.withDeliveryMode(deliveryMode); - return this; - } - - /** - * Set the textHighlights value. - * - * @param textHighlights the textHighlights value to set - * @return the Activity object itself. - */ - public ActivityImpl withTextHighlights(List textHighlights) { - super.withTextHighlights(textHighlights); - return this; - } - - /** - * Return an MessageActivity mask if this is a message activity - */ - public MessageActivity AsMessageActivity() { - return IsActivity(ActivityTypes.MESSAGE.toString()) ? (MessageActivity) (Activity) this : null; - } - - /** - * 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; - } - - - - /** - * Return an InstallationUpdateActivity mask if this is a installation update activity - */ - //public InstallationUpdateActivity AsInstallationUpdateActivity() { return IsActivity(ActivityTypes.INSTALLATION_UPDATE.toString()) ? this : null; } - - /** - * Return an ConversationUpdateActivity mask if this is a conversation update activity - */ - //public ConversationUpdateActivity AsConversationUpdateActivity() { return IsActivity(ActivityTypes.ConversationUpdate) ? this : null; } - - /** - * Return an TypingActivity mask if this is a typing activity - */ - // public TypingActivity AsTypingActivity() { return IsActivity(ActivityTypes.TYPING.toString()) ? (TypingActivity)(Activity)this : null; } - - /** - * Return an IEndOfConversationActivity mask if this is an end of conversation activity - */ - //public IEndOfConversationActivity AsEndOfConversationActivity() { return IsActivity(ActivityTypes.EndOfConversation) ? this : null; } - - /** - * Return an IEventActivity mask if this is an event activity - */ - //public IEventActivity AsEventActivity() { return IsActivity(ActivityTypes.Event) ? this : null; } - - /** - * Return an IInvokeActivity mask if this is an invoke activity - */ - //public IInvokeActivity AsInvokeActivity() { return IsActivity(ActivityTypes.Invoke) ? this : null; } - - /** - * Return an IMessageUpdateAcitvity if this is a MessageUpdate activity - * @return - */ - //public IMessageUpdateActivity AsMessageUpdateActivity() { return IsActivity(ActivityTypes.MessageUpdate) ? this : null; } - - /** - * Return an IMessageDeleteActivity if this is a MessageDelete activity - * @return - */ - //public IMessageDeleteActivity AsMessageDeleteActivity() { return IsActivity(ActivityTypes.MessageDelete) ? this : null; } - - /** - * Return an IMessageReactionActivity if this is a MessageReaction activity - * @return - */ - //public IMessageReactionActivity AsMessageReactionActivity() { return IsActivity(ActivityTypes.MessageReaction) ? this : null; } - - /** - * Return an ISuggestionActivity if this is a Suggestion activity - * @return - */ - //public ISuggestionActivity AsSuggestionActivity() { return IsActivity(ActivityTypes.Suggestion) ? this : null; } - - /** - * Return an ITraceActivity if this is a Trace activity - * @return - */ - //public ITraceActivity AsTraceActivity() { return IsActivity(ActivityTypes.Trace) ? this : null; } - - /** - * 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; - - if (!StringUtils.isBlank(this.summary())) - return true; - - if (this.attachments() != null && this.attachments().size() > 0) - return true; - - if (this.channelData() != null) - return true; - - return false; - } - - public Mention convertToMention(JsonNode node) { - try { - return ActivityImpl.mapper.treeToValue(node, Mention.class); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - return null; - - } - /** - * 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 GetMentions() { - ArrayList list = null; -// (ArrayList) this.entities().stream() -// .filter(entity -> entity.type().equalsIgnoreCase("mention")) -// .map(entity -> convertToMention(entity.getProperties())) -// .collect(Collectors.toCollection(ArrayList::new)); // create mutable list - return list; - } - - /** - * Get channeldata as typed structure - * @param activity - * @param TypeT type to use - * @return typed Object or default(TypeT) - */ - public TypeT GetChannelData(Class classType) throws JsonProcessingException { - if (this.channelData() == null) - return null; - - if (classType.isInstance(this.channelData())) { - return (TypeT) this.channelData(); - } - JsonNode node = mapper.valueToTree(this.channelData()); - return mapper.treeToValue((TreeNode) node, classType); - } - - /** - * 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 ResultPair TryGetChannelData(Class clsType) { - TypeT instance = null; - if (this.channelData() == null) - return new ResultPair<>(false, instance); - - try { - instance = this.GetChannelData(clsType); - } catch (JsonProcessingException e) { - return new ResultPair(false, instance); - } - return new ResultPair(true, instance); - } - /** - * Clone a activity - * @param activity - * @return new cloned activity - */ - public static Activity CloneActity(Activity activity) { - Activity clone = new Activity() - .withType(activity.type()) - .withId(activity.id()) - .withTimestamp(activity.timestamp()) - .withLocalTimestamp(activity.localTimestamp()) - .withText(activity.text()) - .withFrom(activity.from()) - .withRecipient(activity.recipient()) - .withConversation(activity.conversation()) - .withChannelId(activity.channelId()) - .withServiceUrl(activity.serviceUrl()) - .withChannelId(activity.channelId()) - .withText(activity.text()) - .withSpeak(activity.speak()) - .withInputHint(activity.inputHint()) - .withSummary(activity.summary()) - .withSuggestedActions(activity.suggestedActions()) - .withAttachments(activity.attachments()) - .withEntities(activity.entities()) - .withChannelData(activity.channelData()) - .withAction(activity.action()) - .withReplyToId(activity.replyToId()) - .withLabel(activity.label()) - .withValueType(activity.valueType()) - .withValue(activity.value()) - .withName(activity.name()) - .withRelatesTo(activity.relatesTo()) - .withCode(activity.code()) - .withExpiration(activity.expiration()) - .withImportance(activity.importance()) - .withDeliveryMode(activity.deliveryMode()) - .withTextHighlights(activity.textHighlights()); - for (Map.Entry entry : activity.properties().entrySet()) { - clone.setProperties(entry.getKey(), entry.getValue()); - } - return clone; - - } - -} +package com.microsoft.bot.schema; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.TreeNode; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.bot.schema.models.Activity; +import com.microsoft.bot.schema.models.ActivityTypes; +import com.microsoft.bot.schema.models.Attachment; +import com.microsoft.bot.schema.models.ChannelAccount; +import com.microsoft.bot.schema.models.ConversationAccount; +import com.microsoft.bot.schema.models.ConversationReference; +import com.microsoft.bot.schema.models.ConversationUpdateActivity; +import com.microsoft.bot.schema.models.EndOfConversationCodes; +import com.microsoft.bot.schema.models.InputHints; +import com.microsoft.bot.schema.models.Mention; +import com.microsoft.bot.schema.models.MessageActivity; +import com.microsoft.bot.schema.models.SuggestedActions; +import com.microsoft.bot.schema.models.TextHighlight; + +import org.apache.commons.lang3.StringUtils; +import org.joda.time.DateTime; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * 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 { + /** + * Content-type for an Activity + */ + public final String ContentType = "application/vnd.microsoft.activity"; + private static final ObjectMapper mapper = new ObjectMapper(); + + void CustomInit() { + } + + /** + * 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); + } + + public ActivityImpl CreateReply(String text) { + return CreateReply(text, null); + } + + public ActivityImpl CreateReply(String text, String locale) { + ActivityImpl reply = new ActivityImpl(); + reply.withType(ActivityTypes.MESSAGE); + reply.withTimestamp(DateTime.now()); + reply.withFrom(new ChannelAccount() + .withId(recipient().id()) + .withName(recipient().name())); + reply.withRecipient(new ChannelAccount() + .withId(from().id()) + .withName(from().name())); + reply.withReplyToId(this.id()); + reply.withServiceUrl(this.serviceUrl()); + reply.withChannelId(channelId()); + reply.withConversation(new ConversationAccount() + .withIsGroup(conversation().isGroup()) + .withId(conversation().id()) + .withName(conversation().name())); + reply.withText((text == null) ? "" : text); + reply.withLocale((locale == null) ? "" : locale); + reply.withAttachments(new ArrayList()); + reply.withEntities(new ArrayList()); + return reply; + } + + /** + * 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); + } + + public TraceActivity CreateTrace(String name, Object value) { + return CreateTrace(name, value, null, null); + + } + + public TraceActivity CreateTrace(String name, Object value, String valueType) { + return CreateTrace(name, value, valueType, null); + } + + // public TraceActivity CreateTrace(String name, Object value, String valueType, [CallerMemberName] String label) + public TraceActivity CreateTrace(String name, Object value, String valueType, String label) { + TraceActivity reply = new TraceActivity(); + reply.withType(ActivityTypes.TRACE); + reply.withTimestamp(DateTime.now()); + reply.withFrom(new ChannelAccount() + .withId(recipient().id()) + .withName(recipient().name())); + reply.withRecipient(new ChannelAccount() + .withId(from().id()) + .withName(from().name())); + reply.withReplyToId(this.id()); + reply.withServiceUrl(this.serviceUrl()); + reply.withChannelId(channelId()); + reply.withConversation(new ConversationAccount() + .withIsGroup(conversation().isGroup()) + .withId(conversation().id()) + .withName(conversation().name())); + reply.withName(name); + reply.withLabel(label); + reply.withValueType((valueType == null) ? value.getClass().getTypeName() : valueType); + reply.withValue(value); + return reply; + } + + /** + * 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); + } + + public static TraceActivity CreateTraceActivity(String name, String valueType, Object value) { + return CreateTraceActivity(name, valueType, value, null); + } + + // public static TraceActivity CreateTraceActivity(String name, String valueType, Object value, [CallerMemberName] String label=null) + public static TraceActivity CreateTraceActivity(String name, String valueType, Object value, String label) { + TraceActivity reply = (TraceActivity) new TraceActivity(); + reply.withType(ActivityTypes.TRACE); + reply.withName(name); + reply.withLabel(label); + reply.withValueType((valueType == null) ? value.getClass().getTypeName() : valueType); + reply.withValue(value); + return reply; + + } + + /** + * Extension data for overflow of properties + */ + // [JsonExtensionData(ReadData = true, WriteData = true)] + //public JObject Properties { get; set; } = new JObject(); + + /** + * Create an instance of the Activity class with MessageActivity masking + */ + public static MessageActivity CreateMessageActivity() { + MessageActivity reply = new MessageActivity(); + reply.withType(ActivityTypes.TRACE); + reply.withTimestamp(DateTime.now()); + reply.withAttachments(new ArrayList()); + reply.withEntities(new ArrayList()); + return reply; + } + + /** + * 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; + } + + /** + * Create an instance of the Activity class with IConversationUpdateActivity masking + */ + public static ConversationUpdateActivity CreateConversationUpdateActivity() { + ConversationUpdateActivity reply = new ConversationUpdateActivity(); + reply.withType(ActivityTypes.CONVERSATION_UPDATE); + reply.withMembersAdded(new ArrayList()); + reply.withMembersRemoved(new ArrayList()); + return reply; + } + + /** + * Create an instance of the Activity class with ITypingActivity masking + */ + //public static TypingActivity CreateTypingActivity() { return new Activity(ActivityTypes.Typing); } + + /** + * Create an instance of the Activity class with IEndOfConversationActivity masking + */ + //public static IEndOfConversationActivity CreateEndOfConversationActivity() { return new Activity(ActivityTypes.EndOfConversation); } + + /** + * Create an instance of the Activity class with an IEventActivity masking + */ + //public static IEventActivity CreateEventActivity() { return new Activity(ActivityTypes.Event); } + + /** + * Create an instance of the Activity class with IInvokeActivity masking + */ + //public static IInvokeActivity CreateInvokeActivity() { return new Activity(ActivityTypes.Invoke); } + + + /** + * 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 + * this problem, this code is purposefully more verbose due to optimizations. + * + * This main goal of the optimizations was to make zero allocations because it is called + * by all of the .AsXXXActivity methods which are used in a pattern heavily upstream to + * "pseudo-cast" the activity based on its type. + */ + + ActivityTypes type = this.type(); + + // If there's no type set then we can't tell if it's the type they're looking for + if (type == null) { + return false; + } + + // Check if the full type value starts with the type they're looking for + + + boolean result = StringUtils.startsWith(type.toString().toLowerCase(), activityType.toLowerCase()); + + // If the full type value starts with the type they're looking for, then we need to check a little further to check if it's definitely the right type + if (result) { + // If the lengths are equal, then it's the exact type they're looking for + result = type.toString().length() == activityType.length(); + + if (!result) { + // Finally, if the type is longer than the type they're looking for then we need to check if there's a / separator right after the type they're looking for + result = type.toString().length() > activityType.length() + && + type.toString().indexOf(activityType.length()) == '/'; + } + } + + return result; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the Activity object itself. + */ + public ActivityImpl withType(ActivityTypes type) { + super.withType(type); + return this; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the Activity object itself. + */ + public ActivityImpl withId(String id) { + super.withId(id); + return this; + } + + /** + * Set the timestamp value. + * + * @param timestamp the timestamp value to set + * @return the Activity object itself. + */ + public ActivityImpl withTimestamp(DateTime timestamp) { + super.withTimestamp(timestamp); + return this; + } + /** + * Set the localTimestamp value. + * + * @param localTimestamp the localTimestamp value to set + * @return the Activity object itself. + */ + public ActivityImpl withLocalTimestamp(DateTime localTimestamp) { + super.withLocalTimestamp(localTimestamp); + return this; + } + + /** + * Set the serviceUrl value. + * + * @param serviceUrl the serviceUrl value to set + * @return the Activity object itself. + */ + public ActivityImpl withServiceUrl(String serviceUrl) { + super.withServiceUrl(serviceUrl); + return this; + } + + /** + * Set the channelId value. + * + * @param channelId the channelId value to set + * @return the Activity object itself. + */ + public ActivityImpl withChannelId(String channelId) { + super.withChannelId(channelId); + return this; + } + /** + * Set the from value. + * + * @param from the from value to set + * @return the Activity object itself. + */ + public ActivityImpl withFrom(ChannelAccount from) { + super.withFrom(from); + return this; + } + /** + * Set the conversation value. + * + * @param conversation the conversation value to set + * @return the Activity object itself. + */ + public ActivityImpl withConversation(ConversationAccount conversation) { + super.withConversation(conversation); + return this; + } + /** + * Set the recipient value. + * + * @param recipient the recipient value to set + * @return the Activity object itself. + */ + public ActivityImpl withRecipient(ChannelAccount recipient) { + super.withRecipient(recipient); + return this; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the Activity object itself. + */ + public ActivityImpl withText(String text) { + super.withText(text); + return this; + } + + /** + * Set the speak value. + * + * @param speak the speak value to set + * @return the Activity object itself. + */ + public ActivityImpl withSpeak(String speak) { + super.withSpeak(speak); + return this; + } + + + /** + * Set the inputHint value. + * + * @param inputHint the inputHint value to set + * @return the Activity object itself. + */ + public ActivityImpl withInputHint(InputHints inputHint) { + super.withInputHint(inputHint); + return this; + } + + /** + * Set the summary value. + * + * @param summary the summary value to set + * @return the Activity object itself. + */ + public ActivityImpl withSummary(String summary) { + super.withSummary(summary); + return this; + } + + + /** + * Set the suggestedActions value. + * + * @param suggestedActions the suggestedActions value to set + * @return the Activity object itself. + */ + public ActivityImpl withSuggestedActions(SuggestedActions suggestedActions) { + super.withSuggestedActions(suggestedActions); + return this; + } + + + /** + * Set the attachments value. + * + * @param attachments the attachments value to set + * @return the Activity object itself. + */ + public ActivityImpl withAttachments(List attachments) { + super.withAttachments(attachments); + return this; + } + + + /** + * Set the entities value. + * + * @param entities the entities value to set + * @return the Activity object itself. + */ + public ActivityImpl withEntities(List entities) { + super.withEntities(entities); + return this; + } + + + /** + * Set the channelData value. + * + * @param channelData the channelData value to set + * @return the Activity object itself. + */ + public ActivityImpl withChannelData(Object channelData) { + super.withChannelData(channelData); + return this; + } + + + /** + * Set the action value. + * + * @param action the action value to set + * @return the Activity object itself. + */ + public ActivityImpl withAction(String action) { + super.withAction(action); + return this; + } + + /** + * Set the replyToId value. + * + * @param replyToId the replyToId value to set + * @return the Activity object itself. + */ + public ActivityImpl withReplyToId(String replyToId) { + super.withReplyToId(replyToId); + return this; + } + + /** + * Set the label value. + * + * @param label the label value to set + * @return the Activity object itself. + */ + public ActivityImpl withLabel(String label) { + super.withLabel(label); + return this; + } + + /** + * Set the valueType value. + * + * @param valueType the valueType value to set + * @return the Activity object itself. + */ + public ActivityImpl withValueType(String valueType) { + super.withValueType(valueType); + return this; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the Activity object itself. + */ + public ActivityImpl withValue(Object value) { + super.withValue(value); + return this; + } + + + /** + * Set the name value. + * + * @param name the name value to set + * @return the Activity object itself. + */ + public ActivityImpl withName(String name) { + super.withName(name); + return this; + } + + + /** + * Set the relatesTo value. + * + * @param relatesTo the relatesTo value to set + * @return the Activity object itself. + */ + public ActivityImpl withRelatesTo(ConversationReference relatesTo) { + super.withRelatesTo(relatesTo); + return this; + } + + /** + * Set the code value. + * + * @param code the code value to set + * @return the Activity object itself. + */ + public ActivityImpl withCode(EndOfConversationCodes code) { + super.withCode(code); + return this; + } + + /** + * Set the expiration value. + * + * @param expiration the expiration value to set + * @return the Activity object itself. + */ + public ActivityImpl withExpiration(DateTime expiration) { + super.withExpiration(expiration); + return this; + } + + /** + * Set the importance value. + * + * @param importance the importance value to set + * @return the Activity object itself. + */ + public ActivityImpl withImportance(String importance) { + super.withImportance(importance); + return this; + } + + /** + * Set the deliveryMode value. + * + * @param deliveryMode the deliveryMode value to set + * @return the Activity object itself. + */ + public ActivityImpl withDeliveryMode(String deliveryMode) { + super.withDeliveryMode(deliveryMode); + return this; + } + + /** + * Set the textHighlights value. + * + * @param textHighlights the textHighlights value to set + * @return the Activity object itself. + */ + public ActivityImpl withTextHighlights(List textHighlights) { + super.withTextHighlights(textHighlights); + return this; + } + + /** + * Return an MessageActivity mask if this is a message activity + */ + public MessageActivity AsMessageActivity() { + return IsActivity(ActivityTypes.MESSAGE.toString()) ? (MessageActivity) (Activity) this : null; + } + + /** + * 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; + } + + + + /** + * Return an InstallationUpdateActivity mask if this is a installation update activity + */ + //public InstallationUpdateActivity AsInstallationUpdateActivity() { return IsActivity(ActivityTypes.INSTALLATION_UPDATE.toString()) ? this : null; } + + /** + * Return an ConversationUpdateActivity mask if this is a conversation update activity + */ + //public ConversationUpdateActivity AsConversationUpdateActivity() { return IsActivity(ActivityTypes.ConversationUpdate) ? this : null; } + + /** + * Return an TypingActivity mask if this is a typing activity + */ + // public TypingActivity AsTypingActivity() { return IsActivity(ActivityTypes.TYPING.toString()) ? (TypingActivity)(Activity)this : null; } + + /** + * Return an IEndOfConversationActivity mask if this is an end of conversation activity + */ + //public IEndOfConversationActivity AsEndOfConversationActivity() { return IsActivity(ActivityTypes.EndOfConversation) ? this : null; } + + /** + * Return an IEventActivity mask if this is an event activity + */ + //public IEventActivity AsEventActivity() { return IsActivity(ActivityTypes.Event) ? this : null; } + + /** + * Return an IInvokeActivity mask if this is an invoke activity + */ + //public IInvokeActivity AsInvokeActivity() { return IsActivity(ActivityTypes.Invoke) ? this : null; } + + /** + * Return an IMessageUpdateAcitvity if this is a MessageUpdate activity + * @return + */ + //public IMessageUpdateActivity AsMessageUpdateActivity() { return IsActivity(ActivityTypes.MessageUpdate) ? this : null; } + + /** + * Return an IMessageDeleteActivity if this is a MessageDelete activity + * @return + */ + //public IMessageDeleteActivity AsMessageDeleteActivity() { return IsActivity(ActivityTypes.MessageDelete) ? this : null; } + + /** + * Return an IMessageReactionActivity if this is a MessageReaction activity + * @return + */ + //public IMessageReactionActivity AsMessageReactionActivity() { return IsActivity(ActivityTypes.MessageReaction) ? this : null; } + + /** + * Return an ISuggestionActivity if this is a Suggestion activity + * @return + */ + //public ISuggestionActivity AsSuggestionActivity() { return IsActivity(ActivityTypes.Suggestion) ? this : null; } + + /** + * Return an ITraceActivity if this is a Trace activity + * @return + */ + //public ITraceActivity AsTraceActivity() { return IsActivity(ActivityTypes.Trace) ? this : null; } + + /** + * 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; + + if (!StringUtils.isBlank(this.summary())) + return true; + + if (this.attachments() != null && this.attachments().size() > 0) + return true; + + if (this.channelData() != null) + return true; + + return false; + } + + public Mention convertToMention(JsonNode node) { + try { + return ActivityImpl.mapper.treeToValue(node, Mention.class); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + return null; + + } + /** + * 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 GetMentions() { + ArrayList list = null; +// (ArrayList) this.entities().stream() +// .filter(entity -> entity.type().equalsIgnoreCase("mention")) +// .map(entity -> convertToMention(entity.getProperties())) +// .collect(Collectors.toCollection(ArrayList::new)); // create mutable list + return list; + } + + /** + * Get channeldata as typed structure + * @param activity + * @param TypeT type to use + * @return typed Object or default(TypeT) + */ + public TypeT GetChannelData(Class classType) throws JsonProcessingException { + if (this.channelData() == null) + return null; + + if (classType.isInstance(this.channelData())) { + return (TypeT) this.channelData(); + } + JsonNode node = mapper.valueToTree(this.channelData()); + return mapper.treeToValue((TreeNode) node, classType); + } + + /** + * 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 ResultPair TryGetChannelData(Class clsType) { + TypeT instance = null; + if (this.channelData() == null) + return new ResultPair<>(false, instance); + + try { + instance = this.GetChannelData(clsType); + } catch (JsonProcessingException e) { + return new ResultPair(false, instance); + } + return new ResultPair(true, instance); + } + /** + * Clone a activity + * @param activity + * @return new cloned activity + */ + public static Activity CloneActity(Activity activity) { + Activity clone = new Activity() + .withType(activity.type()) + .withId(activity.id()) + .withTimestamp(activity.timestamp()) + .withLocalTimestamp(activity.localTimestamp()) + .withText(activity.text()) + .withFrom(activity.from()) + .withRecipient(activity.recipient()) + .withConversation(activity.conversation()) + .withChannelId(activity.channelId()) + .withServiceUrl(activity.serviceUrl()) + .withChannelId(activity.channelId()) + .withText(activity.text()) + .withSpeak(activity.speak()) + .withInputHint(activity.inputHint()) + .withSummary(activity.summary()) + .withSuggestedActions(activity.suggestedActions()) + .withAttachments(activity.attachments()) + .withEntities(activity.entities()) + .withChannelData(activity.channelData()) + .withAction(activity.action()) + .withReplyToId(activity.replyToId()) + .withLabel(activity.label()) + .withValueType(activity.valueType()) + .withValue(activity.value()) + .withName(activity.name()) + .withRelatesTo(activity.relatesTo()) + .withCode(activity.code()) + .withExpiration(activity.expiration()) + .withImportance(activity.importance()) + .withDeliveryMode(activity.deliveryMode()) + .withTextHighlights(activity.textHighlights()); + for (Map.Entry entry : activity.properties().entrySet()) { + clone.setProperties(entry.getKey(), entry.getValue()); + } + return clone; + + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/ContactRelationUpdateActivity.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/ContactRelationUpdateActivity.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/ContactRelationUpdateActivity.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/ContactRelationUpdateActivity.java index c06848e6..e31c7e8b 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/ContactRelationUpdateActivity.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/ContactRelationUpdateActivity.java @@ -1,18 +1,18 @@ -package com.microsoft.bot.schema; - -import com.microsoft.bot.schema.models.Activity; - -public class ContactRelationUpdateActivity extends Activity { - /** - * add|remove - */ - private String _action; - - public String getAction() { - return _action; - } - - public void setAction(String action) { - this._action = action; - } -} +package com.microsoft.bot.schema; + +import com.microsoft.bot.schema.models.Activity; + +public class ContactRelationUpdateActivity extends Activity { + /** + * add|remove + */ + private String _action; + + public String getAction() { + return _action; + } + + public void setAction(String action) { + this._action = action; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/EntityImpl.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/EntityImpl.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/EntityImpl.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/EntityImpl.java index e7daf126..e8ebd210 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/EntityImpl.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/EntityImpl.java @@ -1,146 +1,146 @@ -package com.microsoft.bot.schema; - - - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.bot.schema.models.Entity; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - - - -public class EntityImpl extends Entity { - private ObjectMapper objectMapper = new ObjectMapper(); - - /** - * Initializes a new instance of the Entity class. - */ - public EntityImpl() { - CustomInit(); - } - - - /** - * 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(); - } - - /** - * An initialization method that performs custom operations like setting defaults - */ - void CustomInit() { - } - /** - * Gets or sets entity Type (typically from schema.org types) - */ - public String type; - - - /** - * @return - */ - private HashMap properties = new HashMap(); - - @JsonAnyGetter - public Map properties() { - - return this.properties; - - } - - - @JsonAnySetter - public void setProperties(String key, JsonNode value) { - this.properties.put(key, value); - } - - - /** - */ - - /** - * Retrieve internal payload. - */ - - /** - */ - - /** - * @param T - */ - - /** - * @return - */ - - public T GetAs(Class type) { - - // Serialize - String tempJson; - try { - tempJson = objectMapper.writeValueAsString(this); - } catch (JsonProcessingException e) { - e.printStackTrace(); - return null; - } - - // Deserialize - T newObj = null; - try { - newObj = (T) objectMapper.readValue(tempJson, type); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - - return newObj; - - - } - - - /** - * Set internal payload. - * @param T - * @param obj - */ - - public boolean SetAs(T obj) { - // Serialize - String tempJson; - try { - tempJson = objectMapper.writeValueAsString(obj); - } catch (JsonProcessingException e) { - e.printStackTrace(); - return false; - } - - EntityImpl tempEntity; - try { - tempEntity = objectMapper.readValue(tempJson, EntityImpl.class); - } catch (IOException e) { - e.printStackTrace(); - return false; - } - - for (Map.Entry entry : tempEntity.properties.entrySet()) { - this.properties.put(entry.getKey(), entry.getValue()); - } - this.type = obj.getClass().getTypeName(); - - return true; - - } -} - +package com.microsoft.bot.schema; + + + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.bot.schema.models.Entity; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + + + +public class EntityImpl extends Entity { + private ObjectMapper objectMapper = new ObjectMapper(); + + /** + * Initializes a new instance of the Entity class. + */ + public EntityImpl() { + CustomInit(); + } + + + /** + * 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(); + } + + /** + * An initialization method that performs custom operations like setting defaults + */ + void CustomInit() { + } + /** + * Gets or sets entity Type (typically from schema.org types) + */ + public String type; + + + /** + * @return + */ + private HashMap properties = new HashMap(); + + @JsonAnyGetter + public Map properties() { + + return this.properties; + + } + + + @JsonAnySetter + public void setProperties(String key, JsonNode value) { + this.properties.put(key, value); + } + + + /** + */ + + /** + * Retrieve internal payload. + */ + + /** + */ + + /** + * @param T + */ + + /** + * @return + */ + + public T GetAs(Class type) { + + // Serialize + String tempJson; + try { + tempJson = objectMapper.writeValueAsString(this); + } catch (JsonProcessingException e) { + e.printStackTrace(); + return null; + } + + // Deserialize + T newObj = null; + try { + newObj = (T) objectMapper.readValue(tempJson, type); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + + return newObj; + + + } + + + /** + * Set internal payload. + * @param T + * @param obj + */ + + public boolean SetAs(T obj) { + // Serialize + String tempJson; + try { + tempJson = objectMapper.writeValueAsString(obj); + } catch (JsonProcessingException e) { + e.printStackTrace(); + return false; + } + + EntityImpl tempEntity; + try { + tempEntity = objectMapper.readValue(tempJson, EntityImpl.class); + } catch (IOException e) { + e.printStackTrace(); + return false; + } + + for (Map.Entry entry : tempEntity.properties.entrySet()) { + this.properties.put(entry.getKey(), entry.getValue()); + } + this.type = obj.getClass().getTypeName(); + + return true; + + } +} + diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/ResultPair.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/ResultPair.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/ResultPair.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/ResultPair.java index 5a6480b4..b089df1b 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/ResultPair.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/ResultPair.java @@ -1,10 +1,10 @@ -package com.microsoft.bot.schema; - -public class ResultPair { - public final X x; - public final Y y; - public ResultPair(X x, Y y) { - this.x = x; - this.y = y; - } -} +package com.microsoft.bot.schema; + +public class ResultPair { + public final X x; + public final Y y; + public ResultPair(X x, Y y) { + this.x = x; + this.y = y; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/TokenExchangeState.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/TokenExchangeState.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/TokenExchangeState.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/TokenExchangeState.java index 53282efc..ecc14593 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/TokenExchangeState.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/TokenExchangeState.java @@ -1,62 +1,62 @@ -package com.microsoft.bot.schema; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.bot.schema.models.ConversationReference; - -/** - * State object passed to the bot token service. - */ -public class TokenExchangeState -{ - /** - * The connection name that was used - */ - @JsonProperty(value = "connectionName") - private String connectionName; - public String connectionName() { - return this.connectionName; - } - public TokenExchangeState withConnectionName(String connectionName) { - this.connectionName = connectionName; - return this; - } - - /** - * A reference to the conversation - */ - @JsonProperty(value = "conversation") - private ConversationReference conversation; - public ConversationReference conversation() { - return this.conversation; - } - public TokenExchangeState withConversation(ConversationReference conversation) { - this.conversation = conversation; - return this; - } - - /** - * The URL of the bot messaging endpoint - */ - @JsonProperty("botUrl") - private String botUrl; - public String botUrl() { - return this.botUrl; - } - public TokenExchangeState withBotUrl(String botUrl) { - this.botUrl = botUrl; - return this; - } - - /** - * The bot's registered application ID - */ - @JsonProperty("msAppId") - String msAppId; - public String msAppId() { - return this.msAppId; - } - public TokenExchangeState withMsAppId(String msAppId) { - this.msAppId = msAppId; - return this; - } -} +package com.microsoft.bot.schema; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.bot.schema.models.ConversationReference; + +/** + * State object passed to the bot token service. + */ +public class TokenExchangeState +{ + /** + * The connection name that was used + */ + @JsonProperty(value = "connectionName") + private String connectionName; + public String connectionName() { + return this.connectionName; + } + public TokenExchangeState withConnectionName(String connectionName) { + this.connectionName = connectionName; + return this; + } + + /** + * A reference to the conversation + */ + @JsonProperty(value = "conversation") + private ConversationReference conversation; + public ConversationReference conversation() { + return this.conversation; + } + public TokenExchangeState withConversation(ConversationReference conversation) { + this.conversation = conversation; + return this; + } + + /** + * The URL of the bot messaging endpoint + */ + @JsonProperty("botUrl") + private String botUrl; + public String botUrl() { + return this.botUrl; + } + public TokenExchangeState withBotUrl(String botUrl) { + this.botUrl = botUrl; + return this; + } + + /** + * The bot's registered application ID + */ + @JsonProperty("msAppId") + String msAppId; + public String msAppId() { + return this.msAppId; + } + public TokenExchangeState withMsAppId(String msAppId) { + this.msAppId = msAppId; + return this; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/TraceActivity.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/TraceActivity.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/TraceActivity.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/TraceActivity.java index 927a597a..514bf89b 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/TraceActivity.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/TraceActivity.java @@ -1,73 +1,73 @@ -package com.microsoft.bot.schema; - -import com.microsoft.bot.schema.models.ConversationReference; - -/** - * An activity by which a bot can log internal information into a logged conversation transcript - */ -public class TraceActivity extends ActivityImpl { - /** - * Name of the trace activity - */ - private String _name; - - public String getName() { - return _name; - } - - public void setName(String name) { - _name = name; - } - - /** - * Descriptive label for the trace - */ - private String _label; - - public String getLabel() { - return _label; - } - - public void setLabel(String label) { - this._label = label; - } - - /** - * Unique string which identifies the format of the value object - */ - private String _value_type; - - public String getValueType() { - return _value_type; - } - - public void setValueType(String value_type) { - _value_type = value_type; - } - - /** - * Open-ended value - */ - private Object _value; - - Object getValue() { - return _value; - } - - void setValue(Object value) { - _value = value; - } - - /** - * Reference to another conversation or activity - */ - private ConversationReference _relates_to; - - ConversationReference getRelatesTo() { - return _relates_to; - } - - void setRelatesTo(ConversationReference relates_to) { - _relates_to = relates_to; - } -} +package com.microsoft.bot.schema; + +import com.microsoft.bot.schema.models.ConversationReference; + +/** + * An activity by which a bot can log internal information into a logged conversation transcript + */ +public class TraceActivity extends ActivityImpl { + /** + * Name of the trace activity + */ + private String _name; + + public String getName() { + return _name; + } + + public void setName(String name) { + _name = name; + } + + /** + * Descriptive label for the trace + */ + private String _label; + + public String getLabel() { + return _label; + } + + public void setLabel(String label) { + this._label = label; + } + + /** + * Unique string which identifies the format of the value object + */ + private String _value_type; + + public String getValueType() { + return _value_type; + } + + public void setValueType(String value_type) { + _value_type = value_type; + } + + /** + * Open-ended value + */ + private Object _value; + + Object getValue() { + return _value; + } + + void setValue(Object value) { + _value = value; + } + + /** + * Reference to another conversation or activity + */ + private ConversationReference _relates_to; + + ConversationReference getRelatesTo() { + return _relates_to; + } + + void setRelatesTo(ConversationReference relates_to) { + _relates_to = relates_to; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ActionTypes.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ActionTypes.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ActionTypes.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ActionTypes.java index d083a3e0..4299a67e 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ActionTypes.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ActionTypes.java @@ -1,82 +1,82 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines action types for clickable buttons. - */ -public enum ActionTypes { - /** Enum value openUrl. */ - OPEN_URL("openUrl"), - - /** Enum value imBack. */ - IM_BACK("imBack"), - - /** Enum value postBack. */ - POST_BACK("postBack"), - - /** Enum value playAudio. */ - PLAY_AUDIO("playAudio"), - - /** Enum value playVideo. */ - PLAY_VIDEO("playVideo"), - - /** Enum value showImage. */ - SHOW_IMAGE("showImage"), - - /** Enum value downloadFile. */ - DOWNLOAD_FILE("downloadFile"), - - /** Enum value signin. */ - SIGNIN("signin"), - - /** Enum value call. */ - CALL("call"), - - /** Enum value payment. */ - PAYMENT("payment"), - - /** Enum value messageBack. */ - MESSAGE_BACK("messageBack"); - - /** The actual serialized value for a ActionTypes instance. */ - private String value; - - ActionTypes(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a ActionTypes instance. - * - * @param value the serialized value to parse. - * @return the parsed ActionTypes object, or null if unable to parse. - */ - @JsonCreator - public static ActionTypes fromString(String value) { - ActionTypes[] items = ActionTypes.values(); - for (ActionTypes item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines action types for clickable buttons. + */ +public enum ActionTypes { + /** Enum value openUrl. */ + OPEN_URL("openUrl"), + + /** Enum value imBack. */ + IM_BACK("imBack"), + + /** Enum value postBack. */ + POST_BACK("postBack"), + + /** Enum value playAudio. */ + PLAY_AUDIO("playAudio"), + + /** Enum value playVideo. */ + PLAY_VIDEO("playVideo"), + + /** Enum value showImage. */ + SHOW_IMAGE("showImage"), + + /** Enum value downloadFile. */ + DOWNLOAD_FILE("downloadFile"), + + /** Enum value signin. */ + SIGNIN("signin"), + + /** Enum value call. */ + CALL("call"), + + /** Enum value payment. */ + PAYMENT("payment"), + + /** Enum value messageBack. */ + MESSAGE_BACK("messageBack"); + + /** The actual serialized value for a ActionTypes instance. */ + private String value; + + ActionTypes(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ActionTypes instance. + * + * @param value the serialized value to parse. + * @return the parsed ActionTypes object, or null if unable to parse. + */ + @JsonCreator + public static ActionTypes fromString(String value) { + ActionTypes[] items = ActionTypes.values(); + for (ActionTypes item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Activity.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Activity.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Activity.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Activity.java index c39dd41b..3d479de2 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Activity.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Activity.java @@ -1,1178 +1,1178 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.databind.JsonNode; -import com.microsoft.bot.schema.EntityImpl; -import org.joda.time.DateTime; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * An Activity is the basic communication type for the Bot Framework 3.0 - * protocol. - */ -public class Activity { - /** - * The type of the activity. Possible values include: 'message', - * 'contactRelationUpdate', 'conversationUpdate', 'typing', 'ping', - * 'endOfConversation', 'event', 'invoke', 'deleteUserData', - * 'messageUpdate', 'messageDelete', 'installationUpdate', - * 'messageReaction', 'suggestion', 'trace'. - */ - @JsonProperty(value = "type") - private ActivityTypes type; - - /** - * Contains an ID that uniquely identifies the activity on the channel. - */ - @JsonProperty(value = "id") - private String id; - - /** - * Contains the date and time that the message was sent, in UTC, expressed in ISO-8601 format. - */ - @JsonProperty(value = "timestamp") - private DateTime timestamp; - - /** - * Contains the local date and time of the message, expressed in ISO-8601 format. - * For example, 2016-09-23T13:07:49.4714686-07:00. - */ - @JsonProperty(value = "localTimestamp") - private DateTime localTimestamp; - - /** - * Contains the name of the local timezone of the message, expressed in IANA Time Zone database format. - * For example, America/Los_Angeles. - */ - @JsonProperty(value = "localTimezone") - private String localTimezone; - - /** - * A string containing an IRI identifying the caller of a bot. This field is not intended to be transmitted - * over the wire, but is instead populated by bots and clients based on cryptographically verifiable data - * that asserts the identity of the callers (e.g. tokens). - */ - @JsonProperty(value = "callerId") - private String callerId; - - /** - * Contains the URL that specifies the channel's service endpoint. Set by the channel. - */ - @JsonProperty(value = "serviceUrl") - private String serviceUrl; - - /** - * Contains an ID that uniquely identifies the channel. Set by the channel. - */ - @JsonProperty(value = "channelId") - private String channelId; - - /** - * Identifies the sender of the message. - */ - @JsonProperty(value = "from") - private ChannelAccount from; - - /** - * Identifies the conversation to which the activity belongs. - */ - @JsonProperty(value = "conversation") - private ConversationAccount conversation; - - /** - * Identifies the recipient of the message. - */ - @JsonProperty(value = "recipient") - private ChannelAccount recipient; - - /** - * Format of text fields Default:markdown. Possible values include: - * 'markdown', 'plain', 'xml'. - */ - @JsonProperty(value = "textFormat") - private TextFormatTypes textFormat; - - /** - * The layout hint for multiple attachments. Default: list. - */ - @JsonProperty(value = "attachmentLayout") - private AttachmentLayoutTypes attachmentLayout; - - /** - * The collection of members added to the conversation. - */ - @JsonProperty(value = "membersAdded") - private List membersAdded; - - /** - * The collection of members removed from the conversation. - */ - @JsonProperty(value = "membersRemoved") - private List membersRemoved; - - /** - * The collection of reactions added to the conversation. - */ - @JsonProperty(value = "reactionsAdded") - private List reactionsAdded; - - /** - * The collection of reactions removed from the conversation. - */ - @JsonProperty(value = "reactionsRemoved") - private List reactionsRemoved; - - /** - * The updated topic name of the conversation. - */ - @JsonProperty(value = "topicName") - private String topicName; - - /** - * Indicates whether the prior history of the channel is disclosed. - */ - @JsonProperty(value = "historyDisclosed") - private Boolean historyDisclosed; - - /** - * A locale name for the contents of the text field. - * The locale name is a combination of an ISO 639 two- or three-letter culture code associated with a language - * and an ISO 3166 two-letter subculture code associated with a country or region. - * - * The locale name can also correspond to a valid BCP-47 language tag. - */ - @JsonProperty(value = "locale") - private String locale; - - /** - * The text content of the message. - */ - @JsonProperty(value = "text") - private String text; - - /** - * The text to speak. - */ - @JsonProperty(value = "speak") - private String speak; - - /** - * Indicates whether your bot is accepting, expecting, or ignoring user input after the message - * is delivered to the client. - */ - @JsonProperty(value = "inputHint") - private InputHints inputHint; - - /** - * The text to display if the channel cannot render cards. - */ - @JsonProperty(value = "summary") - private String summary; - - /** - * The suggested actions for the activity. - */ - @JsonProperty(value = "suggestedActions") - private SuggestedActions suggestedActions; - - /** - * Attachments. - */ - @JsonProperty(value = "attachments") - private List attachments; - - /** - * Represents the entities that were mentioned in the message. - */ - @JsonProperty(value = "entities") - private List entities; - - /** - * Contains channel-specific content. - */ - @JsonProperty(value = "channelData") - private Object channelData; - - /** - * Indicates whether the recipient of a contactRelationUpdate was added or removed from the sender's contact list. - */ - @JsonProperty(value = "action") - private String action; - - /** - * Contains the ID of the message to which this message is a reply. - */ - @JsonProperty(value = "replyToId") - private String replyToId; - - /** - * A descriptive label for the activity. - */ - @JsonProperty(value = "label") - private String label; - - /** - * The type of the activity's value object. - */ - @JsonProperty(value = "valueType") - private String valueType; - - /** - * A value that is associated with the activity. - */ - @JsonProperty(value = "value") - private Object value; - - /** - * The name of the operation associated with an invoke or event activity. - */ - @JsonProperty(value = "name") - private String name; - - /** - * A reference to another conversation or activity. - */ - @JsonProperty(value = "relatesTo") - private ConversationReference relatesTo; - - /** - * The a code for endOfConversation activities that indicates why the conversation ended. - */ - @JsonProperty(value = "code") - private EndOfConversationCodes code; - - /** - * The time at which the activity should be considered to be expired and should not be presented to the recipient. - */ - @JsonProperty(value = "expiration") - private DateTime expiration; - - /** - * The importance of the activity. - */ - @JsonProperty(value = "importance") - private String importance; - - /** - * A delivery hint to signal to the recipient alternate delivery paths for the activity. - * - * The default delivery mode is \"default\". - */ - @JsonProperty(value = "deliveryMode") - private String deliveryMode; - - /** - * List of phrases and references that speech and language priming systems should listen for. - */ - @JsonProperty(value = "listenFor") - private List listenFor; - - /** - * The collection of text fragments to highlight when the activity contains a ReplyToId value. - */ - @JsonProperty(value = "textHighlights") - private List textHighlights; - - /** - * Get the type value. - * - * @return the type value - */ - public ActivityTypes type() { - return this.type; - } - - /** - * Set the type value. - * - * @param type the type value to set - * @return the Activity object itself. - */ - public Activity withType(ActivityTypes type) { - this.type = type; - return this; - } - - /** - * Get the id value. - * - * @return the id value - */ - public String id() { - return this.id; - } - - /** - * Set the id value. - * - * @param id the id value to set - * @return the Activity object itself. - */ - public Activity withId(String id) { - this.id = id; - return this; - } - - /** - * Get the timestamp value. - * - * @return the timestamp value - */ - public DateTime timestamp() { - return this.timestamp; - } - - /** - * Set the timestamp value. - * - * @param timestamp the timestamp value to set - * @return the Activity object itself. - */ - public Activity withTimestamp(DateTime timestamp) { - this.timestamp = timestamp; - return this; - } - - /** - * Get the localTimestamp value. - * - * @return the localTimestamp value - */ - public DateTime localTimestamp() { - return this.localTimestamp; - } - - /** - * Set the localTimestamp value. - * - * @param localTimestamp the localTimestamp value to set - * @return the Activity object itself. - */ - public Activity withLocalTimestamp(DateTime localTimestamp) { - this.localTimestamp = localTimestamp; - return this; - } - - /** - * Gets the localTimezone. - * - * @return The name of the local timezone of the message, expressed in IANA Time Zone database format. - */ - public String localTimezone(){ - return this.localTimezone; - } - - /** - * Sets the localTimezone. - * @param localTimezone The name of the local timezone of the message, expressed in IANA Time Zone database format. - */ - public Activity withLocalTimeZone(String localTimezone){ - this.localTimezone = localTimezone; - return this; - } - - /** - * Gets the callerId - */ - public String callerId(){ - return this.callerId; - } - - /** - * Sets the callerId - * - * @param callerId A string containing an IRI identifying the caller of a bot. - */ - public Activity withCallerId(String callerId){ - this.callerId = callerId; - return this; - } - - /** - * Get the serviceUrl value. - * - * @return the serviceUrl value - */ - public String serviceUrl() { - return this.serviceUrl; - } - - /** - * Set the serviceUrl value. - * - * @param serviceUrl the serviceUrl value to set - * @return the Activity object itself. - */ - public Activity withServiceUrl(String serviceUrl) { - this.serviceUrl = serviceUrl; - return this; - } - - /** - * Get the channelId value. - * - * @return the channelId value - */ - public String channelId() { - return this.channelId; - } - - /** - * Set the channelId value. - * - * @param channelId the channelId value to set - * @return the Activity object itself. - */ - public Activity withChannelId(String channelId) { - this.channelId = channelId; - return this; - } - - /** - * Get the from value. - * - * @return the from value - */ - public ChannelAccount from() { - return this.from; - } - - /** - * Set the from value. - * - * @param from the from value to set - * @return the Activity object itself. - */ - public Activity withFrom(ChannelAccount from) { - this.from = from; - return this; - } - - /** - * Get the conversation value. - * - * @return the conversation value - */ - public ConversationAccount conversation() { - return this.conversation; - } - - /** - * Set the conversation value. - * - * @param conversation the conversation value to set - * @return the Activity object itself. - */ - public Activity withConversation(ConversationAccount conversation) { - this.conversation = conversation; - return this; - } - - /** - * Get the recipient value. - * - * @return the recipient value - */ - public ChannelAccount recipient() { - return this.recipient; - } - - /** - * Set the recipient value. - * - * @param recipient the recipient value to set - * @return the Activity object itself. - */ - public Activity withRecipient(ChannelAccount recipient) { - this.recipient = recipient; - return this; - } - - /** - * Get the textFormat value. - * - * @return the textFormat value - */ - public TextFormatTypes textFormat() { - return this.textFormat; - } - - /** - * Set the textFormat value. - * - * @param textFormat the textFormat value to set - * @return the Activity object itself. - */ - public Activity withTextFormat(TextFormatTypes textFormat) { - this.textFormat = textFormat; - return this; - } - - /** - * Get the attachmentLayout value. - * - * @return the attachmentLayout value - */ - public AttachmentLayoutTypes attachmentLayout() { - return this.attachmentLayout; - } - - /** - * Set the attachmentLayout value. - * - * @param attachmentLayout the attachmentLayout value to set - * @return the Activity object itself. - */ - public Activity withAttachmentLayout(AttachmentLayoutTypes attachmentLayout) { - this.attachmentLayout = attachmentLayout; - return this; - } - - /** - * Get the membersAdded value. - * - * @return the membersAdded value - */ - public List membersAdded() { - return this.membersAdded; - } - - /** - * Set the membersAdded value. - * - * @param membersAdded the membersAdded value to set - * @return the Activity object itself. - */ - public Activity withMembersAdded(List membersAdded) { - this.membersAdded = membersAdded; - return this; - } - - /** - * Get the membersRemoved value. - * - * @return the membersRemoved value - */ - public List membersRemoved() { - return this.membersRemoved; - } - - /** - * Set the membersRemoved value. - * - * @param membersRemoved the membersRemoved value to set - * @return the Activity object itself. - */ - public Activity withMembersRemoved(List membersRemoved) { - this.membersRemoved = membersRemoved; - return this; - } - - /** - * Get the reactionsAdded value. - * - * @return the reactionsAdded value - */ - public List reactionsAdded() { - return this.reactionsAdded; - } - - /** - * Set the reactionsAdded value. - * - * @param reactionsAdded the reactionsAdded value to set - * @return the Activity object itself. - */ - public Activity withReactionsAdded(List reactionsAdded) { - this.reactionsAdded = reactionsAdded; - return this; - } - - /** - * Get the reactionsRemoved value. - * - * @return the reactionsRemoved value - */ - public List reactionsRemoved() { - return this.reactionsRemoved; - } - - /** - * Set the reactionsRemoved value. - * - * @param reactionsRemoved the reactionsRemoved value to set - * @return the Activity object itself. - */ - public Activity withReactionsRemoved(List reactionsRemoved) { - this.reactionsRemoved = reactionsRemoved; - return this; - } - - /** - * Get the topicName value. - * - * @return the topicName value - */ - public String topicName() { - return this.topicName; - } - - /** - * Set the topicName value. - * - * @param topicName the topicName value to set - * @return the Activity object itself. - */ - public Activity withTopicName(String topicName) { - this.topicName = topicName; - return this; - } - - /** - * Get the historyDisclosed value. - * - * @return the historyDisclosed value - */ - public Boolean historyDisclosed() { - return this.historyDisclosed; - } - - /** - * Set the historyDisclosed value. - * - * @param historyDisclosed the historyDisclosed value to set - * @return the Activity object itself. - */ - public Activity withHistoryDisclosed(Boolean historyDisclosed) { - this.historyDisclosed = historyDisclosed; - return this; - } - - /** - * Get the locale value. - * - * @return the locale value - */ - public String locale() { - return this.locale; - } - - /** - * Set the locale value. - * - * @param locale the locale value to set - * @return the Activity object itself. - */ - public Activity withLocale(String locale) { - this.locale = locale; - return this; - } - - /** - * Get the text value. - * - * @return the text value - */ - public String text() { - return this.text; - } - - /** - * Set the text value. - * - * @param text the text value to set - * @return the Activity object itself. - */ - public Activity withText(String text) { - this.text = text; - return this; - } - - /** - * Get the speak value. - * - * @return the speak value - */ - public String speak() { - return this.speak; - } - - /** - * Set the speak value. - * - * @param speak the speak value to set - * @return the Activity object itself. - */ - public Activity withSpeak(String speak) { - this.speak = speak; - return this; - } - - /** - * Get the inputHint value. - * - * @return the inputHint value - */ - public InputHints inputHint() { - return this.inputHint; - } - - /** - * Set the inputHint value. - * - * @param inputHint the inputHint value to set - * @return the Activity object itself. - */ - public Activity withInputHint(InputHints inputHint) { - this.inputHint = inputHint; - return this; - } - - /** - * Get the summary value. - * - * @return the summary value - */ - public String summary() { - return this.summary; - } - - /** - * Set the summary value. - * - * @param summary the summary value to set - * @return the Activity object itself. - */ - public Activity withSummary(String summary) { - this.summary = summary; - return this; - } - - /** - * Get the suggestedActions value. - * - * @return the suggestedActions value - */ - public SuggestedActions suggestedActions() { - return this.suggestedActions; - } - - /** - * Set the suggestedActions value. - * - * @param suggestedActions the suggestedActions value to set - * @return the Activity object itself. - */ - public Activity withSuggestedActions(SuggestedActions suggestedActions) { - this.suggestedActions = suggestedActions; - return this; - } - - /** - * Get the attachments value. - * - * @return the attachments value - */ - public List attachments() { - return this.attachments; - } - - /** - * Set the attachments value. - * - * @param attachments the attachments value to set - * @return the Activity object itself. - */ - public Activity withAttachments(List attachments) { - this.attachments = attachments; - return this; - } - - /** - * Get the entities value. - * - * @return the entities value - */ - public List entities() { - return this.entities; - } - - /** - * Set the entities value. - * - * @param entities the entities value to set - * @return the Activity object itself. - */ - public Activity withEntities(List entities) { - this.entities = entities; - return this; - } - - /** - * Get the channelData value. - * - * @return the channelData value - */ - public Object channelData() { - return this.channelData; - } - - /** - * Set the channelData value. - * - * @param channelData the channelData value to set - * @return the Activity object itself. - */ - public Activity withChannelData(Object channelData) { - this.channelData = channelData; - return this; - } - - /** - * Get the action value. - * - * @return the action value - */ - public String action() { - return this.action; - } - - /** - * Set the action value. - * - * @param action the action value to set - * @return the Activity object itself. - */ - public Activity withAction(String action) { - this.action = action; - return this; - } - - /** - * Get the replyToId value. - * - * @return the replyToId value - */ - public String replyToId() { - return this.replyToId; - } - - /** - * Set the replyToId value. - * - * @param replyToId the replyToId value to set - * @return the Activity object itself. - */ - public Activity withReplyToId(String replyToId) { - this.replyToId = replyToId; - return this; - } - - /** - * Get the label value. - * - * @return the label value - */ - public String label() { - return this.label; - } - - /** - * Set the label value. - * - * @param label the label value to set - * @return the Activity object itself. - */ - public Activity withLabel(String label) { - this.label = label; - return this; - } - - /** - * Get the valueType value. - * - * @return the valueType value - */ - public String valueType() { - return this.valueType; - } - - /** - * Set the valueType value. - * - * @param valueType the valueType value to set - * @return the Activity object itself. - */ - public Activity withValueType(String valueType) { - this.valueType = valueType; - return this; - } - - /** - * Get the value value. - * - * @return the value value - */ - public Object value() { - return this.value; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the Activity object itself. - */ - public Activity withValue(Object value) { - this.value = value; - return this; - } - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the Activity object itself. - */ - public Activity withName(String name) { - this.name = name; - return this; - } - - /** - * Get the relatesTo value. - * - * @return the relatesTo value - */ - public ConversationReference relatesTo() { - return this.relatesTo; - } - - /** - * Set the relatesTo value. - * - * @param relatesTo the relatesTo value to set - * @return the Activity object itself. - */ - public Activity withRelatesTo(ConversationReference relatesTo) { - this.relatesTo = relatesTo; - return this; - } - - /** - * Get the code value. - * - * @return the code value - */ - public EndOfConversationCodes code() { - return this.code; - } - - /** - * Set the code value. - * - * @param code the code value to set - * @return the Activity object itself. - */ - public Activity withCode(EndOfConversationCodes code) { - this.code = code; - return this; - } - - /** - * Get the expiration value. - * - * @return the expiration value - */ - public DateTime expiration() { - return this.expiration; - } - - /** - * Set the expiration value. - * - * @param expiration the expiration value to set - * @return the Activity object itself. - */ - public Activity withExpiration(DateTime expiration) { - this.expiration = expiration; - return this; - } - - /** - * Get the importance value. - * - * @return the importance value - */ - public String importance() { - return this.importance; - } - - /** - * Set the importance value. - * - * @param importance the importance value to set - * @return the Activity object itself. - */ - public Activity withImportance(String importance) { - this.importance = importance; - return this; - } - - /** - * Get the deliveryMode value. - * - * @return the deliveryMode value - */ - public String deliveryMode() { - return this.deliveryMode; - } - - /** - * Set the deliveryMode value. - * - * @param deliveryMode the deliveryMode value to set - * @return the Activity object itself. - */ - public Activity withDeliveryMode(String deliveryMode) { - this.deliveryMode = deliveryMode; - return this; - } - - /** - * Gets listenFor value. - */ - public List listenFor(){ - return this.listenFor; - } - - /** - * Sets listenFor value on this object. - */ - public Activity withListenFor(List listenFor){ - this.listenFor = listenFor; - return this; - } - - /** - * Get the textHighlights value. - * - * @return the textHighlights value - */ - public List textHighlights() { - return this.textHighlights; - } - - /** - * Set the textHighlights value. - * - * @param textHighlights the textHighlights value to set - * @return the Activity object itself. - */ - public Activity withTextHighlights(List textHighlights) { - this.textHighlights = textHighlights; - return this; - } - /** - * Holds the overflow properties that aren't first class - * properties in the object. This allows extensibility - * while maintaining the object. - * - */ - private HashMap properties = new HashMap(); - - /** - * Overflow properties. - * Properties that are not modelled as first class properties in the object are accessible here. - * Note: A property value can be be nested. - * - * @return A Key-Value map of the properties - */ - @JsonAnyGetter - public Map properties() { - return this.properties; - } - - /** - * Set overflow properties. - * - * @param key Key for the property - * @param value JsonNode of value (can be nested) - * - */ - - @JsonAnySetter - public void setProperties(String key, JsonNode value) { - this.properties.put(key, value); - } - - /** - Updates this activity with the delivery information from an existing - conversation reference. - - @param reference The conversation reference. - @param isIncoming (Optional) true to treat the activity as an - incoming activity, where the bot is the recipient; otherwaire false. - Default is false, and the activity will show the bot as the sender. - Call on an incoming - activity to get a conversation reference that you can then use to update an - outgoing activity with the correct delivery information. - - */ - - - public final Activity applyConversationReference(ConversationReference reference) - { - return applyConversationReference(reference, false); - } - - public final Activity applyConversationReference(ConversationReference reference, boolean isIncoming) - { - this.withChannelId(reference.channelId()); - this.withServiceUrl(reference.serviceUrl()); - this.withConversation(reference.conversation()); - - if (isIncoming) - { - this.withFrom(reference.user()); - this.withRecipient(reference.bot()); - if (reference.activityId() != null) - { - this.withId(reference.activityId()); - } - } - else // Outgoing - { - this.withFrom(reference.bot()); - this.withRecipient(reference.user()); - if (reference.activityId() != null) - { - this.withReplyToId(reference.activityId()); - } - } - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.databind.JsonNode; +import com.microsoft.bot.schema.EntityImpl; +import org.joda.time.DateTime; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * An Activity is the basic communication type for the Bot Framework 3.0 + * protocol. + */ +public class Activity { + /** + * The type of the activity. Possible values include: 'message', + * 'contactRelationUpdate', 'conversationUpdate', 'typing', 'ping', + * 'endOfConversation', 'event', 'invoke', 'deleteUserData', + * 'messageUpdate', 'messageDelete', 'installationUpdate', + * 'messageReaction', 'suggestion', 'trace'. + */ + @JsonProperty(value = "type") + private ActivityTypes type; + + /** + * Contains an ID that uniquely identifies the activity on the channel. + */ + @JsonProperty(value = "id") + private String id; + + /** + * Contains the date and time that the message was sent, in UTC, expressed in ISO-8601 format. + */ + @JsonProperty(value = "timestamp") + private DateTime timestamp; + + /** + * Contains the local date and time of the message, expressed in ISO-8601 format. + * For example, 2016-09-23T13:07:49.4714686-07:00. + */ + @JsonProperty(value = "localTimestamp") + private DateTime localTimestamp; + + /** + * Contains the name of the local timezone of the message, expressed in IANA Time Zone database format. + * For example, America/Los_Angeles. + */ + @JsonProperty(value = "localTimezone") + private String localTimezone; + + /** + * A string containing an IRI identifying the caller of a bot. This field is not intended to be transmitted + * over the wire, but is instead populated by bots and clients based on cryptographically verifiable data + * that asserts the identity of the callers (e.g. tokens). + */ + @JsonProperty(value = "callerId") + private String callerId; + + /** + * Contains the URL that specifies the channel's service endpoint. Set by the channel. + */ + @JsonProperty(value = "serviceUrl") + private String serviceUrl; + + /** + * Contains an ID that uniquely identifies the channel. Set by the channel. + */ + @JsonProperty(value = "channelId") + private String channelId; + + /** + * Identifies the sender of the message. + */ + @JsonProperty(value = "from") + private ChannelAccount from; + + /** + * Identifies the conversation to which the activity belongs. + */ + @JsonProperty(value = "conversation") + private ConversationAccount conversation; + + /** + * Identifies the recipient of the message. + */ + @JsonProperty(value = "recipient") + private ChannelAccount recipient; + + /** + * Format of text fields Default:markdown. Possible values include: + * 'markdown', 'plain', 'xml'. + */ + @JsonProperty(value = "textFormat") + private TextFormatTypes textFormat; + + /** + * The layout hint for multiple attachments. Default: list. + */ + @JsonProperty(value = "attachmentLayout") + private AttachmentLayoutTypes attachmentLayout; + + /** + * The collection of members added to the conversation. + */ + @JsonProperty(value = "membersAdded") + private List membersAdded; + + /** + * The collection of members removed from the conversation. + */ + @JsonProperty(value = "membersRemoved") + private List membersRemoved; + + /** + * The collection of reactions added to the conversation. + */ + @JsonProperty(value = "reactionsAdded") + private List reactionsAdded; + + /** + * The collection of reactions removed from the conversation. + */ + @JsonProperty(value = "reactionsRemoved") + private List reactionsRemoved; + + /** + * The updated topic name of the conversation. + */ + @JsonProperty(value = "topicName") + private String topicName; + + /** + * Indicates whether the prior history of the channel is disclosed. + */ + @JsonProperty(value = "historyDisclosed") + private Boolean historyDisclosed; + + /** + * A locale name for the contents of the text field. + * The locale name is a combination of an ISO 639 two- or three-letter culture code associated with a language + * and an ISO 3166 two-letter subculture code associated with a country or region. + * + * The locale name can also correspond to a valid BCP-47 language tag. + */ + @JsonProperty(value = "locale") + private String locale; + + /** + * The text content of the message. + */ + @JsonProperty(value = "text") + private String text; + + /** + * The text to speak. + */ + @JsonProperty(value = "speak") + private String speak; + + /** + * Indicates whether your bot is accepting, expecting, or ignoring user input after the message + * is delivered to the client. + */ + @JsonProperty(value = "inputHint") + private InputHints inputHint; + + /** + * The text to display if the channel cannot render cards. + */ + @JsonProperty(value = "summary") + private String summary; + + /** + * The suggested actions for the activity. + */ + @JsonProperty(value = "suggestedActions") + private SuggestedActions suggestedActions; + + /** + * Attachments. + */ + @JsonProperty(value = "attachments") + private List attachments; + + /** + * Represents the entities that were mentioned in the message. + */ + @JsonProperty(value = "entities") + private List entities; + + /** + * Contains channel-specific content. + */ + @JsonProperty(value = "channelData") + private Object channelData; + + /** + * Indicates whether the recipient of a contactRelationUpdate was added or removed from the sender's contact list. + */ + @JsonProperty(value = "action") + private String action; + + /** + * Contains the ID of the message to which this message is a reply. + */ + @JsonProperty(value = "replyToId") + private String replyToId; + + /** + * A descriptive label for the activity. + */ + @JsonProperty(value = "label") + private String label; + + /** + * The type of the activity's value object. + */ + @JsonProperty(value = "valueType") + private String valueType; + + /** + * A value that is associated with the activity. + */ + @JsonProperty(value = "value") + private Object value; + + /** + * The name of the operation associated with an invoke or event activity. + */ + @JsonProperty(value = "name") + private String name; + + /** + * A reference to another conversation or activity. + */ + @JsonProperty(value = "relatesTo") + private ConversationReference relatesTo; + + /** + * The a code for endOfConversation activities that indicates why the conversation ended. + */ + @JsonProperty(value = "code") + private EndOfConversationCodes code; + + /** + * The time at which the activity should be considered to be expired and should not be presented to the recipient. + */ + @JsonProperty(value = "expiration") + private DateTime expiration; + + /** + * The importance of the activity. + */ + @JsonProperty(value = "importance") + private String importance; + + /** + * A delivery hint to signal to the recipient alternate delivery paths for the activity. + * + * The default delivery mode is \"default\". + */ + @JsonProperty(value = "deliveryMode") + private String deliveryMode; + + /** + * List of phrases and references that speech and language priming systems should listen for. + */ + @JsonProperty(value = "listenFor") + private List listenFor; + + /** + * The collection of text fragments to highlight when the activity contains a ReplyToId value. + */ + @JsonProperty(value = "textHighlights") + private List textHighlights; + + /** + * Get the type value. + * + * @return the type value + */ + public ActivityTypes type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the Activity object itself. + */ + public Activity withType(ActivityTypes type) { + this.type = type; + return this; + } + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the Activity object itself. + */ + public Activity withId(String id) { + this.id = id; + return this; + } + + /** + * Get the timestamp value. + * + * @return the timestamp value + */ + public DateTime timestamp() { + return this.timestamp; + } + + /** + * Set the timestamp value. + * + * @param timestamp the timestamp value to set + * @return the Activity object itself. + */ + public Activity withTimestamp(DateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Get the localTimestamp value. + * + * @return the localTimestamp value + */ + public DateTime localTimestamp() { + return this.localTimestamp; + } + + /** + * Set the localTimestamp value. + * + * @param localTimestamp the localTimestamp value to set + * @return the Activity object itself. + */ + public Activity withLocalTimestamp(DateTime localTimestamp) { + this.localTimestamp = localTimestamp; + return this; + } + + /** + * Gets the localTimezone. + * + * @return The name of the local timezone of the message, expressed in IANA Time Zone database format. + */ + public String localTimezone(){ + return this.localTimezone; + } + + /** + * Sets the localTimezone. + * @param localTimezone The name of the local timezone of the message, expressed in IANA Time Zone database format. + */ + public Activity withLocalTimeZone(String localTimezone){ + this.localTimezone = localTimezone; + return this; + } + + /** + * Gets the callerId + */ + public String callerId(){ + return this.callerId; + } + + /** + * Sets the callerId + * + * @param callerId A string containing an IRI identifying the caller of a bot. + */ + public Activity withCallerId(String callerId){ + this.callerId = callerId; + return this; + } + + /** + * Get the serviceUrl value. + * + * @return the serviceUrl value + */ + public String serviceUrl() { + return this.serviceUrl; + } + + /** + * Set the serviceUrl value. + * + * @param serviceUrl the serviceUrl value to set + * @return the Activity object itself. + */ + public Activity withServiceUrl(String serviceUrl) { + this.serviceUrl = serviceUrl; + return this; + } + + /** + * Get the channelId value. + * + * @return the channelId value + */ + public String channelId() { + return this.channelId; + } + + /** + * Set the channelId value. + * + * @param channelId the channelId value to set + * @return the Activity object itself. + */ + public Activity withChannelId(String channelId) { + this.channelId = channelId; + return this; + } + + /** + * Get the from value. + * + * @return the from value + */ + public ChannelAccount from() { + return this.from; + } + + /** + * Set the from value. + * + * @param from the from value to set + * @return the Activity object itself. + */ + public Activity withFrom(ChannelAccount from) { + this.from = from; + return this; + } + + /** + * Get the conversation value. + * + * @return the conversation value + */ + public ConversationAccount conversation() { + return this.conversation; + } + + /** + * Set the conversation value. + * + * @param conversation the conversation value to set + * @return the Activity object itself. + */ + public Activity withConversation(ConversationAccount conversation) { + this.conversation = conversation; + return this; + } + + /** + * Get the recipient value. + * + * @return the recipient value + */ + public ChannelAccount recipient() { + return this.recipient; + } + + /** + * Set the recipient value. + * + * @param recipient the recipient value to set + * @return the Activity object itself. + */ + public Activity withRecipient(ChannelAccount recipient) { + this.recipient = recipient; + return this; + } + + /** + * Get the textFormat value. + * + * @return the textFormat value + */ + public TextFormatTypes textFormat() { + return this.textFormat; + } + + /** + * Set the textFormat value. + * + * @param textFormat the textFormat value to set + * @return the Activity object itself. + */ + public Activity withTextFormat(TextFormatTypes textFormat) { + this.textFormat = textFormat; + return this; + } + + /** + * Get the attachmentLayout value. + * + * @return the attachmentLayout value + */ + public AttachmentLayoutTypes attachmentLayout() { + return this.attachmentLayout; + } + + /** + * Set the attachmentLayout value. + * + * @param attachmentLayout the attachmentLayout value to set + * @return the Activity object itself. + */ + public Activity withAttachmentLayout(AttachmentLayoutTypes attachmentLayout) { + this.attachmentLayout = attachmentLayout; + return this; + } + + /** + * Get the membersAdded value. + * + * @return the membersAdded value + */ + public List membersAdded() { + return this.membersAdded; + } + + /** + * Set the membersAdded value. + * + * @param membersAdded the membersAdded value to set + * @return the Activity object itself. + */ + public Activity withMembersAdded(List membersAdded) { + this.membersAdded = membersAdded; + return this; + } + + /** + * Get the membersRemoved value. + * + * @return the membersRemoved value + */ + public List membersRemoved() { + return this.membersRemoved; + } + + /** + * Set the membersRemoved value. + * + * @param membersRemoved the membersRemoved value to set + * @return the Activity object itself. + */ + public Activity withMembersRemoved(List membersRemoved) { + this.membersRemoved = membersRemoved; + return this; + } + + /** + * Get the reactionsAdded value. + * + * @return the reactionsAdded value + */ + public List reactionsAdded() { + return this.reactionsAdded; + } + + /** + * Set the reactionsAdded value. + * + * @param reactionsAdded the reactionsAdded value to set + * @return the Activity object itself. + */ + public Activity withReactionsAdded(List reactionsAdded) { + this.reactionsAdded = reactionsAdded; + return this; + } + + /** + * Get the reactionsRemoved value. + * + * @return the reactionsRemoved value + */ + public List reactionsRemoved() { + return this.reactionsRemoved; + } + + /** + * Set the reactionsRemoved value. + * + * @param reactionsRemoved the reactionsRemoved value to set + * @return the Activity object itself. + */ + public Activity withReactionsRemoved(List reactionsRemoved) { + this.reactionsRemoved = reactionsRemoved; + return this; + } + + /** + * Get the topicName value. + * + * @return the topicName value + */ + public String topicName() { + return this.topicName; + } + + /** + * Set the topicName value. + * + * @param topicName the topicName value to set + * @return the Activity object itself. + */ + public Activity withTopicName(String topicName) { + this.topicName = topicName; + return this; + } + + /** + * Get the historyDisclosed value. + * + * @return the historyDisclosed value + */ + public Boolean historyDisclosed() { + return this.historyDisclosed; + } + + /** + * Set the historyDisclosed value. + * + * @param historyDisclosed the historyDisclosed value to set + * @return the Activity object itself. + */ + public Activity withHistoryDisclosed(Boolean historyDisclosed) { + this.historyDisclosed = historyDisclosed; + return this; + } + + /** + * Get the locale value. + * + * @return the locale value + */ + public String locale() { + return this.locale; + } + + /** + * Set the locale value. + * + * @param locale the locale value to set + * @return the Activity object itself. + */ + public Activity withLocale(String locale) { + this.locale = locale; + return this; + } + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the Activity object itself. + */ + public Activity withText(String text) { + this.text = text; + return this; + } + + /** + * Get the speak value. + * + * @return the speak value + */ + public String speak() { + return this.speak; + } + + /** + * Set the speak value. + * + * @param speak the speak value to set + * @return the Activity object itself. + */ + public Activity withSpeak(String speak) { + this.speak = speak; + return this; + } + + /** + * Get the inputHint value. + * + * @return the inputHint value + */ + public InputHints inputHint() { + return this.inputHint; + } + + /** + * Set the inputHint value. + * + * @param inputHint the inputHint value to set + * @return the Activity object itself. + */ + public Activity withInputHint(InputHints inputHint) { + this.inputHint = inputHint; + return this; + } + + /** + * Get the summary value. + * + * @return the summary value + */ + public String summary() { + return this.summary; + } + + /** + * Set the summary value. + * + * @param summary the summary value to set + * @return the Activity object itself. + */ + public Activity withSummary(String summary) { + this.summary = summary; + return this; + } + + /** + * Get the suggestedActions value. + * + * @return the suggestedActions value + */ + public SuggestedActions suggestedActions() { + return this.suggestedActions; + } + + /** + * Set the suggestedActions value. + * + * @param suggestedActions the suggestedActions value to set + * @return the Activity object itself. + */ + public Activity withSuggestedActions(SuggestedActions suggestedActions) { + this.suggestedActions = suggestedActions; + return this; + } + + /** + * Get the attachments value. + * + * @return the attachments value + */ + public List attachments() { + return this.attachments; + } + + /** + * Set the attachments value. + * + * @param attachments the attachments value to set + * @return the Activity object itself. + */ + public Activity withAttachments(List attachments) { + this.attachments = attachments; + return this; + } + + /** + * Get the entities value. + * + * @return the entities value + */ + public List entities() { + return this.entities; + } + + /** + * Set the entities value. + * + * @param entities the entities value to set + * @return the Activity object itself. + */ + public Activity withEntities(List entities) { + this.entities = entities; + return this; + } + + /** + * Get the channelData value. + * + * @return the channelData value + */ + public Object channelData() { + return this.channelData; + } + + /** + * Set the channelData value. + * + * @param channelData the channelData value to set + * @return the Activity object itself. + */ + public Activity withChannelData(Object channelData) { + this.channelData = channelData; + return this; + } + + /** + * Get the action value. + * + * @return the action value + */ + public String action() { + return this.action; + } + + /** + * Set the action value. + * + * @param action the action value to set + * @return the Activity object itself. + */ + public Activity withAction(String action) { + this.action = action; + return this; + } + + /** + * Get the replyToId value. + * + * @return the replyToId value + */ + public String replyToId() { + return this.replyToId; + } + + /** + * Set the replyToId value. + * + * @param replyToId the replyToId value to set + * @return the Activity object itself. + */ + public Activity withReplyToId(String replyToId) { + this.replyToId = replyToId; + return this; + } + + /** + * Get the label value. + * + * @return the label value + */ + public String label() { + return this.label; + } + + /** + * Set the label value. + * + * @param label the label value to set + * @return the Activity object itself. + */ + public Activity withLabel(String label) { + this.label = label; + return this; + } + + /** + * Get the valueType value. + * + * @return the valueType value + */ + public String valueType() { + return this.valueType; + } + + /** + * Set the valueType value. + * + * @param valueType the valueType value to set + * @return the Activity object itself. + */ + public Activity withValueType(String valueType) { + this.valueType = valueType; + return this; + } + + /** + * Get the value value. + * + * @return the value value + */ + public Object value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the Activity object itself. + */ + public Activity withValue(Object value) { + this.value = value; + return this; + } + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the Activity object itself. + */ + public Activity withName(String name) { + this.name = name; + return this; + } + + /** + * Get the relatesTo value. + * + * @return the relatesTo value + */ + public ConversationReference relatesTo() { + return this.relatesTo; + } + + /** + * Set the relatesTo value. + * + * @param relatesTo the relatesTo value to set + * @return the Activity object itself. + */ + public Activity withRelatesTo(ConversationReference relatesTo) { + this.relatesTo = relatesTo; + return this; + } + + /** + * Get the code value. + * + * @return the code value + */ + public EndOfConversationCodes code() { + return this.code; + } + + /** + * Set the code value. + * + * @param code the code value to set + * @return the Activity object itself. + */ + public Activity withCode(EndOfConversationCodes code) { + this.code = code; + return this; + } + + /** + * Get the expiration value. + * + * @return the expiration value + */ + public DateTime expiration() { + return this.expiration; + } + + /** + * Set the expiration value. + * + * @param expiration the expiration value to set + * @return the Activity object itself. + */ + public Activity withExpiration(DateTime expiration) { + this.expiration = expiration; + return this; + } + + /** + * Get the importance value. + * + * @return the importance value + */ + public String importance() { + return this.importance; + } + + /** + * Set the importance value. + * + * @param importance the importance value to set + * @return the Activity object itself. + */ + public Activity withImportance(String importance) { + this.importance = importance; + return this; + } + + /** + * Get the deliveryMode value. + * + * @return the deliveryMode value + */ + public String deliveryMode() { + return this.deliveryMode; + } + + /** + * Set the deliveryMode value. + * + * @param deliveryMode the deliveryMode value to set + * @return the Activity object itself. + */ + public Activity withDeliveryMode(String deliveryMode) { + this.deliveryMode = deliveryMode; + return this; + } + + /** + * Gets listenFor value. + */ + public List listenFor(){ + return this.listenFor; + } + + /** + * Sets listenFor value on this object. + */ + public Activity withListenFor(List listenFor){ + this.listenFor = listenFor; + return this; + } + + /** + * Get the textHighlights value. + * + * @return the textHighlights value + */ + public List textHighlights() { + return this.textHighlights; + } + + /** + * Set the textHighlights value. + * + * @param textHighlights the textHighlights value to set + * @return the Activity object itself. + */ + public Activity withTextHighlights(List textHighlights) { + this.textHighlights = textHighlights; + return this; + } + /** + * Holds the overflow properties that aren't first class + * properties in the object. This allows extensibility + * while maintaining the object. + * + */ + private HashMap properties = new HashMap(); + + /** + * Overflow properties. + * Properties that are not modelled as first class properties in the object are accessible here. + * Note: A property value can be be nested. + * + * @return A Key-Value map of the properties + */ + @JsonAnyGetter + public Map properties() { + return this.properties; + } + + /** + * Set overflow properties. + * + * @param key Key for the property + * @param value JsonNode of value (can be nested) + * + */ + + @JsonAnySetter + public void setProperties(String key, JsonNode value) { + this.properties.put(key, value); + } + + /** + Updates this activity with the delivery information from an existing + conversation reference. + + @param reference The conversation reference. + @param isIncoming (Optional) true to treat the activity as an + incoming activity, where the bot is the recipient; otherwaire false. + Default is false, and the activity will show the bot as the sender. + Call on an incoming + activity to get a conversation reference that you can then use to update an + outgoing activity with the correct delivery information. + + */ + + + public final Activity applyConversationReference(ConversationReference reference) + { + return applyConversationReference(reference, false); + } + + public final Activity applyConversationReference(ConversationReference reference, boolean isIncoming) + { + this.withChannelId(reference.channelId()); + this.withServiceUrl(reference.serviceUrl()); + this.withConversation(reference.conversation()); + + if (isIncoming) + { + this.withFrom(reference.user()); + this.withRecipient(reference.bot()); + if (reference.activityId() != null) + { + this.withId(reference.activityId()); + } + } + else // Outgoing + { + this.withFrom(reference.bot()); + this.withRecipient(reference.user()); + if (reference.activityId() != null) + { + this.withReplyToId(reference.activityId()); + } + } + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ActivityImportance.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ActivityImportance.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ActivityImportance.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ActivityImportance.java index fc99e54f..0ba0dc51 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ActivityImportance.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ActivityImportance.java @@ -1,58 +1,58 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for ActivityImportance. - */ -public enum ActivityImportance { - /** Enum value low. */ - LOW("low"), - - /** Enum value normal. */ - NORMAL("normal"), - - /** Enum value high. */ - HIGH("high"); - - /** The actual serialized value for a ActivityImportance instance. */ - private String value; - - ActivityImportance(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a ActivityImportance instance. - * - * @param value the serialized value to parse. - * @return the parsed ActivityImportance object, or null if unable to parse. - */ - @JsonCreator - public static ActivityImportance fromString(String value) { - ActivityImportance[] items = ActivityImportance.values(); - for (ActivityImportance item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for ActivityImportance. + */ +public enum ActivityImportance { + /** Enum value low. */ + LOW("low"), + + /** Enum value normal. */ + NORMAL("normal"), + + /** Enum value high. */ + HIGH("high"); + + /** The actual serialized value for a ActivityImportance instance. */ + private String value; + + ActivityImportance(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ActivityImportance instance. + * + * @param value the serialized value to parse. + * @return the parsed ActivityImportance object, or null if unable to parse. + */ + @JsonCreator + public static ActivityImportance fromString(String value) { + ActivityImportance[] items = ActivityImportance.values(); + for (ActivityImportance item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ActivityTypes.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ActivityTypes.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ActivityTypes.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ActivityTypes.java index ad01428c..d593a310 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ActivityTypes.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ActivityTypes.java @@ -1,94 +1,94 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for ActivityTypes. - */ -public enum ActivityTypes { - /** Enum value message. */ - MESSAGE("message"), - - /** Enum value contactRelationUpdate. */ - CONTACT_RELATION_UPDATE("contactRelationUpdate"), - - /** Enum value conversationUpdate. */ - CONVERSATION_UPDATE("conversationUpdate"), - - /** Enum value typing. */ - TYPING("typing"), - - /** Enum value endOfConversation. */ - END_OF_CONVERSATION("endOfConversation"), - - /** Enum value event. */ - EVENT("event"), - - /** Enum value invoke. */ - INVOKE("invoke"), - - /** Enum value deleteUserData. */ - DELETE_USER_DATA("deleteUserData"), - - /** Enum value messageUpdate. */ - MESSAGE_UPDATE("messageUpdate"), - - /** Enum value messageDelete. */ - MESSAGE_DELETE("messageDelete"), - - /** Enum value installationUpdate. */ - INSTALLATION_UPDATE("installationUpdate"), - - /** Enum value messageReaction. */ - MESSAGE_REACTION("messageReaction"), - - /** Enum value suggestion. */ - SUGGESTION("suggestion"), - - /** Enum value trace. */ - TRACE("trace"), - - /** Enum value handoff. */ - HANDOFF("handoff"); - - /** The actual serialized value for a ActivityTypes instance. */ - private String value; - - ActivityTypes(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a ActivityTypes instance. - * - * @param value the serialized value to parse. - * @return the parsed ActivityTypes object, or null if unable to parse. - */ - @JsonCreator - public static ActivityTypes fromString(String value) { - ActivityTypes[] items = ActivityTypes.values(); - for (ActivityTypes item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for ActivityTypes. + */ +public enum ActivityTypes { + /** Enum value message. */ + MESSAGE("message"), + + /** Enum value contactRelationUpdate. */ + CONTACT_RELATION_UPDATE("contactRelationUpdate"), + + /** Enum value conversationUpdate. */ + CONVERSATION_UPDATE("conversationUpdate"), + + /** Enum value typing. */ + TYPING("typing"), + + /** Enum value endOfConversation. */ + END_OF_CONVERSATION("endOfConversation"), + + /** Enum value event. */ + EVENT("event"), + + /** Enum value invoke. */ + INVOKE("invoke"), + + /** Enum value deleteUserData. */ + DELETE_USER_DATA("deleteUserData"), + + /** Enum value messageUpdate. */ + MESSAGE_UPDATE("messageUpdate"), + + /** Enum value messageDelete. */ + MESSAGE_DELETE("messageDelete"), + + /** Enum value installationUpdate. */ + INSTALLATION_UPDATE("installationUpdate"), + + /** Enum value messageReaction. */ + MESSAGE_REACTION("messageReaction"), + + /** Enum value suggestion. */ + SUGGESTION("suggestion"), + + /** Enum value trace. */ + TRACE("trace"), + + /** Enum value handoff. */ + HANDOFF("handoff"); + + /** The actual serialized value for a ActivityTypes instance. */ + private String value; + + ActivityTypes(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ActivityTypes instance. + * + * @param value the serialized value to parse. + * @return the parsed ActivityTypes object, or null if unable to parse. + */ + @JsonCreator + public static ActivityTypes fromString(String value) { + ActivityTypes[] items = ActivityTypes.values(); + for (ActivityTypes item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AnimationCard.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AnimationCard.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AnimationCard.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AnimationCard.java index c0ecd11e..ce00f77b 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AnimationCard.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AnimationCard.java @@ -1,332 +1,332 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * An animation card (Ex: gif or short video clip). - */ -public class AnimationCard { - /** - * Title of this card. - */ - @JsonProperty(value = "title") - private String title; - - /** - * Subtitle of this card. - */ - @JsonProperty(value = "subtitle") - private String subtitle; - - /** - * Text of this card. - */ - @JsonProperty(value = "text") - private String text; - - /** - * Thumbnail placeholder. - */ - @JsonProperty(value = "image") - private ThumbnailUrl image; - - /** - * Media URLs for this card. When this field contains more than one URL, each URL is an alternative format of the same content. - */ - @JsonProperty(value = "media") - private List media; - - /** - * Actions on this card. - */ - @JsonProperty(value = "buttons") - private List buttons; - - /** - * This content may be shared with others (default:true). - */ - @JsonProperty(value = "shareable") - private Boolean shareable; - - /** - * Should the client loop playback at end of content (default:true). - */ - @JsonProperty(value = "autoloop") - private Boolean autoloop; - - /** - * Should the client automatically start playback of media in this card - * (default:true). - */ - @JsonProperty(value = "autostart") - private Boolean autostart; - - /** - * Aspect ratio of thumbnail/media placeholder, allowed values are "16:9" - * and "4:3". - */ - @JsonProperty(value = "aspect") - private String aspect; - - /** - * Describes the length of the media content without requiring a receiver to open the content. Formatted as an ISO 8601 Duration field. - */ - @JsonProperty(value = "duration") - private String duration; - - /** - * Supplementary parameter for this card. - */ - @JsonProperty(value = "value") - private Object value; - - /** - * Get the title value. - * - * @return the title value - */ - public String title() { - return this.title; - } - - /** - * Set the title value. - * - * @param title the title value to set - * @return the AnimationCard object itself. - */ - public AnimationCard withTitle(String title) { - this.title = title; - return this; - } - - /** - * Get the subtitle value. - * - * @return the subtitle value - */ - public String subtitle() { - return this.subtitle; - } - - /** - * Set the subtitle value. - * - * @param subtitle the subtitle value to set - * @return the AnimationCard object itself. - */ - public AnimationCard withSubtitle(String subtitle) { - this.subtitle = subtitle; - return this; - } - - /** - * Get the text value. - * - * @return the text value - */ - public String text() { - return this.text; - } - - /** - * Set the text value. - * - * @param text the text value to set - * @return the AnimationCard object itself. - */ - public AnimationCard withText(String text) { - this.text = text; - return this; - } - - /** - * Get the image value. - * - * @return the image value - */ - public ThumbnailUrl image() { - return this.image; - } - - /** - * Set the image value. - * - * @param image the image value to set - * @return the AnimationCard object itself. - */ - public AnimationCard withImage(ThumbnailUrl image) { - this.image = image; - return this; - } - - /** - * Get the media value. - * - * @return the media value - */ - public List media() { - return this.media; - } - - /** - * Set the media value. - * - * @param media the media value to set - * @return the AnimationCard object itself. - */ - public AnimationCard withMedia(List media) { - this.media = media; - return this; - } - - /** - * Get the buttons value. - * - * @return the buttons value - */ - public List buttons() { - return this.buttons; - } - - /** - * Set the buttons value. - * - * @param buttons the buttons value to set - * @return the AnimationCard object itself. - */ - public AnimationCard withButtons(List buttons) { - this.buttons = buttons; - return this; - } - - /** - * Get the shareable value. - * - * @return the shareable value - */ - public Boolean shareable() { - return this.shareable; - } - - /** - * Set the shareable value. - * - * @param shareable the shareable value to set - * @return the AnimationCard object itself. - */ - public AnimationCard withShareable(Boolean shareable) { - this.shareable = shareable; - return this; - } - - /** - * Get the autoloop value. - * - * @return the autoloop value - */ - public Boolean autoloop() { - return this.autoloop; - } - - /** - * Set the autoloop value. - * - * @param autoloop the autoloop value to set - * @return the AnimationCard object itself. - */ - public AnimationCard withAutoloop(Boolean autoloop) { - this.autoloop = autoloop; - return this; - } - - /** - * Get the autostart value. - * - * @return the autostart value - */ - public Boolean autostart() { - return this.autostart; - } - - /** - * Set the autostart value. - * - * @param autostart the autostart value to set - * @return the AnimationCard object itself. - */ - public AnimationCard withAutostart(Boolean autostart) { - this.autostart = autostart; - return this; - } - - /** - * Get the aspect value. - * - * @return the aspect value - */ - public String aspect() { - return this.aspect; - } - - /** - * Set the aspect value. - * - * @param aspect the aspect value to set - * @return the AnimationCard object itself. - */ - public AnimationCard withAspect(String aspect) { - this.aspect = aspect; - return this; - } - - /** - * Gets the duration value. - */ - public String duration(){ - return this.duration; - } - - /** - * Sets the duration value. - * - * @param duration the duration value to set - * @return the AnimationCard object itself. - */ - public AnimationCard withDuration(String duration){ - this.duration = duration; - return this; - } - - /** - * Get the value value. - * - * @return the value value - */ - public Object value() { - return this.value; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the AnimationCard object itself. - */ - public AnimationCard withValue(Object value) { - this.value = value; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * An animation card (Ex: gif or short video clip). + */ +public class AnimationCard { + /** + * Title of this card. + */ + @JsonProperty(value = "title") + private String title; + + /** + * Subtitle of this card. + */ + @JsonProperty(value = "subtitle") + private String subtitle; + + /** + * Text of this card. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Thumbnail placeholder. + */ + @JsonProperty(value = "image") + private ThumbnailUrl image; + + /** + * Media URLs for this card. When this field contains more than one URL, each URL is an alternative format of the same content. + */ + @JsonProperty(value = "media") + private List media; + + /** + * Actions on this card. + */ + @JsonProperty(value = "buttons") + private List buttons; + + /** + * This content may be shared with others (default:true). + */ + @JsonProperty(value = "shareable") + private Boolean shareable; + + /** + * Should the client loop playback at end of content (default:true). + */ + @JsonProperty(value = "autoloop") + private Boolean autoloop; + + /** + * Should the client automatically start playback of media in this card + * (default:true). + */ + @JsonProperty(value = "autostart") + private Boolean autostart; + + /** + * Aspect ratio of thumbnail/media placeholder, allowed values are "16:9" + * and "4:3". + */ + @JsonProperty(value = "aspect") + private String aspect; + + /** + * Describes the length of the media content without requiring a receiver to open the content. Formatted as an ISO 8601 Duration field. + */ + @JsonProperty(value = "duration") + private String duration; + + /** + * Supplementary parameter for this card. + */ + @JsonProperty(value = "value") + private Object value; + + /** + * Get the title value. + * + * @return the title value + */ + public String title() { + return this.title; + } + + /** + * Set the title value. + * + * @param title the title value to set + * @return the AnimationCard object itself. + */ + public AnimationCard withTitle(String title) { + this.title = title; + return this; + } + + /** + * Get the subtitle value. + * + * @return the subtitle value + */ + public String subtitle() { + return this.subtitle; + } + + /** + * Set the subtitle value. + * + * @param subtitle the subtitle value to set + * @return the AnimationCard object itself. + */ + public AnimationCard withSubtitle(String subtitle) { + this.subtitle = subtitle; + return this; + } + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the AnimationCard object itself. + */ + public AnimationCard withText(String text) { + this.text = text; + return this; + } + + /** + * Get the image value. + * + * @return the image value + */ + public ThumbnailUrl image() { + return this.image; + } + + /** + * Set the image value. + * + * @param image the image value to set + * @return the AnimationCard object itself. + */ + public AnimationCard withImage(ThumbnailUrl image) { + this.image = image; + return this; + } + + /** + * Get the media value. + * + * @return the media value + */ + public List media() { + return this.media; + } + + /** + * Set the media value. + * + * @param media the media value to set + * @return the AnimationCard object itself. + */ + public AnimationCard withMedia(List media) { + this.media = media; + return this; + } + + /** + * Get the buttons value. + * + * @return the buttons value + */ + public List buttons() { + return this.buttons; + } + + /** + * Set the buttons value. + * + * @param buttons the buttons value to set + * @return the AnimationCard object itself. + */ + public AnimationCard withButtons(List buttons) { + this.buttons = buttons; + return this; + } + + /** + * Get the shareable value. + * + * @return the shareable value + */ + public Boolean shareable() { + return this.shareable; + } + + /** + * Set the shareable value. + * + * @param shareable the shareable value to set + * @return the AnimationCard object itself. + */ + public AnimationCard withShareable(Boolean shareable) { + this.shareable = shareable; + return this; + } + + /** + * Get the autoloop value. + * + * @return the autoloop value + */ + public Boolean autoloop() { + return this.autoloop; + } + + /** + * Set the autoloop value. + * + * @param autoloop the autoloop value to set + * @return the AnimationCard object itself. + */ + public AnimationCard withAutoloop(Boolean autoloop) { + this.autoloop = autoloop; + return this; + } + + /** + * Get the autostart value. + * + * @return the autostart value + */ + public Boolean autostart() { + return this.autostart; + } + + /** + * Set the autostart value. + * + * @param autostart the autostart value to set + * @return the AnimationCard object itself. + */ + public AnimationCard withAutostart(Boolean autostart) { + this.autostart = autostart; + return this; + } + + /** + * Get the aspect value. + * + * @return the aspect value + */ + public String aspect() { + return this.aspect; + } + + /** + * Set the aspect value. + * + * @param aspect the aspect value to set + * @return the AnimationCard object itself. + */ + public AnimationCard withAspect(String aspect) { + this.aspect = aspect; + return this; + } + + /** + * Gets the duration value. + */ + public String duration(){ + return this.duration; + } + + /** + * Sets the duration value. + * + * @param duration the duration value to set + * @return the AnimationCard object itself. + */ + public AnimationCard withDuration(String duration){ + this.duration = duration; + return this; + } + + /** + * Get the value value. + * + * @return the value value + */ + public Object value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the AnimationCard object itself. + */ + public AnimationCard withValue(Object value) { + this.value = value; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Attachment.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Attachment.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Attachment.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Attachment.java index 01c94d9c..a0e4c51c 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Attachment.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Attachment.java @@ -1,185 +1,185 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.JsonNode; - -import java.util.HashMap; -import java.util.Map; - -/** - * An attachment within an activity. - */ -public class Attachment { - /** - * mimetype/Contenttype for the file. - */ - @JsonProperty(value = "contentType") - private String contentType; - - /** - * Content Url. - */ - @JsonProperty(value = "contentUrl") - private String contentUrl; - - /** - * Embedded content. - */ - @JsonProperty(value = "content") - private Object content; - - /** - * (OPTIONAL) The name of the attachment. - */ - @JsonProperty(value = "name") - private String name; - - /** - * (OPTIONAL) Thumbnail associated with attachment. - */ - @JsonProperty(value = "thumbnailUrl") - private String thumbnailUrl; - - /** - * Get the contentType value. - * - * @return the contentType value - */ - public String contentType() { - return this.contentType; - } - - /** - * Set the contentType value. - * - * @param contentType the contentType value to set - * @return the Attachment object itself. - */ - public Attachment withContentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * Get the contentUrl value. - * - * @return the contentUrl value - */ - public String contentUrl() { - return this.contentUrl; - } - - /** - * Set the contentUrl value. - * - * @param contentUrl the contentUrl value to set - * @return the Attachment object itself. - */ - public Attachment withContentUrl(String contentUrl) { - this.contentUrl = contentUrl; - return this; - } - - /** - * Get the content value. - * - * @return the content value - */ - public Object content() { - return this.content; - } - - /** - * Set the content value. - * - * @param content the content value to set - * @return the Attachment object itself. - */ - public Attachment withContent(Object content) { - this.content = content; - return this; - } - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the Attachment object itself. - */ - public Attachment withName(String name) { - this.name = name; - return this; - } - - /** - * Get the thumbnailUrl value. - * - * @return the thumbnailUrl value - */ - public String thumbnailUrl() { - return this.thumbnailUrl; - } - - /** - * Set the thumbnailUrl value. - * - * @param thumbnailUrl the thumbnailUrl value to set - * @return the Attachment object itself. - */ - public Attachment withThumbnailUrl(String thumbnailUrl) { - this.thumbnailUrl = thumbnailUrl; - return this; - } - /** - * Holds the overflow properties that aren't first class - * properties in the object. This allows extensibility - * while maintaining the object. - * - */ - private HashMap properties = new HashMap(); - - /** - * Overflow properties. - * Properties that are not modelled as first class properties in the object are accessible here. - * Note: A property value can be be nested. - * - * @return A Key-Value map of the properties - */ - @JsonAnyGetter - public Map properties() { - return this.properties; - } - - /** - * Set overflow properties. - * - * @param key Key for the property - * @param value JsonNode of value (can be nested) - * - */ - - @JsonAnySetter - public void setProperties(String key, JsonNode value) { - this.properties.put(key, value); - } - - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.HashMap; +import java.util.Map; + +/** + * An attachment within an activity. + */ +public class Attachment { + /** + * mimetype/Contenttype for the file. + */ + @JsonProperty(value = "contentType") + private String contentType; + + /** + * Content Url. + */ + @JsonProperty(value = "contentUrl") + private String contentUrl; + + /** + * Embedded content. + */ + @JsonProperty(value = "content") + private Object content; + + /** + * (OPTIONAL) The name of the attachment. + */ + @JsonProperty(value = "name") + private String name; + + /** + * (OPTIONAL) Thumbnail associated with attachment. + */ + @JsonProperty(value = "thumbnailUrl") + private String thumbnailUrl; + + /** + * Get the contentType value. + * + * @return the contentType value + */ + public String contentType() { + return this.contentType; + } + + /** + * Set the contentType value. + * + * @param contentType the contentType value to set + * @return the Attachment object itself. + */ + public Attachment withContentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Get the contentUrl value. + * + * @return the contentUrl value + */ + public String contentUrl() { + return this.contentUrl; + } + + /** + * Set the contentUrl value. + * + * @param contentUrl the contentUrl value to set + * @return the Attachment object itself. + */ + public Attachment withContentUrl(String contentUrl) { + this.contentUrl = contentUrl; + return this; + } + + /** + * Get the content value. + * + * @return the content value + */ + public Object content() { + return this.content; + } + + /** + * Set the content value. + * + * @param content the content value to set + * @return the Attachment object itself. + */ + public Attachment withContent(Object content) { + this.content = content; + return this; + } + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the Attachment object itself. + */ + public Attachment withName(String name) { + this.name = name; + return this; + } + + /** + * Get the thumbnailUrl value. + * + * @return the thumbnailUrl value + */ + public String thumbnailUrl() { + return this.thumbnailUrl; + } + + /** + * Set the thumbnailUrl value. + * + * @param thumbnailUrl the thumbnailUrl value to set + * @return the Attachment object itself. + */ + public Attachment withThumbnailUrl(String thumbnailUrl) { + this.thumbnailUrl = thumbnailUrl; + return this; + } + /** + * Holds the overflow properties that aren't first class + * properties in the object. This allows extensibility + * while maintaining the object. + * + */ + private HashMap properties = new HashMap(); + + /** + * Overflow properties. + * Properties that are not modelled as first class properties in the object are accessible here. + * Note: A property value can be be nested. + * + * @return A Key-Value map of the properties + */ + @JsonAnyGetter + public Map properties() { + return this.properties; + } + + /** + * Set overflow properties. + * + * @param key Key for the property + * @param value JsonNode of value (can be nested) + * + */ + + @JsonAnySetter + public void setProperties(String key, JsonNode value) { + this.properties.put(key, value); + } + + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentData.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentData.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentData.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentData.java index 5e12ea60..e58585d9 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentData.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentData.java @@ -1,123 +1,123 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Attachment data. - */ -public class AttachmentData { - /** - * Content-Type of the attachment. - */ - @JsonProperty(value = "type") - private String type; - - /** - * Name of the attachment. - */ - @JsonProperty(value = "name") - private String name; - - /** - * Attachment content. - */ - @JsonProperty(value = "originalBase64") - private byte[] originalBase64; - - /** - * Attachment thumbnail. - */ - @JsonProperty(value = "thumbnailBase64") - private byte[] thumbnailBase64; - - /** - * Get the type value. - * - * @return the type value - */ - public String type() { - return this.type; - } - - /** - * Set the type value. - * - * @param type the type value to set - * @return the AttachmentData object itself. - */ - public AttachmentData withType(String type) { - this.type = type; - return this; - } - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the AttachmentData object itself. - */ - public AttachmentData withName(String name) { - this.name = name; - return this; - } - - /** - * Get the originalBase64 value. - * - * @return the originalBase64 value - */ - public byte[] originalBase64() { - return this.originalBase64; - } - - /** - * Set the originalBase64 value. - * - * @param originalBase64 the originalBase64 value to set - * @return the AttachmentData object itself. - */ - public AttachmentData withOriginalBase64(byte[] originalBase64) { - this.originalBase64 = originalBase64; - return this; - } - - /** - * Get the thumbnailBase64 value. - * - * @return the thumbnailBase64 value - */ - public byte[] thumbnailBase64() { - return this.thumbnailBase64; - } - - /** - * Set the thumbnailBase64 value. - * - * @param thumbnailBase64 the thumbnailBase64 value to set - * @return the AttachmentData object itself. - */ - public AttachmentData withThumbnailBase64(byte[] thumbnailBase64) { - this.thumbnailBase64 = thumbnailBase64; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Attachment data. + */ +public class AttachmentData { + /** + * Content-Type of the attachment. + */ + @JsonProperty(value = "type") + private String type; + + /** + * Name of the attachment. + */ + @JsonProperty(value = "name") + private String name; + + /** + * Attachment content. + */ + @JsonProperty(value = "originalBase64") + private byte[] originalBase64; + + /** + * Attachment thumbnail. + */ + @JsonProperty(value = "thumbnailBase64") + private byte[] thumbnailBase64; + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the AttachmentData object itself. + */ + public AttachmentData withType(String type) { + this.type = type; + return this; + } + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the AttachmentData object itself. + */ + public AttachmentData withName(String name) { + this.name = name; + return this; + } + + /** + * Get the originalBase64 value. + * + * @return the originalBase64 value + */ + public byte[] originalBase64() { + return this.originalBase64; + } + + /** + * Set the originalBase64 value. + * + * @param originalBase64 the originalBase64 value to set + * @return the AttachmentData object itself. + */ + public AttachmentData withOriginalBase64(byte[] originalBase64) { + this.originalBase64 = originalBase64; + return this; + } + + /** + * Get the thumbnailBase64 value. + * + * @return the thumbnailBase64 value + */ + public byte[] thumbnailBase64() { + return this.thumbnailBase64; + } + + /** + * Set the thumbnailBase64 value. + * + * @param thumbnailBase64 the thumbnailBase64 value to set + * @return the AttachmentData object itself. + */ + public AttachmentData withThumbnailBase64(byte[] thumbnailBase64) { + this.thumbnailBase64 = thumbnailBase64; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentInfo.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentInfo.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentInfo.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentInfo.java index 0cf2e5bb..829db6fb 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentInfo.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentInfo.java @@ -1,98 +1,98 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Metdata for an attachment. - */ -public class AttachmentInfo { - /** - * Name of the attachment. - */ - @JsonProperty(value = "name") - private String name; - - /** - * ContentType of the attachment. - */ - @JsonProperty(value = "type") - private String type; - - /** - * attachment views. - */ - @JsonProperty(value = "views") - private List views; - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the AttachmentInfo object itself. - */ - public AttachmentInfo withName(String name) { - this.name = name; - return this; - } - - /** - * Get the type value. - * - * @return the type value - */ - public String type() { - return this.type; - } - - /** - * Set the type value. - * - * @param type the type value to set - * @return the AttachmentInfo object itself. - */ - public AttachmentInfo withType(String type) { - this.type = type; - return this; - } - - /** - * Get the views value. - * - * @return the views value - */ - public List views() { - return this.views; - } - - /** - * Set the views value. - * - * @param views the views value to set - * @return the AttachmentInfo object itself. - */ - public AttachmentInfo withViews(List views) { - this.views = views; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Metdata for an attachment. + */ +public class AttachmentInfo { + /** + * Name of the attachment. + */ + @JsonProperty(value = "name") + private String name; + + /** + * ContentType of the attachment. + */ + @JsonProperty(value = "type") + private String type; + + /** + * attachment views. + */ + @JsonProperty(value = "views") + private List views; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the AttachmentInfo object itself. + */ + public AttachmentInfo withName(String name) { + this.name = name; + return this; + } + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the AttachmentInfo object itself. + */ + public AttachmentInfo withType(String type) { + this.type = type; + return this; + } + + /** + * Get the views value. + * + * @return the views value + */ + public List views() { + return this.views; + } + + /** + * Set the views value. + * + * @param views the views value to set + * @return the AttachmentInfo object itself. + */ + public AttachmentInfo withViews(List views) { + this.views = views; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentLayoutTypes.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentLayoutTypes.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentLayoutTypes.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentLayoutTypes.java index f45e4d04..2939adc0 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentLayoutTypes.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentLayoutTypes.java @@ -1,55 +1,55 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for AttachmentLayoutTypes. - */ -public enum AttachmentLayoutTypes { - /** Enum value list. */ - LIST("list"), - - /** Enum value carousel. */ - CAROUSEL("carousel"); - - /** The actual serialized value for a AttachmentLayoutTypes instance. */ - private String value; - - AttachmentLayoutTypes(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a AttachmentLayoutTypes instance. - * - * @param value the serialized value to parse. - * @return the parsed AttachmentLayoutTypes object, or null if unable to parse. - */ - @JsonCreator - public static AttachmentLayoutTypes fromString(String value) { - AttachmentLayoutTypes[] items = AttachmentLayoutTypes.values(); - for (AttachmentLayoutTypes item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for AttachmentLayoutTypes. + */ +public enum AttachmentLayoutTypes { + /** Enum value list. */ + LIST("list"), + + /** Enum value carousel. */ + CAROUSEL("carousel"); + + /** The actual serialized value for a AttachmentLayoutTypes instance. */ + private String value; + + AttachmentLayoutTypes(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a AttachmentLayoutTypes instance. + * + * @param value the serialized value to parse. + * @return the parsed AttachmentLayoutTypes object, or null if unable to parse. + */ + @JsonCreator + public static AttachmentLayoutTypes fromString(String value) { + AttachmentLayoutTypes[] items = AttachmentLayoutTypes.values(); + for (AttachmentLayoutTypes item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentView.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentView.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentView.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentView.java index 3717a005..4bb0e072 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentView.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AttachmentView.java @@ -1,71 +1,71 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Attachment View name and size. - */ -public class AttachmentView { - /** - * Id of the attachment. - */ - @JsonProperty(value = "viewId") - private String viewId; - - /** - * Size of the attachment. - */ - @JsonProperty(value = "size") - private Integer size; - - /** - * Get the viewId value. - * - * @return the viewId value - */ - public String viewId() { - return this.viewId; - } - - /** - * Set the viewId value. - * - * @param viewId the viewId value to set - * @return the AttachmentView object itself. - */ - public AttachmentView withViewId(String viewId) { - this.viewId = viewId; - return this; - } - - /** - * Get the size value. - * - * @return the size value - */ - public Integer size() { - return this.size; - } - - /** - * Set the size value. - * - * @param size the size value to set - * @return the AttachmentView object itself. - */ - public AttachmentView withSize(Integer size) { - this.size = size; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Attachment View name and size. + */ +public class AttachmentView { + /** + * Id of the attachment. + */ + @JsonProperty(value = "viewId") + private String viewId; + + /** + * Size of the attachment. + */ + @JsonProperty(value = "size") + private Integer size; + + /** + * Get the viewId value. + * + * @return the viewId value + */ + public String viewId() { + return this.viewId; + } + + /** + * Set the viewId value. + * + * @param viewId the viewId value to set + * @return the AttachmentView object itself. + */ + public AttachmentView withViewId(String viewId) { + this.viewId = viewId; + return this; + } + + /** + * Get the size value. + * + * @return the size value + */ + public Integer size() { + return this.size; + } + + /** + * Set the size value. + * + * @param size the size value to set + * @return the AttachmentView object itself. + */ + public AttachmentView withSize(Integer size) { + this.size = size; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AudioCard.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AudioCard.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AudioCard.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AudioCard.java index d1c015bb..2f0d4aa3 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/AudioCard.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/AudioCard.java @@ -1,332 +1,332 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Audio card. - */ -public class AudioCard { - /** - * Title of this card. - */ - @JsonProperty(value = "title") - private String title; - - /** - * Subtitle of this card. - */ - @JsonProperty(value = "subtitle") - private String subtitle; - - /** - * Text of this card. - */ - @JsonProperty(value = "text") - private String text; - - /** - * Thumbnail placeholder. - */ - @JsonProperty(value = "image") - private ThumbnailUrl image; - - /** - * Media URLs for this card. When this field contains more than one URL, each URL is an alternative format of the same content. - */ - @JsonProperty(value = "media") - private List media; - - /** - * Actions on this card. - */ - @JsonProperty(value = "buttons") - private List buttons; - - /** - * This content may be shared with others (default:true). - */ - @JsonProperty(value = "shareable") - private Boolean shareable; - - /** - * Should the client loop playback at end of content (default:true). - */ - @JsonProperty(value = "autoloop") - private Boolean autoloop; - - /** - * Should the client automatically start playback of media in this card - * (default:true). - */ - @JsonProperty(value = "autostart") - private Boolean autostart; - - /** - * Aspect ratio of thumbnail/media placeholder, allowed values are "16:9" - * and "4:3". - */ - @JsonProperty(value = "aspect") - private String aspect; - - /** - * Describes the length of the media content without requiring a receiver to open the content. Formatted as an ISO 8601 Duration field. - */ - @JsonProperty(value = "duration") - private String duration; - - /** - * Supplementary parameter for this card. - */ - @JsonProperty(value = "value") - private Object value; - - /** - * Get the title value. - * - * @return the title value - */ - public String title() { - return this.title; - } - - /** - * Set the title value. - * - * @param title the title value to set - * @return the AudioCard object itself. - */ - public AudioCard withTitle(String title) { - this.title = title; - return this; - } - - /** - * Get the subtitle value. - * - * @return the subtitle value - */ - public String subtitle() { - return this.subtitle; - } - - /** - * Set the subtitle value. - * - * @param subtitle the subtitle value to set - * @return the AudioCard object itself. - */ - public AudioCard withSubtitle(String subtitle) { - this.subtitle = subtitle; - return this; - } - - /** - * Get the text value. - * - * @return the text value - */ - public String text() { - return this.text; - } - - /** - * Set the text value. - * - * @param text the text value to set - * @return the AudioCard object itself. - */ - public AudioCard withText(String text) { - this.text = text; - return this; - } - - /** - * Get the image value. - * - * @return the image value - */ - public ThumbnailUrl image() { - return this.image; - } - - /** - * Set the image value. - * - * @param image the image value to set - * @return the AudioCard object itself. - */ - public AudioCard withImage(ThumbnailUrl image) { - this.image = image; - return this; - } - - /** - * Get the media value. - * - * @return the media value - */ - public List media() { - return this.media; - } - - /** - * Set the media value. - * - * @param media the media value to set - * @return the AudioCard object itself. - */ - public AudioCard withMedia(List media) { - this.media = media; - return this; - } - - /** - * Get the buttons value. - * - * @return the buttons value - */ - public List buttons() { - return this.buttons; - } - - /** - * Set the buttons value. - * - * @param buttons the buttons value to set - * @return the AudioCard object itself. - */ - public AudioCard withButtons(List buttons) { - this.buttons = buttons; - return this; - } - - /** - * Get the shareable value. - * - * @return the shareable value - */ - public Boolean shareable() { - return this.shareable; - } - - /** - * Set the shareable value. - * - * @param shareable the shareable value to set - * @return the AudioCard object itself. - */ - public AudioCard withShareable(Boolean shareable) { - this.shareable = shareable; - return this; - } - - /** - * Get the autoloop value. - * - * @return the autoloop value - */ - public Boolean autoloop() { - return this.autoloop; - } - - /** - * Set the autoloop value. - * - * @param autoloop the autoloop value to set - * @return the AudioCard object itself. - */ - public AudioCard withAutoloop(Boolean autoloop) { - this.autoloop = autoloop; - return this; - } - - /** - * Get the autostart value. - * - * @return the autostart value - */ - public Boolean autostart() { - return this.autostart; - } - - /** - * Set the autostart value. - * - * @param autostart the autostart value to set - * @return the AudioCard object itself. - */ - public AudioCard withAutostart(Boolean autostart) { - this.autostart = autostart; - return this; - } - - /** - * Get the aspect value. - * - * @return the aspect value - */ - public String aspect() { - return this.aspect; - } - - /** - * Set the aspect value. - * - * @param aspect the aspect value to set - * @return the AudioCard object itself. - */ - public AudioCard withAspect(String aspect) { - this.aspect = aspect; - return this; - } - - /** - * Gets the duration value. - */ - public String duration(){ - return this.duration; - } - - /** - * Sets the duration value. - * - * @param duration the duration value to set - * @return the AudioCard object itself. - */ - public AudioCard withDuration(String duration){ - this.duration = duration; - return this; - } - - /** - * Get the value value. - * - * @return the value value - */ - public Object value() { - return this.value; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the AudioCard object itself. - */ - public AudioCard withValue(Object value) { - this.value = value; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Audio card. + */ +public class AudioCard { + /** + * Title of this card. + */ + @JsonProperty(value = "title") + private String title; + + /** + * Subtitle of this card. + */ + @JsonProperty(value = "subtitle") + private String subtitle; + + /** + * Text of this card. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Thumbnail placeholder. + */ + @JsonProperty(value = "image") + private ThumbnailUrl image; + + /** + * Media URLs for this card. When this field contains more than one URL, each URL is an alternative format of the same content. + */ + @JsonProperty(value = "media") + private List media; + + /** + * Actions on this card. + */ + @JsonProperty(value = "buttons") + private List buttons; + + /** + * This content may be shared with others (default:true). + */ + @JsonProperty(value = "shareable") + private Boolean shareable; + + /** + * Should the client loop playback at end of content (default:true). + */ + @JsonProperty(value = "autoloop") + private Boolean autoloop; + + /** + * Should the client automatically start playback of media in this card + * (default:true). + */ + @JsonProperty(value = "autostart") + private Boolean autostart; + + /** + * Aspect ratio of thumbnail/media placeholder, allowed values are "16:9" + * and "4:3". + */ + @JsonProperty(value = "aspect") + private String aspect; + + /** + * Describes the length of the media content without requiring a receiver to open the content. Formatted as an ISO 8601 Duration field. + */ + @JsonProperty(value = "duration") + private String duration; + + /** + * Supplementary parameter for this card. + */ + @JsonProperty(value = "value") + private Object value; + + /** + * Get the title value. + * + * @return the title value + */ + public String title() { + return this.title; + } + + /** + * Set the title value. + * + * @param title the title value to set + * @return the AudioCard object itself. + */ + public AudioCard withTitle(String title) { + this.title = title; + return this; + } + + /** + * Get the subtitle value. + * + * @return the subtitle value + */ + public String subtitle() { + return this.subtitle; + } + + /** + * Set the subtitle value. + * + * @param subtitle the subtitle value to set + * @return the AudioCard object itself. + */ + public AudioCard withSubtitle(String subtitle) { + this.subtitle = subtitle; + return this; + } + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the AudioCard object itself. + */ + public AudioCard withText(String text) { + this.text = text; + return this; + } + + /** + * Get the image value. + * + * @return the image value + */ + public ThumbnailUrl image() { + return this.image; + } + + /** + * Set the image value. + * + * @param image the image value to set + * @return the AudioCard object itself. + */ + public AudioCard withImage(ThumbnailUrl image) { + this.image = image; + return this; + } + + /** + * Get the media value. + * + * @return the media value + */ + public List media() { + return this.media; + } + + /** + * Set the media value. + * + * @param media the media value to set + * @return the AudioCard object itself. + */ + public AudioCard withMedia(List media) { + this.media = media; + return this; + } + + /** + * Get the buttons value. + * + * @return the buttons value + */ + public List buttons() { + return this.buttons; + } + + /** + * Set the buttons value. + * + * @param buttons the buttons value to set + * @return the AudioCard object itself. + */ + public AudioCard withButtons(List buttons) { + this.buttons = buttons; + return this; + } + + /** + * Get the shareable value. + * + * @return the shareable value + */ + public Boolean shareable() { + return this.shareable; + } + + /** + * Set the shareable value. + * + * @param shareable the shareable value to set + * @return the AudioCard object itself. + */ + public AudioCard withShareable(Boolean shareable) { + this.shareable = shareable; + return this; + } + + /** + * Get the autoloop value. + * + * @return the autoloop value + */ + public Boolean autoloop() { + return this.autoloop; + } + + /** + * Set the autoloop value. + * + * @param autoloop the autoloop value to set + * @return the AudioCard object itself. + */ + public AudioCard withAutoloop(Boolean autoloop) { + this.autoloop = autoloop; + return this; + } + + /** + * Get the autostart value. + * + * @return the autostart value + */ + public Boolean autostart() { + return this.autostart; + } + + /** + * Set the autostart value. + * + * @param autostart the autostart value to set + * @return the AudioCard object itself. + */ + public AudioCard withAutostart(Boolean autostart) { + this.autostart = autostart; + return this; + } + + /** + * Get the aspect value. + * + * @return the aspect value + */ + public String aspect() { + return this.aspect; + } + + /** + * Set the aspect value. + * + * @param aspect the aspect value to set + * @return the AudioCard object itself. + */ + public AudioCard withAspect(String aspect) { + this.aspect = aspect; + return this; + } + + /** + * Gets the duration value. + */ + public String duration(){ + return this.duration; + } + + /** + * Sets the duration value. + * + * @param duration the duration value to set + * @return the AudioCard object itself. + */ + public AudioCard withDuration(String duration){ + this.duration = duration; + return this; + } + + /** + * Get the value value. + * + * @return the value value + */ + public Object value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the AudioCard object itself. + */ + public AudioCard withValue(Object value) { + this.value = value; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/BasicCard.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/BasicCard.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/BasicCard.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/BasicCard.java index 10b41e92..2ad6f2d5 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/BasicCard.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/BasicCard.java @@ -1,176 +1,176 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A basic card. - */ -public class BasicCard { - /** - * Title of the card. - */ - @JsonProperty(value = "title") - private String title; - - /** - * Subtitle of the card. - */ - @JsonProperty(value = "subtitle") - private String subtitle; - - /** - * Text for the card. - */ - @JsonProperty(value = "text") - private String text; - - /** - * Array of images for the card. - */ - @JsonProperty(value = "images") - private List images; - - /** - * Set of actions applicable to the current card. - */ - @JsonProperty(value = "buttons") - private List buttons; - - /** - * This action will be activated when user taps on the card itself. - */ - @JsonProperty(value = "tap") - private CardAction tap; - - /** - * Get the title value. - * - * @return the title value - */ - public String title() { - return this.title; - } - - /** - * Set the title value. - * - * @param title the title value to set - * @return the BasicCard object itself. - */ - public BasicCard withTitle(String title) { - this.title = title; - return this; - } - - /** - * Get the subtitle value. - * - * @return the subtitle value - */ - public String subtitle() { - return this.subtitle; - } - - /** - * Set the subtitle value. - * - * @param subtitle the subtitle value to set - * @return the BasicCard object itself. - */ - public BasicCard withSubtitle(String subtitle) { - this.subtitle = subtitle; - return this; - } - - /** - * Get the text value. - * - * @return the text value - */ - public String text() { - return this.text; - } - - /** - * Set the text value. - * - * @param text the text value to set - * @return the BasicCard object itself. - */ - public BasicCard withText(String text) { - this.text = text; - return this; - } - - /** - * Get the images value. - * - * @return the images value - */ - public List images() { - return this.images; - } - - /** - * Set the images value. - * - * @param images the images value to set - * @return the BasicCard object itself. - */ - public BasicCard withImages(List images) { - this.images = images; - return this; - } - - /** - * Get the buttons value. - * - * @return the buttons value - */ - public List buttons() { - return this.buttons; - } - - /** - * Set the buttons value. - * - * @param buttons the buttons value to set - * @return the BasicCard object itself. - */ - public BasicCard withButtons(List buttons) { - this.buttons = buttons; - return this; - } - - /** - * Get the tap value. - * - * @return the tap value - */ - public CardAction tap() { - return this.tap; - } - - /** - * Set the tap value. - * - * @param tap the tap value to set - * @return the BasicCard object itself. - */ - public BasicCard withTap(CardAction tap) { - this.tap = tap; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A basic card. + */ +public class BasicCard { + /** + * Title of the card. + */ + @JsonProperty(value = "title") + private String title; + + /** + * Subtitle of the card. + */ + @JsonProperty(value = "subtitle") + private String subtitle; + + /** + * Text for the card. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Array of images for the card. + */ + @JsonProperty(value = "images") + private List images; + + /** + * Set of actions applicable to the current card. + */ + @JsonProperty(value = "buttons") + private List buttons; + + /** + * This action will be activated when user taps on the card itself. + */ + @JsonProperty(value = "tap") + private CardAction tap; + + /** + * Get the title value. + * + * @return the title value + */ + public String title() { + return this.title; + } + + /** + * Set the title value. + * + * @param title the title value to set + * @return the BasicCard object itself. + */ + public BasicCard withTitle(String title) { + this.title = title; + return this; + } + + /** + * Get the subtitle value. + * + * @return the subtitle value + */ + public String subtitle() { + return this.subtitle; + } + + /** + * Set the subtitle value. + * + * @param subtitle the subtitle value to set + * @return the BasicCard object itself. + */ + public BasicCard withSubtitle(String subtitle) { + this.subtitle = subtitle; + return this; + } + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the BasicCard object itself. + */ + public BasicCard withText(String text) { + this.text = text; + return this; + } + + /** + * Get the images value. + * + * @return the images value + */ + public List images() { + return this.images; + } + + /** + * Set the images value. + * + * @param images the images value to set + * @return the BasicCard object itself. + */ + public BasicCard withImages(List images) { + this.images = images; + return this; + } + + /** + * Get the buttons value. + * + * @return the buttons value + */ + public List buttons() { + return this.buttons; + } + + /** + * Set the buttons value. + * + * @param buttons the buttons value to set + * @return the BasicCard object itself. + */ + public BasicCard withButtons(List buttons) { + this.buttons = buttons; + return this; + } + + /** + * Get the tap value. + * + * @return the tap value + */ + public CardAction tap() { + return this.tap; + } + + /** + * Set the tap value. + * + * @param tap the tap value to set + * @return the BasicCard object itself. + */ + public BasicCard withTap(CardAction tap) { + this.tap = tap; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/CardAction.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/CardAction.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/CardAction.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/CardAction.java index af7af9eb..ff0b4691 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/CardAction.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/CardAction.java @@ -1,201 +1,201 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A clickable action. - */ -public class CardAction { - /** - * The type of action implemented by this button. Possible values include: - * 'openUrl', 'imBack', 'postBack', 'playAudio', 'playVideo', 'showImage', - * 'downloadFile', 'signin', 'call', 'payment', 'messageBack'. - */ - @JsonProperty(value = "type") - private ActionTypes type; - - /** - * Text description which appears on the button. - */ - @JsonProperty(value = "title") - private String title; - - /** - * Image URL which will appear on the button, next to text label. - */ - @JsonProperty(value = "image") - private String image; - - /** - * Text for this action. - */ - @JsonProperty(value = "text") - private String text; - - /** - * (Optional) text to display in the chat feed if the button is clicked. - */ - @JsonProperty(value = "displayText") - private String displayText; - - /** - * Supplementary parameter for action. Content of this property depends on - * the ActionType. - */ - @JsonProperty(value = "value") - private Object value; - - /** - * Channel-specific data associated with this action. - */ - @JsonProperty(value = "channelData") - private Object channelData; - - /** - * Get the type value. - * - * @return the type value - */ - public ActionTypes type() { - return this.type; - } - - /** - * Set the type value. - * - * @param type the type value to set - * @return the CardAction object itself. - */ - public CardAction withType(ActionTypes type) { - this.type = type; - return this; - } - - /** - * Get the title value. - * - * @return the title value - */ - public String title() { - return this.title; - } - - /** - * Set the title value. - * - * @param title the title value to set - * @return the CardAction object itself. - */ - public CardAction withTitle(String title) { - this.title = title; - return this; - } - - /** - * Get the image value. - * - * @return the image value - */ - public String image() { - return this.image; - } - - /** - * Set the image value. - * - * @param image the image value to set - * @return the CardAction object itself. - */ - public CardAction withImage(String image) { - this.image = image; - return this; - } - - /** - * Get the text value. - * - * @return the text value - */ - public String text() { - return this.text; - } - - /** - * Set the text value. - * - * @param text the text value to set - * @return the CardAction object itself. - */ - public CardAction withText(String text) { - this.text = text; - return this; - } - - /** - * Get the displayText value. - * - * @return the displayText value - */ - public String displayText() { - return this.displayText; - } - - /** - * Set the displayText value. - * - * @param displayText the displayText value to set - * @return the CardAction object itself. - */ - public CardAction withDisplayText(String displayText) { - this.displayText = displayText; - return this; - } - - /** - * Get the value value. - * - * @return the value value - */ - public Object value() { - return this.value; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the CardAction object itself. - */ - public CardAction withValue(Object value) { - this.value = value; - return this; - } - - /** - * Gets the channelData value. - */ - public Object channelData(){ - return this.channelData; - } - - /** - * Sets the channelData value. - * - * @param channelData The channelData object to set. - * @return the CardAction object itself. - */ - public CardAction withChannelData(Object channelData){ - this.channelData = channelData; - return this; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A clickable action. + */ +public class CardAction { + /** + * The type of action implemented by this button. Possible values include: + * 'openUrl', 'imBack', 'postBack', 'playAudio', 'playVideo', 'showImage', + * 'downloadFile', 'signin', 'call', 'payment', 'messageBack'. + */ + @JsonProperty(value = "type") + private ActionTypes type; + + /** + * Text description which appears on the button. + */ + @JsonProperty(value = "title") + private String title; + + /** + * Image URL which will appear on the button, next to text label. + */ + @JsonProperty(value = "image") + private String image; + + /** + * Text for this action. + */ + @JsonProperty(value = "text") + private String text; + + /** + * (Optional) text to display in the chat feed if the button is clicked. + */ + @JsonProperty(value = "displayText") + private String displayText; + + /** + * Supplementary parameter for action. Content of this property depends on + * the ActionType. + */ + @JsonProperty(value = "value") + private Object value; + + /** + * Channel-specific data associated with this action. + */ + @JsonProperty(value = "channelData") + private Object channelData; + + /** + * Get the type value. + * + * @return the type value + */ + public ActionTypes type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the CardAction object itself. + */ + public CardAction withType(ActionTypes type) { + this.type = type; + return this; + } + + /** + * Get the title value. + * + * @return the title value + */ + public String title() { + return this.title; + } + + /** + * Set the title value. + * + * @param title the title value to set + * @return the CardAction object itself. + */ + public CardAction withTitle(String title) { + this.title = title; + return this; + } + + /** + * Get the image value. + * + * @return the image value + */ + public String image() { + return this.image; + } + + /** + * Set the image value. + * + * @param image the image value to set + * @return the CardAction object itself. + */ + public CardAction withImage(String image) { + this.image = image; + return this; + } + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the CardAction object itself. + */ + public CardAction withText(String text) { + this.text = text; + return this; + } + + /** + * Get the displayText value. + * + * @return the displayText value + */ + public String displayText() { + return this.displayText; + } + + /** + * Set the displayText value. + * + * @param displayText the displayText value to set + * @return the CardAction object itself. + */ + public CardAction withDisplayText(String displayText) { + this.displayText = displayText; + return this; + } + + /** + * Get the value value. + * + * @return the value value + */ + public Object value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the CardAction object itself. + */ + public CardAction withValue(Object value) { + this.value = value; + return this; + } + + /** + * Gets the channelData value. + */ + public Object channelData(){ + return this.channelData; + } + + /** + * Sets the channelData value. + * + * @param channelData The channelData object to set. + * @return the CardAction object itself. + */ + public CardAction withChannelData(Object channelData){ + this.channelData = channelData; + return this; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/CardImage.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/CardImage.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/CardImage.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/CardImage.java index 51bcfbef..9507af95 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/CardImage.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/CardImage.java @@ -1,97 +1,97 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * An image on a card. - */ -public class CardImage { - /** - * URL thumbnail image for major content property. - */ - @JsonProperty(value = "url") - private String url; - - /** - * Image description intended for screen readers. - */ - @JsonProperty(value = "alt") - private String alt; - - /** - * Action assigned to specific Attachment. - */ - @JsonProperty(value = "tap") - private CardAction tap; - - /** - * Get the url value. - * - * @return the url value - */ - public String url() { - return this.url; - } - - /** - * Set the url value. - * - * @param url the url value to set - * @return the CardImage object itself. - */ - public CardImage withUrl(String url) { - this.url = url; - return this; - } - - /** - * Get the alt value. - * - * @return the alt value - */ - public String alt() { - return this.alt; - } - - /** - * Set the alt value. - * - * @param alt the alt value to set - * @return the CardImage object itself. - */ - public CardImage withAlt(String alt) { - this.alt = alt; - return this; - } - - /** - * Get the tap value. - * - * @return the tap value - */ - public CardAction tap() { - return this.tap; - } - - /** - * Set the tap value. - * - * @param tap the tap value to set - * @return the CardImage object itself. - */ - public CardImage withTap(CardAction tap) { - this.tap = tap; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * An image on a card. + */ +public class CardImage { + /** + * URL thumbnail image for major content property. + */ + @JsonProperty(value = "url") + private String url; + + /** + * Image description intended for screen readers. + */ + @JsonProperty(value = "alt") + private String alt; + + /** + * Action assigned to specific Attachment. + */ + @JsonProperty(value = "tap") + private CardAction tap; + + /** + * Get the url value. + * + * @return the url value + */ + public String url() { + return this.url; + } + + /** + * Set the url value. + * + * @param url the url value to set + * @return the CardImage object itself. + */ + public CardImage withUrl(String url) { + this.url = url; + return this; + } + + /** + * Get the alt value. + * + * @return the alt value + */ + public String alt() { + return this.alt; + } + + /** + * Set the alt value. + * + * @param alt the alt value to set + * @return the CardImage object itself. + */ + public CardImage withAlt(String alt) { + this.alt = alt; + return this; + } + + /** + * Get the tap value. + * + * @return the tap value + */ + public CardAction tap() { + return this.tap; + } + + /** + * Set the tap value. + * + * @param tap the tap value to set + * @return the CardImage object itself. + */ + public CardImage withTap(CardAction tap) { + this.tap = tap; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ChannelAccount.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ChannelAccount.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ChannelAccount.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ChannelAccount.java index 6e01acba..e2584f47 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ChannelAccount.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ChannelAccount.java @@ -1,156 +1,156 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.JsonNode; - -import java.util.HashMap; -import java.util.Map; - -/** - * Channel account information needed to route a message. - */ -public class ChannelAccount { - /** - * Channel id for the user or bot on this channel (Example: joe@smith.com, - * or @joesmith or 123456). - */ - @JsonProperty(value = "id") - private String id; - - /** - * Display friendly name. - */ - @JsonProperty(value = "name") - private String name; - - /** - * This account's object ID within Azure Active Directory (AAD) - */ - @JsonProperty(value = "aadObjectId") - private String aadObjectId; - - /** - * Role of the entity behind the account (Example: User, Bot, etc.). - * Possible values include: 'user', 'bot'. - */ - @JsonProperty(value = "role") - private RoleTypes role; - - /** - * Get the id value. - * - * @return the id value - */ - public String id() { - return this.id; - } - - /** - * Set the id value. - * - * @param id the id value to set - * @return the ChannelAccount object itself. - */ - public ChannelAccount withId(String id) { - this.id = id; - return this; - } - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the ChannelAccount object itself. - */ - public ChannelAccount withName(String name) { - this.name = name; - return this; - } - - /** - * Get the role value. - * - * @return the role value - */ - public RoleTypes role() { - return this.role; - } - - /** - * Set the role value. - * - * @param role the role value to set - * @return the ChannelAccount object itself. - */ - public ChannelAccount withRole(RoleTypes role) { - this.role = role; - return this; - } - - - /** - * Holds the overflow properties that aren't first class - * properties in the object. This allows extensibility - * while maintaining the object. - * - */ - private HashMap properties = new HashMap(); - - /** - * Overflow properties. - * Properties that are not modelled as first class properties in the object are accessible here. - * Note: A property value can be be nested. - * - * @return A Key-Value map of the properties - */ - @JsonAnyGetter - public Map properties() { - return this.properties; - } - - /** - * Set overflow properties. - * - * @param key Key for the property - * @param value JsonNode of value (can be nested) - * - */ - - @JsonAnySetter - public void setProperties(String key, JsonNode value) { - this.properties.put(key, value); - } - - /** - * Gets aadObjectId - */ - public String aadObjectId(){ - return this.aadObjectId; - } - - /** - * Sets aadObjectId - */ - public ChannelAccount withAadObjectId(String aadObjectId){ - this.aadObjectId = aadObjectId; - return this; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.HashMap; +import java.util.Map; + +/** + * Channel account information needed to route a message. + */ +public class ChannelAccount { + /** + * Channel id for the user or bot on this channel (Example: joe@smith.com, + * or @joesmith or 123456). + */ + @JsonProperty(value = "id") + private String id; + + /** + * Display friendly name. + */ + @JsonProperty(value = "name") + private String name; + + /** + * This account's object ID within Azure Active Directory (AAD) + */ + @JsonProperty(value = "aadObjectId") + private String aadObjectId; + + /** + * Role of the entity behind the account (Example: User, Bot, etc.). + * Possible values include: 'user', 'bot'. + */ + @JsonProperty(value = "role") + private RoleTypes role; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the ChannelAccount object itself. + */ + public ChannelAccount withId(String id) { + this.id = id; + return this; + } + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the ChannelAccount object itself. + */ + public ChannelAccount withName(String name) { + this.name = name; + return this; + } + + /** + * Get the role value. + * + * @return the role value + */ + public RoleTypes role() { + return this.role; + } + + /** + * Set the role value. + * + * @param role the role value to set + * @return the ChannelAccount object itself. + */ + public ChannelAccount withRole(RoleTypes role) { + this.role = role; + return this; + } + + + /** + * Holds the overflow properties that aren't first class + * properties in the object. This allows extensibility + * while maintaining the object. + * + */ + private HashMap properties = new HashMap(); + + /** + * Overflow properties. + * Properties that are not modelled as first class properties in the object are accessible here. + * Note: A property value can be be nested. + * + * @return A Key-Value map of the properties + */ + @JsonAnyGetter + public Map properties() { + return this.properties; + } + + /** + * Set overflow properties. + * + * @param key Key for the property + * @param value JsonNode of value (can be nested) + * + */ + + @JsonAnySetter + public void setProperties(String key, JsonNode value) { + this.properties.put(key, value); + } + + /** + * Gets aadObjectId + */ + public String aadObjectId(){ + return this.aadObjectId; + } + + /** + * Sets aadObjectId + */ + public ChannelAccount withAadObjectId(String aadObjectId){ + this.aadObjectId = aadObjectId; + return this; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ContactRelationUpdateActionTypes.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ContactRelationUpdateActionTypes.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ContactRelationUpdateActionTypes.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ContactRelationUpdateActionTypes.java index c0bba688..77f48dc6 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ContactRelationUpdateActionTypes.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ContactRelationUpdateActionTypes.java @@ -1,55 +1,55 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for ContactRelationUpdateActionTypes. - */ -public enum ContactRelationUpdateActionTypes { - /** Enum value add. */ - ADD("add"), - - /** Enum value remove. */ - REMOVE("remove"); - - /** The actual serialized value for a ContactRelationUpdateActionTypes instance. */ - private String value; - - ContactRelationUpdateActionTypes(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a ContactRelationUpdateActionTypes instance. - * - * @param value the serialized value to parse. - * @return the parsed ContactRelationUpdateActionTypes object, or null if unable to parse. - */ - @JsonCreator - public static ContactRelationUpdateActionTypes fromString(String value) { - ContactRelationUpdateActionTypes[] items = ContactRelationUpdateActionTypes.values(); - for (ContactRelationUpdateActionTypes item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for ContactRelationUpdateActionTypes. + */ +public enum ContactRelationUpdateActionTypes { + /** Enum value add. */ + ADD("add"), + + /** Enum value remove. */ + REMOVE("remove"); + + /** The actual serialized value for a ContactRelationUpdateActionTypes instance. */ + private String value; + + ContactRelationUpdateActionTypes(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ContactRelationUpdateActionTypes instance. + * + * @param value the serialized value to parse. + * @return the parsed ContactRelationUpdateActionTypes object, or null if unable to parse. + */ + @JsonCreator + public static ContactRelationUpdateActionTypes fromString(String value) { + ContactRelationUpdateActionTypes[] items = ContactRelationUpdateActionTypes.values(); + for (ContactRelationUpdateActionTypes item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationAccount.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationAccount.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationAccount.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationAccount.java index ea761457..83b17e9c 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationAccount.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationAccount.java @@ -1,231 +1,231 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Conversation account represents the identity of the conversation within a channel. - */ -public class ConversationAccount { - /** - * Indicates whether the conversation contains more than two participants - * at the time the activity was generated. - */ - @JsonProperty(value = "isGroup") - private Boolean isGroup; - - /** - * Indicates the type of the conversation in channels that distinguish - * between conversation types. - */ - @JsonProperty(value = "conversationType") - private String conversationType; - - /** - * This conversation's tenant ID. - */ - @JsonProperty(value = "tenantId") - private String tenantId; - - /** - * Channel id for the user or bot on this channel (Example: joe@smith.com, - * or @joesmith or 123456). - */ - @JsonProperty(value = "id") - private String id; - - /** - * Display friendly name. - */ - @JsonProperty(value = "name") - private String name; - - /** - * This account's object ID within Azure Active Directory (AAD). - */ - @JsonProperty(value = "aadObjectId") - private String aadObjectId; - - /** - * Role of the entity behind the account (Example: User, Bot, etc.). - * Possible values include: 'user', 'bot'. - */ - @JsonProperty(value = "role") - private RoleTypes role; - - /** - * Get the isGroup value. - * - * @return the isGroup value - */ - public Boolean isGroup() { - return this.isGroup; - } - - /** - * Set the isGroup value. - * - * @param isGroup the isGroup value to set - * @return the ConversationAccount object itself. - */ - public ConversationAccount withIsGroup(Boolean isGroup) { - this.isGroup = isGroup; - return this; - } - - /** - * Get the conversationType value. - * - * @return the conversationType value - */ - public String conversationType() { - return this.conversationType; - } - - /** - * Set the conversationType value. - * - * @param conversationType the conversationType value to set - * @return the ConversationAccount object itself. - */ - public ConversationAccount withConversationType(String conversationType) { - this.conversationType = conversationType; - return this; - } - - /** - * Gets this conversation's tenant ID. - */ - public String tenantId(){ - return this.tenantId; - } - - /** - * Sets this conversation's tenant ID. - * - * @param tenantId this conversation's tenant ID - * @return the ConversationAccount object itself. - */ - public ConversationAccount withTenantId(String tenantId){ - this.tenantId = tenantId; - return this; - } - - /** - * Get the id value. - * - * @return the id value - */ - public String id() { - return this.id; - } - - /** - * Set the id value. - * - * @param id the id value to set - * @return the ConversationAccount object itself. - */ - public ConversationAccount withId(String id) { - this.id = id; - return this; - } - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the ConversationAccount object itself. - */ - public ConversationAccount withName(String name) { - this.name = name; - return this; - } - - /** - * Gets this account's object ID within Azure Active Directory (AAD). - */ - public String aadObjectId(){ - return this.aadObjectId; - } - - /** - * Sets this account's object ID within Azure Active Directory (AAD). - - * @param name the AAD ID to set - * @return the ConversationAccount object itself. - */ - public ConversationAccount withAadObjectId(String aadObjectId){ - this.aadObjectId = aadObjectId; - return this; - } - - /** - * Get the role value. - * - * @return the role value - */ - public RoleTypes role() { - return this.role; - } - - /** - * Set the role value. - * - * @param role the role value to set - * @return the ConversationAccount object itself. - */ - public ConversationAccount withRole(RoleTypes role) { - this.role = role; - return this; - } - /** - * Holds the overflow properties that aren't first class - * properties in the object. This allows extensibility - * while maintaining the object. - * - */ -// private HashMap properties = new HashMap(); - - /** - * Overflow properties. - * Properties that are not modelled as first class properties in the object are accessible here. - * Note: A property value can be be nested. - * - * @return A Key-Value map of the properties - */ -// @JsonAnyGetter -// public Map properties() { -// return this.properties; -// } - - /** - * Set overflow properties. - * - * @param key Key for the property - * @param value JsonNode of value (can be nested) - * - */ - -// @JsonAnySetter -// public void setProperties(String key, JsonNode value) { -// this.properties.put(key, value); -// } - - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Conversation account represents the identity of the conversation within a channel. + */ +public class ConversationAccount { + /** + * Indicates whether the conversation contains more than two participants + * at the time the activity was generated. + */ + @JsonProperty(value = "isGroup") + private Boolean isGroup; + + /** + * Indicates the type of the conversation in channels that distinguish + * between conversation types. + */ + @JsonProperty(value = "conversationType") + private String conversationType; + + /** + * This conversation's tenant ID. + */ + @JsonProperty(value = "tenantId") + private String tenantId; + + /** + * Channel id for the user or bot on this channel (Example: joe@smith.com, + * or @joesmith or 123456). + */ + @JsonProperty(value = "id") + private String id; + + /** + * Display friendly name. + */ + @JsonProperty(value = "name") + private String name; + + /** + * This account's object ID within Azure Active Directory (AAD). + */ + @JsonProperty(value = "aadObjectId") + private String aadObjectId; + + /** + * Role of the entity behind the account (Example: User, Bot, etc.). + * Possible values include: 'user', 'bot'. + */ + @JsonProperty(value = "role") + private RoleTypes role; + + /** + * Get the isGroup value. + * + * @return the isGroup value + */ + public Boolean isGroup() { + return this.isGroup; + } + + /** + * Set the isGroup value. + * + * @param isGroup the isGroup value to set + * @return the ConversationAccount object itself. + */ + public ConversationAccount withIsGroup(Boolean isGroup) { + this.isGroup = isGroup; + return this; + } + + /** + * Get the conversationType value. + * + * @return the conversationType value + */ + public String conversationType() { + return this.conversationType; + } + + /** + * Set the conversationType value. + * + * @param conversationType the conversationType value to set + * @return the ConversationAccount object itself. + */ + public ConversationAccount withConversationType(String conversationType) { + this.conversationType = conversationType; + return this; + } + + /** + * Gets this conversation's tenant ID. + */ + public String tenantId(){ + return this.tenantId; + } + + /** + * Sets this conversation's tenant ID. + * + * @param tenantId this conversation's tenant ID + * @return the ConversationAccount object itself. + */ + public ConversationAccount withTenantId(String tenantId){ + this.tenantId = tenantId; + return this; + } + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the ConversationAccount object itself. + */ + public ConversationAccount withId(String id) { + this.id = id; + return this; + } + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the ConversationAccount object itself. + */ + public ConversationAccount withName(String name) { + this.name = name; + return this; + } + + /** + * Gets this account's object ID within Azure Active Directory (AAD). + */ + public String aadObjectId(){ + return this.aadObjectId; + } + + /** + * Sets this account's object ID within Azure Active Directory (AAD). + + * @param name the AAD ID to set + * @return the ConversationAccount object itself. + */ + public ConversationAccount withAadObjectId(String aadObjectId){ + this.aadObjectId = aadObjectId; + return this; + } + + /** + * Get the role value. + * + * @return the role value + */ + public RoleTypes role() { + return this.role; + } + + /** + * Set the role value. + * + * @param role the role value to set + * @return the ConversationAccount object itself. + */ + public ConversationAccount withRole(RoleTypes role) { + this.role = role; + return this; + } + /** + * Holds the overflow properties that aren't first class + * properties in the object. This allows extensibility + * while maintaining the object. + * + */ +// private HashMap properties = new HashMap(); + + /** + * Overflow properties. + * Properties that are not modelled as first class properties in the object are accessible here. + * Note: A property value can be be nested. + * + * @return A Key-Value map of the properties + */ +// @JsonAnyGetter +// public Map properties() { +// return this.properties; +// } + + /** + * Set overflow properties. + * + * @param key Key for the property + * @param value JsonNode of value (can be nested) + * + */ + +// @JsonAnySetter +// public void setProperties(String key, JsonNode value) { +// this.properties.put(key, value); +// } + + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationMembers.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationMembers.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationMembers.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationMembers.java index 2d611712..a6b2d21d 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationMembers.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationMembers.java @@ -1,72 +1,72 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Conversation and its members. - */ -public class ConversationMembers { - /** - * Conversation ID. - */ - @JsonProperty(value = "id") - private String id; - - /** - * List of members in this conversation. - */ - @JsonProperty(value = "members") - private List members; - - /** - * Get the id value. - * - * @return the id value - */ - public String id() { - return this.id; - } - - /** - * Set the id value. - * - * @param id the id value to set - * @return the ConversationMembers object itself. - */ - public ConversationMembers withId(String id) { - this.id = id; - return this; - } - - /** - * Get the members value. - * - * @return the members value - */ - public List members() { - return this.members; - } - - /** - * Set the members value. - * - * @param members the members value to set - * @return the ConversationMembers object itself. - */ - public ConversationMembers withMembers(List members) { - this.members = members; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Conversation and its members. + */ +public class ConversationMembers { + /** + * Conversation ID. + */ + @JsonProperty(value = "id") + private String id; + + /** + * List of members in this conversation. + */ + @JsonProperty(value = "members") + private List members; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the ConversationMembers object itself. + */ + public ConversationMembers withId(String id) { + this.id = id; + return this; + } + + /** + * Get the members value. + * + * @return the members value + */ + public List members() { + return this.members; + } + + /** + * Set the members value. + * + * @param members the members value to set + * @return the ConversationMembers object itself. + */ + public ConversationMembers withMembers(List members) { + this.members = members; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationParameters.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationParameters.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationParameters.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationParameters.java index dc7a39b7..9cd54446 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationParameters.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationParameters.java @@ -1,197 +1,197 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Parameters for creating a new conversation. - */ -public class ConversationParameters { - /** - * IsGroup. - */ - @JsonProperty(value = "isGroup") - private Boolean isGroup; - - /** - * The bot address for this conversation. - */ - @JsonProperty(value = "bot") - private ChannelAccount bot; - - /** - * Members to add to the conversation. - */ - @JsonProperty(value = "members") - private List members; - - /** - * (Optional) Topic of the conversation (if supported by the channel). - */ - @JsonProperty(value = "topicName") - private String topicName; - - /** - * (Optional) The tenant ID in which the conversation should be created. - */ - @JsonProperty(value = "tenantId") - private String tenantId; - - /** - * (Optional) When creating a new conversation, use this activity as the - * intial message to the conversation. - */ - @JsonProperty(value = "activity") - private Activity activity; - - /** - * Channel specific payload for creating the conversation. - */ - @JsonProperty(value = "channelData") - private Object channelData; - - /** - * Get the isGroup value. - * - * @return the isGroup value - */ - public Boolean isGroup() { - return this.isGroup; - } - - /** - * Set the isGroup value. - * - * @param isGroup the isGroup value to set - * @return the ConversationParameters object itself. - */ - public ConversationParameters withIsGroup(Boolean isGroup) { - this.isGroup = isGroup; - return this; - } - - /** - * Get the bot value. - * - * @return the bot value - */ - public ChannelAccount bot() { - return this.bot; - } - - /** - * Set the bot value. - * - * @param bot the bot value to set - * @return the ConversationParameters object itself. - */ - public ConversationParameters withBot(ChannelAccount bot) { - this.bot = bot; - return this; - } - - /** - * Get the members value. - * - * @return the members value - */ - public List members() { - return this.members; - } - - /** - * Set the members value. - * - * @param members the members value to set - * @return the ConversationParameters object itself. - */ - public ConversationParameters withMembers(List members) { - this.members = members; - return this; - } - - /** - * Get the topicName value. - * - * @return the topicName value - */ - public String topicName() { - return this.topicName; - } - - /** - * Set the topicName value. - * - * @param topicName the topicName value to set - * @return the ConversationParameters object itself. - */ - public ConversationParameters withTopicName(String topicName) { - this.topicName = topicName; - return this; - } - - /** - * Get the activity value. - * - * @return the activity value - */ - public Activity activity() { - return this.activity; - } - - /** - * Set the activity value. - * - * @param activity the activity value to set - * @return the ConversationParameters object itself. - */ - public ConversationParameters withActivity(Activity activity) { - this.activity = activity; - return this; - } - - /** - * Get the channelData value. - * - * @return the channelData value - */ - public Object channelData() { - return this.channelData; - } - - /** - * Set the channelData value. - * - * @param channelData the channelData value to set - * @return the ConversationParameters object itself. - */ - public ConversationParameters withChannelData(Object channelData) { - this.channelData = channelData; - return this; - } - - /** - * Gets tenantId - */ - public String tenantId(){ - return this.tenantId; - } - - /** - * Sets tenantId - */ - public ConversationParameters withTenantId(String tenantId){ - this.tenantId = tenantId; - return this; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Parameters for creating a new conversation. + */ +public class ConversationParameters { + /** + * IsGroup. + */ + @JsonProperty(value = "isGroup") + private Boolean isGroup; + + /** + * The bot address for this conversation. + */ + @JsonProperty(value = "bot") + private ChannelAccount bot; + + /** + * Members to add to the conversation. + */ + @JsonProperty(value = "members") + private List members; + + /** + * (Optional) Topic of the conversation (if supported by the channel). + */ + @JsonProperty(value = "topicName") + private String topicName; + + /** + * (Optional) The tenant ID in which the conversation should be created. + */ + @JsonProperty(value = "tenantId") + private String tenantId; + + /** + * (Optional) When creating a new conversation, use this activity as the + * intial message to the conversation. + */ + @JsonProperty(value = "activity") + private Activity activity; + + /** + * Channel specific payload for creating the conversation. + */ + @JsonProperty(value = "channelData") + private Object channelData; + + /** + * Get the isGroup value. + * + * @return the isGroup value + */ + public Boolean isGroup() { + return this.isGroup; + } + + /** + * Set the isGroup value. + * + * @param isGroup the isGroup value to set + * @return the ConversationParameters object itself. + */ + public ConversationParameters withIsGroup(Boolean isGroup) { + this.isGroup = isGroup; + return this; + } + + /** + * Get the bot value. + * + * @return the bot value + */ + public ChannelAccount bot() { + return this.bot; + } + + /** + * Set the bot value. + * + * @param bot the bot value to set + * @return the ConversationParameters object itself. + */ + public ConversationParameters withBot(ChannelAccount bot) { + this.bot = bot; + return this; + } + + /** + * Get the members value. + * + * @return the members value + */ + public List members() { + return this.members; + } + + /** + * Set the members value. + * + * @param members the members value to set + * @return the ConversationParameters object itself. + */ + public ConversationParameters withMembers(List members) { + this.members = members; + return this; + } + + /** + * Get the topicName value. + * + * @return the topicName value + */ + public String topicName() { + return this.topicName; + } + + /** + * Set the topicName value. + * + * @param topicName the topicName value to set + * @return the ConversationParameters object itself. + */ + public ConversationParameters withTopicName(String topicName) { + this.topicName = topicName; + return this; + } + + /** + * Get the activity value. + * + * @return the activity value + */ + public Activity activity() { + return this.activity; + } + + /** + * Set the activity value. + * + * @param activity the activity value to set + * @return the ConversationParameters object itself. + */ + public ConversationParameters withActivity(Activity activity) { + this.activity = activity; + return this; + } + + /** + * Get the channelData value. + * + * @return the channelData value + */ + public Object channelData() { + return this.channelData; + } + + /** + * Set the channelData value. + * + * @param channelData the channelData value to set + * @return the ConversationParameters object itself. + */ + public ConversationParameters withChannelData(Object channelData) { + this.channelData = channelData; + return this; + } + + /** + * Gets tenantId + */ + public String tenantId(){ + return this.tenantId; + } + + /** + * Sets tenantId + */ + public ConversationParameters withTenantId(String tenantId){ + this.tenantId = tenantId; + return this; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationReference.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationReference.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationReference.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationReference.java index e28835c0..da4b56dc 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationReference.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationReference.java @@ -1,176 +1,176 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * An object relating to a particular point in a conversation. - */ -public class ConversationReference { - /** - * (Optional) ID of the activity to refer to. - */ - @JsonProperty(value = "activityId") - private String activityId; - - /** - * (Optional) User participating in this conversation. - */ - @JsonProperty(value = "user") - private ChannelAccount user; - - /** - * Bot participating in this conversation. - */ - @JsonProperty(value = "bot") - private ChannelAccount bot; - - /** - * Conversation reference. - */ - @JsonProperty(value = "conversation") - private ConversationAccount conversation; - - /** - * Channel ID. - */ - @JsonProperty(value = "channelId") - private String channelId; - - /** - * Service endpoint where operations concerning the referenced conversation - * may be performed. - */ - @JsonProperty(value = "serviceUrl") - private String serviceUrl; - - /** - * Get the activityId value. - * - * @return the activityId value - */ - public String activityId() { - return this.activityId; - } - - /** - * Set the activityId value. - * - * @param activityId the activityId value to set - * @return the ConversationReference object itself. - */ - public ConversationReference withActivityId(String activityId) { - this.activityId = activityId; - return this; - } - - /** - * Get the user value. - * - * @return the user value - */ - public ChannelAccount user() { - return this.user; - } - - /** - * Set the user value. - * - * @param user the user value to set - * @return the ConversationReference object itself. - */ - public ConversationReference withUser(ChannelAccount user) { - this.user = user; - return this; - } - - /** - * Get the bot value. - * - * @return the bot value - */ - public ChannelAccount bot() { - return this.bot; - } - - /** - * Set the bot value. - * - * @param bot the bot value to set - * @return the ConversationReference object itself. - */ - public ConversationReference withBot(ChannelAccount bot) { - this.bot = bot; - return this; - } - - /** - * Get the conversation value. - * - * @return the conversation value - */ - public ConversationAccount conversation() { - return this.conversation; - } - - /** - * Set the conversation value. - * - * @param conversation the conversation value to set - * @return the ConversationReference object itself. - */ - public ConversationReference withConversation(ConversationAccount conversation) { - this.conversation = conversation; - return this; - } - - /** - * Get the channelId value. - * - * @return the channelId value - */ - public String channelId() { - return this.channelId; - } - - /** - * Set the channelId value. - * - * @param channelId the channelId value to set - * @return the ConversationReference object itself. - */ - public ConversationReference withChannelId(String channelId) { - this.channelId = channelId; - return this; - } - - /** - * Get the serviceUrl value. - * - * @return the serviceUrl value - */ - public String serviceUrl() { - return this.serviceUrl; - } - - /** - * Set the serviceUrl value. - * - * @param serviceUrl the serviceUrl value to set - * @return the ConversationReference object itself. - */ - public ConversationReference withServiceUrl(String serviceUrl) { - this.serviceUrl = serviceUrl; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * An object relating to a particular point in a conversation. + */ +public class ConversationReference { + /** + * (Optional) ID of the activity to refer to. + */ + @JsonProperty(value = "activityId") + private String activityId; + + /** + * (Optional) User participating in this conversation. + */ + @JsonProperty(value = "user") + private ChannelAccount user; + + /** + * Bot participating in this conversation. + */ + @JsonProperty(value = "bot") + private ChannelAccount bot; + + /** + * Conversation reference. + */ + @JsonProperty(value = "conversation") + private ConversationAccount conversation; + + /** + * Channel ID. + */ + @JsonProperty(value = "channelId") + private String channelId; + + /** + * Service endpoint where operations concerning the referenced conversation + * may be performed. + */ + @JsonProperty(value = "serviceUrl") + private String serviceUrl; + + /** + * Get the activityId value. + * + * @return the activityId value + */ + public String activityId() { + return this.activityId; + } + + /** + * Set the activityId value. + * + * @param activityId the activityId value to set + * @return the ConversationReference object itself. + */ + public ConversationReference withActivityId(String activityId) { + this.activityId = activityId; + return this; + } + + /** + * Get the user value. + * + * @return the user value + */ + public ChannelAccount user() { + return this.user; + } + + /** + * Set the user value. + * + * @param user the user value to set + * @return the ConversationReference object itself. + */ + public ConversationReference withUser(ChannelAccount user) { + this.user = user; + return this; + } + + /** + * Get the bot value. + * + * @return the bot value + */ + public ChannelAccount bot() { + return this.bot; + } + + /** + * Set the bot value. + * + * @param bot the bot value to set + * @return the ConversationReference object itself. + */ + public ConversationReference withBot(ChannelAccount bot) { + this.bot = bot; + return this; + } + + /** + * Get the conversation value. + * + * @return the conversation value + */ + public ConversationAccount conversation() { + return this.conversation; + } + + /** + * Set the conversation value. + * + * @param conversation the conversation value to set + * @return the ConversationReference object itself. + */ + public ConversationReference withConversation(ConversationAccount conversation) { + this.conversation = conversation; + return this; + } + + /** + * Get the channelId value. + * + * @return the channelId value + */ + public String channelId() { + return this.channelId; + } + + /** + * Set the channelId value. + * + * @param channelId the channelId value to set + * @return the ConversationReference object itself. + */ + public ConversationReference withChannelId(String channelId) { + this.channelId = channelId; + return this; + } + + /** + * Get the serviceUrl value. + * + * @return the serviceUrl value + */ + public String serviceUrl() { + return this.serviceUrl; + } + + /** + * Set the serviceUrl value. + * + * @param serviceUrl the serviceUrl value to set + * @return the ConversationReference object itself. + */ + public ConversationReference withServiceUrl(String serviceUrl) { + this.serviceUrl = serviceUrl; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationReferenceHelper.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationReferenceHelper.java similarity index 97% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationReferenceHelper.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationReferenceHelper.java index 34c62ff8..8a8b83a6 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationReferenceHelper.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationReferenceHelper.java @@ -1,50 +1,50 @@ -package com.microsoft.bot.schema.models; - -import com.microsoft.bot.schema.ActivityImpl; - -import java.util.UUID; - -public class ConversationReferenceHelper { - private ConversationReference reference; - public ConversationReferenceHelper(ConversationReference reference) { - this.reference = reference; - } - /** - * Creates {@link Activity} from conversation reference as it is posted to bot. - */ - public ActivityImpl GetPostToBotMessage() - { - return (ActivityImpl) new ActivityImpl() - .withType(ActivityTypes.MESSAGE) - .withId(UUID.randomUUID().toString()) - .withRecipient(new ChannelAccount() - .withId(reference.bot().id()) - .withName(reference.bot().name())) - .withChannelId(reference.channelId()) - .withServiceUrl(reference.serviceUrl()) - .withConversation(new ConversationAccount() - .withId(reference.conversation().id()) - .withIsGroup(reference.conversation().isGroup()) - .withName(reference.conversation().name())) - .withFrom(new ChannelAccount() - .withId(reference.user().id()) - .withName(reference.user().name())); - } - - /** - * Creates {@link Activity} from conversation reference that can be posted to user as reply. - */ - public ActivityImpl GetPostToUserMessage() - { - Activity msg = this.GetPostToBotMessage(); - - // swap from and recipient - ChannelAccount bot = msg.recipient(); - ChannelAccount user = msg.from(); - msg.withFrom(bot); - msg.withRecipient(user); - return (ActivityImpl) msg; - } -} - - +package com.microsoft.bot.schema.models; + +import com.microsoft.bot.schema.ActivityImpl; + +import java.util.UUID; + +public class ConversationReferenceHelper { + private ConversationReference reference; + public ConversationReferenceHelper(ConversationReference reference) { + this.reference = reference; + } + /** + * Creates {@link Activity} from conversation reference as it is posted to bot. + */ + public ActivityImpl GetPostToBotMessage() + { + return (ActivityImpl) new ActivityImpl() + .withType(ActivityTypes.MESSAGE) + .withId(UUID.randomUUID().toString()) + .withRecipient(new ChannelAccount() + .withId(reference.bot().id()) + .withName(reference.bot().name())) + .withChannelId(reference.channelId()) + .withServiceUrl(reference.serviceUrl()) + .withConversation(new ConversationAccount() + .withId(reference.conversation().id()) + .withIsGroup(reference.conversation().isGroup()) + .withName(reference.conversation().name())) + .withFrom(new ChannelAccount() + .withId(reference.user().id()) + .withName(reference.user().name())); + } + + /** + * Creates {@link Activity} from conversation reference that can be posted to user as reply. + */ + public ActivityImpl GetPostToUserMessage() + { + Activity msg = this.GetPostToBotMessage(); + + // swap from and recipient + ChannelAccount bot = msg.recipient(); + ChannelAccount user = msg.from(); + msg.withFrom(bot); + msg.withRecipient(user); + return (ActivityImpl) msg; + } +} + + diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationResourceResponse.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationResourceResponse.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationResourceResponse.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationResourceResponse.java index 7e2a7508..9d6cf8b1 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationResourceResponse.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationResourceResponse.java @@ -1,98 +1,98 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A response containing a resource. - */ -public class ConversationResourceResponse { - /** - * ID of the Activity (if sent). - */ - @JsonProperty(value = "activityId") - private String activityId; - - /** - * Service endpoint where operations concerning the conversation may be - * performed. - */ - @JsonProperty(value = "serviceUrl") - private String serviceUrl; - - /** - * Id of the resource. - */ - @JsonProperty(value = "id") - private String id; - - /** - * Get the activityId value. - * - * @return the activityId value - */ - public String activityId() { - return this.activityId; - } - - /** - * Set the activityId value. - * - * @param activityId the activityId value to set - * @return the ConversationResourceResponse object itself. - */ - public ConversationResourceResponse withActivityId(String activityId) { - this.activityId = activityId; - return this; - } - - /** - * Get the serviceUrl value. - * - * @return the serviceUrl value - */ - public String serviceUrl() { - return this.serviceUrl; - } - - /** - * Set the serviceUrl value. - * - * @param serviceUrl the serviceUrl value to set - * @return the ConversationResourceResponse object itself. - */ - public ConversationResourceResponse withServiceUrl(String serviceUrl) { - this.serviceUrl = serviceUrl; - return this; - } - - /** - * Get the id value. - * - * @return the id value - */ - public String id() { - return this.id; - } - - /** - * Set the id value. - * - * @param id the id value to set - * @return the ConversationResourceResponse object itself. - */ - public ConversationResourceResponse withId(String id) { - this.id = id; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A response containing a resource. + */ +public class ConversationResourceResponse { + /** + * ID of the Activity (if sent). + */ + @JsonProperty(value = "activityId") + private String activityId; + + /** + * Service endpoint where operations concerning the conversation may be + * performed. + */ + @JsonProperty(value = "serviceUrl") + private String serviceUrl; + + /** + * Id of the resource. + */ + @JsonProperty(value = "id") + private String id; + + /** + * Get the activityId value. + * + * @return the activityId value + */ + public String activityId() { + return this.activityId; + } + + /** + * Set the activityId value. + * + * @param activityId the activityId value to set + * @return the ConversationResourceResponse object itself. + */ + public ConversationResourceResponse withActivityId(String activityId) { + this.activityId = activityId; + return this; + } + + /** + * Get the serviceUrl value. + * + * @return the serviceUrl value + */ + public String serviceUrl() { + return this.serviceUrl; + } + + /** + * Set the serviceUrl value. + * + * @param serviceUrl the serviceUrl value to set + * @return the ConversationResourceResponse object itself. + */ + public ConversationResourceResponse withServiceUrl(String serviceUrl) { + this.serviceUrl = serviceUrl; + return this; + } + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the ConversationResourceResponse object itself. + */ + public ConversationResourceResponse withId(String id) { + this.id = id; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationUpdateActivity.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationUpdateActivity.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationUpdateActivity.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationUpdateActivity.java index 09847729..9c8578a5 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationUpdateActivity.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationUpdateActivity.java @@ -1,64 +1,64 @@ -package com.microsoft.bot.schema.models; - -// Note: In C# implementation, main Activity interface does not contain complete wire format. - -import java.util.List; - -public class ConversationUpdateActivity extends MessageActivity { - /** - * Members added to the conversation - */ - private List membersAdded; - - @Override - public List membersAdded() { - return this.membersAdded; - } - @Override - public ConversationUpdateActivity withMembersAdded(List membersAdded) { - this.membersAdded = membersAdded; - return this; - } - - /** - * Members removed from the conversation - */ - private List membersRemoved; - public List membersRemoved() { - return this.membersRemoved; - } - @Override - public ConversationUpdateActivity withMembersRemoved(List membersRemoved) { - - this.membersRemoved = membersRemoved; - return this; - } - - /** - * The conversation's updated topic name - */ - private String topicName; - @Override - public String topicName() { - return this.topicName; - } - @Override - public ConversationUpdateActivity withTopicName(String topicname) { - this.topicName = topicname; - return this; - } - - - /** - * 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; - } - public ConversationUpdateActivity withHistoryDisclosed(Boolean historydisclosed) { - this.historyDisclosed = historydisclosed; - return this; - } -} +package com.microsoft.bot.schema.models; + +// Note: In C# implementation, main Activity interface does not contain complete wire format. + +import java.util.List; + +public class ConversationUpdateActivity extends MessageActivity { + /** + * Members added to the conversation + */ + private List membersAdded; + + @Override + public List membersAdded() { + return this.membersAdded; + } + @Override + public ConversationUpdateActivity withMembersAdded(List membersAdded) { + this.membersAdded = membersAdded; + return this; + } + + /** + * Members removed from the conversation + */ + private List membersRemoved; + public List membersRemoved() { + return this.membersRemoved; + } + @Override + public ConversationUpdateActivity withMembersRemoved(List membersRemoved) { + + this.membersRemoved = membersRemoved; + return this; + } + + /** + * The conversation's updated topic name + */ + private String topicName; + @Override + public String topicName() { + return this.topicName; + } + @Override + public ConversationUpdateActivity withTopicName(String topicname) { + this.topicName = topicname; + return this; + } + + + /** + * 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; + } + public ConversationUpdateActivity withHistoryDisclosed(Boolean historydisclosed) { + this.historyDisclosed = historydisclosed; + return this; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationsResult.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationsResult.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationsResult.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationsResult.java index 38cfee4b..35e4151d 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ConversationsResult.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ConversationsResult.java @@ -1,72 +1,72 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Conversations result. - */ -public class ConversationsResult { - /** - * Paging token. - */ - @JsonProperty(value = "continuationToken") - private String continuationToken; - - /** - * List of conversations. - */ - @JsonProperty(value = "conversations") - private List conversations; - - /** - * Get the continuationToken value. - * - * @return the continuationToken value - */ - public String continuationToken() { - return this.continuationToken; - } - - /** - * Set the continuationToken value. - * - * @param continuationToken the continuationToken value to set - * @return the ConversationsResult object itself. - */ - public ConversationsResult withContinuationToken(String continuationToken) { - this.continuationToken = continuationToken; - return this; - } - - /** - * Get the conversations value. - * - * @return the conversations value - */ - public List conversations() { - return this.conversations; - } - - /** - * Set the conversations value. - * - * @param conversations the conversations value to set - * @return the ConversationsResult object itself. - */ - public ConversationsResult withConversations(List conversations) { - this.conversations = conversations; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Conversations result. + */ +public class ConversationsResult { + /** + * Paging token. + */ + @JsonProperty(value = "continuationToken") + private String continuationToken; + + /** + * List of conversations. + */ + @JsonProperty(value = "conversations") + private List conversations; + + /** + * Get the continuationToken value. + * + * @return the continuationToken value + */ + public String continuationToken() { + return this.continuationToken; + } + + /** + * Set the continuationToken value. + * + * @param continuationToken the continuationToken value to set + * @return the ConversationsResult object itself. + */ + public ConversationsResult withContinuationToken(String continuationToken) { + this.continuationToken = continuationToken; + return this; + } + + /** + * Get the conversations value. + * + * @return the conversations value + */ + public List conversations() { + return this.conversations; + } + + /** + * Set the conversations value. + * + * @param conversations the conversations value to set + * @return the ConversationsResult object itself. + */ + public ConversationsResult withConversations(List conversations) { + this.conversations = conversations; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/DeliveryModes.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/DeliveryModes.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/DeliveryModes.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/DeliveryModes.java index 251b6387..c0a7ca28 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/DeliveryModes.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/DeliveryModes.java @@ -1,56 +1,56 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Values for deliveryMode field. - */ -public enum DeliveryModes { - /** Enum value normal. */ - NORMAL("normal"), - - /** Enum value notification. */ - NOTIFICATION("notification"); - - - /** The actual serialized value for a DeliveryModes instance. */ - private String value; - - DeliveryModes(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a ActivityTypes instance. - * - * @param value the serialized value to parse. - * @return the parsed ActivityTypes object, or null if unable to parse. - */ - @JsonCreator - public static DeliveryModes fromString(String value) { - DeliveryModes[] items = DeliveryModes.values(); - for (DeliveryModes item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Values for deliveryMode field. + */ +public enum DeliveryModes { + /** Enum value normal. */ + NORMAL("normal"), + + /** Enum value notification. */ + NOTIFICATION("notification"); + + + /** The actual serialized value for a DeliveryModes instance. */ + private String value; + + DeliveryModes(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ActivityTypes instance. + * + * @param value the serialized value to parse. + * @return the parsed ActivityTypes object, or null if unable to parse. + */ + @JsonCreator + public static DeliveryModes fromString(String value) { + DeliveryModes[] items = DeliveryModes.values(); + for (DeliveryModes item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/EndOfConversationCodes.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/EndOfConversationCodes.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/EndOfConversationCodes.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/EndOfConversationCodes.java index bd14b096..43b9fbf4 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/EndOfConversationCodes.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/EndOfConversationCodes.java @@ -1,67 +1,67 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for EndOfConversationCodes. - */ -public enum EndOfConversationCodes { - /** Enum value unknown. */ - UNKNOWN("unknown"), - - /** Enum value completedSuccessfully. */ - COMPLETED_SUCCESSFULLY("completedSuccessfully"), - - /** Enum value userCancelled. */ - USER_CANCELLED("userCancelled"), - - /** Enum value botTimedOut. */ - BOT_TIMED_OUT("botTimedOut"), - - /** Enum value botIssuedInvalidMessage. */ - BOT_ISSUED_INVALID_MESSAGE("botIssuedInvalidMessage"), - - /** Enum value channelFailed. */ - CHANNEL_FAILED("channelFailed"); - - /** The actual serialized value for a EndOfConversationCodes instance. */ - private String value; - - EndOfConversationCodes(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a EndOfConversationCodes instance. - * - * @param value the serialized value to parse. - * @return the parsed EndOfConversationCodes object, or null if unable to parse. - */ - @JsonCreator - public static EndOfConversationCodes fromString(String value) { - EndOfConversationCodes[] items = EndOfConversationCodes.values(); - for (EndOfConversationCodes item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for EndOfConversationCodes. + */ +public enum EndOfConversationCodes { + /** Enum value unknown. */ + UNKNOWN("unknown"), + + /** Enum value completedSuccessfully. */ + COMPLETED_SUCCESSFULLY("completedSuccessfully"), + + /** Enum value userCancelled. */ + USER_CANCELLED("userCancelled"), + + /** Enum value botTimedOut. */ + BOT_TIMED_OUT("botTimedOut"), + + /** Enum value botIssuedInvalidMessage. */ + BOT_ISSUED_INVALID_MESSAGE("botIssuedInvalidMessage"), + + /** Enum value channelFailed. */ + CHANNEL_FAILED("channelFailed"); + + /** The actual serialized value for a EndOfConversationCodes instance. */ + private String value; + + EndOfConversationCodes(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a EndOfConversationCodes instance. + * + * @param value the serialized value to parse. + * @return the parsed EndOfConversationCodes object, or null if unable to parse. + */ + @JsonCreator + public static EndOfConversationCodes fromString(String value) { + EndOfConversationCodes[] items = EndOfConversationCodes.values(); + for (EndOfConversationCodes item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Entity.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Entity.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Entity.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Entity.java index 4d202a7a..e24c0802 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Entity.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Entity.java @@ -1,45 +1,45 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Metadata object pertaining to an activity - */ -public class Entity { - /** - * Type of this entity (RFC 3987 IRI). - */ - @JsonProperty(value = "type") - private String type; - - /** - * Get the type value. - * - * @return the type value - */ - public String type() { - return this.type; - } - - /** - * Set the type value. - * - * @param type the type value to set - * @return the Entity object itself. - */ - public Entity withType(String type) { - this.type = type; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Metadata object pertaining to an activity + */ +public class Entity { + /** + * Type of this entity (RFC 3987 IRI). + */ + @JsonProperty(value = "type") + private String type; + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the Entity object itself. + */ + public Entity withType(String type) { + this.type = type; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Error.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Error.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Error.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Error.java index f8c56716..a5ece49f 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Error.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Error.java @@ -1,91 +1,91 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Object representing error information. - */ -public class Error { - /** - * Error code. - */ - @JsonProperty(value = "code") - private String code; - - /** - * Error message. - */ - @JsonProperty(value = "message") - private String message; - - /** - * Error from inner http call - */ - @JsonProperty(value = "innerHttpError") - private InnerHttpError innerHttpError; - - /** - * Get the code value. - * - * @return the code value - */ - public String code() { - return this.code; - } - - /** - * Set the code value. - * - * @param code the code value to set - * @return the Error object itself. - */ - public Error withCode(String code) { - this.code = code; - return this; - } - - /** - * Get the message value. - * - * @return the message value - */ - public String message() { - return this.message; - } - - /** - * Set the message value. - * - * @param message the message value to set - * @return the Error object itself. - */ - public Error withMessage(String message) { - this.message = message; - return this; - } - - /** - * Gets error from inner http call. - */ - public InnerHttpError innerHttpError(){ - return this.innerHttpError; - } - - /** - * Sets error from inner http call. - */ - public Error withInnerHttpError(InnerHttpError innerHttpError){ - this.innerHttpError = innerHttpError; - return this; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Object representing error information. + */ +public class Error { + /** + * Error code. + */ + @JsonProperty(value = "code") + private String code; + + /** + * Error message. + */ + @JsonProperty(value = "message") + private String message; + + /** + * Error from inner http call + */ + @JsonProperty(value = "innerHttpError") + private InnerHttpError innerHttpError; + + /** + * Get the code value. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Set the code value. + * + * @param code the code value to set + * @return the Error object itself. + */ + public Error withCode(String code) { + this.code = code; + return this; + } + + /** + * Get the message value. + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set the message value. + * + * @param message the message value to set + * @return the Error object itself. + */ + public Error withMessage(String message) { + this.message = message; + return this; + } + + /** + * Gets error from inner http call. + */ + public InnerHttpError innerHttpError(){ + return this.innerHttpError; + } + + /** + * Sets error from inner http call. + */ + public Error withInnerHttpError(InnerHttpError innerHttpError){ + this.innerHttpError = innerHttpError; + return this; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ErrorResponse.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ErrorResponse.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ErrorResponse.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ErrorResponse.java index 9afef503..ae3f0fd8 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ErrorResponse.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ErrorResponse.java @@ -1,45 +1,45 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * An HTTP API response. - */ -public class ErrorResponse { - /** - * Error message. - */ - @JsonProperty(value = "error") - private Error error; - - /** - * Get the error value. - * - * @return the error value - */ - public Error error() { - return this.error; - } - - /** - * Set the error value. - * - * @param error the error value to set - * @return the ErrorResponse object itself. - */ - public ErrorResponse withError(Error error) { - this.error = error; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * An HTTP API response. + */ +public class ErrorResponse { + /** + * Error message. + */ + @JsonProperty(value = "error") + private Error error; + + /** + * Get the error value. + * + * @return the error value + */ + public Error error() { + return this.error; + } + + /** + * Set the error value. + * + * @param error the error value to set + * @return the ErrorResponse object itself. + */ + public ErrorResponse withError(Error error) { + this.error = error; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Fact.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Fact.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Fact.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Fact.java index 48852114..2793cc6e 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Fact.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Fact.java @@ -1,74 +1,74 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Set of key-value pairs. Advantage of this section is that key and value - * properties will be - * rendered with default style information with some delimiter between them. So - * there is no need for developer to specify style information. - */ -public class Fact { - /** - * The key for this Fact. - */ - @JsonProperty(value = "key") - private String key; - - /** - * The value for this Fact. - */ - @JsonProperty(value = "value") - private String value; - - /** - * Get the key value. - * - * @return the key value - */ - public String key() { - return this.key; - } - - /** - * Set the key value. - * - * @param key the key value to set - * @return the Fact object itself. - */ - public Fact withKey(String key) { - this.key = key; - return this; - } - - /** - * Get the value value. - * - * @return the value value - */ - public String value() { - return this.value; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the Fact object itself. - */ - public Fact withValue(String value) { - this.value = value; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Set of key-value pairs. Advantage of this section is that key and value + * properties will be + * rendered with default style information with some delimiter between them. So + * there is no need for developer to specify style information. + */ +public class Fact { + /** + * The key for this Fact. + */ + @JsonProperty(value = "key") + private String key; + + /** + * The value for this Fact. + */ + @JsonProperty(value = "value") + private String value; + + /** + * Get the key value. + * + * @return the key value + */ + public String key() { + return this.key; + } + + /** + * Set the key value. + * + * @param key the key value to set + * @return the Fact object itself. + */ + public Fact withKey(String key) { + this.key = key; + return this; + } + + /** + * Get the value value. + * + * @return the value value + */ + public String value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the Fact object itself. + */ + public Fact withValue(String value) { + this.value = value; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/GeoCoordinates.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/GeoCoordinates.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/GeoCoordinates.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/GeoCoordinates.java index ecfd8684..3973c555 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/GeoCoordinates.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/GeoCoordinates.java @@ -1,149 +1,149 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.bot.schema.EntityImpl; - -/** - * GeoCoordinates (entity type: "https://schema.org/GeoCoordinates"). - */ -public class GeoCoordinates extends EntityImpl { - /** - * Elevation of the location [WGS - * 84](https://en.wikipedia.org/wiki/World_Geodetic_System). - */ - @JsonProperty(value = "elevation") - private Double elevation; - - /** - * Latitude of the location [WGS - * 84](https://en.wikipedia.org/wiki/World_Geodetic_System). - */ - @JsonProperty(value = "latitude") - private Double latitude; - - /** - * Longitude of the location [WGS - * 84](https://en.wikipedia.org/wiki/World_Geodetic_System). - */ - @JsonProperty(value = "longitude") - private Double longitude; - - /** - * The type of the thing. - */ - @JsonProperty(value = "type") - private String type; - - /** - * The name of the thing. - */ - @JsonProperty(value = "name") - private String name; - - /** - * Get the elevation value. - * - * @return the elevation value - */ - public Double elevation() { - return this.elevation; - } - - /** - * Set the elevation value. - * - * @param elevation the elevation value to set - * @return the GeoCoordinates object itself. - */ - public GeoCoordinates withElevation(Double elevation) { - this.elevation = elevation; - return this; - } - - /** - * Get the latitude value. - * - * @return the latitude value - */ - public Double latitude() { - return this.latitude; - } - - /** - * Set the latitude value. - * - * @param latitude the latitude value to set - * @return the GeoCoordinates object itself. - */ - public GeoCoordinates withLatitude(Double latitude) { - this.latitude = latitude; - return this; - } - - /** - * Get the longitude value. - * - * @return the longitude value - */ - public Double longitude() { - return this.longitude; - } - - /** - * Set the longitude value. - * - * @param longitude the longitude value to set - * @return the GeoCoordinates object itself. - */ - public GeoCoordinates withLongitude(Double longitude) { - this.longitude = longitude; - return this; - } - - /** - * Get the type value. - * - * @return the type value - */ - public String type() { - return this.type; - } - - /** - * Set the type value. - * - * @param type the type value to set - * @return the GeoCoordinates object itself. - */ - public GeoCoordinates withType(String type) { - this.type = type; - return this; - } - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the GeoCoordinates object itself. - */ - public GeoCoordinates withName(String name) { - this.name = name; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.bot.schema.EntityImpl; + +/** + * GeoCoordinates (entity type: "https://schema.org/GeoCoordinates"). + */ +public class GeoCoordinates extends EntityImpl { + /** + * Elevation of the location [WGS + * 84](https://en.wikipedia.org/wiki/World_Geodetic_System). + */ + @JsonProperty(value = "elevation") + private Double elevation; + + /** + * Latitude of the location [WGS + * 84](https://en.wikipedia.org/wiki/World_Geodetic_System). + */ + @JsonProperty(value = "latitude") + private Double latitude; + + /** + * Longitude of the location [WGS + * 84](https://en.wikipedia.org/wiki/World_Geodetic_System). + */ + @JsonProperty(value = "longitude") + private Double longitude; + + /** + * The type of the thing. + */ + @JsonProperty(value = "type") + private String type; + + /** + * The name of the thing. + */ + @JsonProperty(value = "name") + private String name; + + /** + * Get the elevation value. + * + * @return the elevation value + */ + public Double elevation() { + return this.elevation; + } + + /** + * Set the elevation value. + * + * @param elevation the elevation value to set + * @return the GeoCoordinates object itself. + */ + public GeoCoordinates withElevation(Double elevation) { + this.elevation = elevation; + return this; + } + + /** + * Get the latitude value. + * + * @return the latitude value + */ + public Double latitude() { + return this.latitude; + } + + /** + * Set the latitude value. + * + * @param latitude the latitude value to set + * @return the GeoCoordinates object itself. + */ + public GeoCoordinates withLatitude(Double latitude) { + this.latitude = latitude; + return this; + } + + /** + * Get the longitude value. + * + * @return the longitude value + */ + public Double longitude() { + return this.longitude; + } + + /** + * Set the longitude value. + * + * @param longitude the longitude value to set + * @return the GeoCoordinates object itself. + */ + public GeoCoordinates withLongitude(Double longitude) { + this.longitude = longitude; + return this; + } + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the GeoCoordinates object itself. + */ + public GeoCoordinates withType(String type) { + this.type = type; + return this; + } + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the GeoCoordinates object itself. + */ + public GeoCoordinates withName(String name) { + this.name = name; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/HeroCard.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/HeroCard.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/HeroCard.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/HeroCard.java index a073a138..15e8d28e 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/HeroCard.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/HeroCard.java @@ -1,176 +1,176 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A Hero card (card with a single, large image). - */ -public class HeroCard { - /** - * Title of the card. - */ - @JsonProperty(value = "title") - private String title; - - /** - * Subtitle of the card. - */ - @JsonProperty(value = "subtitle") - private String subtitle; - - /** - * Text for the card. - */ - @JsonProperty(value = "text") - private String text; - - /** - * Array of images for the card. - */ - @JsonProperty(value = "images") - private List images; - - /** - * Set of actions applicable to the current card. - */ - @JsonProperty(value = "buttons") - private List buttons; - - /** - * This action will be activated when user taps on the card itself. - */ - @JsonProperty(value = "tap") - private CardAction tap; - - /** - * Get the title value. - * - * @return the title value - */ - public String title() { - return this.title; - } - - /** - * Set the title value. - * - * @param title the title value to set - * @return the HeroCard object itself. - */ - public HeroCard withTitle(String title) { - this.title = title; - return this; - } - - /** - * Get the subtitle value. - * - * @return the subtitle value - */ - public String subtitle() { - return this.subtitle; - } - - /** - * Set the subtitle value. - * - * @param subtitle the subtitle value to set - * @return the HeroCard object itself. - */ - public HeroCard withSubtitle(String subtitle) { - this.subtitle = subtitle; - return this; - } - - /** - * Get the text value. - * - * @return the text value - */ - public String text() { - return this.text; - } - - /** - * Set the text value. - * - * @param text the text value to set - * @return the HeroCard object itself. - */ - public HeroCard withText(String text) { - this.text = text; - return this; - } - - /** - * Get the images value. - * - * @return the images value - */ - public List images() { - return this.images; - } - - /** - * Set the images value. - * - * @param images the images value to set - * @return the HeroCard object itself. - */ - public HeroCard withImages(List images) { - this.images = images; - return this; - } - - /** - * Get the buttons value. - * - * @return the buttons value - */ - public List buttons() { - return this.buttons; - } - - /** - * Set the buttons value. - * - * @param buttons the buttons value to set - * @return the HeroCard object itself. - */ - public HeroCard withButtons(List buttons) { - this.buttons = buttons; - return this; - } - - /** - * Get the tap value. - * - * @return the tap value - */ - public CardAction tap() { - return this.tap; - } - - /** - * Set the tap value. - * - * @param tap the tap value to set - * @return the HeroCard object itself. - */ - public HeroCard withTap(CardAction tap) { - this.tap = tap; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A Hero card (card with a single, large image). + */ +public class HeroCard { + /** + * Title of the card. + */ + @JsonProperty(value = "title") + private String title; + + /** + * Subtitle of the card. + */ + @JsonProperty(value = "subtitle") + private String subtitle; + + /** + * Text for the card. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Array of images for the card. + */ + @JsonProperty(value = "images") + private List images; + + /** + * Set of actions applicable to the current card. + */ + @JsonProperty(value = "buttons") + private List buttons; + + /** + * This action will be activated when user taps on the card itself. + */ + @JsonProperty(value = "tap") + private CardAction tap; + + /** + * Get the title value. + * + * @return the title value + */ + public String title() { + return this.title; + } + + /** + * Set the title value. + * + * @param title the title value to set + * @return the HeroCard object itself. + */ + public HeroCard withTitle(String title) { + this.title = title; + return this; + } + + /** + * Get the subtitle value. + * + * @return the subtitle value + */ + public String subtitle() { + return this.subtitle; + } + + /** + * Set the subtitle value. + * + * @param subtitle the subtitle value to set + * @return the HeroCard object itself. + */ + public HeroCard withSubtitle(String subtitle) { + this.subtitle = subtitle; + return this; + } + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the HeroCard object itself. + */ + public HeroCard withText(String text) { + this.text = text; + return this; + } + + /** + * Get the images value. + * + * @return the images value + */ + public List images() { + return this.images; + } + + /** + * Set the images value. + * + * @param images the images value to set + * @return the HeroCard object itself. + */ + public HeroCard withImages(List images) { + this.images = images; + return this; + } + + /** + * Get the buttons value. + * + * @return the buttons value + */ + public List buttons() { + return this.buttons; + } + + /** + * Set the buttons value. + * + * @param buttons the buttons value to set + * @return the HeroCard object itself. + */ + public HeroCard withButtons(List buttons) { + this.buttons = buttons; + return this; + } + + /** + * Get the tap value. + * + * @return the tap value + */ + public CardAction tap() { + return this.tap; + } + + /** + * Set the tap value. + * + * @param tap the tap value to set + * @return the HeroCard object itself. + */ + public HeroCard withTap(CardAction tap) { + this.tap = tap; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/InnerHttpError.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/InnerHttpError.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/InnerHttpError.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/InnerHttpError.java index 82df998a..4bb294d6 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/InnerHttpError.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/InnerHttpError.java @@ -1,66 +1,66 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Object representing inner http error. - */ -public class InnerHttpError { - /** - * HttpStatusCode from failed request. - */ - @JsonProperty(value = "statusCode") - private int statusCode; - - /** - * Body from failed request. - */ - @JsonProperty(value = "body") - private Object body; - - /** - * Gets HttpStatusCode from failed request. - * - * @return the statusCode value - */ - public int statusCode() { - return this.statusCode; - } - - /** - * Sets HttpStatusCode from failed request. - * - * @param activities the activities value to set - * @return the InnerHttpError object itself. - */ - public InnerHttpError withStatusCode(int statusCode) { - this.statusCode = statusCode; - return this; - } - - /** - * Gets Body from failed request. - */ - public Object body(){ - return this.body; - } - - /** - * Sets Body from failed request. - * @param body The body to set - */ - public InnerHttpError withBody(Object body){ - this.body = body; - return this; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Object representing inner http error. + */ +public class InnerHttpError { + /** + * HttpStatusCode from failed request. + */ + @JsonProperty(value = "statusCode") + private int statusCode; + + /** + * Body from failed request. + */ + @JsonProperty(value = "body") + private Object body; + + /** + * Gets HttpStatusCode from failed request. + * + * @return the statusCode value + */ + public int statusCode() { + return this.statusCode; + } + + /** + * Sets HttpStatusCode from failed request. + * + * @param activities the activities value to set + * @return the InnerHttpError object itself. + */ + public InnerHttpError withStatusCode(int statusCode) { + this.statusCode = statusCode; + return this; + } + + /** + * Gets Body from failed request. + */ + public Object body(){ + return this.body; + } + + /** + * Sets Body from failed request. + * @param body The body to set + */ + public InnerHttpError withBody(Object body){ + this.body = body; + return this; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/InputHints.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/InputHints.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/InputHints.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/InputHints.java index 13bdcb0d..847f836f 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/InputHints.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/InputHints.java @@ -1,58 +1,58 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for InputHints. - */ -public enum InputHints { - /** Enum value acceptingInput. */ - ACCEPTING_INPUT("acceptingInput"), - - /** Enum value ignoringInput. */ - IGNORING_INPUT("ignoringInput"), - - /** Enum value expectingInput. */ - EXPECTING_INPUT("expectingInput"); - - /** The actual serialized value for a InputHints instance. */ - private String value; - - InputHints(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a InputHints instance. - * - * @param value the serialized value to parse. - * @return the parsed InputHints object, or null if unable to parse. - */ - @JsonCreator - public static InputHints fromString(String value) { - InputHints[] items = InputHints.values(); - for (InputHints item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for InputHints. + */ +public enum InputHints { + /** Enum value acceptingInput. */ + ACCEPTING_INPUT("acceptingInput"), + + /** Enum value ignoringInput. */ + IGNORING_INPUT("ignoringInput"), + + /** Enum value expectingInput. */ + EXPECTING_INPUT("expectingInput"); + + /** The actual serialized value for a InputHints instance. */ + private String value; + + InputHints(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a InputHints instance. + * + * @param value the serialized value to parse. + * @return the parsed InputHints object, or null if unable to parse. + */ + @JsonCreator + public static InputHints fromString(String value) { + InputHints[] items = InputHints.values(); + for (InputHints item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/InstallationUpdateActionTypes.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/InstallationUpdateActionTypes.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/InstallationUpdateActionTypes.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/InstallationUpdateActionTypes.java index a9ef922c..5b5c70ad 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/InstallationUpdateActionTypes.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/InstallationUpdateActionTypes.java @@ -1,55 +1,55 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for InstallationUpdateActionTypes. - */ -public enum InstallationUpdateActionTypes { - /** Enum value add. */ - ADD("add"), - - /** Enum value remove. */ - REMOVE("remove"); - - /** The actual serialized value for a InstallationUpdateActionTypes instance. */ - private String value; - - InstallationUpdateActionTypes(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a InstallationUpdateActionTypes instance. - * - * @param value the serialized value to parse. - * @return the parsed InstallationUpdateActionTypes object, or null if unable to parse. - */ - @JsonCreator - public static InstallationUpdateActionTypes fromString(String value) { - InstallationUpdateActionTypes[] items = InstallationUpdateActionTypes.values(); - for (InstallationUpdateActionTypes item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for InstallationUpdateActionTypes. + */ +public enum InstallationUpdateActionTypes { + /** Enum value add. */ + ADD("add"), + + /** Enum value remove. */ + REMOVE("remove"); + + /** The actual serialized value for a InstallationUpdateActionTypes instance. */ + private String value; + + InstallationUpdateActionTypes(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a InstallationUpdateActionTypes instance. + * + * @param value the serialized value to parse. + * @return the parsed InstallationUpdateActionTypes object, or null if unable to parse. + */ + @JsonCreator + public static InstallationUpdateActionTypes fromString(String value) { + InstallationUpdateActionTypes[] items = InstallationUpdateActionTypes.values(); + for (InstallationUpdateActionTypes item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MediaCard.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MediaCard.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MediaCard.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MediaCard.java index f6807422..9a54ce6b 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MediaCard.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MediaCard.java @@ -1,332 +1,332 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Media card. - */ -public class MediaCard { - /** - * Title of this card. - */ - @JsonProperty(value = "title") - private String title; - - /** - * Subtitle of this card. - */ - @JsonProperty(value = "subtitle") - private String subtitle; - - /** - * Text of this card. - */ - @JsonProperty(value = "text") - private String text; - - /** - * Thumbnail placeholder. - */ - @JsonProperty(value = "image") - private ThumbnailUrl image; - - /** - * Media URLs for this card. When this field contains more than one URL, each URL is an alternative format of the same content. - */ - @JsonProperty(value = "media") - private List media; - - /** - * Actions on this card. - */ - @JsonProperty(value = "buttons") - private List buttons; - - /** - * This content may be shared with others (default:true). - */ - @JsonProperty(value = "shareable") - private Boolean shareable; - - /** - * Should the client loop playback at end of content (default:true). - */ - @JsonProperty(value = "autoloop") - private Boolean autoloop; - - /** - * Should the client automatically start playback of media in this card - * (default:true). - */ - @JsonProperty(value = "autostart") - private Boolean autostart; - - /** - * Aspect ratio of thumbnail/media placeholder, allowed values are "16:9" - * and "4:3". - */ - @JsonProperty(value = "aspect") - private String aspect; - - /** - * Describes the length of the media content without requiring a receiver to open the content. Formatted as an ISO 8601 Duration field. - */ - @JsonProperty(value = "duration") - private String duration; - - /** - * Supplementary parameter for this card. - */ - @JsonProperty(value = "value") - private Object value; - - /** - * Get the title value. - * - * @return the title value - */ - public String title() { - return this.title; - } - - /** - * Set the title value. - * - * @param title the title value to set - * @return the MediaCard object itself. - */ - public MediaCard withTitle(String title) { - this.title = title; - return this; - } - - /** - * Get the subtitle value. - * - * @return the subtitle value - */ - public String subtitle() { - return this.subtitle; - } - - /** - * Set the subtitle value. - * - * @param subtitle the subtitle value to set - * @return the MediaCard object itself. - */ - public MediaCard withSubtitle(String subtitle) { - this.subtitle = subtitle; - return this; - } - - /** - * Get the text value. - * - * @return the text value - */ - public String text() { - return this.text; - } - - /** - * Set the text value. - * - * @param text the text value to set - * @return the MediaCard object itself. - */ - public MediaCard withText(String text) { - this.text = text; - return this; - } - - /** - * Get the image value. - * - * @return the image value - */ - public ThumbnailUrl image() { - return this.image; - } - - /** - * Set the image value. - * - * @param image the image value to set - * @return the MediaCard object itself. - */ - public MediaCard withImage(ThumbnailUrl image) { - this.image = image; - return this; - } - - /** - * Get the media value. - * - * @return the media value - */ - public List media() { - return this.media; - } - - /** - * Set the media value. - * - * @param media the media value to set - * @return the MediaCard object itself. - */ - public MediaCard withMedia(List media) { - this.media = media; - return this; - } - - /** - * Get the buttons value. - * - * @return the buttons value - */ - public List buttons() { - return this.buttons; - } - - /** - * Set the buttons value. - * - * @param buttons the buttons value to set - * @return the MediaCard object itself. - */ - public MediaCard withButtons(List buttons) { - this.buttons = buttons; - return this; - } - - /** - * Get the shareable value. - * - * @return the shareable value - */ - public Boolean shareable() { - return this.shareable; - } - - /** - * Set the shareable value. - * - * @param shareable the shareable value to set - * @return the MediaCard object itself. - */ - public MediaCard withShareable(Boolean shareable) { - this.shareable = shareable; - return this; - } - - /** - * Get the autoloop value. - * - * @return the autoloop value - */ - public Boolean autoloop() { - return this.autoloop; - } - - /** - * Set the autoloop value. - * - * @param autoloop the autoloop value to set - * @return the MediaCard object itself. - */ - public MediaCard withAutoloop(Boolean autoloop) { - this.autoloop = autoloop; - return this; - } - - /** - * Get the autostart value. - * - * @return the autostart value - */ - public Boolean autostart() { - return this.autostart; - } - - /** - * Set the autostart value. - * - * @param autostart the autostart value to set - * @return the MediaCard object itself. - */ - public MediaCard withAutostart(Boolean autostart) { - this.autostart = autostart; - return this; - } - - /** - * Get the aspect value. - * - * @return the aspect value - */ - public String aspect() { - return this.aspect; - } - - /** - * Set the aspect value. - * - * @param aspect the aspect value to set - * @return the MediaCard object itself. - */ - public MediaCard withAspect(String aspect) { - this.aspect = aspect; - return this; - } - - /** - * Gets the duration value. - */ - public String duration(){ - return this.duration; - } - - /** - * Sets the duration value. - * - * @param duration the duration value to set - * @return the MediaCard object itself. - */ - public MediaCard withDuration(String duration){ - this.duration = duration; - return this; - } - - /** - * Get the value value. - * - * @return the value value - */ - public Object value() { - return this.value; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the MediaCard object itself. - */ - public MediaCard withValue(Object value) { - this.value = value; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Media card. + */ +public class MediaCard { + /** + * Title of this card. + */ + @JsonProperty(value = "title") + private String title; + + /** + * Subtitle of this card. + */ + @JsonProperty(value = "subtitle") + private String subtitle; + + /** + * Text of this card. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Thumbnail placeholder. + */ + @JsonProperty(value = "image") + private ThumbnailUrl image; + + /** + * Media URLs for this card. When this field contains more than one URL, each URL is an alternative format of the same content. + */ + @JsonProperty(value = "media") + private List media; + + /** + * Actions on this card. + */ + @JsonProperty(value = "buttons") + private List buttons; + + /** + * This content may be shared with others (default:true). + */ + @JsonProperty(value = "shareable") + private Boolean shareable; + + /** + * Should the client loop playback at end of content (default:true). + */ + @JsonProperty(value = "autoloop") + private Boolean autoloop; + + /** + * Should the client automatically start playback of media in this card + * (default:true). + */ + @JsonProperty(value = "autostart") + private Boolean autostart; + + /** + * Aspect ratio of thumbnail/media placeholder, allowed values are "16:9" + * and "4:3". + */ + @JsonProperty(value = "aspect") + private String aspect; + + /** + * Describes the length of the media content without requiring a receiver to open the content. Formatted as an ISO 8601 Duration field. + */ + @JsonProperty(value = "duration") + private String duration; + + /** + * Supplementary parameter for this card. + */ + @JsonProperty(value = "value") + private Object value; + + /** + * Get the title value. + * + * @return the title value + */ + public String title() { + return this.title; + } + + /** + * Set the title value. + * + * @param title the title value to set + * @return the MediaCard object itself. + */ + public MediaCard withTitle(String title) { + this.title = title; + return this; + } + + /** + * Get the subtitle value. + * + * @return the subtitle value + */ + public String subtitle() { + return this.subtitle; + } + + /** + * Set the subtitle value. + * + * @param subtitle the subtitle value to set + * @return the MediaCard object itself. + */ + public MediaCard withSubtitle(String subtitle) { + this.subtitle = subtitle; + return this; + } + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the MediaCard object itself. + */ + public MediaCard withText(String text) { + this.text = text; + return this; + } + + /** + * Get the image value. + * + * @return the image value + */ + public ThumbnailUrl image() { + return this.image; + } + + /** + * Set the image value. + * + * @param image the image value to set + * @return the MediaCard object itself. + */ + public MediaCard withImage(ThumbnailUrl image) { + this.image = image; + return this; + } + + /** + * Get the media value. + * + * @return the media value + */ + public List media() { + return this.media; + } + + /** + * Set the media value. + * + * @param media the media value to set + * @return the MediaCard object itself. + */ + public MediaCard withMedia(List media) { + this.media = media; + return this; + } + + /** + * Get the buttons value. + * + * @return the buttons value + */ + public List buttons() { + return this.buttons; + } + + /** + * Set the buttons value. + * + * @param buttons the buttons value to set + * @return the MediaCard object itself. + */ + public MediaCard withButtons(List buttons) { + this.buttons = buttons; + return this; + } + + /** + * Get the shareable value. + * + * @return the shareable value + */ + public Boolean shareable() { + return this.shareable; + } + + /** + * Set the shareable value. + * + * @param shareable the shareable value to set + * @return the MediaCard object itself. + */ + public MediaCard withShareable(Boolean shareable) { + this.shareable = shareable; + return this; + } + + /** + * Get the autoloop value. + * + * @return the autoloop value + */ + public Boolean autoloop() { + return this.autoloop; + } + + /** + * Set the autoloop value. + * + * @param autoloop the autoloop value to set + * @return the MediaCard object itself. + */ + public MediaCard withAutoloop(Boolean autoloop) { + this.autoloop = autoloop; + return this; + } + + /** + * Get the autostart value. + * + * @return the autostart value + */ + public Boolean autostart() { + return this.autostart; + } + + /** + * Set the autostart value. + * + * @param autostart the autostart value to set + * @return the MediaCard object itself. + */ + public MediaCard withAutostart(Boolean autostart) { + this.autostart = autostart; + return this; + } + + /** + * Get the aspect value. + * + * @return the aspect value + */ + public String aspect() { + return this.aspect; + } + + /** + * Set the aspect value. + * + * @param aspect the aspect value to set + * @return the MediaCard object itself. + */ + public MediaCard withAspect(String aspect) { + this.aspect = aspect; + return this; + } + + /** + * Gets the duration value. + */ + public String duration(){ + return this.duration; + } + + /** + * Sets the duration value. + * + * @param duration the duration value to set + * @return the MediaCard object itself. + */ + public MediaCard withDuration(String duration){ + this.duration = duration; + return this; + } + + /** + * Get the value value. + * + * @return the value value + */ + public Object value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the MediaCard object itself. + */ + public MediaCard withValue(Object value) { + this.value = value; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MediaEventValue.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MediaEventValue.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MediaEventValue.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MediaEventValue.java index e849e5ca..d539a84e 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MediaEventValue.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MediaEventValue.java @@ -1,46 +1,46 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Supplementary parameter for media events. - */ -public class MediaEventValue { - /** - * Callback parameter specified in the Value field of the MediaCard that - * originated this event. - */ - @JsonProperty(value = "cardValue") - private Object cardValue; - - /** - * Get the cardValue value. - * - * @return the cardValue value - */ - public Object cardValue() { - return this.cardValue; - } - - /** - * Set the cardValue value. - * - * @param cardValue the cardValue value to set - * @return the MediaEventValue object itself. - */ - public MediaEventValue withCardValue(Object cardValue) { - this.cardValue = cardValue; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Supplementary parameter for media events. + */ +public class MediaEventValue { + /** + * Callback parameter specified in the Value field of the MediaCard that + * originated this event. + */ + @JsonProperty(value = "cardValue") + private Object cardValue; + + /** + * Get the cardValue value. + * + * @return the cardValue value + */ + public Object cardValue() { + return this.cardValue; + } + + /** + * Set the cardValue value. + * + * @param cardValue the cardValue value to set + * @return the MediaEventValue object itself. + */ + public MediaEventValue withCardValue(Object cardValue) { + this.cardValue = cardValue; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MediaUrl.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MediaUrl.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MediaUrl.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MediaUrl.java index f2b22cf4..cbe993be 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MediaUrl.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MediaUrl.java @@ -1,72 +1,72 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Media URL. - */ -public class MediaUrl { - /** - * Url for the media. - */ - @JsonProperty(value = "url") - private String url; - - /** - * Optional profile hint to the client to differentiate multiple MediaUrl - * objects from each other. - */ - @JsonProperty(value = "profile") - private String profile; - - /** - * Get the url value. - * - * @return the url value - */ - public String url() { - return this.url; - } - - /** - * Set the url value. - * - * @param url the url value to set - * @return the MediaUrl object itself. - */ - public MediaUrl withUrl(String url) { - this.url = url; - return this; - } - - /** - * Get the profile value. - * - * @return the profile value - */ - public String profile() { - return this.profile; - } - - /** - * Set the profile value. - * - * @param profile the profile value to set - * @return the MediaUrl object itself. - */ - public MediaUrl withProfile(String profile) { - this.profile = profile; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Media URL. + */ +public class MediaUrl { + /** + * Url for the media. + */ + @JsonProperty(value = "url") + private String url; + + /** + * Optional profile hint to the client to differentiate multiple MediaUrl + * objects from each other. + */ + @JsonProperty(value = "profile") + private String profile; + + /** + * Get the url value. + * + * @return the url value + */ + public String url() { + return this.url; + } + + /** + * Set the url value. + * + * @param url the url value to set + * @return the MediaUrl object itself. + */ + public MediaUrl withUrl(String url) { + this.url = url; + return this; + } + + /** + * Get the profile value. + * + * @return the profile value + */ + public String profile() { + return this.profile; + } + + /** + * Set the profile value. + * + * @param profile the profile value to set + * @return the MediaUrl object itself. + */ + public MediaUrl withProfile(String profile) { + this.profile = profile; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Mention.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Mention.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Mention.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Mention.java index 3369c5d1..32112fc8 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Mention.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Mention.java @@ -1,95 +1,95 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.bot.schema.EntityImpl; - -/** - * Mention information (entity type: "mention"). - */ -public class Mention extends EntityImpl { - /** - * The mentioned user. - */ - @JsonProperty(value = "mentioned") - private ChannelAccount mentioned; - - /** - * Sub Text which represents the mention (can be null or empty). - */ - @JsonProperty(value = "text") - private String text; - - /** - * Type of this entity (RFC 3987 IRI). - */ - @JsonProperty(value = "type") - private String type; - - /** - * Get the mentioned value. - * - * @return the mentioned value - */ - public ChannelAccount mentioned() { - return this.mentioned; - } - - /** - * Set the mentioned value. - * - * @param mentioned the mentioned value to set - * @return the Mention object itself. - */ - public Mention withMentioned(ChannelAccount mentioned) { - this.mentioned = mentioned; - return this; - } - - /** - * Get the text value. - * - * @return the text value - */ - public String text() { - return this.text; - } - - /** - * Set the text value. - * - * @param text the text value to set - * @return the Mention object itself. - */ - public Mention withText(String text) { - this.text = text; - return this; - } - - /** - * Get the type value. - * - * @return the type value - */ - public String type() { - return this.type; - } - - /** - * Set the type value. - * - * @param type the type value to set - * @return the Mention object itself. - */ - public Mention withType(String type) { - this.type = type; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.bot.schema.EntityImpl; + +/** + * Mention information (entity type: "mention"). + */ +public class Mention extends EntityImpl { + /** + * The mentioned user. + */ + @JsonProperty(value = "mentioned") + private ChannelAccount mentioned; + + /** + * Sub Text which represents the mention (can be null or empty). + */ + @JsonProperty(value = "text") + private String text; + + /** + * Type of this entity (RFC 3987 IRI). + */ + @JsonProperty(value = "type") + private String type; + + /** + * Get the mentioned value. + * + * @return the mentioned value + */ + public ChannelAccount mentioned() { + return this.mentioned; + } + + /** + * Set the mentioned value. + * + * @param mentioned the mentioned value to set + * @return the Mention object itself. + */ + public Mention withMentioned(ChannelAccount mentioned) { + this.mentioned = mentioned; + return this; + } + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the Mention object itself. + */ + public Mention withText(String text) { + this.text = text; + return this; + } + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the Mention object itself. + */ + public Mention withType(String type) { + this.type = type; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MessageActivity.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MessageActivity.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MessageActivity.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MessageActivity.java index eed35b8a..6e39c21e 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MessageActivity.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MessageActivity.java @@ -1,190 +1,190 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - - -package com.microsoft.bot.schema.models; - -import com.microsoft.bot.schema.ActivityImpl; - -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.List; - - /** - * A message in a conversation - */ -public class MessageActivity extends ActivityImpl -{ - /** - * The language code of the Text field - */ - private String locale; - public String getLocale() { - return this.locale; - } - public void setLocale(String locale) { - this.locale = locale; - - } - - /** - * Content for the message - */ - private String text; - public void setText(String text){ - this.text = text; - } - public String getText() { - - return this.text; - } - - /** - * Speak tag (SSML markup for text to speech) - */ - private String speak; - public void setSpeak(String speak){ - this.speak = speak; - } - public String getSpeak(){ - return this.speak; - } - - /** - * Indicates whether the bot is accepting, expecting, or ignoring input - */ - private String inputHint; - public String getInputHint(){ - return this.inputHint; - } - public void setInputHint(String inputHint){ - this.inputHint = inputHint; - } - - /** - * Text to display if the channel cannot render cards - */ - private String summary; - public String getSummary(){ - return this.summary; - } - public void setSummary(String summary) { - this.summary = summary; - } - - /** - * Format of text fields [plain|markdown] Default:markdown - */ - private String textFormat; - public String getTextFormat() { - - return this.textFormat; - } - public void setTextFormat(String textFormat) { - this.textFormat = textFormat; - } - - /** - * Hint for how to deal with multiple attachments: [list|carousel] Default:list - */ - private String attachmentLayout; - public String getAttachmentLayout() { - return this.attachmentLayout; - } - public void setAttachmentLayout(String attachmentLayout) { - this.attachmentLayout = attachmentLayout; - } - - /** - * Attachments - */ - private List attachments; - public List getAttachments() { - return this.attachments; - } - public void setAttachments(List attachments) { - this.attachments = attachments; - } - - /** - * SuggestedActions are used to express actions for interacting with a card like keyboards/quickReplies - */ - private SuggestedActions suggestedActions; - public SuggestedActions getSuggestedActions() { - return this.suggestedActions; - } - public void setSuggestedActions(SuggestedActions suggestedActions) { - this.suggestedActions = suggestedActions; - } - - - /** - * Importance of the activity - * Valid values are "low", "normal", and "high". Default value is "normal." - */ - private String importance; - public String getImportance() { - return this.importance; - } - public void setImportance(String importance) { - this.importance = importance; - } - - /** - * 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; - } - public void setDeliveryMode(String deliveryMode) { - this.deliveryMode = deliveryMode; - } - - /** - * DateTime to expire the activity as ISO 8601 encoded datetime - */ - private OffsetDateTime expiration; - public OffsetDateTime getExpiration() { - return this.expiration; - } - public void setExpiration(OffsetDateTime expiration) { - this.expiration = expiration; - } - - /** - * Get mentions - */ - private ArrayList mentions; - public ArrayList GetMentions() { - return this.mentions; - } - - /** - * Value provided with CardAction - */ - private Object value; - public Object getValue() { - return this.value; - } - public void setValue(Object value) { - this.value = value; - } - - - /** - * Create an instance of the Activity class with IConversationUpdateActivity masking - */ - public static ConversationUpdateActivity CreateConversationUpdateActivity() - { - ConversationUpdateActivity conversationActivity = new ConversationUpdateActivity(); - conversationActivity.withType(ActivityTypes.CONVERSATION_UPDATE); - conversationActivity.withMembersAdded(new ArrayList()); - conversationActivity.withMembersRemoved(new ArrayList()); - return conversationActivity; - } - -} +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + + +package com.microsoft.bot.schema.models; + +import com.microsoft.bot.schema.ActivityImpl; + +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; + + /** + * A message in a conversation + */ +public class MessageActivity extends ActivityImpl +{ + /** + * The language code of the Text field + */ + private String locale; + public String getLocale() { + return this.locale; + } + public void setLocale(String locale) { + this.locale = locale; + + } + + /** + * Content for the message + */ + private String text; + public void setText(String text){ + this.text = text; + } + public String getText() { + + return this.text; + } + + /** + * Speak tag (SSML markup for text to speech) + */ + private String speak; + public void setSpeak(String speak){ + this.speak = speak; + } + public String getSpeak(){ + return this.speak; + } + + /** + * Indicates whether the bot is accepting, expecting, or ignoring input + */ + private String inputHint; + public String getInputHint(){ + return this.inputHint; + } + public void setInputHint(String inputHint){ + this.inputHint = inputHint; + } + + /** + * Text to display if the channel cannot render cards + */ + private String summary; + public String getSummary(){ + return this.summary; + } + public void setSummary(String summary) { + this.summary = summary; + } + + /** + * Format of text fields [plain|markdown] Default:markdown + */ + private String textFormat; + public String getTextFormat() { + + return this.textFormat; + } + public void setTextFormat(String textFormat) { + this.textFormat = textFormat; + } + + /** + * Hint for how to deal with multiple attachments: [list|carousel] Default:list + */ + private String attachmentLayout; + public String getAttachmentLayout() { + return this.attachmentLayout; + } + public void setAttachmentLayout(String attachmentLayout) { + this.attachmentLayout = attachmentLayout; + } + + /** + * Attachments + */ + private List attachments; + public List getAttachments() { + return this.attachments; + } + public void setAttachments(List attachments) { + this.attachments = attachments; + } + + /** + * SuggestedActions are used to express actions for interacting with a card like keyboards/quickReplies + */ + private SuggestedActions suggestedActions; + public SuggestedActions getSuggestedActions() { + return this.suggestedActions; + } + public void setSuggestedActions(SuggestedActions suggestedActions) { + this.suggestedActions = suggestedActions; + } + + + /** + * Importance of the activity + * Valid values are "low", "normal", and "high". Default value is "normal." + */ + private String importance; + public String getImportance() { + return this.importance; + } + public void setImportance(String importance) { + this.importance = importance; + } + + /** + * 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; + } + public void setDeliveryMode(String deliveryMode) { + this.deliveryMode = deliveryMode; + } + + /** + * DateTime to expire the activity as ISO 8601 encoded datetime + */ + private OffsetDateTime expiration; + public OffsetDateTime getExpiration() { + return this.expiration; + } + public void setExpiration(OffsetDateTime expiration) { + this.expiration = expiration; + } + + /** + * Get mentions + */ + private ArrayList mentions; + public ArrayList GetMentions() { + return this.mentions; + } + + /** + * Value provided with CardAction + */ + private Object value; + public Object getValue() { + return this.value; + } + public void setValue(Object value) { + this.value = value; + } + + + /** + * Create an instance of the Activity class with IConversationUpdateActivity masking + */ + public static ConversationUpdateActivity CreateConversationUpdateActivity() + { + ConversationUpdateActivity conversationActivity = new ConversationUpdateActivity(); + conversationActivity.withType(ActivityTypes.CONVERSATION_UPDATE); + conversationActivity.withMembersAdded(new ArrayList()); + conversationActivity.withMembersRemoved(new ArrayList()); + return conversationActivity; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MessageReaction.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MessageReaction.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MessageReaction.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MessageReaction.java index b419aa36..31721c77 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MessageReaction.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MessageReaction.java @@ -1,45 +1,45 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Message reaction object. - */ -public class MessageReaction { - /** - * Message reaction type. Possible values include: 'like', 'plusOne'. - */ - @JsonProperty(value = "type") - private MessageReactionTypes type; - - /** - * Get the type value. - * - * @return the type value - */ - public MessageReactionTypes type() { - return this.type; - } - - /** - * Set the type value. - * - * @param type the type value to set - * @return the MessageReaction object itself. - */ - public MessageReaction withType(MessageReactionTypes type) { - this.type = type; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Message reaction object. + */ +public class MessageReaction { + /** + * Message reaction type. Possible values include: 'like', 'plusOne'. + */ + @JsonProperty(value = "type") + private MessageReactionTypes type; + + /** + * Get the type value. + * + * @return the type value + */ + public MessageReactionTypes type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the MessageReaction object itself. + */ + public MessageReaction withType(MessageReactionTypes type) { + this.type = type; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MessageReactionTypes.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MessageReactionTypes.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MessageReactionTypes.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MessageReactionTypes.java index fc982130..b3fb538d 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MessageReactionTypes.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MessageReactionTypes.java @@ -1,55 +1,55 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for MessageReactionTypes. - */ -public enum MessageReactionTypes { - /** Enum value like. */ - LIKE("like"), - - /** Enum value plusOne. */ - PLUS_ONE("plusOne"); - - /** The actual serialized value for a MessageReactionTypes instance. */ - private String value; - - MessageReactionTypes(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a MessageReactionTypes instance. - * - * @param value the serialized value to parse. - * @return the parsed MessageReactionTypes object, or null if unable to parse. - */ - @JsonCreator - public static MessageReactionTypes fromString(String value) { - MessageReactionTypes[] items = MessageReactionTypes.values(); - for (MessageReactionTypes item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for MessageReactionTypes. + */ +public enum MessageReactionTypes { + /** Enum value like. */ + LIKE("like"), + + /** Enum value plusOne. */ + PLUS_ONE("plusOne"); + + /** The actual serialized value for a MessageReactionTypes instance. */ + private String value; + + MessageReactionTypes(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a MessageReactionTypes instance. + * + * @param value the serialized value to parse. + * @return the parsed MessageReactionTypes object, or null if unable to parse. + */ + @JsonCreator + public static MessageReactionTypes fromString(String value) { + MessageReactionTypes[] items = MessageReactionTypes.values(); + for (MessageReactionTypes item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MicrosoftPayMethodData.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MicrosoftPayMethodData.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MicrosoftPayMethodData.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MicrosoftPayMethodData.java index 47adc58c..38d9088b 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/MicrosoftPayMethodData.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/MicrosoftPayMethodData.java @@ -1,98 +1,98 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * W3C Payment Method Data for Microsoft Pay. - */ -public class MicrosoftPayMethodData { - /** - * Microsoft Pay Merchant ID. - */ - @JsonProperty(value = "merchantId") - private String merchantId; - - /** - * Supported payment networks (e.g., "visa" and "mastercard"). - */ - @JsonProperty(value = "supportedNetworks") - private List supportedNetworks; - - /** - * Supported payment types (e.g., "credit"). - */ - @JsonProperty(value = "supportedTypes") - private List supportedTypes; - - /** - * Get the merchantId value. - * - * @return the merchantId value - */ - public String merchantId() { - return this.merchantId; - } - - /** - * Set the merchantId value. - * - * @param merchantId the merchantId value to set - * @return the MicrosoftPayMethodData object itself. - */ - public MicrosoftPayMethodData withMerchantId(String merchantId) { - this.merchantId = merchantId; - return this; - } - - /** - * Get the supportedNetworks value. - * - * @return the supportedNetworks value - */ - public List supportedNetworks() { - return this.supportedNetworks; - } - - /** - * Set the supportedNetworks value. - * - * @param supportedNetworks the supportedNetworks value to set - * @return the MicrosoftPayMethodData object itself. - */ - public MicrosoftPayMethodData withSupportedNetworks(List supportedNetworks) { - this.supportedNetworks = supportedNetworks; - return this; - } - - /** - * Get the supportedTypes value. - * - * @return the supportedTypes value - */ - public List supportedTypes() { - return this.supportedTypes; - } - - /** - * Set the supportedTypes value. - * - * @param supportedTypes the supportedTypes value to set - * @return the MicrosoftPayMethodData object itself. - */ - public MicrosoftPayMethodData withSupportedTypes(List supportedTypes) { - this.supportedTypes = supportedTypes; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * W3C Payment Method Data for Microsoft Pay. + */ +public class MicrosoftPayMethodData { + /** + * Microsoft Pay Merchant ID. + */ + @JsonProperty(value = "merchantId") + private String merchantId; + + /** + * Supported payment networks (e.g., "visa" and "mastercard"). + */ + @JsonProperty(value = "supportedNetworks") + private List supportedNetworks; + + /** + * Supported payment types (e.g., "credit"). + */ + @JsonProperty(value = "supportedTypes") + private List supportedTypes; + + /** + * Get the merchantId value. + * + * @return the merchantId value + */ + public String merchantId() { + return this.merchantId; + } + + /** + * Set the merchantId value. + * + * @param merchantId the merchantId value to set + * @return the MicrosoftPayMethodData object itself. + */ + public MicrosoftPayMethodData withMerchantId(String merchantId) { + this.merchantId = merchantId; + return this; + } + + /** + * Get the supportedNetworks value. + * + * @return the supportedNetworks value + */ + public List supportedNetworks() { + return this.supportedNetworks; + } + + /** + * Set the supportedNetworks value. + * + * @param supportedNetworks the supportedNetworks value to set + * @return the MicrosoftPayMethodData object itself. + */ + public MicrosoftPayMethodData withSupportedNetworks(List supportedNetworks) { + this.supportedNetworks = supportedNetworks; + return this; + } + + /** + * Get the supportedTypes value. + * + * @return the supportedTypes value + */ + public List supportedTypes() { + return this.supportedTypes; + } + + /** + * Set the supportedTypes value. + * + * @param supportedTypes the supportedTypes value to set + * @return the MicrosoftPayMethodData object itself. + */ + public MicrosoftPayMethodData withSupportedTypes(List supportedTypes) { + this.supportedTypes = supportedTypes; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/OAuthCard.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/OAuthCard.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/OAuthCard.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/OAuthCard.java index 44b71aa4..585f862a 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/OAuthCard.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/OAuthCard.java @@ -1,98 +1,98 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A card representing a request to peform a sign in via OAuth. - */ -public class OAuthCard { - /** - * Text for signin request. - */ - @JsonProperty(value = "text") - private String text; - - /** - * The name of the registered connection. - */ - @JsonProperty(value = "connectionName") - private String connectionName; - - /** - * Action to use to perform signin. - */ - @JsonProperty(value = "buttons") - private List buttons; - - /** - * Get the text value. - * - * @return the text value - */ - public String text() { - return this.text; - } - - /** - * Set the text value. - * - * @param text the text value to set - * @return the OAuthCard object itself. - */ - public OAuthCard withText(String text) { - this.text = text; - return this; - } - - /** - * Get the connectionName value. - * - * @return the connectionName value - */ - public String connectionName() { - return this.connectionName; - } - - /** - * Set the connectionName value. - * - * @param connectionName the connectionName value to set - * @return the OAuthCard object itself. - */ - public OAuthCard withConnectionName(String connectionName) { - this.connectionName = connectionName; - return this; - } - - /** - * Get the buttons value. - * - * @return the buttons value - */ - public List buttons() { - return this.buttons; - } - - /** - * Set the buttons value. - * - * @param buttons the buttons value to set - * @return the OAuthCard object itself. - */ - public OAuthCard withButtons(List buttons) { - this.buttons = buttons; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A card representing a request to peform a sign in via OAuth. + */ +public class OAuthCard { + /** + * Text for signin request. + */ + @JsonProperty(value = "text") + private String text; + + /** + * The name of the registered connection. + */ + @JsonProperty(value = "connectionName") + private String connectionName; + + /** + * Action to use to perform signin. + */ + @JsonProperty(value = "buttons") + private List buttons; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the OAuthCard object itself. + */ + public OAuthCard withText(String text) { + this.text = text; + return this; + } + + /** + * Get the connectionName value. + * + * @return the connectionName value + */ + public String connectionName() { + return this.connectionName; + } + + /** + * Set the connectionName value. + * + * @param connectionName the connectionName value to set + * @return the OAuthCard object itself. + */ + public OAuthCard withConnectionName(String connectionName) { + this.connectionName = connectionName; + return this; + } + + /** + * Get the buttons value. + * + * @return the buttons value + */ + public List buttons() { + return this.buttons; + } + + /** + * Set the buttons value. + * + * @param buttons the buttons value to set + * @return the OAuthCard object itself. + */ + public OAuthCard withButtons(List buttons) { + this.buttons = buttons; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PagedMembersResult.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PagedMembersResult.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PagedMembersResult.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PagedMembersResult.java index 70ea3270..61a1aa6e 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PagedMembersResult.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PagedMembersResult.java @@ -1,66 +1,66 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Page of members - */ -public class PagedMembersResult { - - @JsonProperty(value = "continuationToken") - private String continuationToken; - - /** - * List of members in this conversation. - */ - @JsonProperty(value = "members") - private List members; - - /** - * Gets paging token - */ - public String continuationToken(){ - return this.continuationToken; - } - - /** - * Sets paging token - * - * @return the PagedMembersResult object itself. - */ - public PagedMembersResult withContinuationToken(String continuationToken){ - this.continuationToken = continuationToken; - return this; - } - - /** - * Gets the Channel Accounts. - * - * @return the members value - */ - public List members() { - return this.members; - } - - /** - * Sets the Channel Accounts. - * - * @param members the members value to set - * @return the PagedMembersResult object itself. - */ - public PagedMembersResult withMembers(List members) { - this.members = members; - return this; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Page of members + */ +public class PagedMembersResult { + + @JsonProperty(value = "continuationToken") + private String continuationToken; + + /** + * List of members in this conversation. + */ + @JsonProperty(value = "members") + private List members; + + /** + * Gets paging token + */ + public String continuationToken(){ + return this.continuationToken; + } + + /** + * Sets paging token + * + * @return the PagedMembersResult object itself. + */ + public PagedMembersResult withContinuationToken(String continuationToken){ + this.continuationToken = continuationToken; + return this; + } + + /** + * Gets the Channel Accounts. + * + * @return the members value + */ + public List members() { + return this.members; + } + + /** + * Sets the Channel Accounts. + * + * @param members the members value to set + * @return the PagedMembersResult object itself. + */ + public PagedMembersResult withMembers(List members) { + this.members = members; + return this; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentAddress.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentAddress.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentAddress.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentAddress.java index 6e6e11a3..0e7b24f0 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentAddress.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentAddress.java @@ -1,314 +1,314 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Address within a Payment Request. - */ -public class PaymentAddress { - /** - * This is the CLDR (Common Locale Data Repository) region code. For - * example, US, GB, CN, or JP. - */ - @JsonProperty(value = "country") - private String country; - - /** - * This is the most specific part of the address. It can include, for - * example, a street name, a house number, apartment number, a rural - * delivery route, descriptive instructions, or a post office box number. - */ - @JsonProperty(value = "addressLine") - private List addressLine; - - /** - * This is the top level administrative subdivision of the country. For - * example, this can be a state, a province, an oblast, or a prefecture. - */ - @JsonProperty(value = "region") - private String region; - - /** - * This is the city/town portion of the address. - */ - @JsonProperty(value = "city") - private String city; - - /** - * This is the dependent locality or sublocality within a city. For - * example, used for neighborhoods, boroughs, districts, or UK dependent - * localities. - */ - @JsonProperty(value = "dependentLocality") - private String dependentLocality; - - /** - * This is the postal code or ZIP code, also known as PIN code in India. - */ - @JsonProperty(value = "postalCode") - private String postalCode; - - /** - * This is the sorting code as used in, for example, France. - */ - @JsonProperty(value = "sortingCode") - private String sortingCode; - - /** - * This is the BCP-47 language code for the address. It's used to determine - * the field separators and the order of fields when formatting the address - * for display. - */ - @JsonProperty(value = "languageCode") - private String languageCode; - - /** - * This is the organization, firm, company, or institution at this address. - */ - @JsonProperty(value = "organization") - private String organization; - - /** - * This is the name of the recipient or contact person. - */ - @JsonProperty(value = "recipient") - private String recipient; - - /** - * This is the phone number of the recipient or contact person. - */ - @JsonProperty(value = "phone") - private String phone; - - /** - * Get the country value. - * - * @return the country value - */ - public String country() { - return this.country; - } - - /** - * Set the country value. - * - * @param country the country value to set - * @return the PaymentAddress object itself. - */ - public PaymentAddress withCountry(String country) { - this.country = country; - return this; - } - - /** - * Get the addressLine value. - * - * @return the addressLine value - */ - public List addressLine() { - return this.addressLine; - } - - /** - * Set the addressLine value. - * - * @param addressLine the addressLine value to set - * @return the PaymentAddress object itself. - */ - public PaymentAddress withAddressLine(List addressLine) { - this.addressLine = addressLine; - return this; - } - - /** - * Get the region value. - * - * @return the region value - */ - public String region() { - return this.region; - } - - /** - * Set the region value. - * - * @param region the region value to set - * @return the PaymentAddress object itself. - */ - public PaymentAddress withRegion(String region) { - this.region = region; - return this; - } - - /** - * Get the city value. - * - * @return the city value - */ - public String city() { - return this.city; - } - - /** - * Set the city value. - * - * @param city the city value to set - * @return the PaymentAddress object itself. - */ - public PaymentAddress withCity(String city) { - this.city = city; - return this; - } - - /** - * Get the dependentLocality value. - * - * @return the dependentLocality value - */ - public String dependentLocality() { - return this.dependentLocality; - } - - /** - * Set the dependentLocality value. - * - * @param dependentLocality the dependentLocality value to set - * @return the PaymentAddress object itself. - */ - public PaymentAddress withDependentLocality(String dependentLocality) { - this.dependentLocality = dependentLocality; - return this; - } - - /** - * Get the postalCode value. - * - * @return the postalCode value - */ - public String postalCode() { - return this.postalCode; - } - - /** - * Set the postalCode value. - * - * @param postalCode the postalCode value to set - * @return the PaymentAddress object itself. - */ - public PaymentAddress withPostalCode(String postalCode) { - this.postalCode = postalCode; - return this; - } - - /** - * Get the sortingCode value. - * - * @return the sortingCode value - */ - public String sortingCode() { - return this.sortingCode; - } - - /** - * Set the sortingCode value. - * - * @param sortingCode the sortingCode value to set - * @return the PaymentAddress object itself. - */ - public PaymentAddress withSortingCode(String sortingCode) { - this.sortingCode = sortingCode; - return this; - } - - /** - * Get the languageCode value. - * - * @return the languageCode value - */ - public String languageCode() { - return this.languageCode; - } - - /** - * Set the languageCode value. - * - * @param languageCode the languageCode value to set - * @return the PaymentAddress object itself. - */ - public PaymentAddress withLanguageCode(String languageCode) { - this.languageCode = languageCode; - return this; - } - - /** - * Get the organization value. - * - * @return the organization value - */ - public String organization() { - return this.organization; - } - - /** - * Set the organization value. - * - * @param organization the organization value to set - * @return the PaymentAddress object itself. - */ - public PaymentAddress withOrganization(String organization) { - this.organization = organization; - return this; - } - - /** - * Get the recipient value. - * - * @return the recipient value - */ - public String recipient() { - return this.recipient; - } - - /** - * Set the recipient value. - * - * @param recipient the recipient value to set - * @return the PaymentAddress object itself. - */ - public PaymentAddress withRecipient(String recipient) { - this.recipient = recipient; - return this; - } - - /** - * Get the phone value. - * - * @return the phone value - */ - public String phone() { - return this.phone; - } - - /** - * Set the phone value. - * - * @param phone the phone value to set - * @return the PaymentAddress object itself. - */ - public PaymentAddress withPhone(String phone) { - this.phone = phone; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Address within a Payment Request. + */ +public class PaymentAddress { + /** + * This is the CLDR (Common Locale Data Repository) region code. For + * example, US, GB, CN, or JP. + */ + @JsonProperty(value = "country") + private String country; + + /** + * This is the most specific part of the address. It can include, for + * example, a street name, a house number, apartment number, a rural + * delivery route, descriptive instructions, or a post office box number. + */ + @JsonProperty(value = "addressLine") + private List addressLine; + + /** + * This is the top level administrative subdivision of the country. For + * example, this can be a state, a province, an oblast, or a prefecture. + */ + @JsonProperty(value = "region") + private String region; + + /** + * This is the city/town portion of the address. + */ + @JsonProperty(value = "city") + private String city; + + /** + * This is the dependent locality or sublocality within a city. For + * example, used for neighborhoods, boroughs, districts, or UK dependent + * localities. + */ + @JsonProperty(value = "dependentLocality") + private String dependentLocality; + + /** + * This is the postal code or ZIP code, also known as PIN code in India. + */ + @JsonProperty(value = "postalCode") + private String postalCode; + + /** + * This is the sorting code as used in, for example, France. + */ + @JsonProperty(value = "sortingCode") + private String sortingCode; + + /** + * This is the BCP-47 language code for the address. It's used to determine + * the field separators and the order of fields when formatting the address + * for display. + */ + @JsonProperty(value = "languageCode") + private String languageCode; + + /** + * This is the organization, firm, company, or institution at this address. + */ + @JsonProperty(value = "organization") + private String organization; + + /** + * This is the name of the recipient or contact person. + */ + @JsonProperty(value = "recipient") + private String recipient; + + /** + * This is the phone number of the recipient or contact person. + */ + @JsonProperty(value = "phone") + private String phone; + + /** + * Get the country value. + * + * @return the country value + */ + public String country() { + return this.country; + } + + /** + * Set the country value. + * + * @param country the country value to set + * @return the PaymentAddress object itself. + */ + public PaymentAddress withCountry(String country) { + this.country = country; + return this; + } + + /** + * Get the addressLine value. + * + * @return the addressLine value + */ + public List addressLine() { + return this.addressLine; + } + + /** + * Set the addressLine value. + * + * @param addressLine the addressLine value to set + * @return the PaymentAddress object itself. + */ + public PaymentAddress withAddressLine(List addressLine) { + this.addressLine = addressLine; + return this; + } + + /** + * Get the region value. + * + * @return the region value + */ + public String region() { + return this.region; + } + + /** + * Set the region value. + * + * @param region the region value to set + * @return the PaymentAddress object itself. + */ + public PaymentAddress withRegion(String region) { + this.region = region; + return this; + } + + /** + * Get the city value. + * + * @return the city value + */ + public String city() { + return this.city; + } + + /** + * Set the city value. + * + * @param city the city value to set + * @return the PaymentAddress object itself. + */ + public PaymentAddress withCity(String city) { + this.city = city; + return this; + } + + /** + * Get the dependentLocality value. + * + * @return the dependentLocality value + */ + public String dependentLocality() { + return this.dependentLocality; + } + + /** + * Set the dependentLocality value. + * + * @param dependentLocality the dependentLocality value to set + * @return the PaymentAddress object itself. + */ + public PaymentAddress withDependentLocality(String dependentLocality) { + this.dependentLocality = dependentLocality; + return this; + } + + /** + * Get the postalCode value. + * + * @return the postalCode value + */ + public String postalCode() { + return this.postalCode; + } + + /** + * Set the postalCode value. + * + * @param postalCode the postalCode value to set + * @return the PaymentAddress object itself. + */ + public PaymentAddress withPostalCode(String postalCode) { + this.postalCode = postalCode; + return this; + } + + /** + * Get the sortingCode value. + * + * @return the sortingCode value + */ + public String sortingCode() { + return this.sortingCode; + } + + /** + * Set the sortingCode value. + * + * @param sortingCode the sortingCode value to set + * @return the PaymentAddress object itself. + */ + public PaymentAddress withSortingCode(String sortingCode) { + this.sortingCode = sortingCode; + return this; + } + + /** + * Get the languageCode value. + * + * @return the languageCode value + */ + public String languageCode() { + return this.languageCode; + } + + /** + * Set the languageCode value. + * + * @param languageCode the languageCode value to set + * @return the PaymentAddress object itself. + */ + public PaymentAddress withLanguageCode(String languageCode) { + this.languageCode = languageCode; + return this; + } + + /** + * Get the organization value. + * + * @return the organization value + */ + public String organization() { + return this.organization; + } + + /** + * Set the organization value. + * + * @param organization the organization value to set + * @return the PaymentAddress object itself. + */ + public PaymentAddress withOrganization(String organization) { + this.organization = organization; + return this; + } + + /** + * Get the recipient value. + * + * @return the recipient value + */ + public String recipient() { + return this.recipient; + } + + /** + * Set the recipient value. + * + * @param recipient the recipient value to set + * @return the PaymentAddress object itself. + */ + public PaymentAddress withRecipient(String recipient) { + this.recipient = recipient; + return this; + } + + /** + * Get the phone value. + * + * @return the phone value + */ + public String phone() { + return this.phone; + } + + /** + * Set the phone value. + * + * @param phone the phone value to set + * @return the PaymentAddress object itself. + */ + public PaymentAddress withPhone(String phone) { + this.phone = phone; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentCurrencyAmount.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentCurrencyAmount.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentCurrencyAmount.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentCurrencyAmount.java index c954bca5..d210b415 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentCurrencyAmount.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentCurrencyAmount.java @@ -1,97 +1,97 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Supplies monetary amounts. - */ -public class PaymentCurrencyAmount { - /** - * A currency identifier. - */ - @JsonProperty(value = "currency") - private String currency; - - /** - * Decimal monetary value. - */ - @JsonProperty(value = "value") - private String value; - - /** - * Currency system. - */ - @JsonProperty(value = "currencySystem") - private String currencySystem; - - /** - * Get the currency value. - * - * @return the currency value - */ - public String currency() { - return this.currency; - } - - /** - * Set the currency value. - * - * @param currency the currency value to set - * @return the PaymentCurrencyAmount object itself. - */ - public PaymentCurrencyAmount withCurrency(String currency) { - this.currency = currency; - return this; - } - - /** - * Get the value value. - * - * @return the value value - */ - public String value() { - return this.value; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the PaymentCurrencyAmount object itself. - */ - public PaymentCurrencyAmount withValue(String value) { - this.value = value; - return this; - } - - /** - * Get the currencySystem value. - * - * @return the currencySystem value - */ - public String currencySystem() { - return this.currencySystem; - } - - /** - * Set the currencySystem value. - * - * @param currencySystem the currencySystem value to set - * @return the PaymentCurrencyAmount object itself. - */ - public PaymentCurrencyAmount withCurrencySystem(String currencySystem) { - this.currencySystem = currencySystem; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Supplies monetary amounts. + */ +public class PaymentCurrencyAmount { + /** + * A currency identifier. + */ + @JsonProperty(value = "currency") + private String currency; + + /** + * Decimal monetary value. + */ + @JsonProperty(value = "value") + private String value; + + /** + * Currency system. + */ + @JsonProperty(value = "currencySystem") + private String currencySystem; + + /** + * Get the currency value. + * + * @return the currency value + */ + public String currency() { + return this.currency; + } + + /** + * Set the currency value. + * + * @param currency the currency value to set + * @return the PaymentCurrencyAmount object itself. + */ + public PaymentCurrencyAmount withCurrency(String currency) { + this.currency = currency; + return this; + } + + /** + * Get the value value. + * + * @return the value value + */ + public String value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the PaymentCurrencyAmount object itself. + */ + public PaymentCurrencyAmount withValue(String value) { + this.value = value; + return this; + } + + /** + * Get the currencySystem value. + * + * @return the currencySystem value + */ + public String currencySystem() { + return this.currencySystem; + } + + /** + * Set the currencySystem value. + * + * @param currencySystem the currencySystem value to set + * @return the PaymentCurrencyAmount object itself. + */ + public PaymentCurrencyAmount withCurrencySystem(String currencySystem) { + this.currencySystem = currencySystem; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentDetails.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentDetails.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentDetails.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentDetails.java index cd093455..07561f55 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentDetails.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentDetails.java @@ -1,152 +1,152 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Provides information about the requested transaction. - */ -public class PaymentDetails { - /** - * Contains the total amount of the payment request. - */ - @JsonProperty(value = "total") - private PaymentItem total; - - /** - * Contains line items for the payment request that the user agent may - * display. - */ - @JsonProperty(value = "displayItems") - private List displayItems; - - /** - * A sequence containing the different shipping options for the user to - * choose from. - */ - @JsonProperty(value = "shippingOptions") - private List shippingOptions; - - /** - * Contains modifiers for particular payment method identifiers. - */ - @JsonProperty(value = "modifiers") - private List modifiers; - - /** - * Error description. - */ - @JsonProperty(value = "error") - private String error; - - /** - * Get the total value. - * - * @return the total value - */ - public PaymentItem total() { - return this.total; - } - - /** - * Set the total value. - * - * @param total the total value to set - * @return the PaymentDetails object itself. - */ - public PaymentDetails withTotal(PaymentItem total) { - this.total = total; - return this; - } - - /** - * Get the displayItems value. - * - * @return the displayItems value - */ - public List displayItems() { - return this.displayItems; - } - - /** - * Set the displayItems value. - * - * @param displayItems the displayItems value to set - * @return the PaymentDetails object itself. - */ - public PaymentDetails withDisplayItems(List displayItems) { - this.displayItems = displayItems; - return this; - } - - /** - * Get the shippingOptions value. - * - * @return the shippingOptions value - */ - public List shippingOptions() { - return this.shippingOptions; - } - - /** - * Set the shippingOptions value. - * - * @param shippingOptions the shippingOptions value to set - * @return the PaymentDetails object itself. - */ - public PaymentDetails withShippingOptions(List shippingOptions) { - this.shippingOptions = shippingOptions; - return this; - } - - /** - * Get the modifiers value. - * - * @return the modifiers value - */ - public List modifiers() { - return this.modifiers; - } - - /** - * Set the modifiers value. - * - * @param modifiers the modifiers value to set - * @return the PaymentDetails object itself. - */ - public PaymentDetails withModifiers(List modifiers) { - this.modifiers = modifiers; - return this; - } - - /** - * Get the error value. - * - * @return the error value - */ - public String error() { - return this.error; - } - - /** - * Set the error value. - * - * @param error the error value to set - * @return the PaymentDetails object itself. - */ - public PaymentDetails withError(String error) { - this.error = error; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Provides information about the requested transaction. + */ +public class PaymentDetails { + /** + * Contains the total amount of the payment request. + */ + @JsonProperty(value = "total") + private PaymentItem total; + + /** + * Contains line items for the payment request that the user agent may + * display. + */ + @JsonProperty(value = "displayItems") + private List displayItems; + + /** + * A sequence containing the different shipping options for the user to + * choose from. + */ + @JsonProperty(value = "shippingOptions") + private List shippingOptions; + + /** + * Contains modifiers for particular payment method identifiers. + */ + @JsonProperty(value = "modifiers") + private List modifiers; + + /** + * Error description. + */ + @JsonProperty(value = "error") + private String error; + + /** + * Get the total value. + * + * @return the total value + */ + public PaymentItem total() { + return this.total; + } + + /** + * Set the total value. + * + * @param total the total value to set + * @return the PaymentDetails object itself. + */ + public PaymentDetails withTotal(PaymentItem total) { + this.total = total; + return this; + } + + /** + * Get the displayItems value. + * + * @return the displayItems value + */ + public List displayItems() { + return this.displayItems; + } + + /** + * Set the displayItems value. + * + * @param displayItems the displayItems value to set + * @return the PaymentDetails object itself. + */ + public PaymentDetails withDisplayItems(List displayItems) { + this.displayItems = displayItems; + return this; + } + + /** + * Get the shippingOptions value. + * + * @return the shippingOptions value + */ + public List shippingOptions() { + return this.shippingOptions; + } + + /** + * Set the shippingOptions value. + * + * @param shippingOptions the shippingOptions value to set + * @return the PaymentDetails object itself. + */ + public PaymentDetails withShippingOptions(List shippingOptions) { + this.shippingOptions = shippingOptions; + return this; + } + + /** + * Get the modifiers value. + * + * @return the modifiers value + */ + public List modifiers() { + return this.modifiers; + } + + /** + * Set the modifiers value. + * + * @param modifiers the modifiers value to set + * @return the PaymentDetails object itself. + */ + public PaymentDetails withModifiers(List modifiers) { + this.modifiers = modifiers; + return this; + } + + /** + * Get the error value. + * + * @return the error value + */ + public String error() { + return this.error; + } + + /** + * Set the error value. + * + * @param error the error value to set + * @return the PaymentDetails object itself. + */ + public PaymentDetails withError(String error) { + this.error = error; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentDetailsModifier.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentDetailsModifier.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentDetailsModifier.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentDetailsModifier.java index 2d0c937f..12b3e36c 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentDetailsModifier.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentDetailsModifier.java @@ -1,129 +1,129 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Provides details that modify the PaymentDetails based on payment method - * identifier. - */ -public class PaymentDetailsModifier { - /** - * Contains a sequence of payment method identifiers. - */ - @JsonProperty(value = "supportedMethods") - private List supportedMethods; - - /** - * This value overrides the total field in the PaymentDetails dictionary - * for the payment method identifiers in the supportedMethods field. - */ - @JsonProperty(value = "total") - private PaymentItem total; - - /** - * Provides additional display items that are appended to the displayItems - * field in the PaymentDetails dictionary for the payment method - * identifiers in the supportedMethods field. - */ - @JsonProperty(value = "additionalDisplayItems") - private List additionalDisplayItems; - - /** - * A JSON-serializable object that provides optional information that might - * be needed by the supported payment methods. - */ - @JsonProperty(value = "data") - private Object data; - - /** - * Get the supportedMethods value. - * - * @return the supportedMethods value - */ - public List supportedMethods() { - return this.supportedMethods; - } - - /** - * Set the supportedMethods value. - * - * @param supportedMethods the supportedMethods value to set - * @return the PaymentDetailsModifier object itself. - */ - public PaymentDetailsModifier withSupportedMethods(List supportedMethods) { - this.supportedMethods = supportedMethods; - return this; - } - - /** - * Get the total value. - * - * @return the total value - */ - public PaymentItem total() { - return this.total; - } - - /** - * Set the total value. - * - * @param total the total value to set - * @return the PaymentDetailsModifier object itself. - */ - public PaymentDetailsModifier withTotal(PaymentItem total) { - this.total = total; - return this; - } - - /** - * Get the additionalDisplayItems value. - * - * @return the additionalDisplayItems value - */ - public List additionalDisplayItems() { - return this.additionalDisplayItems; - } - - /** - * Set the additionalDisplayItems value. - * - * @param additionalDisplayItems the additionalDisplayItems value to set - * @return the PaymentDetailsModifier object itself. - */ - public PaymentDetailsModifier withAdditionalDisplayItems(List additionalDisplayItems) { - this.additionalDisplayItems = additionalDisplayItems; - return this; - } - - /** - * Get the data value. - * - * @return the data value - */ - public Object data() { - return this.data; - } - - /** - * Set the data value. - * - * @param data the data value to set - * @return the PaymentDetailsModifier object itself. - */ - public PaymentDetailsModifier withData(Object data) { - this.data = data; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Provides details that modify the PaymentDetails based on payment method + * identifier. + */ +public class PaymentDetailsModifier { + /** + * Contains a sequence of payment method identifiers. + */ + @JsonProperty(value = "supportedMethods") + private List supportedMethods; + + /** + * This value overrides the total field in the PaymentDetails dictionary + * for the payment method identifiers in the supportedMethods field. + */ + @JsonProperty(value = "total") + private PaymentItem total; + + /** + * Provides additional display items that are appended to the displayItems + * field in the PaymentDetails dictionary for the payment method + * identifiers in the supportedMethods field. + */ + @JsonProperty(value = "additionalDisplayItems") + private List additionalDisplayItems; + + /** + * A JSON-serializable object that provides optional information that might + * be needed by the supported payment methods. + */ + @JsonProperty(value = "data") + private Object data; + + /** + * Get the supportedMethods value. + * + * @return the supportedMethods value + */ + public List supportedMethods() { + return this.supportedMethods; + } + + /** + * Set the supportedMethods value. + * + * @param supportedMethods the supportedMethods value to set + * @return the PaymentDetailsModifier object itself. + */ + public PaymentDetailsModifier withSupportedMethods(List supportedMethods) { + this.supportedMethods = supportedMethods; + return this; + } + + /** + * Get the total value. + * + * @return the total value + */ + public PaymentItem total() { + return this.total; + } + + /** + * Set the total value. + * + * @param total the total value to set + * @return the PaymentDetailsModifier object itself. + */ + public PaymentDetailsModifier withTotal(PaymentItem total) { + this.total = total; + return this; + } + + /** + * Get the additionalDisplayItems value. + * + * @return the additionalDisplayItems value + */ + public List additionalDisplayItems() { + return this.additionalDisplayItems; + } + + /** + * Set the additionalDisplayItems value. + * + * @param additionalDisplayItems the additionalDisplayItems value to set + * @return the PaymentDetailsModifier object itself. + */ + public PaymentDetailsModifier withAdditionalDisplayItems(List additionalDisplayItems) { + this.additionalDisplayItems = additionalDisplayItems; + return this; + } + + /** + * Get the data value. + * + * @return the data value + */ + public Object data() { + return this.data; + } + + /** + * Set the data value. + * + * @param data the data value to set + * @return the PaymentDetailsModifier object itself. + */ + public PaymentDetailsModifier withData(Object data) { + this.data = data; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentItem.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentItem.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentItem.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentItem.java index ca15ce80..9d707242 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentItem.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentItem.java @@ -1,97 +1,97 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Indicates what the payment request is for and the value asked for. - */ -public class PaymentItem { - /** - * Human-readable description of the item. - */ - @JsonProperty(value = "label") - private String label; - - /** - * Monetary amount for the item. - */ - @JsonProperty(value = "amount") - private PaymentCurrencyAmount amount; - - /** - * When set to true this flag means that the amount field is not final. - */ - @JsonProperty(value = "pending") - private Boolean pending; - - /** - * Get the label value. - * - * @return the label value - */ - public String label() { - return this.label; - } - - /** - * Set the label value. - * - * @param label the label value to set - * @return the PaymentItem object itself. - */ - public PaymentItem withLabel(String label) { - this.label = label; - return this; - } - - /** - * Get the amount value. - * - * @return the amount value - */ - public PaymentCurrencyAmount amount() { - return this.amount; - } - - /** - * Set the amount value. - * - * @param amount the amount value to set - * @return the PaymentItem object itself. - */ - public PaymentItem withAmount(PaymentCurrencyAmount amount) { - this.amount = amount; - return this; - } - - /** - * Get the pending value. - * - * @return the pending value - */ - public Boolean pending() { - return this.pending; - } - - /** - * Set the pending value. - * - * @param pending the pending value to set - * @return the PaymentItem object itself. - */ - public PaymentItem withPending(Boolean pending) { - this.pending = pending; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Indicates what the payment request is for and the value asked for. + */ +public class PaymentItem { + /** + * Human-readable description of the item. + */ + @JsonProperty(value = "label") + private String label; + + /** + * Monetary amount for the item. + */ + @JsonProperty(value = "amount") + private PaymentCurrencyAmount amount; + + /** + * When set to true this flag means that the amount field is not final. + */ + @JsonProperty(value = "pending") + private Boolean pending; + + /** + * Get the label value. + * + * @return the label value + */ + public String label() { + return this.label; + } + + /** + * Set the label value. + * + * @param label the label value to set + * @return the PaymentItem object itself. + */ + public PaymentItem withLabel(String label) { + this.label = label; + return this; + } + + /** + * Get the amount value. + * + * @return the amount value + */ + public PaymentCurrencyAmount amount() { + return this.amount; + } + + /** + * Set the amount value. + * + * @param amount the amount value to set + * @return the PaymentItem object itself. + */ + public PaymentItem withAmount(PaymentCurrencyAmount amount) { + this.amount = amount; + return this; + } + + /** + * Get the pending value. + * + * @return the pending value + */ + public Boolean pending() { + return this.pending; + } + + /** + * Set the pending value. + * + * @param pending the pending value to set + * @return the PaymentItem object itself. + */ + public PaymentItem withPending(Boolean pending) { + this.pending = pending; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentMethodData.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentMethodData.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentMethodData.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentMethodData.java index 0564459f..94cd64bf 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentMethodData.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentMethodData.java @@ -1,75 +1,75 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Indicates a set of supported payment methods and any associated payment - * method specific data for those methods. - */ -public class PaymentMethodData { - /** - * Required sequence of strings containing payment method identifiers for - * payment methods that the merchant web site accepts. - */ - @JsonProperty(value = "supportedMethods") - private List supportedMethods; - - /** - * A JSON-serializable object that provides optional information that might - * be needed by the supported payment methods. - */ - @JsonProperty(value = "data") - private Object data; - - /** - * Get the supportedMethods value. - * - * @return the supportedMethods value - */ - public List supportedMethods() { - return this.supportedMethods; - } - - /** - * Set the supportedMethods value. - * - * @param supportedMethods the supportedMethods value to set - * @return the PaymentMethodData object itself. - */ - public PaymentMethodData withSupportedMethods(List supportedMethods) { - this.supportedMethods = supportedMethods; - return this; - } - - /** - * Get the data value. - * - * @return the data value - */ - public Object data() { - return this.data; - } - - /** - * Set the data value. - * - * @param data the data value to set - * @return the PaymentMethodData object itself. - */ - public PaymentMethodData withData(Object data) { - this.data = data; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Indicates a set of supported payment methods and any associated payment + * method specific data for those methods. + */ +public class PaymentMethodData { + /** + * Required sequence of strings containing payment method identifiers for + * payment methods that the merchant web site accepts. + */ + @JsonProperty(value = "supportedMethods") + private List supportedMethods; + + /** + * A JSON-serializable object that provides optional information that might + * be needed by the supported payment methods. + */ + @JsonProperty(value = "data") + private Object data; + + /** + * Get the supportedMethods value. + * + * @return the supportedMethods value + */ + public List supportedMethods() { + return this.supportedMethods; + } + + /** + * Set the supportedMethods value. + * + * @param supportedMethods the supportedMethods value to set + * @return the PaymentMethodData object itself. + */ + public PaymentMethodData withSupportedMethods(List supportedMethods) { + this.supportedMethods = supportedMethods; + return this; + } + + /** + * Get the data value. + * + * @return the data value + */ + public Object data() { + return this.data; + } + + /** + * Set the data value. + * + * @param data the data value to set + * @return the PaymentMethodData object itself. + */ + public PaymentMethodData withData(Object data) { + this.data = data; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentOptions.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentOptions.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentOptions.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentOptions.java index c9a0f4c6..86ac8fd6 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentOptions.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentOptions.java @@ -1,155 +1,155 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Provides information about the options desired for the payment request. - */ -public class PaymentOptions { - /** - * Indicates whether the user agent should collect and return the payer's - * name as part of the payment request. - */ - @JsonProperty(value = "requestPayerName") - private Boolean requestPayerName; - - /** - * Indicates whether the user agent should collect and return the payer's - * email address as part of the payment request. - */ - @JsonProperty(value = "requestPayerEmail") - private Boolean requestPayerEmail; - - /** - * Indicates whether the user agent should collect and return the payer's - * phone number as part of the payment request. - */ - @JsonProperty(value = "requestPayerPhone") - private Boolean requestPayerPhone; - - /** - * Indicates whether the user agent should collect and return a shipping - * address as part of the payment request. - */ - @JsonProperty(value = "requestShipping") - private Boolean requestShipping; - - /** - * If requestShipping is set to true, then the shippingType field may be - * used to influence the way the user agent presents the user interface for - * gathering the shipping address. - */ - @JsonProperty(value = "shippingType") - private String shippingType; - - /** - * Get the requestPayerName value. - * - * @return the requestPayerName value - */ - public Boolean requestPayerName() { - return this.requestPayerName; - } - - /** - * Set the requestPayerName value. - * - * @param requestPayerName the requestPayerName value to set - * @return the PaymentOptions object itself. - */ - public PaymentOptions withRequestPayerName(Boolean requestPayerName) { - this.requestPayerName = requestPayerName; - return this; - } - - /** - * Get the requestPayerEmail value. - * - * @return the requestPayerEmail value - */ - public Boolean requestPayerEmail() { - return this.requestPayerEmail; - } - - /** - * Set the requestPayerEmail value. - * - * @param requestPayerEmail the requestPayerEmail value to set - * @return the PaymentOptions object itself. - */ - public PaymentOptions withRequestPayerEmail(Boolean requestPayerEmail) { - this.requestPayerEmail = requestPayerEmail; - return this; - } - - /** - * Get the requestPayerPhone value. - * - * @return the requestPayerPhone value - */ - public Boolean requestPayerPhone() { - return this.requestPayerPhone; - } - - /** - * Set the requestPayerPhone value. - * - * @param requestPayerPhone the requestPayerPhone value to set - * @return the PaymentOptions object itself. - */ - public PaymentOptions withRequestPayerPhone(Boolean requestPayerPhone) { - this.requestPayerPhone = requestPayerPhone; - return this; - } - - /** - * Get the requestShipping value. - * - * @return the requestShipping value - */ - public Boolean requestShipping() { - return this.requestShipping; - } - - /** - * Set the requestShipping value. - * - * @param requestShipping the requestShipping value to set - * @return the PaymentOptions object itself. - */ - public PaymentOptions withRequestShipping(Boolean requestShipping) { - this.requestShipping = requestShipping; - return this; - } - - /** - * Get the shippingType value. - * - * @return the shippingType value - */ - public String shippingType() { - return this.shippingType; - } - - /** - * Set the shippingType value. - * - * @param shippingType the shippingType value to set - * @return the PaymentOptions object itself. - */ - public PaymentOptions withShippingType(String shippingType) { - this.shippingType = shippingType; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Provides information about the options desired for the payment request. + */ +public class PaymentOptions { + /** + * Indicates whether the user agent should collect and return the payer's + * name as part of the payment request. + */ + @JsonProperty(value = "requestPayerName") + private Boolean requestPayerName; + + /** + * Indicates whether the user agent should collect and return the payer's + * email address as part of the payment request. + */ + @JsonProperty(value = "requestPayerEmail") + private Boolean requestPayerEmail; + + /** + * Indicates whether the user agent should collect and return the payer's + * phone number as part of the payment request. + */ + @JsonProperty(value = "requestPayerPhone") + private Boolean requestPayerPhone; + + /** + * Indicates whether the user agent should collect and return a shipping + * address as part of the payment request. + */ + @JsonProperty(value = "requestShipping") + private Boolean requestShipping; + + /** + * If requestShipping is set to true, then the shippingType field may be + * used to influence the way the user agent presents the user interface for + * gathering the shipping address. + */ + @JsonProperty(value = "shippingType") + private String shippingType; + + /** + * Get the requestPayerName value. + * + * @return the requestPayerName value + */ + public Boolean requestPayerName() { + return this.requestPayerName; + } + + /** + * Set the requestPayerName value. + * + * @param requestPayerName the requestPayerName value to set + * @return the PaymentOptions object itself. + */ + public PaymentOptions withRequestPayerName(Boolean requestPayerName) { + this.requestPayerName = requestPayerName; + return this; + } + + /** + * Get the requestPayerEmail value. + * + * @return the requestPayerEmail value + */ + public Boolean requestPayerEmail() { + return this.requestPayerEmail; + } + + /** + * Set the requestPayerEmail value. + * + * @param requestPayerEmail the requestPayerEmail value to set + * @return the PaymentOptions object itself. + */ + public PaymentOptions withRequestPayerEmail(Boolean requestPayerEmail) { + this.requestPayerEmail = requestPayerEmail; + return this; + } + + /** + * Get the requestPayerPhone value. + * + * @return the requestPayerPhone value + */ + public Boolean requestPayerPhone() { + return this.requestPayerPhone; + } + + /** + * Set the requestPayerPhone value. + * + * @param requestPayerPhone the requestPayerPhone value to set + * @return the PaymentOptions object itself. + */ + public PaymentOptions withRequestPayerPhone(Boolean requestPayerPhone) { + this.requestPayerPhone = requestPayerPhone; + return this; + } + + /** + * Get the requestShipping value. + * + * @return the requestShipping value + */ + public Boolean requestShipping() { + return this.requestShipping; + } + + /** + * Set the requestShipping value. + * + * @param requestShipping the requestShipping value to set + * @return the PaymentOptions object itself. + */ + public PaymentOptions withRequestShipping(Boolean requestShipping) { + this.requestShipping = requestShipping; + return this; + } + + /** + * Get the shippingType value. + * + * @return the shippingType value + */ + public String shippingType() { + return this.shippingType; + } + + /** + * Set the shippingType value. + * + * @param shippingType the shippingType value to set + * @return the PaymentOptions object itself. + */ + public PaymentOptions withShippingType(String shippingType) { + this.shippingType = shippingType; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequest.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequest.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequest.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequest.java index d4c931ad..07b22384 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequest.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequest.java @@ -1,150 +1,150 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A request to make a payment. - */ -public class PaymentRequest { - /** - * ID of this payment request. - */ - @JsonProperty(value = "id") - private String id; - - /** - * Allowed payment methods for this request. - */ - @JsonProperty(value = "methodData") - private List methodData; - - /** - * Details for this request. - */ - @JsonProperty(value = "details") - private PaymentDetails details; - - /** - * Provides information about the options desired for the payment request. - */ - @JsonProperty(value = "options") - private PaymentOptions options; - - /** - * Expiration for this request, in ISO 8601 duration format (e.g., 'P1D'). - */ - @JsonProperty(value = "expires") - private String expires; - - /** - * Get the id value. - * - * @return the id value - */ - public String id() { - return this.id; - } - - /** - * Set the id value. - * - * @param id the id value to set - * @return the PaymentRequest object itself. - */ - public PaymentRequest withId(String id) { - this.id = id; - return this; - } - - /** - * Get the methodData value. - * - * @return the methodData value - */ - public List methodData() { - return this.methodData; - } - - /** - * Set the methodData value. - * - * @param methodData the methodData value to set - * @return the PaymentRequest object itself. - */ - public PaymentRequest withMethodData(List methodData) { - this.methodData = methodData; - return this; - } - - /** - * Get the details value. - * - * @return the details value - */ - public PaymentDetails details() { - return this.details; - } - - /** - * Set the details value. - * - * @param details the details value to set - * @return the PaymentRequest object itself. - */ - public PaymentRequest withDetails(PaymentDetails details) { - this.details = details; - return this; - } - - /** - * Get the options value. - * - * @return the options value - */ - public PaymentOptions options() { - return this.options; - } - - /** - * Set the options value. - * - * @param options the options value to set - * @return the PaymentRequest object itself. - */ - public PaymentRequest withOptions(PaymentOptions options) { - this.options = options; - return this; - } - - /** - * Get the expires value. - * - * @return the expires value - */ - public String expires() { - return this.expires; - } - - /** - * Set the expires value. - * - * @param expires the expires value to set - * @return the PaymentRequest object itself. - */ - public PaymentRequest withExpires(String expires) { - this.expires = expires; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A request to make a payment. + */ +public class PaymentRequest { + /** + * ID of this payment request. + */ + @JsonProperty(value = "id") + private String id; + + /** + * Allowed payment methods for this request. + */ + @JsonProperty(value = "methodData") + private List methodData; + + /** + * Details for this request. + */ + @JsonProperty(value = "details") + private PaymentDetails details; + + /** + * Provides information about the options desired for the payment request. + */ + @JsonProperty(value = "options") + private PaymentOptions options; + + /** + * Expiration for this request, in ISO 8601 duration format (e.g., 'P1D'). + */ + @JsonProperty(value = "expires") + private String expires; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the PaymentRequest object itself. + */ + public PaymentRequest withId(String id) { + this.id = id; + return this; + } + + /** + * Get the methodData value. + * + * @return the methodData value + */ + public List methodData() { + return this.methodData; + } + + /** + * Set the methodData value. + * + * @param methodData the methodData value to set + * @return the PaymentRequest object itself. + */ + public PaymentRequest withMethodData(List methodData) { + this.methodData = methodData; + return this; + } + + /** + * Get the details value. + * + * @return the details value + */ + public PaymentDetails details() { + return this.details; + } + + /** + * Set the details value. + * + * @param details the details value to set + * @return the PaymentRequest object itself. + */ + public PaymentRequest withDetails(PaymentDetails details) { + this.details = details; + return this; + } + + /** + * Get the options value. + * + * @return the options value + */ + public PaymentOptions options() { + return this.options; + } + + /** + * Set the options value. + * + * @param options the options value to set + * @return the PaymentRequest object itself. + */ + public PaymentRequest withOptions(PaymentOptions options) { + this.options = options; + return this; + } + + /** + * Get the expires value. + * + * @return the expires value + */ + public String expires() { + return this.expires; + } + + /** + * Set the expires value. + * + * @param expires the expires value to set + * @return the PaymentRequest object itself. + */ + public PaymentRequest withExpires(String expires) { + this.expires = expires; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestComplete.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestComplete.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestComplete.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestComplete.java index 413bba39..cb75350c 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestComplete.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestComplete.java @@ -1,97 +1,97 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Payload delivered when completing a payment request. - */ -public class PaymentRequestComplete { - /** - * Payment request ID. - */ - @JsonProperty(value = "id") - private String id; - - /** - * Initial payment request. - */ - @JsonProperty(value = "paymentRequest") - private PaymentRequest paymentRequest; - - /** - * Corresponding payment response. - */ - @JsonProperty(value = "paymentResponse") - private PaymentResponse paymentResponse; - - /** - * Get the id value. - * - * @return the id value - */ - public String id() { - return this.id; - } - - /** - * Set the id value. - * - * @param id the id value to set - * @return the PaymentRequestComplete object itself. - */ - public PaymentRequestComplete withId(String id) { - this.id = id; - return this; - } - - /** - * Get the paymentRequest value. - * - * @return the paymentRequest value - */ - public PaymentRequest paymentRequest() { - return this.paymentRequest; - } - - /** - * Set the paymentRequest value. - * - * @param paymentRequest the paymentRequest value to set - * @return the PaymentRequestComplete object itself. - */ - public PaymentRequestComplete withPaymentRequest(PaymentRequest paymentRequest) { - this.paymentRequest = paymentRequest; - return this; - } - - /** - * Get the paymentResponse value. - * - * @return the paymentResponse value - */ - public PaymentResponse paymentResponse() { - return this.paymentResponse; - } - - /** - * Set the paymentResponse value. - * - * @param paymentResponse the paymentResponse value to set - * @return the PaymentRequestComplete object itself. - */ - public PaymentRequestComplete withPaymentResponse(PaymentResponse paymentResponse) { - this.paymentResponse = paymentResponse; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Payload delivered when completing a payment request. + */ +public class PaymentRequestComplete { + /** + * Payment request ID. + */ + @JsonProperty(value = "id") + private String id; + + /** + * Initial payment request. + */ + @JsonProperty(value = "paymentRequest") + private PaymentRequest paymentRequest; + + /** + * Corresponding payment response. + */ + @JsonProperty(value = "paymentResponse") + private PaymentResponse paymentResponse; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the PaymentRequestComplete object itself. + */ + public PaymentRequestComplete withId(String id) { + this.id = id; + return this; + } + + /** + * Get the paymentRequest value. + * + * @return the paymentRequest value + */ + public PaymentRequest paymentRequest() { + return this.paymentRequest; + } + + /** + * Set the paymentRequest value. + * + * @param paymentRequest the paymentRequest value to set + * @return the PaymentRequestComplete object itself. + */ + public PaymentRequestComplete withPaymentRequest(PaymentRequest paymentRequest) { + this.paymentRequest = paymentRequest; + return this; + } + + /** + * Get the paymentResponse value. + * + * @return the paymentResponse value + */ + public PaymentResponse paymentResponse() { + return this.paymentResponse; + } + + /** + * Set the paymentResponse value. + * + * @param paymentResponse the paymentResponse value to set + * @return the PaymentRequestComplete object itself. + */ + public PaymentRequestComplete withPaymentResponse(PaymentResponse paymentResponse) { + this.paymentResponse = paymentResponse; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestCompleteResult.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestCompleteResult.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestCompleteResult.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestCompleteResult.java index 3741dd01..fc89d4f3 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestCompleteResult.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestCompleteResult.java @@ -1,45 +1,45 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Result from a completed payment request. - */ -public class PaymentRequestCompleteResult { - /** - * Result of the payment request completion. - */ - @JsonProperty(value = "result") - private String result; - - /** - * Get the result value. - * - * @return the result value - */ - public String result() { - return this.result; - } - - /** - * Set the result value. - * - * @param result the result value to set - * @return the PaymentRequestCompleteResult object itself. - */ - public PaymentRequestCompleteResult withResult(String result) { - this.result = result; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Result from a completed payment request. + */ +public class PaymentRequestCompleteResult { + /** + * Result of the payment request completion. + */ + @JsonProperty(value = "result") + private String result; + + /** + * Get the result value. + * + * @return the result value + */ + public String result() { + return this.result; + } + + /** + * Set the result value. + * + * @param result the result value to set + * @return the PaymentRequestCompleteResult object itself. + */ + public PaymentRequestCompleteResult withResult(String result) { + this.result = result; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestUpdate.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestUpdate.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestUpdate.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestUpdate.java index 68843cc0..316ddcfa 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestUpdate.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestUpdate.java @@ -1,123 +1,123 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * An update to a payment request. - */ -public class PaymentRequestUpdate { - /** - * ID for the payment request to update. - */ - @JsonProperty(value = "id") - private String id; - - /** - * Update payment details. - */ - @JsonProperty(value = "details") - private PaymentDetails details; - - /** - * Updated shipping address. - */ - @JsonProperty(value = "shippingAddress") - private PaymentAddress shippingAddress; - - /** - * Updated shipping options. - */ - @JsonProperty(value = "shippingOption") - private String shippingOption; - - /** - * Get the id value. - * - * @return the id value - */ - public String id() { - return this.id; - } - - /** - * Set the id value. - * - * @param id the id value to set - * @return the PaymentRequestUpdate object itself. - */ - public PaymentRequestUpdate withId(String id) { - this.id = id; - return this; - } - - /** - * Get the details value. - * - * @return the details value - */ - public PaymentDetails details() { - return this.details; - } - - /** - * Set the details value. - * - * @param details the details value to set - * @return the PaymentRequestUpdate object itself. - */ - public PaymentRequestUpdate withDetails(PaymentDetails details) { - this.details = details; - return this; - } - - /** - * Get the shippingAddress value. - * - * @return the shippingAddress value - */ - public PaymentAddress shippingAddress() { - return this.shippingAddress; - } - - /** - * Set the shippingAddress value. - * - * @param shippingAddress the shippingAddress value to set - * @return the PaymentRequestUpdate object itself. - */ - public PaymentRequestUpdate withShippingAddress(PaymentAddress shippingAddress) { - this.shippingAddress = shippingAddress; - return this; - } - - /** - * Get the shippingOption value. - * - * @return the shippingOption value - */ - public String shippingOption() { - return this.shippingOption; - } - - /** - * Set the shippingOption value. - * - * @param shippingOption the shippingOption value to set - * @return the PaymentRequestUpdate object itself. - */ - public PaymentRequestUpdate withShippingOption(String shippingOption) { - this.shippingOption = shippingOption; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * An update to a payment request. + */ +public class PaymentRequestUpdate { + /** + * ID for the payment request to update. + */ + @JsonProperty(value = "id") + private String id; + + /** + * Update payment details. + */ + @JsonProperty(value = "details") + private PaymentDetails details; + + /** + * Updated shipping address. + */ + @JsonProperty(value = "shippingAddress") + private PaymentAddress shippingAddress; + + /** + * Updated shipping options. + */ + @JsonProperty(value = "shippingOption") + private String shippingOption; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the PaymentRequestUpdate object itself. + */ + public PaymentRequestUpdate withId(String id) { + this.id = id; + return this; + } + + /** + * Get the details value. + * + * @return the details value + */ + public PaymentDetails details() { + return this.details; + } + + /** + * Set the details value. + * + * @param details the details value to set + * @return the PaymentRequestUpdate object itself. + */ + public PaymentRequestUpdate withDetails(PaymentDetails details) { + this.details = details; + return this; + } + + /** + * Get the shippingAddress value. + * + * @return the shippingAddress value + */ + public PaymentAddress shippingAddress() { + return this.shippingAddress; + } + + /** + * Set the shippingAddress value. + * + * @param shippingAddress the shippingAddress value to set + * @return the PaymentRequestUpdate object itself. + */ + public PaymentRequestUpdate withShippingAddress(PaymentAddress shippingAddress) { + this.shippingAddress = shippingAddress; + return this; + } + + /** + * Get the shippingOption value. + * + * @return the shippingOption value + */ + public String shippingOption() { + return this.shippingOption; + } + + /** + * Set the shippingOption value. + * + * @param shippingOption the shippingOption value to set + * @return the PaymentRequestUpdate object itself. + */ + public PaymentRequestUpdate withShippingOption(String shippingOption) { + this.shippingOption = shippingOption; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestUpdateResult.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestUpdateResult.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestUpdateResult.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestUpdateResult.java index 4088b7f5..9f0552f2 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestUpdateResult.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentRequestUpdateResult.java @@ -1,45 +1,45 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A result object from a Payment Request Update invoke operation. - */ -public class PaymentRequestUpdateResult { - /** - * Update payment details. - */ - @JsonProperty(value = "details") - private PaymentDetails details; - - /** - * Get the details value. - * - * @return the details value - */ - public PaymentDetails details() { - return this.details; - } - - /** - * Set the details value. - * - * @param details the details value to set - * @return the PaymentRequestUpdateResult object itself. - */ - public PaymentRequestUpdateResult withDetails(PaymentDetails details) { - this.details = details; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A result object from a Payment Request Update invoke operation. + */ +public class PaymentRequestUpdateResult { + /** + * Update payment details. + */ + @JsonProperty(value = "details") + private PaymentDetails details; + + /** + * Get the details value. + * + * @return the details value + */ + public PaymentDetails details() { + return this.details; + } + + /** + * Set the details value. + * + * @param details the details value to set + * @return the PaymentRequestUpdateResult object itself. + */ + public PaymentRequestUpdateResult withDetails(PaymentDetails details) { + this.details = details; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentResponse.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentResponse.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentResponse.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentResponse.java index d531ccca..85287f20 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentResponse.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentResponse.java @@ -1,187 +1,187 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A PaymentResponse is returned when a user has selected a payment method and - * approved a payment request. - */ -public class PaymentResponse { - /** - * The payment method identifier for the payment method that the user - * selected to fulfil the transaction. - */ - @JsonProperty(value = "methodName") - private String methodName; - - /** - * A JSON-serializable object that provides a payment method specific - * message used by the merchant to process the transaction and determine - * successful fund transfer. - */ - @JsonProperty(value = "details") - private Object details; - - /** - * If the requestShipping flag was set to true in the PaymentOptions passed - * to the PaymentRequest constructor, then shippingAddress will be the full - * and final shipping address chosen by the user. - */ - @JsonProperty(value = "shippingAddress") - private PaymentAddress shippingAddress; - - /** - * If the requestShipping flag was set to true in the PaymentOptions passed - * to the PaymentRequest constructor, then shippingOption will be the id - * attribute of the selected shipping option. - */ - @JsonProperty(value = "shippingOption") - private String shippingOption; - - /** - * If the requestPayerEmail flag was set to true in the PaymentOptions - * passed to the PaymentRequest constructor, then payerEmail will be the - * email address chosen by the user. - */ - @JsonProperty(value = "payerEmail") - private String payerEmail; - - /** - * If the requestPayerPhone flag was set to true in the PaymentOptions - * passed to the PaymentRequest constructor, then payerPhone will be the - * phone number chosen by the user. - */ - @JsonProperty(value = "payerPhone") - private String payerPhone; - - /** - * Get the methodName value. - * - * @return the methodName value - */ - public String methodName() { - return this.methodName; - } - - /** - * Set the methodName value. - * - * @param methodName the methodName value to set - * @return the PaymentResponse object itself. - */ - public PaymentResponse withMethodName(String methodName) { - this.methodName = methodName; - return this; - } - - /** - * Get the details value. - * - * @return the details value - */ - public Object details() { - return this.details; - } - - /** - * Set the details value. - * - * @param details the details value to set - * @return the PaymentResponse object itself. - */ - public PaymentResponse withDetails(Object details) { - this.details = details; - return this; - } - - /** - * Get the shippingAddress value. - * - * @return the shippingAddress value - */ - public PaymentAddress shippingAddress() { - return this.shippingAddress; - } - - /** - * Set the shippingAddress value. - * - * @param shippingAddress the shippingAddress value to set - * @return the PaymentResponse object itself. - */ - public PaymentResponse withShippingAddress(PaymentAddress shippingAddress) { - this.shippingAddress = shippingAddress; - return this; - } - - /** - * Get the shippingOption value. - * - * @return the shippingOption value - */ - public String shippingOption() { - return this.shippingOption; - } - - /** - * Set the shippingOption value. - * - * @param shippingOption the shippingOption value to set - * @return the PaymentResponse object itself. - */ - public PaymentResponse withShippingOption(String shippingOption) { - this.shippingOption = shippingOption; - return this; - } - - /** - * Get the payerEmail value. - * - * @return the payerEmail value - */ - public String payerEmail() { - return this.payerEmail; - } - - /** - * Set the payerEmail value. - * - * @param payerEmail the payerEmail value to set - * @return the PaymentResponse object itself. - */ - public PaymentResponse withPayerEmail(String payerEmail) { - this.payerEmail = payerEmail; - return this; - } - - /** - * Get the payerPhone value. - * - * @return the payerPhone value - */ - public String payerPhone() { - return this.payerPhone; - } - - /** - * Set the payerPhone value. - * - * @param payerPhone the payerPhone value to set - * @return the PaymentResponse object itself. - */ - public PaymentResponse withPayerPhone(String payerPhone) { - this.payerPhone = payerPhone; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A PaymentResponse is returned when a user has selected a payment method and + * approved a payment request. + */ +public class PaymentResponse { + /** + * The payment method identifier for the payment method that the user + * selected to fulfil the transaction. + */ + @JsonProperty(value = "methodName") + private String methodName; + + /** + * A JSON-serializable object that provides a payment method specific + * message used by the merchant to process the transaction and determine + * successful fund transfer. + */ + @JsonProperty(value = "details") + private Object details; + + /** + * If the requestShipping flag was set to true in the PaymentOptions passed + * to the PaymentRequest constructor, then shippingAddress will be the full + * and final shipping address chosen by the user. + */ + @JsonProperty(value = "shippingAddress") + private PaymentAddress shippingAddress; + + /** + * If the requestShipping flag was set to true in the PaymentOptions passed + * to the PaymentRequest constructor, then shippingOption will be the id + * attribute of the selected shipping option. + */ + @JsonProperty(value = "shippingOption") + private String shippingOption; + + /** + * If the requestPayerEmail flag was set to true in the PaymentOptions + * passed to the PaymentRequest constructor, then payerEmail will be the + * email address chosen by the user. + */ + @JsonProperty(value = "payerEmail") + private String payerEmail; + + /** + * If the requestPayerPhone flag was set to true in the PaymentOptions + * passed to the PaymentRequest constructor, then payerPhone will be the + * phone number chosen by the user. + */ + @JsonProperty(value = "payerPhone") + private String payerPhone; + + /** + * Get the methodName value. + * + * @return the methodName value + */ + public String methodName() { + return this.methodName; + } + + /** + * Set the methodName value. + * + * @param methodName the methodName value to set + * @return the PaymentResponse object itself. + */ + public PaymentResponse withMethodName(String methodName) { + this.methodName = methodName; + return this; + } + + /** + * Get the details value. + * + * @return the details value + */ + public Object details() { + return this.details; + } + + /** + * Set the details value. + * + * @param details the details value to set + * @return the PaymentResponse object itself. + */ + public PaymentResponse withDetails(Object details) { + this.details = details; + return this; + } + + /** + * Get the shippingAddress value. + * + * @return the shippingAddress value + */ + public PaymentAddress shippingAddress() { + return this.shippingAddress; + } + + /** + * Set the shippingAddress value. + * + * @param shippingAddress the shippingAddress value to set + * @return the PaymentResponse object itself. + */ + public PaymentResponse withShippingAddress(PaymentAddress shippingAddress) { + this.shippingAddress = shippingAddress; + return this; + } + + /** + * Get the shippingOption value. + * + * @return the shippingOption value + */ + public String shippingOption() { + return this.shippingOption; + } + + /** + * Set the shippingOption value. + * + * @param shippingOption the shippingOption value to set + * @return the PaymentResponse object itself. + */ + public PaymentResponse withShippingOption(String shippingOption) { + this.shippingOption = shippingOption; + return this; + } + + /** + * Get the payerEmail value. + * + * @return the payerEmail value + */ + public String payerEmail() { + return this.payerEmail; + } + + /** + * Set the payerEmail value. + * + * @param payerEmail the payerEmail value to set + * @return the PaymentResponse object itself. + */ + public PaymentResponse withPayerEmail(String payerEmail) { + this.payerEmail = payerEmail; + return this; + } + + /** + * Get the payerPhone value. + * + * @return the payerPhone value + */ + public String payerPhone() { + return this.payerPhone; + } + + /** + * Set the payerPhone value. + * + * @param payerPhone the payerPhone value to set + * @return the PaymentResponse object itself. + */ + public PaymentResponse withPayerPhone(String payerPhone) { + this.payerPhone = payerPhone; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentShippingOption.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentShippingOption.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentShippingOption.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentShippingOption.java index a10222f9..76a4da91 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/PaymentShippingOption.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/PaymentShippingOption.java @@ -1,123 +1,123 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Describes a shipping option. - */ -public class PaymentShippingOption { - /** - * String identifier used to reference this PaymentShippingOption. - */ - @JsonProperty(value = "id") - private String id; - - /** - * Human-readable description of the item. - */ - @JsonProperty(value = "label") - private String label; - - /** - * Contains the monetary amount for the item. - */ - @JsonProperty(value = "amount") - private PaymentCurrencyAmount amount; - - /** - * Indicates whether this is the default selected PaymentShippingOption. - */ - @JsonProperty(value = "selected") - private Boolean selected; - - /** - * Get the id value. - * - * @return the id value - */ - public String id() { - return this.id; - } - - /** - * Set the id value. - * - * @param id the id value to set - * @return the PaymentShippingOption object itself. - */ - public PaymentShippingOption withId(String id) { - this.id = id; - return this; - } - - /** - * Get the label value. - * - * @return the label value - */ - public String label() { - return this.label; - } - - /** - * Set the label value. - * - * @param label the label value to set - * @return the PaymentShippingOption object itself. - */ - public PaymentShippingOption withLabel(String label) { - this.label = label; - return this; - } - - /** - * Get the amount value. - * - * @return the amount value - */ - public PaymentCurrencyAmount amount() { - return this.amount; - } - - /** - * Set the amount value. - * - * @param amount the amount value to set - * @return the PaymentShippingOption object itself. - */ - public PaymentShippingOption withAmount(PaymentCurrencyAmount amount) { - this.amount = amount; - return this; - } - - /** - * Get the selected value. - * - * @return the selected value - */ - public Boolean selected() { - return this.selected; - } - - /** - * Set the selected value. - * - * @param selected the selected value to set - * @return the PaymentShippingOption object itself. - */ - public PaymentShippingOption withSelected(Boolean selected) { - this.selected = selected; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Describes a shipping option. + */ +public class PaymentShippingOption { + /** + * String identifier used to reference this PaymentShippingOption. + */ + @JsonProperty(value = "id") + private String id; + + /** + * Human-readable description of the item. + */ + @JsonProperty(value = "label") + private String label; + + /** + * Contains the monetary amount for the item. + */ + @JsonProperty(value = "amount") + private PaymentCurrencyAmount amount; + + /** + * Indicates whether this is the default selected PaymentShippingOption. + */ + @JsonProperty(value = "selected") + private Boolean selected; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the PaymentShippingOption object itself. + */ + public PaymentShippingOption withId(String id) { + this.id = id; + return this; + } + + /** + * Get the label value. + * + * @return the label value + */ + public String label() { + return this.label; + } + + /** + * Set the label value. + * + * @param label the label value to set + * @return the PaymentShippingOption object itself. + */ + public PaymentShippingOption withLabel(String label) { + this.label = label; + return this; + } + + /** + * Get the amount value. + * + * @return the amount value + */ + public PaymentCurrencyAmount amount() { + return this.amount; + } + + /** + * Set the amount value. + * + * @param amount the amount value to set + * @return the PaymentShippingOption object itself. + */ + public PaymentShippingOption withAmount(PaymentCurrencyAmount amount) { + this.amount = amount; + return this; + } + + /** + * Get the selected value. + * + * @return the selected value + */ + public Boolean selected() { + return this.selected; + } + + /** + * Set the selected value. + * + * @param selected the selected value to set + * @return the PaymentShippingOption object itself. + */ + public PaymentShippingOption withSelected(Boolean selected) { + this.selected = selected; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Place.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Place.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Place.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Place.java index 2bcc8412..ebe70fa2 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Place.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Place.java @@ -1,150 +1,150 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.bot.schema.EntityImpl; - -/** - * Place (entity type: "https://schema.org/Place"). - */ -public class Place extends EntityImpl { - /** - * Address of the place (may be `string` or complex object of type - * `PostalAddress`). - */ - @JsonProperty(value = "address") - private Object address; - - /** - * Geo coordinates of the place (may be complex object of type - * `GeoCoordinates` or `GeoShape`). - */ - @JsonProperty(value = "geo") - private Object geo; - - /** - * Map to the place (may be `string` (URL) or complex object of type - * `Map`). - */ - @JsonProperty(value = "hasMap") - private Object hasMap; - - /** - * The type of the thing. - */ - @JsonProperty(value = "type") - private String type; - - /** - * The name of the thing. - */ - @JsonProperty(value = "name") - private String name; - - /** - * Get the address value. - * - * @return the address value - */ - public Object address() { - return this.address; - } - - /** - * Set the address value. - * - * @param address the address value to set - * @return the Place object itself. - */ - public Place withAddress(Object address) { - this.address = address; - return this; - } - - /** - * Get the geo value. - * - * @return the geo value - */ - public Object geo() { - return this.geo; - } - - /** - * Set the geo value. - * - * @param geo the geo value to set - * @return the Place object itself. - */ - public Place withGeo(Object geo) { - this.geo = geo; - return this; - } - - /** - * Get the hasMap value. - * - * @return the hasMap value - */ - public Object hasMap() { - return this.hasMap; - } - - /** - * Set the hasMap value. - * - * @param hasMap the hasMap value to set - * @return the Place object itself. - */ - public Place withHasMap(Object hasMap) { - this.hasMap = hasMap; - return this; - } - - /** - * Get the type value. - * - * @return the type value - */ - public String type() { - return this.type; - } - - /** - * Set the type value. - * - * @param type the type value to set - * @return the Place object itself. - */ - public Place withType(String type) { - this.type = type; - return this; - } - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the Place object itself. - */ - public Place withName(String name) { - this.name = name; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.bot.schema.EntityImpl; + +/** + * Place (entity type: "https://schema.org/Place"). + */ +public class Place extends EntityImpl { + /** + * Address of the place (may be `string` or complex object of type + * `PostalAddress`). + */ + @JsonProperty(value = "address") + private Object address; + + /** + * Geo coordinates of the place (may be complex object of type + * `GeoCoordinates` or `GeoShape`). + */ + @JsonProperty(value = "geo") + private Object geo; + + /** + * Map to the place (may be `string` (URL) or complex object of type + * `Map`). + */ + @JsonProperty(value = "hasMap") + private Object hasMap; + + /** + * The type of the thing. + */ + @JsonProperty(value = "type") + private String type; + + /** + * The name of the thing. + */ + @JsonProperty(value = "name") + private String name; + + /** + * Get the address value. + * + * @return the address value + */ + public Object address() { + return this.address; + } + + /** + * Set the address value. + * + * @param address the address value to set + * @return the Place object itself. + */ + public Place withAddress(Object address) { + this.address = address; + return this; + } + + /** + * Get the geo value. + * + * @return the geo value + */ + public Object geo() { + return this.geo; + } + + /** + * Set the geo value. + * + * @param geo the geo value to set + * @return the Place object itself. + */ + public Place withGeo(Object geo) { + this.geo = geo; + return this; + } + + /** + * Get the hasMap value. + * + * @return the hasMap value + */ + public Object hasMap() { + return this.hasMap; + } + + /** + * Set the hasMap value. + * + * @param hasMap the hasMap value to set + * @return the Place object itself. + */ + public Place withHasMap(Object hasMap) { + this.hasMap = hasMap; + return this; + } + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the Place object itself. + */ + public Place withType(String type) { + this.type = type; + return this; + } + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the Place object itself. + */ + public Place withName(String name) { + this.name = name; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ReceiptCard.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ReceiptCard.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ReceiptCard.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ReceiptCard.java index 9e499e5f..d2ea2f1b 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ReceiptCard.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ReceiptCard.java @@ -1,228 +1,228 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A receipt card. - */ -public class ReceiptCard { - /** - * Title of the card. - */ - @JsonProperty(value = "title") - private String title; - - /** - * Array of Fact objects. - */ - @JsonProperty(value = "facts") - private List facts; - - /** - * Array of Receipt Items. - */ - @JsonProperty(value = "items") - private List items; - - /** - * This action will be activated when user taps on the card. - */ - @JsonProperty(value = "tap") - private CardAction tap; - - /** - * Total amount of money paid (or to be paid). - */ - @JsonProperty(value = "total") - private String total; - - /** - * Total amount of tax paid (or to be paid). - */ - @JsonProperty(value = "tax") - private String tax; - - /** - * Total amount of VAT paid (or to be paid). - */ - @JsonProperty(value = "vat") - private String vat; - - /** - * Set of actions applicable to the current card. - */ - @JsonProperty(value = "buttons") - private List buttons; - - /** - * Get the title value. - * - * @return the title value - */ - public String title() { - return this.title; - } - - /** - * Set the title value. - * - * @param title the title value to set - * @return the ReceiptCard object itself. - */ - public ReceiptCard withTitle(String title) { - this.title = title; - return this; - } - - /** - * Get the facts value. - * - * @return the facts value - */ - public List facts() { - return this.facts; - } - - /** - * Set the facts value. - * - * @param facts the facts value to set - * @return the ReceiptCard object itself. - */ - public ReceiptCard withFacts(List facts) { - this.facts = facts; - return this; - } - - /** - * Get the items value. - * - * @return the items value - */ - public List items() { - return this.items; - } - - /** - * Set the items value. - * - * @param items the items value to set - * @return the ReceiptCard object itself. - */ - public ReceiptCard withItems(List items) { - this.items = items; - return this; - } - - /** - * Get the tap value. - * - * @return the tap value - */ - public CardAction tap() { - return this.tap; - } - - /** - * Set the tap value. - * - * @param tap the tap value to set - * @return the ReceiptCard object itself. - */ - public ReceiptCard withTap(CardAction tap) { - this.tap = tap; - return this; - } - - /** - * Get the total value. - * - * @return the total value - */ - public String total() { - return this.total; - } - - /** - * Set the total value. - * - * @param total the total value to set - * @return the ReceiptCard object itself. - */ - public ReceiptCard withTotal(String total) { - this.total = total; - return this; - } - - /** - * Get the tax value. - * - * @return the tax value - */ - public String tax() { - return this.tax; - } - - /** - * Set the tax value. - * - * @param tax the tax value to set - * @return the ReceiptCard object itself. - */ - public ReceiptCard withTax(String tax) { - this.tax = tax; - return this; - } - - /** - * Get the vat value. - * - * @return the vat value - */ - public String vat() { - return this.vat; - } - - /** - * Set the vat value. - * - * @param vat the vat value to set - * @return the ReceiptCard object itself. - */ - public ReceiptCard withVat(String vat) { - this.vat = vat; - return this; - } - - /** - * Get the buttons value. - * - * @return the buttons value - */ - public List buttons() { - return this.buttons; - } - - /** - * Set the buttons value. - * - * @param buttons the buttons value to set - * @return the ReceiptCard object itself. - */ - public ReceiptCard withButtons(List buttons) { - this.buttons = buttons; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A receipt card. + */ +public class ReceiptCard { + /** + * Title of the card. + */ + @JsonProperty(value = "title") + private String title; + + /** + * Array of Fact objects. + */ + @JsonProperty(value = "facts") + private List facts; + + /** + * Array of Receipt Items. + */ + @JsonProperty(value = "items") + private List items; + + /** + * This action will be activated when user taps on the card. + */ + @JsonProperty(value = "tap") + private CardAction tap; + + /** + * Total amount of money paid (or to be paid). + */ + @JsonProperty(value = "total") + private String total; + + /** + * Total amount of tax paid (or to be paid). + */ + @JsonProperty(value = "tax") + private String tax; + + /** + * Total amount of VAT paid (or to be paid). + */ + @JsonProperty(value = "vat") + private String vat; + + /** + * Set of actions applicable to the current card. + */ + @JsonProperty(value = "buttons") + private List buttons; + + /** + * Get the title value. + * + * @return the title value + */ + public String title() { + return this.title; + } + + /** + * Set the title value. + * + * @param title the title value to set + * @return the ReceiptCard object itself. + */ + public ReceiptCard withTitle(String title) { + this.title = title; + return this; + } + + /** + * Get the facts value. + * + * @return the facts value + */ + public List facts() { + return this.facts; + } + + /** + * Set the facts value. + * + * @param facts the facts value to set + * @return the ReceiptCard object itself. + */ + public ReceiptCard withFacts(List facts) { + this.facts = facts; + return this; + } + + /** + * Get the items value. + * + * @return the items value + */ + public List items() { + return this.items; + } + + /** + * Set the items value. + * + * @param items the items value to set + * @return the ReceiptCard object itself. + */ + public ReceiptCard withItems(List items) { + this.items = items; + return this; + } + + /** + * Get the tap value. + * + * @return the tap value + */ + public CardAction tap() { + return this.tap; + } + + /** + * Set the tap value. + * + * @param tap the tap value to set + * @return the ReceiptCard object itself. + */ + public ReceiptCard withTap(CardAction tap) { + this.tap = tap; + return this; + } + + /** + * Get the total value. + * + * @return the total value + */ + public String total() { + return this.total; + } + + /** + * Set the total value. + * + * @param total the total value to set + * @return the ReceiptCard object itself. + */ + public ReceiptCard withTotal(String total) { + this.total = total; + return this; + } + + /** + * Get the tax value. + * + * @return the tax value + */ + public String tax() { + return this.tax; + } + + /** + * Set the tax value. + * + * @param tax the tax value to set + * @return the ReceiptCard object itself. + */ + public ReceiptCard withTax(String tax) { + this.tax = tax; + return this; + } + + /** + * Get the vat value. + * + * @return the vat value + */ + public String vat() { + return this.vat; + } + + /** + * Set the vat value. + * + * @param vat the vat value to set + * @return the ReceiptCard object itself. + */ + public ReceiptCard withVat(String vat) { + this.vat = vat; + return this; + } + + /** + * Get the buttons value. + * + * @return the buttons value + */ + public List buttons() { + return this.buttons; + } + + /** + * Set the buttons value. + * + * @param buttons the buttons value to set + * @return the ReceiptCard object itself. + */ + public ReceiptCard withButtons(List buttons) { + this.buttons = buttons; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ReceiptItem.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ReceiptItem.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ReceiptItem.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ReceiptItem.java index 9a36c431..d9939066 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ReceiptItem.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ReceiptItem.java @@ -1,203 +1,203 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * An item on a receipt card. - */ -public class ReceiptItem { - /** - * Title of the Card. - */ - @JsonProperty(value = "title") - private String title; - - /** - * Subtitle appears just below Title field, differs from Title in font - * styling only. - */ - @JsonProperty(value = "subtitle") - private String subtitle; - - /** - * Text field appears just below subtitle, differs from Subtitle in font - * styling only. - */ - @JsonProperty(value = "text") - private String text; - - /** - * Image. - */ - @JsonProperty(value = "image") - private CardImage image; - - /** - * Amount with currency. - */ - @JsonProperty(value = "price") - private String price; - - /** - * Number of items of given kind. - */ - @JsonProperty(value = "quantity") - private String quantity; - - /** - * This action will be activated when user taps on the Item bubble. - */ - @JsonProperty(value = "tap") - private CardAction tap; - - /** - * Get the title value. - * - * @return the title value - */ - public String title() { - return this.title; - } - - /** - * Set the title value. - * - * @param title the title value to set - * @return the ReceiptItem object itself. - */ - public ReceiptItem withTitle(String title) { - this.title = title; - return this; - } - - /** - * Get the subtitle value. - * - * @return the subtitle value - */ - public String subtitle() { - return this.subtitle; - } - - /** - * Set the subtitle value. - * - * @param subtitle the subtitle value to set - * @return the ReceiptItem object itself. - */ - public ReceiptItem withSubtitle(String subtitle) { - this.subtitle = subtitle; - return this; - } - - /** - * Get the text value. - * - * @return the text value - */ - public String text() { - return this.text; - } - - /** - * Set the text value. - * - * @param text the text value to set - * @return the ReceiptItem object itself. - */ - public ReceiptItem withText(String text) { - this.text = text; - return this; - } - - /** - * Get the image value. - * - * @return the image value - */ - public CardImage image() { - return this.image; - } - - /** - * Set the image value. - * - * @param image the image value to set - * @return the ReceiptItem object itself. - */ - public ReceiptItem withImage(CardImage image) { - this.image = image; - return this; - } - - /** - * Get the price value. - * - * @return the price value - */ - public String price() { - return this.price; - } - - /** - * Set the price value. - * - * @param price the price value to set - * @return the ReceiptItem object itself. - */ - public ReceiptItem withPrice(String price) { - this.price = price; - return this; - } - - /** - * Get the quantity value. - * - * @return the quantity value - */ - public String quantity() { - return this.quantity; - } - - /** - * Set the quantity value. - * - * @param quantity the quantity value to set - * @return the ReceiptItem object itself. - */ - public ReceiptItem withQuantity(String quantity) { - this.quantity = quantity; - return this; - } - - /** - * Get the tap value. - * - * @return the tap value - */ - public CardAction tap() { - return this.tap; - } - - /** - * Set the tap value. - * - * @param tap the tap value to set - * @return the ReceiptItem object itself. - */ - public ReceiptItem withTap(CardAction tap) { - this.tap = tap; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * An item on a receipt card. + */ +public class ReceiptItem { + /** + * Title of the Card. + */ + @JsonProperty(value = "title") + private String title; + + /** + * Subtitle appears just below Title field, differs from Title in font + * styling only. + */ + @JsonProperty(value = "subtitle") + private String subtitle; + + /** + * Text field appears just below subtitle, differs from Subtitle in font + * styling only. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Image. + */ + @JsonProperty(value = "image") + private CardImage image; + + /** + * Amount with currency. + */ + @JsonProperty(value = "price") + private String price; + + /** + * Number of items of given kind. + */ + @JsonProperty(value = "quantity") + private String quantity; + + /** + * This action will be activated when user taps on the Item bubble. + */ + @JsonProperty(value = "tap") + private CardAction tap; + + /** + * Get the title value. + * + * @return the title value + */ + public String title() { + return this.title; + } + + /** + * Set the title value. + * + * @param title the title value to set + * @return the ReceiptItem object itself. + */ + public ReceiptItem withTitle(String title) { + this.title = title; + return this; + } + + /** + * Get the subtitle value. + * + * @return the subtitle value + */ + public String subtitle() { + return this.subtitle; + } + + /** + * Set the subtitle value. + * + * @param subtitle the subtitle value to set + * @return the ReceiptItem object itself. + */ + public ReceiptItem withSubtitle(String subtitle) { + this.subtitle = subtitle; + return this; + } + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the ReceiptItem object itself. + */ + public ReceiptItem withText(String text) { + this.text = text; + return this; + } + + /** + * Get the image value. + * + * @return the image value + */ + public CardImage image() { + return this.image; + } + + /** + * Set the image value. + * + * @param image the image value to set + * @return the ReceiptItem object itself. + */ + public ReceiptItem withImage(CardImage image) { + this.image = image; + return this; + } + + /** + * Get the price value. + * + * @return the price value + */ + public String price() { + return this.price; + } + + /** + * Set the price value. + * + * @param price the price value to set + * @return the ReceiptItem object itself. + */ + public ReceiptItem withPrice(String price) { + this.price = price; + return this; + } + + /** + * Get the quantity value. + * + * @return the quantity value + */ + public String quantity() { + return this.quantity; + } + + /** + * Set the quantity value. + * + * @param quantity the quantity value to set + * @return the ReceiptItem object itself. + */ + public ReceiptItem withQuantity(String quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get the tap value. + * + * @return the tap value + */ + public CardAction tap() { + return this.tap; + } + + /** + * Set the tap value. + * + * @param tap the tap value to set + * @return the ReceiptItem object itself. + */ + public ReceiptItem withTap(CardAction tap) { + this.tap = tap; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ResourceResponse.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ResourceResponse.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ResourceResponse.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ResourceResponse.java index bd02d913..8fa7b99e 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ResourceResponse.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ResourceResponse.java @@ -1,45 +1,45 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A response containing a resource ID. - */ -public class ResourceResponse { - /** - * Id of the resource. - */ - @JsonProperty(value = "id") - private String id; - - /** - * Get the id value. - * - * @return the id value - */ - public String id() { - return this.id; - } - - /** - * Set the id value. - * - * @param id the id value to set - * @return the ResourceResponse object itself. - */ - public ResourceResponse withId(String id) { - this.id = id; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A response containing a resource ID. + */ +public class ResourceResponse { + /** + * Id of the resource. + */ + @JsonProperty(value = "id") + private String id; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the ResourceResponse object itself. + */ + public ResourceResponse withId(String id) { + this.id = id; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/RoleTypes.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/RoleTypes.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/RoleTypes.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/RoleTypes.java index 9f3df0cf..5a4bb210 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/RoleTypes.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/RoleTypes.java @@ -1,55 +1,55 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Role of the entity behind the account (Example: User, Bot, etc.). - */ -public enum RoleTypes { - /** Enum value user. */ - USER("user"), - - /** Enum value bot. */ - BOT("bot"); - - /** The actual serialized value for a RoleTypes instance. */ - private String value; - - RoleTypes(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a RoleTypes instance. - * - * @param value the serialized value to parse. - * @return the parsed RoleTypes object, or null if unable to parse. - */ - @JsonCreator - public static RoleTypes fromString(String value) { - RoleTypes[] items = RoleTypes.values(); - for (RoleTypes item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Role of the entity behind the account (Example: User, Bot, etc.). + */ +public enum RoleTypes { + /** Enum value user. */ + USER("user"), + + /** Enum value bot. */ + BOT("bot"); + + /** The actual serialized value for a RoleTypes instance. */ + private String value; + + RoleTypes(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a RoleTypes instance. + * + * @param value the serialized value to parse. + * @return the parsed RoleTypes object, or null if unable to parse. + */ + @JsonCreator + public static RoleTypes fromString(String value) { + RoleTypes[] items = RoleTypes.values(); + for (RoleTypes item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/SemanticAction.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/SemanticAction.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/SemanticAction.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/SemanticAction.java index 3ff66047..419ace06 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/SemanticAction.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/SemanticAction.java @@ -1,69 +1,69 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Represents a reference to a programmatic action - */ -public class SemanticAction { - /** - * ID of this action. - */ - @JsonProperty(value = "id") - private String id; - - /** - * Entities associated with this action. - */ - @JsonProperty(value = "entities") - Map entities; - - /** - * Gets ID of this action. - */ - public String id(){ - return this.id; - } - - /** - * Sets ID of this action. - * - * @param id ID of this action - * @return The SemanticAction object itself. - */ - public SemanticAction withId(String id){ - this.id = id; - return this; - } - - /** - * Gets entities associated with this action. - * - * @return the activities value - */ - public Map entities() { - return this.entities; - } - - /** - * Sets entities associated with this action. - * - * @param entities - * @return The SemanticAction object itself. - */ - public SemanticAction withEntities(Map entities){ - this.entities = entities; - return this; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Represents a reference to a programmatic action + */ +public class SemanticAction { + /** + * ID of this action. + */ + @JsonProperty(value = "id") + private String id; + + /** + * Entities associated with this action. + */ + @JsonProperty(value = "entities") + Map entities; + + /** + * Gets ID of this action. + */ + public String id(){ + return this.id; + } + + /** + * Sets ID of this action. + * + * @param id ID of this action + * @return The SemanticAction object itself. + */ + public SemanticAction withId(String id){ + this.id = id; + return this; + } + + /** + * Gets entities associated with this action. + * + * @return the activities value + */ + public Map entities() { + return this.entities; + } + + /** + * Sets entities associated with this action. + * + * @param entities + * @return The SemanticAction object itself. + */ + public SemanticAction withEntities(Map entities){ + this.entities = entities; + return this; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/SemanticActionStates.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/SemanticActionStates.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/SemanticActionStates.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/SemanticActionStates.java index baf80ee7..52faf728 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/SemanticActionStates.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/SemanticActionStates.java @@ -1,59 +1,59 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Indicates whether the semantic action is starting, continuing, or done. - */ -public enum SemanticActionStates { - /** Enum value start. */ - START("start"), - - /** Enum value continue. */ - CONTINUE("continue"), - - /** Enum value done. */ - DONE("done"); - - - /** The actual serialized value for a SemanticActionStates instance. */ - private String value; - - SemanticActionStates(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a ActivityTypes instance. - * - * @param value the serialized value to parse. - * @return the parsed ActivityTypes object, or null if unable to parse. - */ - @JsonCreator - public static SemanticActionStates fromString(String value) { - SemanticActionStates[] items = SemanticActionStates.values(); - for (SemanticActionStates item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Indicates whether the semantic action is starting, continuing, or done. + */ +public enum SemanticActionStates { + /** Enum value start. */ + START("start"), + + /** Enum value continue. */ + CONTINUE("continue"), + + /** Enum value done. */ + DONE("done"); + + + /** The actual serialized value for a SemanticActionStates instance. */ + private String value; + + SemanticActionStates(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ActivityTypes instance. + * + * @param value the serialized value to parse. + * @return the parsed ActivityTypes object, or null if unable to parse. + */ + @JsonCreator + public static SemanticActionStates fromString(String value) { + SemanticActionStates[] items = SemanticActionStates.values(); + for (SemanticActionStates item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/SigninCard.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/SigninCard.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/SigninCard.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/SigninCard.java index d9dc1808..a9d44811 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/SigninCard.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/SigninCard.java @@ -1,72 +1,72 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A card representing a request to sign in. - */ -public class SigninCard { - /** - * Text for signin request. - */ - @JsonProperty(value = "text") - private String text; - - /** - * Action to use to perform signin. - */ - @JsonProperty(value = "buttons") - private List buttons; - - /** - * Get the text value. - * - * @return the text value - */ - public String text() { - return this.text; - } - - /** - * Set the text value. - * - * @param text the text value to set - * @return the SigninCard object itself. - */ - public SigninCard withText(String text) { - this.text = text; - return this; - } - - /** - * Get the buttons value. - * - * @return the buttons value - */ - public List buttons() { - return this.buttons; - } - - /** - * Set the buttons value. - * - * @param buttons the buttons value to set - * @return the SigninCard object itself. - */ - public SigninCard withButtons(List buttons) { - this.buttons = buttons; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A card representing a request to sign in. + */ +public class SigninCard { + /** + * Text for signin request. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Action to use to perform signin. + */ + @JsonProperty(value = "buttons") + private List buttons; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the SigninCard object itself. + */ + public SigninCard withText(String text) { + this.text = text; + return this; + } + + /** + * Get the buttons value. + * + * @return the buttons value + */ + public List buttons() { + return this.buttons; + } + + /** + * Set the buttons value. + * + * @param buttons the buttons value to set + * @return the SigninCard object itself. + */ + public SigninCard withButtons(List buttons) { + this.buttons = buttons; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/SuggestedActions.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/SuggestedActions.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/SuggestedActions.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/SuggestedActions.java index 01be44d9..22b7ca21 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/SuggestedActions.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/SuggestedActions.java @@ -1,74 +1,74 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * SuggestedActions that can be performed. - */ -public class SuggestedActions { - /** - * Ids of the recipients that the actions should be shown to. These Ids - * are relative to the channelId and a subset of all recipients of the - * activity. - */ - @JsonProperty(value = "to") - private List to; - - /** - * Actions that can be shown to the user. - */ - @JsonProperty(value = "actions") - private List actions; - - /** - * Get the to value. - * - * @return the to value - */ - public List to() { - return this.to; - } - - /** - * Set the to value. - * - * @param to the to value to set - * @return the SuggestedActions object itself. - */ - public SuggestedActions withTo(List to) { - this.to = to; - return this; - } - - /** - * Get the actions value. - * - * @return the actions value - */ - public List actions() { - return this.actions; - } - - /** - * Set the actions value. - * - * @param actions the actions value to set - * @return the SuggestedActions object itself. - */ - public SuggestedActions withActions(List actions) { - this.actions = actions; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * SuggestedActions that can be performed. + */ +public class SuggestedActions { + /** + * Ids of the recipients that the actions should be shown to. These Ids + * are relative to the channelId and a subset of all recipients of the + * activity. + */ + @JsonProperty(value = "to") + private List to; + + /** + * Actions that can be shown to the user. + */ + @JsonProperty(value = "actions") + private List actions; + + /** + * Get the to value. + * + * @return the to value + */ + public List to() { + return this.to; + } + + /** + * Set the to value. + * + * @param to the to value to set + * @return the SuggestedActions object itself. + */ + public SuggestedActions withTo(List to) { + this.to = to; + return this; + } + + /** + * Get the actions value. + * + * @return the actions value + */ + public List actions() { + return this.actions; + } + + /** + * Set the actions value. + * + * @param actions the actions value to set + * @return the SuggestedActions object itself. + */ + public SuggestedActions withActions(List actions) { + this.actions = actions; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/TextFormatTypes.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/TextFormatTypes.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/TextFormatTypes.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/TextFormatTypes.java index 676ebe1b..8995059d 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/TextFormatTypes.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/TextFormatTypes.java @@ -1,58 +1,58 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for TextFormatTypes. - */ -public enum TextFormatTypes { - /** Enum value markdown. */ - MARKDOWN("markdown"), - - /** Enum value plain. */ - PLAIN("plain"), - - /** Enum value xml. */ - XML("xml"); - - /** The actual serialized value for a TextFormatTypes instance. */ - private String value; - - TextFormatTypes(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a TextFormatTypes instance. - * - * @param value the serialized value to parse. - * @return the parsed TextFormatTypes object, or null if unable to parse. - */ - @JsonCreator - public static TextFormatTypes fromString(String value) { - TextFormatTypes[] items = TextFormatTypes.values(); - for (TextFormatTypes item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - @JsonValue - @Override - public String toString() { - return this.value; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for TextFormatTypes. + */ +public enum TextFormatTypes { + /** Enum value markdown. */ + MARKDOWN("markdown"), + + /** Enum value plain. */ + PLAIN("plain"), + + /** Enum value xml. */ + XML("xml"); + + /** The actual serialized value for a TextFormatTypes instance. */ + private String value; + + TextFormatTypes(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a TextFormatTypes instance. + * + * @param value the serialized value to parse. + * @return the parsed TextFormatTypes object, or null if unable to parse. + */ + @JsonCreator + public static TextFormatTypes fromString(String value) { + TextFormatTypes[] items = TextFormatTypes.values(); + for (TextFormatTypes item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/TextHighlight.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/TextHighlight.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/TextHighlight.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/TextHighlight.java index 41b1d13f..c7653a20 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/TextHighlight.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/TextHighlight.java @@ -1,71 +1,71 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Refers to a substring of content within another field. - */ -public class TextHighlight { - /** - * Defines the snippet of text to highlight. - */ - @JsonProperty(value = "text") - private String text; - - /** - * Occurrence of the text field within the referenced text, if multiple exist. - */ - @JsonProperty(value = "occurence") - private Integer occurence; - - /** - * Get the text value. - * - * @return the text value - */ - public String text() { - return this.text; - } - - /** - * Set the text value. - * - * @param text the text value to set - * @return the TextHighlight object itself. - */ - public TextHighlight withText(String text) { - this.text = text; - return this; - } - - /** - * Get the occurence value. - * - * @return the occurence value - */ - public Integer occurence() { - return this.occurence; - } - - /** - * Set the occurence value. - * - * @param occurence the occurence value to set - * @return the TextHighlight object itself. - */ - public TextHighlight withOccurence(Integer occurence) { - this.occurence = occurence; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Refers to a substring of content within another field. + */ +public class TextHighlight { + /** + * Defines the snippet of text to highlight. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Occurrence of the text field within the referenced text, if multiple exist. + */ + @JsonProperty(value = "occurence") + private Integer occurence; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the TextHighlight object itself. + */ + public TextHighlight withText(String text) { + this.text = text; + return this; + } + + /** + * Get the occurence value. + * + * @return the occurence value + */ + public Integer occurence() { + return this.occurence; + } + + /** + * Set the occurence value. + * + * @param occurence the occurence value to set + * @return the TextHighlight object itself. + */ + public TextHighlight withOccurence(Integer occurence) { + this.occurence = occurence; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Thing.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Thing.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Thing.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Thing.java index 76318115..c9b7da63 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Thing.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Thing.java @@ -1,71 +1,71 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Thing (entity type: "https://schema.org/Thing"). - */ -public class Thing { - /** - * The type of the thing. - */ - @JsonProperty(value = "type") - private String type; - - /** - * The name of the thing. - */ - @JsonProperty(value = "name") - private String name; - - /** - * Get the type value. - * - * @return the type value - */ - public String type() { - return this.type; - } - - /** - * Set the type value. - * - * @param type the type value to set - * @return the Thing object itself. - */ - public Thing withType(String type) { - this.type = type; - return this; - } - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the Thing object itself. - */ - public Thing withName(String name) { - this.name = name; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Thing (entity type: "https://schema.org/Thing"). + */ +public class Thing { + /** + * The type of the thing. + */ + @JsonProperty(value = "type") + private String type; + + /** + * The name of the thing. + */ + @JsonProperty(value = "name") + private String name; + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the Thing object itself. + */ + public Thing withType(String type) { + this.type = type; + return this; + } + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the Thing object itself. + */ + public Thing withName(String name) { + this.name = name; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ThumbnailCard.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ThumbnailCard.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ThumbnailCard.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ThumbnailCard.java index d1737867..e1fb99cd 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ThumbnailCard.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ThumbnailCard.java @@ -1,176 +1,176 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A thumbnail card (card with a single, small thumbnail image). - */ -public class ThumbnailCard { - /** - * Title of the card. - */ - @JsonProperty(value = "title") - private String title; - - /** - * Subtitle of the card. - */ - @JsonProperty(value = "subtitle") - private String subtitle; - - /** - * Text for the card. - */ - @JsonProperty(value = "text") - private String text; - - /** - * Array of images for the card. - */ - @JsonProperty(value = "images") - private List images; - - /** - * Set of actions applicable to the current card. - */ - @JsonProperty(value = "buttons") - private List buttons; - - /** - * This action will be activated when user taps on the card itself. - */ - @JsonProperty(value = "tap") - private CardAction tap; - - /** - * Get the title value. - * - * @return the title value - */ - public String title() { - return this.title; - } - - /** - * Set the title value. - * - * @param title the title value to set - * @return the ThumbnailCard object itself. - */ - public ThumbnailCard withTitle(String title) { - this.title = title; - return this; - } - - /** - * Get the subtitle value. - * - * @return the subtitle value - */ - public String subtitle() { - return this.subtitle; - } - - /** - * Set the subtitle value. - * - * @param subtitle the subtitle value to set - * @return the ThumbnailCard object itself. - */ - public ThumbnailCard withSubtitle(String subtitle) { - this.subtitle = subtitle; - return this; - } - - /** - * Get the text value. - * - * @return the text value - */ - public String text() { - return this.text; - } - - /** - * Set the text value. - * - * @param text the text value to set - * @return the ThumbnailCard object itself. - */ - public ThumbnailCard withText(String text) { - this.text = text; - return this; - } - - /** - * Get the images value. - * - * @return the images value - */ - public List images() { - return this.images; - } - - /** - * Set the images value. - * - * @param images the images value to set - * @return the ThumbnailCard object itself. - */ - public ThumbnailCard withImages(List images) { - this.images = images; - return this; - } - - /** - * Get the buttons value. - * - * @return the buttons value - */ - public List buttons() { - return this.buttons; - } - - /** - * Set the buttons value. - * - * @param buttons the buttons value to set - * @return the ThumbnailCard object itself. - */ - public ThumbnailCard withButtons(List buttons) { - this.buttons = buttons; - return this; - } - - /** - * Get the tap value. - * - * @return the tap value - */ - public CardAction tap() { - return this.tap; - } - - /** - * Set the tap value. - * - * @param tap the tap value to set - * @return the ThumbnailCard object itself. - */ - public ThumbnailCard withTap(CardAction tap) { - this.tap = tap; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A thumbnail card (card with a single, small thumbnail image). + */ +public class ThumbnailCard { + /** + * Title of the card. + */ + @JsonProperty(value = "title") + private String title; + + /** + * Subtitle of the card. + */ + @JsonProperty(value = "subtitle") + private String subtitle; + + /** + * Text for the card. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Array of images for the card. + */ + @JsonProperty(value = "images") + private List images; + + /** + * Set of actions applicable to the current card. + */ + @JsonProperty(value = "buttons") + private List buttons; + + /** + * This action will be activated when user taps on the card itself. + */ + @JsonProperty(value = "tap") + private CardAction tap; + + /** + * Get the title value. + * + * @return the title value + */ + public String title() { + return this.title; + } + + /** + * Set the title value. + * + * @param title the title value to set + * @return the ThumbnailCard object itself. + */ + public ThumbnailCard withTitle(String title) { + this.title = title; + return this; + } + + /** + * Get the subtitle value. + * + * @return the subtitle value + */ + public String subtitle() { + return this.subtitle; + } + + /** + * Set the subtitle value. + * + * @param subtitle the subtitle value to set + * @return the ThumbnailCard object itself. + */ + public ThumbnailCard withSubtitle(String subtitle) { + this.subtitle = subtitle; + return this; + } + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the ThumbnailCard object itself. + */ + public ThumbnailCard withText(String text) { + this.text = text; + return this; + } + + /** + * Get the images value. + * + * @return the images value + */ + public List images() { + return this.images; + } + + /** + * Set the images value. + * + * @param images the images value to set + * @return the ThumbnailCard object itself. + */ + public ThumbnailCard withImages(List images) { + this.images = images; + return this; + } + + /** + * Get the buttons value. + * + * @return the buttons value + */ + public List buttons() { + return this.buttons; + } + + /** + * Set the buttons value. + * + * @param buttons the buttons value to set + * @return the ThumbnailCard object itself. + */ + public ThumbnailCard withButtons(List buttons) { + this.buttons = buttons; + return this; + } + + /** + * Get the tap value. + * + * @return the tap value + */ + public CardAction tap() { + return this.tap; + } + + /** + * Set the tap value. + * + * @param tap the tap value to set + * @return the ThumbnailCard object itself. + */ + public ThumbnailCard withTap(CardAction tap) { + this.tap = tap; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ThumbnailUrl.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ThumbnailUrl.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ThumbnailUrl.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ThumbnailUrl.java index b73e8960..9e40a7c4 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/ThumbnailUrl.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/ThumbnailUrl.java @@ -1,71 +1,71 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Thumbnail URL. - */ -public class ThumbnailUrl { - /** - * URL pointing to the thumbnail to use for media content. - */ - @JsonProperty(value = "url") - private String url; - - /** - * HTML alt text to include on this thumbnail image. - */ - @JsonProperty(value = "alt") - private String alt; - - /** - * Get the url value. - * - * @return the url value - */ - public String url() { - return this.url; - } - - /** - * Set the url value. - * - * @param url the url value to set - * @return the ThumbnailUrl object itself. - */ - public ThumbnailUrl withUrl(String url) { - this.url = url; - return this; - } - - /** - * Get the alt value. - * - * @return the alt value - */ - public String alt() { - return this.alt; - } - - /** - * Set the alt value. - * - * @param alt the alt value to set - * @return the ThumbnailUrl object itself. - */ - public ThumbnailUrl withAlt(String alt) { - this.alt = alt; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Thumbnail URL. + */ +public class ThumbnailUrl { + /** + * URL pointing to the thumbnail to use for media content. + */ + @JsonProperty(value = "url") + private String url; + + /** + * HTML alt text to include on this thumbnail image. + */ + @JsonProperty(value = "alt") + private String alt; + + /** + * Get the url value. + * + * @return the url value + */ + public String url() { + return this.url; + } + + /** + * Set the url value. + * + * @param url the url value to set + * @return the ThumbnailUrl object itself. + */ + public ThumbnailUrl withUrl(String url) { + this.url = url; + return this; + } + + /** + * Get the alt value. + * + * @return the alt value + */ + public String alt() { + return this.alt; + } + + /** + * Set the alt value. + * + * @param alt the alt value to set + * @return the ThumbnailUrl object itself. + */ + public ThumbnailUrl withAlt(String alt) { + this.alt = alt; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/TokenRequest.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/TokenRequest.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/TokenRequest.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/TokenRequest.java index 8702dded..ac4e043d 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/TokenRequest.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/TokenRequest.java @@ -1,72 +1,72 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A request to receive a user token. - */ -public class TokenRequest { - /** - * The provider to request a user token from. - */ - @JsonProperty(value = "provider") - private String provider; - - /** - * A collection of settings for the specific provider for this request. - */ - @JsonProperty(value = "settings") - private Map settings; - - /** - * Get the provider value. - * - * @return the provider value - */ - public String provider() { - return this.provider; - } - - /** - * Set the provider value. - * - * @param provider the provider value to set - * @return the TokenRequest object itself. - */ - public TokenRequest withProvider(String provider) { - this.provider = provider; - return this; - } - - /** - * Get the settings value. - * - * @return the settings value - */ - public Map settings() { - return this.settings; - } - - /** - * Set the settings value. - * - * @param settings the settings value to set - * @return the TokenRequest object itself. - */ - public TokenRequest withSettings(Map settings) { - this.settings = settings; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A request to receive a user token. + */ +public class TokenRequest { + /** + * The provider to request a user token from. + */ + @JsonProperty(value = "provider") + private String provider; + + /** + * A collection of settings for the specific provider for this request. + */ + @JsonProperty(value = "settings") + private Map settings; + + /** + * Get the provider value. + * + * @return the provider value + */ + public String provider() { + return this.provider; + } + + /** + * Set the provider value. + * + * @param provider the provider value to set + * @return the TokenRequest object itself. + */ + public TokenRequest withProvider(String provider) { + this.provider = provider; + return this; + } + + /** + * Get the settings value. + * + * @return the settings value + */ + public Map settings() { + return this.settings; + } + + /** + * Set the settings value. + * + * @param settings the settings value to set + * @return the TokenRequest object itself. + */ + public TokenRequest withSettings(Map settings) { + this.settings = settings; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/TokenResponse.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/TokenResponse.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/TokenResponse.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/TokenResponse.java index 955c0f04..0c798791 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/TokenResponse.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/TokenResponse.java @@ -1,121 +1,121 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A response that includes a user token. - */ -public class TokenResponse { - /** - * The channelId of the TokenResponse. - */ - @JsonProperty(value = "channelId") - private String channelId; - - /** - * The connection name. - */ - @JsonProperty(value = "connectionName") - private String connectionName; - - /** - * The user token. - */ - @JsonProperty(value = "token") - private String token; - - /** - * Expiration for the token, in ISO 8601 format (e.g. "2007-04-05T14:30Z"). - */ - @JsonProperty(value = "expiration") - private String expiration; - - /** - * Gets the channelId value. - */ - public String channelId(){ - return this.channelId; - } - - /** - * Sets the channelId value. - * - * @param channelId The channel id to set. - * @return the TokenResponse object itself. - */ - public TokenResponse withChannelId(String channelId){ - this.channelId = channelId; - return this; - } - - /** - * Get the connectionName value. - * - * @return the connectionName value - */ - public String connectionName() { - return this.connectionName; - } - - /** - * Set the connectionName value. - * - * @param connectionName the connectionName value to set - * @return the TokenResponse object itself. - */ - public TokenResponse withConnectionName(String connectionName) { - this.connectionName = connectionName; - return this; - } - - /** - * Get the token value. - * - * @return the token value - */ - public String token() { - return this.token; - } - - /** - * Set the token value. - * - * @param token the token value to set - * @return the TokenResponse object itself. - */ - public TokenResponse withToken(String token) { - this.token = token; - return this; - } - - /** - * Get the expiration value. - * - * @return the expiration value - */ - public String expiration() { - return this.expiration; - } - - /** - * Set the expiration value. - * - * @param expiration the expiration value to set - * @return the TokenResponse object itself. - */ - public TokenResponse withExpiration(String expiration) { - this.expiration = expiration; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A response that includes a user token. + */ +public class TokenResponse { + /** + * The channelId of the TokenResponse. + */ + @JsonProperty(value = "channelId") + private String channelId; + + /** + * The connection name. + */ + @JsonProperty(value = "connectionName") + private String connectionName; + + /** + * The user token. + */ + @JsonProperty(value = "token") + private String token; + + /** + * Expiration for the token, in ISO 8601 format (e.g. "2007-04-05T14:30Z"). + */ + @JsonProperty(value = "expiration") + private String expiration; + + /** + * Gets the channelId value. + */ + public String channelId(){ + return this.channelId; + } + + /** + * Sets the channelId value. + * + * @param channelId The channel id to set. + * @return the TokenResponse object itself. + */ + public TokenResponse withChannelId(String channelId){ + this.channelId = channelId; + return this; + } + + /** + * Get the connectionName value. + * + * @return the connectionName value + */ + public String connectionName() { + return this.connectionName; + } + + /** + * Set the connectionName value. + * + * @param connectionName the connectionName value to set + * @return the TokenResponse object itself. + */ + public TokenResponse withConnectionName(String connectionName) { + this.connectionName = connectionName; + return this; + } + + /** + * Get the token value. + * + * @return the token value + */ + public String token() { + return this.token; + } + + /** + * Set the token value. + * + * @param token the token value to set + * @return the TokenResponse object itself. + */ + public TokenResponse withToken(String token) { + this.token = token; + return this; + } + + /** + * Get the expiration value. + * + * @return the expiration value + */ + public String expiration() { + return this.expiration; + } + + /** + * Set the expiration value. + * + * @param expiration the expiration value to set + * @return the TokenResponse object itself. + */ + public TokenResponse withExpiration(String expiration) { + this.expiration = expiration; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Transcript.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Transcript.java similarity index 96% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Transcript.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Transcript.java index 9e14df07..405bf991 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/Transcript.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/Transcript.java @@ -1,45 +1,45 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A collection of Activities that conforms to the Transcript schema. - */ -public class Transcript { - /** - * List of members in this conversation. - */ - @JsonProperty(value = "activities") - private List activities; - - /** - * Gets collection of Activities that conforms to the Transcript schema. - * - * @return the activities value - */ - public List activities() { - return this.activities; - } - - /** - * Sets collection of Activities that conforms to the Transcript schema. - * - * @param activities the activities value to set - * @return the Transcript object itself. - */ - public Transcript withActivities(List activities) { - this.activities = activities; - return this; - } -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A collection of Activities that conforms to the Transcript schema. + */ +public class Transcript { + /** + * List of members in this conversation. + */ + @JsonProperty(value = "activities") + private List activities; + + /** + * Gets collection of Activities that conforms to the Transcript schema. + * + * @return the activities value + */ + public List activities() { + return this.activities; + } + + /** + * Sets collection of Activities that conforms to the Transcript schema. + * + * @param activities the activities value to set + * @return the Transcript object itself. + */ + public Transcript withActivities(List activities) { + this.activities = activities; + return this; + } +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/VideoCard.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/VideoCard.java similarity index 95% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/VideoCard.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/VideoCard.java index 628a0b1b..c08d3649 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/VideoCard.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/VideoCard.java @@ -1,332 +1,332 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.bot.schema.models; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * Video card. - */ -public class VideoCard { - /** - * Title of this card. - */ - @JsonProperty(value = "title") - private String title; - - /** - * Subtitle of this card. - */ - @JsonProperty(value = "subtitle") - private String subtitle; - - /** - * Text of this card. - */ - @JsonProperty(value = "text") - private String text; - - /** - * Thumbnail placeholder. - */ - @JsonProperty(value = "image") - private ThumbnailUrl image; - - /** - * Media URLs for this card. When this field contains more than one URL, each URL is an alternative format of the same content. - */ - @JsonProperty(value = "media") - private List media; - - /** - * Actions on this card. - */ - @JsonProperty(value = "buttons") - private List buttons; - - /** - * This content may be shared with others (default:true). - */ - @JsonProperty(value = "shareable") - private Boolean shareable; - - /** - * Should the client loop playback at end of content (default:true). - */ - @JsonProperty(value = "autoloop") - private Boolean autoloop; - - /** - * Should the client automatically start playback of media in this card - * (default:true). - */ - @JsonProperty(value = "autostart") - private Boolean autostart; - - /** - * Aspect ratio of thumbnail/media placeholder, allowed values are "16:9" - * and "4:3". - */ - @JsonProperty(value = "aspect") - private String aspect; - - /** - * Describes the length of the media content without requiring a receiver to open the content. Formatted as an ISO 8601 Duration field. - */ - @JsonProperty(value = "duration") - private String duration; - - /** - * Supplementary parameter for this card. - */ - @JsonProperty(value = "value") - private Object value; - - /** - * Get the title value. - * - * @return the title value - */ - public String title() { - return this.title; - } - - /** - * Set the title value. - * - * @param title the title value to set - * @return the VideoCard object itself. - */ - public VideoCard withTitle(String title) { - this.title = title; - return this; - } - - /** - * Get the subtitle value. - * - * @return the subtitle value - */ - public String subtitle() { - return this.subtitle; - } - - /** - * Set the subtitle value. - * - * @param subtitle the subtitle value to set - * @return the VideoCard object itself. - */ - public VideoCard withSubtitle(String subtitle) { - this.subtitle = subtitle; - return this; - } - - /** - * Get the text value. - * - * @return the text value - */ - public String text() { - return this.text; - } - - /** - * Set the text value. - * - * @param text the text value to set - * @return the VideoCard object itself. - */ - public VideoCard withText(String text) { - this.text = text; - return this; - } - - /** - * Get the image value. - * - * @return the image value - */ - public ThumbnailUrl image() { - return this.image; - } - - /** - * Set the image value. - * - * @param image the image value to set - * @return the VideoCard object itself. - */ - public VideoCard withImage(ThumbnailUrl image) { - this.image = image; - return this; - } - - /** - * Get the media value. - * - * @return the media value - */ - public List media() { - return this.media; - } - - /** - * Set the media value. - * - * @param media the media value to set - * @return the VideoCard object itself. - */ - public VideoCard withMedia(List media) { - this.media = media; - return this; - } - - /** - * Get the buttons value. - * - * @return the buttons value - */ - public List buttons() { - return this.buttons; - } - - /** - * Set the buttons value. - * - * @param buttons the buttons value to set - * @return the VideoCard object itself. - */ - public VideoCard withButtons(List buttons) { - this.buttons = buttons; - return this; - } - - /** - * Get the shareable value. - * - * @return the shareable value - */ - public Boolean shareable() { - return this.shareable; - } - - /** - * Set the shareable value. - * - * @param shareable the shareable value to set - * @return the VideoCard object itself. - */ - public VideoCard withShareable(Boolean shareable) { - this.shareable = shareable; - return this; - } - - /** - * Get the autoloop value. - * - * @return the autoloop value - */ - public Boolean autoloop() { - return this.autoloop; - } - - /** - * Set the autoloop value. - * - * @param autoloop the autoloop value to set - * @return the VideoCard object itself. - */ - public VideoCard withAutoloop(Boolean autoloop) { - this.autoloop = autoloop; - return this; - } - - /** - * Get the autostart value. - * - * @return the autostart value - */ - public Boolean autostart() { - return this.autostart; - } - - /** - * Set the autostart value. - * - * @param autostart the autostart value to set - * @return the VideoCard object itself. - */ - public VideoCard withAutostart(Boolean autostart) { - this.autostart = autostart; - return this; - } - - /** - * Get the aspect value. - * - * @return the aspect value - */ - public String aspect() { - return this.aspect; - } - - /** - * Set the aspect value. - * - * @param aspect the aspect value to set - * @return the VideoCard object itself. - */ - public VideoCard withAspect(String aspect) { - this.aspect = aspect; - return this; - } - - /** - * Gets the duration value. - */ - public String duration(){ - return this.duration; - } - - /** - * Sets the duration value. - * - * @param duration the duration value to set - * @return the VideoCard object itself. - */ - public VideoCard withDuration(String duration){ - this.duration = duration; - return this; - } - - /** - * Get the value value. - * - * @return the value value - */ - public Object value() { - return this.value; - } - - /** - * Set the value value. - * - * @param value the value value to set - * @return the VideoCard object itself. - */ - public VideoCard withValue(Object value) { - this.value = value; - return this; - } - -} +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.bot.schema.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Video card. + */ +public class VideoCard { + /** + * Title of this card. + */ + @JsonProperty(value = "title") + private String title; + + /** + * Subtitle of this card. + */ + @JsonProperty(value = "subtitle") + private String subtitle; + + /** + * Text of this card. + */ + @JsonProperty(value = "text") + private String text; + + /** + * Thumbnail placeholder. + */ + @JsonProperty(value = "image") + private ThumbnailUrl image; + + /** + * Media URLs for this card. When this field contains more than one URL, each URL is an alternative format of the same content. + */ + @JsonProperty(value = "media") + private List media; + + /** + * Actions on this card. + */ + @JsonProperty(value = "buttons") + private List buttons; + + /** + * This content may be shared with others (default:true). + */ + @JsonProperty(value = "shareable") + private Boolean shareable; + + /** + * Should the client loop playback at end of content (default:true). + */ + @JsonProperty(value = "autoloop") + private Boolean autoloop; + + /** + * Should the client automatically start playback of media in this card + * (default:true). + */ + @JsonProperty(value = "autostart") + private Boolean autostart; + + /** + * Aspect ratio of thumbnail/media placeholder, allowed values are "16:9" + * and "4:3". + */ + @JsonProperty(value = "aspect") + private String aspect; + + /** + * Describes the length of the media content without requiring a receiver to open the content. Formatted as an ISO 8601 Duration field. + */ + @JsonProperty(value = "duration") + private String duration; + + /** + * Supplementary parameter for this card. + */ + @JsonProperty(value = "value") + private Object value; + + /** + * Get the title value. + * + * @return the title value + */ + public String title() { + return this.title; + } + + /** + * Set the title value. + * + * @param title the title value to set + * @return the VideoCard object itself. + */ + public VideoCard withTitle(String title) { + this.title = title; + return this; + } + + /** + * Get the subtitle value. + * + * @return the subtitle value + */ + public String subtitle() { + return this.subtitle; + } + + /** + * Set the subtitle value. + * + * @param subtitle the subtitle value to set + * @return the VideoCard object itself. + */ + public VideoCard withSubtitle(String subtitle) { + this.subtitle = subtitle; + return this; + } + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the VideoCard object itself. + */ + public VideoCard withText(String text) { + this.text = text; + return this; + } + + /** + * Get the image value. + * + * @return the image value + */ + public ThumbnailUrl image() { + return this.image; + } + + /** + * Set the image value. + * + * @param image the image value to set + * @return the VideoCard object itself. + */ + public VideoCard withImage(ThumbnailUrl image) { + this.image = image; + return this; + } + + /** + * Get the media value. + * + * @return the media value + */ + public List media() { + return this.media; + } + + /** + * Set the media value. + * + * @param media the media value to set + * @return the VideoCard object itself. + */ + public VideoCard withMedia(List media) { + this.media = media; + return this; + } + + /** + * Get the buttons value. + * + * @return the buttons value + */ + public List buttons() { + return this.buttons; + } + + /** + * Set the buttons value. + * + * @param buttons the buttons value to set + * @return the VideoCard object itself. + */ + public VideoCard withButtons(List buttons) { + this.buttons = buttons; + return this; + } + + /** + * Get the shareable value. + * + * @return the shareable value + */ + public Boolean shareable() { + return this.shareable; + } + + /** + * Set the shareable value. + * + * @param shareable the shareable value to set + * @return the VideoCard object itself. + */ + public VideoCard withShareable(Boolean shareable) { + this.shareable = shareable; + return this; + } + + /** + * Get the autoloop value. + * + * @return the autoloop value + */ + public Boolean autoloop() { + return this.autoloop; + } + + /** + * Set the autoloop value. + * + * @param autoloop the autoloop value to set + * @return the VideoCard object itself. + */ + public VideoCard withAutoloop(Boolean autoloop) { + this.autoloop = autoloop; + return this; + } + + /** + * Get the autostart value. + * + * @return the autostart value + */ + public Boolean autostart() { + return this.autostart; + } + + /** + * Set the autostart value. + * + * @param autostart the autostart value to set + * @return the VideoCard object itself. + */ + public VideoCard withAutostart(Boolean autostart) { + this.autostart = autostart; + return this; + } + + /** + * Get the aspect value. + * + * @return the aspect value + */ + public String aspect() { + return this.aspect; + } + + /** + * Set the aspect value. + * + * @param aspect the aspect value to set + * @return the VideoCard object itself. + */ + public VideoCard withAspect(String aspect) { + this.aspect = aspect; + return this; + } + + /** + * Gets the duration value. + */ + public String duration(){ + return this.duration; + } + + /** + * Sets the duration value. + * + * @param duration the duration value to set + * @return the VideoCard object itself. + */ + public VideoCard withDuration(String duration){ + this.duration = duration; + return this; + } + + /** + * Get the value value. + * + * @return the value value + */ + public Object value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the VideoCard object itself. + */ + public VideoCard withValue(Object value) { + this.value = value; + return this; + } + +} diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/package-info.java b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/package-info.java similarity index 98% rename from libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/package-info.java rename to libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/package-info.java index 266d6db1..50c92b17 100644 --- a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/package-info.java +++ b/libraries/bot-schema/src/main/java/com/microsoft/bot/schema/models/package-info.java @@ -1,25 +1,25 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the models classes for ConnectorClient. - * The Bot Connector REST API allows your bot to send and receive messages to channels configured in the - [Bot Framework Developer Portal](https://dev.botframework.com). The Connector service uses industry-standard REST - and JSON over HTTPS. - Client libraries for this REST API are available. See below for a list. - Many bots will use both the Bot Connector REST API and the associated [Bot State REST API](/en-us/restapi/state). The - Bot State REST API allows a bot to store and retrieve state associated with users and conversations. - Authentication for both the Bot Connector and Bot State REST APIs is accomplished with JWT Bearer tokens, and is - described in detail in the [Connector Authentication](/en-us/restapi/authentication) document. - # Client Libraries for the Bot Connector REST API - * [Bot Builder for C#](/en-us/csharp/builder/sdkreference/) - * [Bot Builder for Node.js](/en-us/node/builder/overview/) - * Generate your own from the [Connector API Swagger file](https://raw.githubusercontent.com/Microsoft/BotBuilder/master/CSharp/Library/Microsoft.Bot.Connector.Shared/Swagger/ConnectorAPI.json) - © 2016 Microsoft. - */ -package com.microsoft.bot.schema.models; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +/** + * This package contains the models classes for ConnectorClient. + * The Bot Connector REST API allows your bot to send and receive messages to channels configured in the + [Bot Framework Developer Portal](https://dev.botframework.com). The Connector service uses industry-standard REST + and JSON over HTTPS. + Client libraries for this REST API are available. See below for a list. + Many bots will use both the Bot Connector REST API and the associated [Bot State REST API](/en-us/restapi/state). The + Bot State REST API allows a bot to store and retrieve state associated with users and conversations. + Authentication for both the Bot Connector and Bot State REST APIs is accomplished with JWT Bearer tokens, and is + described in detail in the [Connector Authentication](/en-us/restapi/authentication) document. + # Client Libraries for the Bot Connector REST API + * [Bot Builder for C#](/en-us/csharp/builder/sdkreference/) + * [Bot Builder for Node.js](/en-us/node/builder/overview/) + * Generate your own from the [Connector API Swagger file](https://raw.githubusercontent.com/Microsoft/BotBuilder/master/CSharp/Library/Microsoft.Bot.Connector.Shared/Swagger/ConnectorAPI.json) + © 2016 Microsoft. + */ +package com.microsoft.bot.schema.models; diff --git a/pom.xml b/pom.xml index 10d91711..b2b8edbd 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.microsoft.bot bot-parent - 4.0.0-a0 + 4.0.0 pom @@ -30,8 +30,8 @@ - libraries/botbuilder-schema - libraries/botbuilder + libraries/bot-schema + libraries/bot-builder libraries/bot-connector samples/bot-connector-sample @@ -45,10 +45,10 @@ - ./cobertura-report/botbuilder/coverage.xml + ./cobertura-report/bot-builder/coverage.xml - ./cobertura-report/botbuilder-schema/coverage.xml + ./cobertura-report/bot-schema/coverage.xml ./cobertura-report/bot-connector/coverage.xml diff --git a/samples/bot-connector-sample/pom.xml b/samples/bot-connector-sample/pom.xml index 1eb6aebd..1a098b5e 100644 --- a/samples/bot-connector-sample/pom.xml +++ b/samples/bot-connector-sample/pom.xml @@ -2,7 +2,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.microsoft.bot.connector.sample + com.microsoft.bot.sample bot-connector-sample jar 1.0.0 @@ -49,12 +49,12 @@ 1.7.26 - com.microsoft.bot.schema - botbuilder-schema + com.microsoft.bot + bot-schema 4.0.0-SNAPSHOT - com.microsoft.bot.connector + com.microsoft.bot bot-connector 4.0.0-SNAPSHOT