diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java index 0bd102f4fd..31da20413f 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java @@ -51,8 +51,6 @@ import com.ibm.watson.assistant.v2.model.ListReleasesOptions; import com.ibm.watson.assistant.v2.model.LogCollection; import com.ibm.watson.assistant.v2.model.MessageOptions; -import com.ibm.watson.assistant.v2.model.MessageResponse; -import com.ibm.watson.assistant.v2.model.MessageResponseStateless; import com.ibm.watson.assistant.v2.model.MessageStatelessOptions; import com.ibm.watson.assistant.v2.model.Release; import com.ibm.watson.assistant.v2.model.ReleaseCollection; @@ -60,6 +58,8 @@ import com.ibm.watson.assistant.v2.model.Skill; import com.ibm.watson.assistant.v2.model.SkillsAsyncRequestStatus; import com.ibm.watson.assistant.v2.model.SkillsExport; +import com.ibm.watson.assistant.v2.model.StatefulMessageResponse; +import com.ibm.watson.assistant.v2.model.StatelessMessageResponse; import com.ibm.watson.assistant.v2.model.UpdateEnvironmentOptions; import com.ibm.watson.assistant.v2.model.UpdateSkillOptions; import com.ibm.watson.common.SdkCommon; @@ -385,9 +385,9 @@ public ServiceCall deleteSession(DeleteSessionOptions deleteSessionOptions * context data) stored by watsonx Assistant for the duration of the session. * * @param messageOptions the {@link MessageOptions} containing the options for the call - * @return a {@link ServiceCall} with a result of type {@link MessageResponse} + * @return a {@link ServiceCall} with a result of type {@link StatefulMessageResponse} */ - public ServiceCall message(MessageOptions messageOptions) { + public ServiceCall message(MessageOptions messageOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(messageOptions, "messageOptions cannot be null"); Map pathParamsMap = new HashMap(); pathParamsMap.put("assistant_id", messageOptions.assistantId()); @@ -419,9 +419,9 @@ public ServiceCall message(MessageOptions messageOptions) { contentJson.addProperty("user_id", messageOptions.userId()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = + ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() {}.getType()); + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } @@ -433,9 +433,9 @@ public ServiceCall message(MessageOptions messageOptions) { * * @param messageStatelessOptions the {@link MessageStatelessOptions} containing the options for * the call - * @return a {@link ServiceCall} with a result of type {@link MessageResponseStateless} + * @return a {@link ServiceCall} with a result of type {@link StatelessMessageResponse} */ - public ServiceCall messageStateless( + public ServiceCall messageStateless( MessageStatelessOptions messageStatelessOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( messageStatelessOptions, "messageStatelessOptions cannot be null"); @@ -469,9 +469,9 @@ public ServiceCall messageStateless( contentJson.addProperty("user_id", messageStatelessOptions.userId()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = + ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() {}.getType()); + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Log.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Log.java index d073c6d093..8a7db58292 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Log.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/Log.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020, 2023. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -21,8 +21,8 @@ public class Log extends GenericModel { @SerializedName("log_id") protected String logId; - protected MessageRequest request; - protected MessageResponse response; + protected LogRequest request; + protected LogResponse response; @SerializedName("assistant_id") protected String assistantId; @@ -62,22 +62,22 @@ public String getLogId() { /** * Gets the request. * - *

A stateful message request formatted for the Watson Assistant service. + *

A message request formatted for the watsonx Assistant service. * * @return the request */ - public MessageRequest getRequest() { + public LogRequest getRequest() { return request; } /** * Gets the response. * - *

A response from the Watson Assistant service. + *

A response from the watsonx Assistant service. * * @return the response */ - public MessageResponse getResponse() { + public LogResponse getResponse() { return response; } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageRequest.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogRequest.java similarity index 50% rename from assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageRequest.java rename to assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogRequest.java index c530b45679..a76b154364 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageRequest.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogRequest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020, 2023. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -15,103 +15,25 @@ import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** A stateful message request formatted for the Watson Assistant service. */ -public class MessageRequest extends GenericModel { +/** A message request formatted for the watsonx Assistant service. */ +public class LogRequest extends GenericModel { - protected MessageInput input; + protected LogRequestInput input; protected MessageContext context; @SerializedName("user_id") protected String userId; - /** Builder. */ - public static class Builder { - private MessageInput input; - private MessageContext context; - private String userId; - - /** - * Instantiates a new Builder from an existing MessageRequest instance. - * - * @param messageRequest the instance to initialize the Builder with - */ - private Builder(MessageRequest messageRequest) { - this.input = messageRequest.input; - this.context = messageRequest.context; - this.userId = messageRequest.userId; - } - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Builds a MessageRequest. - * - * @return the new MessageRequest instance - */ - public MessageRequest build() { - return new MessageRequest(this); - } - - /** - * Set the input. - * - * @param input the input - * @return the MessageRequest builder - */ - public Builder input(MessageInput input) { - this.input = input; - return this; - } - - /** - * Set the context. - * - * @param context the context - * @return the MessageRequest builder - */ - public Builder context(MessageContext context) { - this.context = context; - return this; - } - - /** - * Set the userId. - * - * @param userId the userId - * @return the MessageRequest builder - */ - public Builder userId(String userId) { - this.userId = userId; - return this; - } - } - - protected MessageRequest() {} - - protected MessageRequest(Builder builder) { - input = builder.input; - context = builder.context; - userId = builder.userId; - } - - /** - * New builder. - * - * @return a MessageRequest builder - */ - public Builder newBuilder() { - return new Builder(this); - } + protected LogRequest() {} /** * Gets the input. * - *

An input object that includes the input text. + *

An input object that includes the input text. All private data is masked or removed. * * @return the input */ - public MessageInput input() { + public LogRequestInput getInput() { return input; } @@ -127,7 +49,7 @@ public MessageInput input() { * * @return the context */ - public MessageContext context() { + public MessageContext getContext() { return context; } @@ -146,7 +68,7 @@ public MessageContext context() { * * @return the userId */ - public String userId() { + public String getUserId() { return userId; } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogRequestInput.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogRequestInput.java new file mode 100644 index 0000000000..9cd634b3e3 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogRequestInput.java @@ -0,0 +1,348 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** An input object that includes the input text. All private data is masked or removed. */ +public class LogRequestInput extends GenericModel { + + /** + * The type of the message: + * + *

- `text`: The user input is processed normally by the assistant. - `search`: Only search + * results are returned. (Any dialog or action skill is bypassed.) + * + *

**Note:** A `search` message results in an error if no search skill is configured for the + * assistant. + */ + public interface MessageType { + /** text. */ + String TEXT = "text"; + /** search. */ + String SEARCH = "search"; + } + + @SerializedName("message_type") + protected String messageType; + + protected String text; + protected List intents; + protected List entities; + + @SerializedName("suggestion_id") + protected String suggestionId; + + protected List attachments; + protected RequestAnalytics analytics; + protected MessageInputOptions options; + + /** Builder. */ + public static class Builder { + private String messageType; + private String text; + private List intents; + private List entities; + private String suggestionId; + private List attachments; + private RequestAnalytics analytics; + private MessageInputOptions options; + + /** + * Instantiates a new Builder from an existing LogRequestInput instance. + * + * @param logRequestInput the instance to initialize the Builder with + */ + private Builder(LogRequestInput logRequestInput) { + this.messageType = logRequestInput.messageType; + this.text = logRequestInput.text; + this.intents = logRequestInput.intents; + this.entities = logRequestInput.entities; + this.suggestionId = logRequestInput.suggestionId; + this.attachments = logRequestInput.attachments; + this.analytics = logRequestInput.analytics; + this.options = logRequestInput.options; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a LogRequestInput. + * + * @return the new LogRequestInput instance + */ + public LogRequestInput build() { + return new LogRequestInput(this); + } + + /** + * Adds a new element to intents. + * + * @param intent the new element to be added + * @return the LogRequestInput builder + */ + public Builder addIntent(RuntimeIntent intent) { + com.ibm.cloud.sdk.core.util.Validator.notNull(intent, "intent cannot be null"); + if (this.intents == null) { + this.intents = new ArrayList(); + } + this.intents.add(intent); + return this; + } + + /** + * Adds a new element to entities. + * + * @param entity the new element to be added + * @return the LogRequestInput builder + */ + public Builder addEntity(RuntimeEntity entity) { + com.ibm.cloud.sdk.core.util.Validator.notNull(entity, "entity cannot be null"); + if (this.entities == null) { + this.entities = new ArrayList(); + } + this.entities.add(entity); + return this; + } + + /** + * Adds a new element to attachments. + * + * @param attachments the new element to be added + * @return the LogRequestInput builder + */ + public Builder addAttachments(MessageInputAttachment attachments) { + com.ibm.cloud.sdk.core.util.Validator.notNull(attachments, "attachments cannot be null"); + if (this.attachments == null) { + this.attachments = new ArrayList(); + } + this.attachments.add(attachments); + return this; + } + + /** + * Set the messageType. + * + * @param messageType the messageType + * @return the LogRequestInput builder + */ + public Builder messageType(String messageType) { + this.messageType = messageType; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the LogRequestInput builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the intents. Existing intents will be replaced. + * + * @param intents the intents + * @return the LogRequestInput builder + */ + public Builder intents(List intents) { + this.intents = intents; + return this; + } + + /** + * Set the entities. Existing entities will be replaced. + * + * @param entities the entities + * @return the LogRequestInput builder + */ + public Builder entities(List entities) { + this.entities = entities; + return this; + } + + /** + * Set the suggestionId. + * + * @param suggestionId the suggestionId + * @return the LogRequestInput builder + */ + public Builder suggestionId(String suggestionId) { + this.suggestionId = suggestionId; + return this; + } + + /** + * Set the attachments. Existing attachments will be replaced. + * + * @param attachments the attachments + * @return the LogRequestInput builder + */ + public Builder attachments(List attachments) { + this.attachments = attachments; + return this; + } + + /** + * Set the analytics. + * + * @param analytics the analytics + * @return the LogRequestInput builder + */ + public Builder analytics(RequestAnalytics analytics) { + this.analytics = analytics; + return this; + } + + /** + * Set the options. + * + * @param options the options + * @return the LogRequestInput builder + */ + public Builder options(MessageInputOptions options) { + this.options = options; + return this; + } + } + + protected LogRequestInput() {} + + protected LogRequestInput(Builder builder) { + messageType = builder.messageType; + text = builder.text; + intents = builder.intents; + entities = builder.entities; + suggestionId = builder.suggestionId; + attachments = builder.attachments; + analytics = builder.analytics; + options = builder.options; + } + + /** + * New builder. + * + * @return a LogRequestInput builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the messageType. + * + *

The type of the message: + * + *

- `text`: The user input is processed normally by the assistant. - `search`: Only search + * results are returned. (Any dialog or action skill is bypassed.) + * + *

**Note:** A `search` message results in an error if no search skill is configured for the + * assistant. + * + * @return the messageType + */ + public String messageType() { + return messageType; + } + + /** + * Gets the text. + * + *

The text of the user input. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the text + */ + public String text() { + return text; + } + + /** + * Gets the intents. + * + *

Intents to use when evaluating the user input. Include intents from the previous response to + * continue using those intents rather than trying to recognize intents in the new input. + * + * @return the intents + */ + public List intents() { + return intents; + } + + /** + * Gets the entities. + * + *

Entities to use when evaluating the message. Include entities from the previous response to + * continue using those entities rather than detecting entities in the new input. + * + * @return the entities + */ + public List entities() { + return entities; + } + + /** + * Gets the suggestionId. + * + *

For internal use only. + * + * @return the suggestionId + */ + public String suggestionId() { + return suggestionId; + } + + /** + * Gets the attachments. + * + *

An array of multimedia attachments to be sent with the message. Attachments are not + * processed by the assistant itself, but can be sent to external services by webhooks. + * + *

**Note:** Attachments are not supported on IBM Cloud Pak for Data. + * + * @return the attachments + */ + public List attachments() { + return attachments; + } + + /** + * Gets the analytics. + * + *

An optional object containing analytics data. Currently, this data is used only for events + * sent to the Segment extension. + * + * @return the analytics + */ + public RequestAnalytics analytics() { + return analytics; + } + + /** + * Gets the options. + * + *

Optional properties that control how the assistant responds. + * + * @return the options + */ + public MessageInputOptions options() { + return options; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogResponse.java similarity index 88% rename from assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageResponse.java rename to assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogResponse.java index 8986224dfe..4addd4267f 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageResponse.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2023. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -15,25 +15,26 @@ import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** A response from the Watson Assistant service. */ -public class MessageResponse extends GenericModel { +/** A response from the watsonx Assistant service. */ +public class LogResponse extends GenericModel { - protected MessageOutput output; + protected LogResponseOutput output; protected MessageContext context; @SerializedName("user_id") protected String userId; - protected MessageResponse() {} + protected LogResponse() {} /** * Gets the output. * - *

Assistant output to be rendered or processed by the client. + *

Assistant output to be rendered or processed by the client. All private data is masked or + * removed. * * @return the output */ - public MessageOutput getOutput() { + public LogResponseOutput getOutput() { return output; } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogResponseOutput.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogResponseOutput.java new file mode 100644 index 0000000000..1229aa9158 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/LogResponseOutput.java @@ -0,0 +1,117 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; +import java.util.Map; + +/** + * Assistant output to be rendered or processed by the client. All private data is masked or + * removed. + */ +public class LogResponseOutput extends GenericModel { + + protected List generic; + protected List intents; + protected List entities; + protected List actions; + protected MessageOutputDebug debug; + + @SerializedName("user_defined") + protected Map userDefined; + + protected MessageOutputSpelling spelling; + + protected LogResponseOutput() {} + + /** + * Gets the generic. + * + *

Output intended for any channel. It is the responsibility of the client application to + * implement the supported response types. + * + * @return the generic + */ + public List getGeneric() { + return generic; + } + + /** + * Gets the intents. + * + *

An array of intents recognized in the user input, sorted in descending order of confidence. + * + * @return the intents + */ + public List getIntents() { + return intents; + } + + /** + * Gets the entities. + * + *

An array of entities identified in the user input. + * + * @return the entities + */ + public List getEntities() { + return entities; + } + + /** + * Gets the actions. + * + *

An array of objects describing any actions requested by the dialog node. + * + * @return the actions + */ + public List getActions() { + return actions; + } + + /** + * Gets the debug. + * + *

Additional detailed information about a message response and how it was generated. + * + * @return the debug + */ + public MessageOutputDebug getDebug() { + return debug; + } + + /** + * Gets the userDefined. + * + *

An object containing any custom properties included in the response. This object includes + * any arbitrary properties defined in the dialog JSON editor as part of the dialog node output. + * + * @return the userDefined + */ + public Map getUserDefined() { + return userDefined; + } + + /** + * Gets the spelling. + * + *

Properties describing any spelling corrections in the user input that was received. + * + * @return the spelling + */ + public MessageOutputSpelling getSpelling() { + return spelling; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextActionSkill.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextActionSkill.java new file mode 100644 index 0000000000..f172a5ccde --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextActionSkill.java @@ -0,0 +1,177 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** + * Context variables that are used by the action skill. Private variables are persisted, but not + * shown. + */ +public class MessageContextActionSkill extends GenericModel { + + @SerializedName("user_defined") + protected Map userDefined; + + protected MessageContextSkillSystem system; + + @SerializedName("action_variables") + protected Map actionVariables; + + @SerializedName("skill_variables") + protected Map skillVariables; + + /** Builder. */ + public static class Builder { + private Map userDefined; + private MessageContextSkillSystem system; + private Map actionVariables; + private Map skillVariables; + + /** + * Instantiates a new Builder from an existing MessageContextActionSkill instance. + * + * @param messageContextActionSkill the instance to initialize the Builder with + */ + private Builder(MessageContextActionSkill messageContextActionSkill) { + this.userDefined = messageContextActionSkill.userDefined; + this.system = messageContextActionSkill.system; + this.actionVariables = messageContextActionSkill.actionVariables; + this.skillVariables = messageContextActionSkill.skillVariables; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a MessageContextActionSkill. + * + * @return the new MessageContextActionSkill instance + */ + public MessageContextActionSkill build() { + return new MessageContextActionSkill(this); + } + + /** + * Set the userDefined. + * + * @param userDefined the userDefined + * @return the MessageContextActionSkill builder + */ + public Builder userDefined(Map userDefined) { + this.userDefined = userDefined; + return this; + } + + /** + * Set the system. + * + * @param system the system + * @return the MessageContextActionSkill builder + */ + public Builder system(MessageContextSkillSystem system) { + this.system = system; + return this; + } + + /** + * Set the actionVariables. + * + * @param actionVariables the actionVariables + * @return the MessageContextActionSkill builder + */ + public Builder actionVariables(Map actionVariables) { + this.actionVariables = actionVariables; + return this; + } + + /** + * Set the skillVariables. + * + * @param skillVariables the skillVariables + * @return the MessageContextActionSkill builder + */ + public Builder skillVariables(Map skillVariables) { + this.skillVariables = skillVariables; + return this; + } + } + + protected MessageContextActionSkill() {} + + protected MessageContextActionSkill(Builder builder) { + userDefined = builder.userDefined; + system = builder.system; + actionVariables = builder.actionVariables; + skillVariables = builder.skillVariables; + } + + /** + * New builder. + * + * @return a MessageContextActionSkill builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the userDefined. + * + *

An object containing any arbitrary variables that can be read and written by a particular + * skill. + * + * @return the userDefined + */ + public Map userDefined() { + return userDefined; + } + + /** + * Gets the system. + * + *

System context data used by the skill. + * + * @return the system + */ + public MessageContextSkillSystem system() { + return system; + } + + /** + * Gets the actionVariables. + * + *

An object containing action variables. Action variables can be accessed only by steps in the + * same action, and do not persist after the action ends. + * + * @return the actionVariables + */ + public Map actionVariables() { + return actionVariables; + } + + /** + * Gets the skillVariables. + * + *

An object containing skill variables. (In the watsonx Assistant user interface, skill + * variables are called _session variables_.) Skill variables can be accessed by any action and + * persist for the duration of the session. + * + * @return the skillVariables + */ + public Map skillVariables() { + return skillVariables; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextDialogSkill.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextDialogSkill.java new file mode 100644 index 0000000000..b53c711235 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextDialogSkill.java @@ -0,0 +1,115 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** Context variables that are used by the dialog skill. */ +public class MessageContextDialogSkill extends GenericModel { + + @SerializedName("user_defined") + protected Map userDefined; + + protected MessageContextSkillSystem system; + + /** Builder. */ + public static class Builder { + private Map userDefined; + private MessageContextSkillSystem system; + + /** + * Instantiates a new Builder from an existing MessageContextDialogSkill instance. + * + * @param messageContextDialogSkill the instance to initialize the Builder with + */ + private Builder(MessageContextDialogSkill messageContextDialogSkill) { + this.userDefined = messageContextDialogSkill.userDefined; + this.system = messageContextDialogSkill.system; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a MessageContextDialogSkill. + * + * @return the new MessageContextDialogSkill instance + */ + public MessageContextDialogSkill build() { + return new MessageContextDialogSkill(this); + } + + /** + * Set the userDefined. + * + * @param userDefined the userDefined + * @return the MessageContextDialogSkill builder + */ + public Builder userDefined(Map userDefined) { + this.userDefined = userDefined; + return this; + } + + /** + * Set the system. + * + * @param system the system + * @return the MessageContextDialogSkill builder + */ + public Builder system(MessageContextSkillSystem system) { + this.system = system; + return this; + } + } + + protected MessageContextDialogSkill() {} + + protected MessageContextDialogSkill(Builder builder) { + userDefined = builder.userDefined; + system = builder.system; + } + + /** + * New builder. + * + * @return a MessageContextDialogSkill builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the userDefined. + * + *

An object containing any arbitrary variables that can be read and written by a particular + * skill. + * + * @return the userDefined + */ + public Map userDefined() { + return userDefined; + } + + /** + * Gets the system. + * + *

System context data used by the skill. + * + * @return the system + */ + public MessageContextSkillSystem system() { + return system; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkills.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkills.java index c95d33ccc7..4d3e065e64 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkills.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkills.java @@ -19,15 +19,15 @@ public class MessageContextSkills extends GenericModel { @SerializedName("main skill") - protected MessageContextSkillDialog mainSkill; + protected MessageContextDialogSkill mainSkill; @SerializedName("actions skill") - protected MessageContextSkillAction actionsSkill; + protected MessageContextActionSkill actionsSkill; /** Builder. */ public static class Builder { - private MessageContextSkillDialog mainSkill; - private MessageContextSkillAction actionsSkill; + private MessageContextDialogSkill mainSkill; + private MessageContextActionSkill actionsSkill; /** * Instantiates a new Builder from an existing MessageContextSkills instance. @@ -57,7 +57,7 @@ public MessageContextSkills build() { * @param mainSkill the mainSkill * @return the MessageContextSkills builder */ - public Builder mainSkill(MessageContextSkillDialog mainSkill) { + public Builder mainSkill(MessageContextDialogSkill mainSkill) { this.mainSkill = mainSkill; return this; } @@ -68,7 +68,7 @@ public Builder mainSkill(MessageContextSkillDialog mainSkill) { * @param actionsSkill the actionsSkill * @return the MessageContextSkills builder */ - public Builder actionsSkill(MessageContextSkillAction actionsSkill) { + public Builder actionsSkill(MessageContextActionSkill actionsSkill) { this.actionsSkill = actionsSkill; return this; } @@ -97,7 +97,7 @@ public Builder newBuilder() { * * @return the mainSkill */ - public MessageContextSkillDialog mainSkill() { + public MessageContextDialogSkill mainSkill() { return mainSkill; } @@ -109,7 +109,7 @@ public MessageContextSkillDialog mainSkill() { * * @return the actionsSkill */ - public MessageContextSkillAction actionsSkill() { + public MessageContextActionSkill actionsSkill() { return actionsSkill; } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOptions.java index 08f237020f..5d9f41c989 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOptions.java @@ -121,19 +121,6 @@ public Builder userId(String userId) { this.userId = userId; return this; } - - /** - * Set the messageRequest. - * - * @param messageRequest the messageRequest - * @return the MessageOptions builder - */ - public Builder messageRequest(MessageRequest messageRequest) { - this.input = messageRequest.input(); - this.context = messageRequest.context(); - this.userId = messageRequest.userId(); - return this; - } } protected MessageOptions() {} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptions.java index bb4e4bdf3d..8e8bddf4e2 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020, 2023. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -18,15 +18,15 @@ public class MessageStatelessOptions extends GenericModel { protected String assistantId; - protected MessageInputStateless input; - protected MessageContextStateless context; + protected StatelessMessageInput input; + protected StatelessMessageContext context; protected String userId; /** Builder. */ public static class Builder { private String assistantId; - private MessageInputStateless input; - private MessageContextStateless context; + private StatelessMessageInput input; + private StatelessMessageContext context; private String userId; /** @@ -79,7 +79,7 @@ public Builder assistantId(String assistantId) { * @param input the input * @return the MessageStatelessOptions builder */ - public Builder input(MessageInputStateless input) { + public Builder input(StatelessMessageInput input) { this.input = input; return this; } @@ -90,7 +90,7 @@ public Builder input(MessageInputStateless input) { * @param context the context * @return the MessageStatelessOptions builder */ - public Builder context(MessageContextStateless context) { + public Builder context(StatelessMessageContext context) { this.context = context; return this; } @@ -135,7 +135,7 @@ public Builder newBuilder() { * environment ID of the environment where the assistant is deployed. - For all other requests, * specify the assistant ID of the assistant. * - *

To find the environment ID or assistant ID in the Watson Assistant user interface, open the + *

To find the environment ID or assistant ID in the watsonx Assistant user interface, open the * assistant settings and scroll to the **Environments** section. * *

**Note:** If you are using the classic Watson Assistant experience, always use the assistant @@ -155,7 +155,7 @@ public String assistantId() { * * @return the input */ - public MessageInputStateless input() { + public StatelessMessageInput input() { return input; } @@ -170,7 +170,7 @@ public MessageInputStateless input() { * * @return the context */ - public MessageContextStateless context() { + public StatelessMessageContext context() { return context; } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatefulMessageResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatefulMessageResponse.java new file mode 100644 index 0000000000..2216d78bb6 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatefulMessageResponse.java @@ -0,0 +1,101 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** A response from the watsonx Assistant service. */ +public class StatefulMessageResponse extends GenericModel { + + protected MessageOutput output; + protected MessageContext context; + + @SerializedName("user_id") + protected String userId; + + @SerializedName("masked_output") + protected MessageOutput maskedOutput; + + @SerializedName("masked_input") + protected MessageInput maskedInput; + + protected StatefulMessageResponse() {} + + /** + * Gets the output. + * + *

Assistant output to be rendered or processed by the client. + * + * @return the output + */ + public MessageOutput getOutput() { + return output; + } + + /** + * Gets the context. + * + *

Context data for the conversation. You can use this property to access context variables. + * The context is stored by the assistant on a per-session basis. + * + *

**Note:** The context is included in message responses only if **return_context**=`true` in + * the message request. Full context is always included in logs. + * + * @return the context + */ + public MessageContext getContext() { + return context; + } + + /** + * Gets the userId. + * + *

A string value that identifies the user who is interacting with the assistant. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.global.session_id**. + * + *

**Note:** This property is the same as the **user_id** property in the global system + * context. + * + * @return the userId + */ + public String getUserId() { + return userId; + } + + /** + * Gets the maskedOutput. + * + *

Assistant output to be rendered or processed by the client. All private data is masked or + * removed. + * + * @return the maskedOutput + */ + public MessageOutput getMaskedOutput() { + return maskedOutput; + } + + /** + * Gets the maskedInput. + * + *

An input object that includes the input text. All private data is masked or removed. + * + * @return the maskedInput + */ + public MessageInput getMaskedInput() { + return maskedInput; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContext.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContext.java new file mode 100644 index 0000000000..7fed7ae990 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContext.java @@ -0,0 +1,139 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** StatelessMessageContext. */ +public class StatelessMessageContext extends GenericModel { + + protected StatelessMessageContextGlobal global; + protected StatelessMessageContextSkills skills; + protected Map integrations; + + /** Builder. */ + public static class Builder { + private StatelessMessageContextGlobal global; + private StatelessMessageContextSkills skills; + private Map integrations; + + /** + * Instantiates a new Builder from an existing StatelessMessageContext instance. + * + * @param statelessMessageContext the instance to initialize the Builder with + */ + private Builder(StatelessMessageContext statelessMessageContext) { + this.global = statelessMessageContext.global; + this.skills = statelessMessageContext.skills; + this.integrations = statelessMessageContext.integrations; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a StatelessMessageContext. + * + * @return the new StatelessMessageContext instance + */ + public StatelessMessageContext build() { + return new StatelessMessageContext(this); + } + + /** + * Set the global. + * + * @param global the global + * @return the StatelessMessageContext builder + */ + public Builder global(StatelessMessageContextGlobal global) { + this.global = global; + return this; + } + + /** + * Set the skills. + * + * @param skills the skills + * @return the StatelessMessageContext builder + */ + public Builder skills(StatelessMessageContextSkills skills) { + this.skills = skills; + return this; + } + + /** + * Set the integrations. + * + * @param integrations the integrations + * @return the StatelessMessageContext builder + */ + public Builder integrations(Map integrations) { + this.integrations = integrations; + return this; + } + } + + protected StatelessMessageContext() {} + + protected StatelessMessageContext(Builder builder) { + global = builder.global; + skills = builder.skills; + integrations = builder.integrations; + } + + /** + * New builder. + * + * @return a StatelessMessageContext builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the global. + * + *

Session context data that is shared by all skills used by the assistant. + * + * @return the global + */ + public StatelessMessageContextGlobal global() { + return global; + } + + /** + * Gets the skills. + * + *

Context data specific to particular skills used by the assistant. + * + * @return the skills + */ + public StatelessMessageContextSkills skills() { + return skills; + } + + /** + * Gets the integrations. + * + *

An object containing context data that is specific to particular integrations. For more + * information, see the + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-integrations). + * + * @return the integrations + */ + public Map integrations() { + return integrations; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextGlobal.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextGlobal.java new file mode 100644 index 0000000000..80f2a41437 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextGlobal.java @@ -0,0 +1,113 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Session context data that is shared by all skills used by the assistant. */ +public class StatelessMessageContextGlobal extends GenericModel { + + protected MessageContextGlobalSystem system; + + @SerializedName("session_id") + protected String sessionId; + + /** Builder. */ + public static class Builder { + private MessageContextGlobalSystem system; + private String sessionId; + + /** + * Instantiates a new Builder from an existing StatelessMessageContextGlobal instance. + * + * @param statelessMessageContextGlobal the instance to initialize the Builder with + */ + private Builder(StatelessMessageContextGlobal statelessMessageContextGlobal) { + this.system = statelessMessageContextGlobal.system; + this.sessionId = statelessMessageContextGlobal.sessionId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a StatelessMessageContextGlobal. + * + * @return the new StatelessMessageContextGlobal instance + */ + public StatelessMessageContextGlobal build() { + return new StatelessMessageContextGlobal(this); + } + + /** + * Set the system. + * + * @param system the system + * @return the StatelessMessageContextGlobal builder + */ + public Builder system(MessageContextGlobalSystem system) { + this.system = system; + return this; + } + + /** + * Set the sessionId. + * + * @param sessionId the sessionId + * @return the StatelessMessageContextGlobal builder + */ + public Builder sessionId(String sessionId) { + this.sessionId = sessionId; + return this; + } + } + + protected StatelessMessageContextGlobal() {} + + protected StatelessMessageContextGlobal(Builder builder) { + system = builder.system; + sessionId = builder.sessionId; + } + + /** + * New builder. + * + * @return a StatelessMessageContextGlobal builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the system. + * + *

Built-in system properties that apply to all skills used by the assistant. + * + * @return the system + */ + public MessageContextGlobalSystem system() { + return system; + } + + /** + * Gets the sessionId. + * + *

The unique identifier of the session. + * + * @return the sessionId + */ + public String sessionId() { + return sessionId; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkills.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkills.java new file mode 100644 index 0000000000..48ea9f6d89 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkills.java @@ -0,0 +1,114 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Context data specific to particular skills used by the assistant. */ +public class StatelessMessageContextSkills extends GenericModel { + + @SerializedName("main skill") + protected MessageContextDialogSkill mainSkill; + + @SerializedName("actions skill") + protected StatelessMessageContextSkillsActionsSkill actionsSkill; + + /** Builder. */ + public static class Builder { + private MessageContextDialogSkill mainSkill; + private StatelessMessageContextSkillsActionsSkill actionsSkill; + + /** + * Instantiates a new Builder from an existing StatelessMessageContextSkills instance. + * + * @param statelessMessageContextSkills the instance to initialize the Builder with + */ + private Builder(StatelessMessageContextSkills statelessMessageContextSkills) { + this.mainSkill = statelessMessageContextSkills.mainSkill; + this.actionsSkill = statelessMessageContextSkills.actionsSkill; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a StatelessMessageContextSkills. + * + * @return the new StatelessMessageContextSkills instance + */ + public StatelessMessageContextSkills build() { + return new StatelessMessageContextSkills(this); + } + + /** + * Set the mainSkill. + * + * @param mainSkill the mainSkill + * @return the StatelessMessageContextSkills builder + */ + public Builder mainSkill(MessageContextDialogSkill mainSkill) { + this.mainSkill = mainSkill; + return this; + } + + /** + * Set the actionsSkill. + * + * @param actionsSkill the actionsSkill + * @return the StatelessMessageContextSkills builder + */ + public Builder actionsSkill(StatelessMessageContextSkillsActionsSkill actionsSkill) { + this.actionsSkill = actionsSkill; + return this; + } + } + + protected StatelessMessageContextSkills() {} + + protected StatelessMessageContextSkills(Builder builder) { + mainSkill = builder.mainSkill; + actionsSkill = builder.actionsSkill; + } + + /** + * New builder. + * + * @return a StatelessMessageContextSkills builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the mainSkill. + * + *

Context variables that are used by the dialog skill. + * + * @return the mainSkill + */ + public MessageContextDialogSkill mainSkill() { + return mainSkill; + } + + /** + * Gets the actionsSkill. + * + *

Context variables that are used by the action skill. + * + * @return the actionsSkill + */ + public StatelessMessageContextSkillsActionsSkill actionsSkill() { + return actionsSkill; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsActionsSkill.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsActionsSkill.java new file mode 100644 index 0000000000..f81d6c7ca3 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsActionsSkill.java @@ -0,0 +1,237 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** Context variables that are used by the action skill. */ +public class StatelessMessageContextSkillsActionsSkill extends GenericModel { + + @SerializedName("user_defined") + protected Map userDefined; + + protected MessageContextSkillSystem system; + + @SerializedName("action_variables") + protected Map actionVariables; + + @SerializedName("skill_variables") + protected Map skillVariables; + + @SerializedName("private_action_variables") + protected Map privateActionVariables; + + @SerializedName("private_skill_variables") + protected Map privateSkillVariables; + + /** Builder. */ + public static class Builder { + private Map userDefined; + private MessageContextSkillSystem system; + private Map actionVariables; + private Map skillVariables; + private Map privateActionVariables; + private Map privateSkillVariables; + + /** + * Instantiates a new Builder from an existing StatelessMessageContextSkillsActionsSkill + * instance. + * + * @param statelessMessageContextSkillsActionsSkill the instance to initialize the Builder with + */ + private Builder( + StatelessMessageContextSkillsActionsSkill statelessMessageContextSkillsActionsSkill) { + this.userDefined = statelessMessageContextSkillsActionsSkill.userDefined; + this.system = statelessMessageContextSkillsActionsSkill.system; + this.actionVariables = statelessMessageContextSkillsActionsSkill.actionVariables; + this.skillVariables = statelessMessageContextSkillsActionsSkill.skillVariables; + this.privateActionVariables = + statelessMessageContextSkillsActionsSkill.privateActionVariables; + this.privateSkillVariables = statelessMessageContextSkillsActionsSkill.privateSkillVariables; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a StatelessMessageContextSkillsActionsSkill. + * + * @return the new StatelessMessageContextSkillsActionsSkill instance + */ + public StatelessMessageContextSkillsActionsSkill build() { + return new StatelessMessageContextSkillsActionsSkill(this); + } + + /** + * Set the userDefined. + * + * @param userDefined the userDefined + * @return the StatelessMessageContextSkillsActionsSkill builder + */ + public Builder userDefined(Map userDefined) { + this.userDefined = userDefined; + return this; + } + + /** + * Set the system. + * + * @param system the system + * @return the StatelessMessageContextSkillsActionsSkill builder + */ + public Builder system(MessageContextSkillSystem system) { + this.system = system; + return this; + } + + /** + * Set the actionVariables. + * + * @param actionVariables the actionVariables + * @return the StatelessMessageContextSkillsActionsSkill builder + */ + public Builder actionVariables(Map actionVariables) { + this.actionVariables = actionVariables; + return this; + } + + /** + * Set the skillVariables. + * + * @param skillVariables the skillVariables + * @return the StatelessMessageContextSkillsActionsSkill builder + */ + public Builder skillVariables(Map skillVariables) { + this.skillVariables = skillVariables; + return this; + } + + /** + * Set the privateActionVariables. + * + * @param privateActionVariables the privateActionVariables + * @return the StatelessMessageContextSkillsActionsSkill builder + */ + public Builder privateActionVariables(Map privateActionVariables) { + this.privateActionVariables = privateActionVariables; + return this; + } + + /** + * Set the privateSkillVariables. + * + * @param privateSkillVariables the privateSkillVariables + * @return the StatelessMessageContextSkillsActionsSkill builder + */ + public Builder privateSkillVariables(Map privateSkillVariables) { + this.privateSkillVariables = privateSkillVariables; + return this; + } + } + + protected StatelessMessageContextSkillsActionsSkill() {} + + protected StatelessMessageContextSkillsActionsSkill(Builder builder) { + userDefined = builder.userDefined; + system = builder.system; + actionVariables = builder.actionVariables; + skillVariables = builder.skillVariables; + privateActionVariables = builder.privateActionVariables; + privateSkillVariables = builder.privateSkillVariables; + } + + /** + * New builder. + * + * @return a StatelessMessageContextSkillsActionsSkill builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the userDefined. + * + *

An object containing any arbitrary variables that can be read and written by a particular + * skill. + * + * @return the userDefined + */ + public Map userDefined() { + return userDefined; + } + + /** + * Gets the system. + * + *

System context data used by the skill. + * + * @return the system + */ + public MessageContextSkillSystem system() { + return system; + } + + /** + * Gets the actionVariables. + * + *

An object containing action variables. Action variables can be accessed only by steps in the + * same action, and do not persist after the action ends. + * + * @return the actionVariables + */ + public Map actionVariables() { + return actionVariables; + } + + /** + * Gets the skillVariables. + * + *

An object containing skill variables. (In the watsonx Assistant user interface, skill + * variables are called _session variables_.) Skill variables can be accessed by any action and + * persist for the duration of the session. + * + * @return the skillVariables + */ + public Map skillVariables() { + return skillVariables; + } + + /** + * Gets the privateActionVariables. + * + *

An object containing private action variables. Action variables can be accessed only by + * steps in the same action, and do not persist after the action ends. Private variables are + * encrypted. + * + * @return the privateActionVariables + */ + public Map privateActionVariables() { + return privateActionVariables; + } + + /** + * Gets the privateSkillVariables. + * + *

An object containing private skill variables. (In the watsonx Assistant user interface, + * skill variables are called _session variables_.) Skill variables can be accessed by any action + * and persist for the duration of the session. Private variables are encrypted. + * + * @return the privateSkillVariables + */ + public Map privateSkillVariables() { + return privateSkillVariables; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageInput.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageInput.java new file mode 100644 index 0000000000..3b4469784c --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageInput.java @@ -0,0 +1,348 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** An input object that includes the input text. */ +public class StatelessMessageInput extends GenericModel { + + /** + * The type of the message: + * + *

- `text`: The user input is processed normally by the assistant. - `search`: Only search + * results are returned. (Any dialog or action skill is bypassed.) + * + *

**Note:** A `search` message results in an error if no search skill is configured for the + * assistant. + */ + public interface MessageType { + /** text. */ + String TEXT = "text"; + /** search. */ + String SEARCH = "search"; + } + + @SerializedName("message_type") + protected String messageType; + + protected String text; + protected List intents; + protected List entities; + + @SerializedName("suggestion_id") + protected String suggestionId; + + protected List attachments; + protected RequestAnalytics analytics; + protected StatelessMessageInputOptions options; + + /** Builder. */ + public static class Builder { + private String messageType; + private String text; + private List intents; + private List entities; + private String suggestionId; + private List attachments; + private RequestAnalytics analytics; + private StatelessMessageInputOptions options; + + /** + * Instantiates a new Builder from an existing StatelessMessageInput instance. + * + * @param statelessMessageInput the instance to initialize the Builder with + */ + private Builder(StatelessMessageInput statelessMessageInput) { + this.messageType = statelessMessageInput.messageType; + this.text = statelessMessageInput.text; + this.intents = statelessMessageInput.intents; + this.entities = statelessMessageInput.entities; + this.suggestionId = statelessMessageInput.suggestionId; + this.attachments = statelessMessageInput.attachments; + this.analytics = statelessMessageInput.analytics; + this.options = statelessMessageInput.options; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a StatelessMessageInput. + * + * @return the new StatelessMessageInput instance + */ + public StatelessMessageInput build() { + return new StatelessMessageInput(this); + } + + /** + * Adds a new element to intents. + * + * @param intent the new element to be added + * @return the StatelessMessageInput builder + */ + public Builder addIntent(RuntimeIntent intent) { + com.ibm.cloud.sdk.core.util.Validator.notNull(intent, "intent cannot be null"); + if (this.intents == null) { + this.intents = new ArrayList(); + } + this.intents.add(intent); + return this; + } + + /** + * Adds a new element to entities. + * + * @param entity the new element to be added + * @return the StatelessMessageInput builder + */ + public Builder addEntity(RuntimeEntity entity) { + com.ibm.cloud.sdk.core.util.Validator.notNull(entity, "entity cannot be null"); + if (this.entities == null) { + this.entities = new ArrayList(); + } + this.entities.add(entity); + return this; + } + + /** + * Adds a new element to attachments. + * + * @param attachments the new element to be added + * @return the StatelessMessageInput builder + */ + public Builder addAttachments(MessageInputAttachment attachments) { + com.ibm.cloud.sdk.core.util.Validator.notNull(attachments, "attachments cannot be null"); + if (this.attachments == null) { + this.attachments = new ArrayList(); + } + this.attachments.add(attachments); + return this; + } + + /** + * Set the messageType. + * + * @param messageType the messageType + * @return the StatelessMessageInput builder + */ + public Builder messageType(String messageType) { + this.messageType = messageType; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the StatelessMessageInput builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the intents. Existing intents will be replaced. + * + * @param intents the intents + * @return the StatelessMessageInput builder + */ + public Builder intents(List intents) { + this.intents = intents; + return this; + } + + /** + * Set the entities. Existing entities will be replaced. + * + * @param entities the entities + * @return the StatelessMessageInput builder + */ + public Builder entities(List entities) { + this.entities = entities; + return this; + } + + /** + * Set the suggestionId. + * + * @param suggestionId the suggestionId + * @return the StatelessMessageInput builder + */ + public Builder suggestionId(String suggestionId) { + this.suggestionId = suggestionId; + return this; + } + + /** + * Set the attachments. Existing attachments will be replaced. + * + * @param attachments the attachments + * @return the StatelessMessageInput builder + */ + public Builder attachments(List attachments) { + this.attachments = attachments; + return this; + } + + /** + * Set the analytics. + * + * @param analytics the analytics + * @return the StatelessMessageInput builder + */ + public Builder analytics(RequestAnalytics analytics) { + this.analytics = analytics; + return this; + } + + /** + * Set the options. + * + * @param options the options + * @return the StatelessMessageInput builder + */ + public Builder options(StatelessMessageInputOptions options) { + this.options = options; + return this; + } + } + + protected StatelessMessageInput() {} + + protected StatelessMessageInput(Builder builder) { + messageType = builder.messageType; + text = builder.text; + intents = builder.intents; + entities = builder.entities; + suggestionId = builder.suggestionId; + attachments = builder.attachments; + analytics = builder.analytics; + options = builder.options; + } + + /** + * New builder. + * + * @return a StatelessMessageInput builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the messageType. + * + *

The type of the message: + * + *

- `text`: The user input is processed normally by the assistant. - `search`: Only search + * results are returned. (Any dialog or action skill is bypassed.) + * + *

**Note:** A `search` message results in an error if no search skill is configured for the + * assistant. + * + * @return the messageType + */ + public String messageType() { + return messageType; + } + + /** + * Gets the text. + * + *

The text of the user input. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the text + */ + public String text() { + return text; + } + + /** + * Gets the intents. + * + *

Intents to use when evaluating the user input. Include intents from the previous response to + * continue using those intents rather than trying to recognize intents in the new input. + * + * @return the intents + */ + public List intents() { + return intents; + } + + /** + * Gets the entities. + * + *

Entities to use when evaluating the message. Include entities from the previous response to + * continue using those entities rather than detecting entities in the new input. + * + * @return the entities + */ + public List entities() { + return entities; + } + + /** + * Gets the suggestionId. + * + *

For internal use only. + * + * @return the suggestionId + */ + public String suggestionId() { + return suggestionId; + } + + /** + * Gets the attachments. + * + *

An array of multimedia attachments to be sent with the message. Attachments are not + * processed by the assistant itself, but can be sent to external services by webhooks. + * + *

**Note:** Attachments are not supported on IBM Cloud Pak for Data. + * + * @return the attachments + */ + public List attachments() { + return attachments; + } + + /** + * Gets the analytics. + * + *

An optional object containing analytics data. Currently, this data is used only for events + * sent to the Segment extension. + * + * @return the analytics + */ + public RequestAnalytics analytics() { + return analytics; + } + + /** + * Gets the options. + * + *

Optional properties that control how the assistant responds. + * + * @return the options + */ + public StatelessMessageInputOptions options() { + return options; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputOptions.java new file mode 100644 index 0000000000..066dabb74e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputOptions.java @@ -0,0 +1,202 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Optional properties that control how the assistant responds. */ +public class StatelessMessageInputOptions extends GenericModel { + + protected Boolean restart; + + @SerializedName("alternate_intents") + protected Boolean alternateIntents; + + @SerializedName("async_callout") + protected Boolean asyncCallout; + + protected MessageInputOptionsSpelling spelling; + protected Boolean debug; + + /** Builder. */ + public static class Builder { + private Boolean restart; + private Boolean alternateIntents; + private Boolean asyncCallout; + private MessageInputOptionsSpelling spelling; + private Boolean debug; + + /** + * Instantiates a new Builder from an existing StatelessMessageInputOptions instance. + * + * @param statelessMessageInputOptions the instance to initialize the Builder with + */ + private Builder(StatelessMessageInputOptions statelessMessageInputOptions) { + this.restart = statelessMessageInputOptions.restart; + this.alternateIntents = statelessMessageInputOptions.alternateIntents; + this.asyncCallout = statelessMessageInputOptions.asyncCallout; + this.spelling = statelessMessageInputOptions.spelling; + this.debug = statelessMessageInputOptions.debug; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a StatelessMessageInputOptions. + * + * @return the new StatelessMessageInputOptions instance + */ + public StatelessMessageInputOptions build() { + return new StatelessMessageInputOptions(this); + } + + /** + * Set the restart. + * + * @param restart the restart + * @return the StatelessMessageInputOptions builder + */ + public Builder restart(Boolean restart) { + this.restart = restart; + return this; + } + + /** + * Set the alternateIntents. + * + * @param alternateIntents the alternateIntents + * @return the StatelessMessageInputOptions builder + */ + public Builder alternateIntents(Boolean alternateIntents) { + this.alternateIntents = alternateIntents; + return this; + } + + /** + * Set the asyncCallout. + * + * @param asyncCallout the asyncCallout + * @return the StatelessMessageInputOptions builder + */ + public Builder asyncCallout(Boolean asyncCallout) { + this.asyncCallout = asyncCallout; + return this; + } + + /** + * Set the spelling. + * + * @param spelling the spelling + * @return the StatelessMessageInputOptions builder + */ + public Builder spelling(MessageInputOptionsSpelling spelling) { + this.spelling = spelling; + return this; + } + + /** + * Set the debug. + * + * @param debug the debug + * @return the StatelessMessageInputOptions builder + */ + public Builder debug(Boolean debug) { + this.debug = debug; + return this; + } + } + + protected StatelessMessageInputOptions() {} + + protected StatelessMessageInputOptions(Builder builder) { + restart = builder.restart; + alternateIntents = builder.alternateIntents; + asyncCallout = builder.asyncCallout; + spelling = builder.spelling; + debug = builder.debug; + } + + /** + * New builder. + * + * @return a StatelessMessageInputOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the restart. + * + *

Whether to restart dialog processing at the root of the dialog, regardless of any previously + * visited nodes. **Note:** This does not affect `turn_count` or any other context variables. + * + * @return the restart + */ + public Boolean restart() { + return restart; + } + + /** + * Gets the alternateIntents. + * + *

Whether to return more than one intent. Set to `true` to return all matching intents. + * + * @return the alternateIntents + */ + public Boolean alternateIntents() { + return alternateIntents; + } + + /** + * Gets the asyncCallout. + * + *

Whether custom extension callouts are executed asynchronously. Asynchronous execution means + * the response to the extension callout will be processed on the subsequent message call, the + * initial message response signals to the client that the operation may be long running. With + * synchronous execution the custom extension is executed and returns the response in a single + * message turn. **Note:** **async_callout** defaults to true for API versions earlier than + * 2023-06-15. + * + * @return the asyncCallout + */ + public Boolean asyncCallout() { + return asyncCallout; + } + + /** + * Gets the spelling. + * + *

Spelling correction options for the message. Any options specified on an individual message + * override the settings configured for the skill. + * + * @return the spelling + */ + public MessageInputOptionsSpelling spelling() { + return spelling; + } + + /** + * Gets the debug. + * + *

Whether to return additional diagnostic information. Set to `true` to return additional + * information in the `output.debug` property. + * + * @return the debug + */ + public Boolean debug() { + return debug; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageResponse.java new file mode 100644 index 0000000000..3be46bf97f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/StatelessMessageResponse.java @@ -0,0 +1,99 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** A stateless response from the watsonx Assistant service. */ +public class StatelessMessageResponse extends GenericModel { + + protected MessageOutput output; + protected StatelessMessageContext context; + + @SerializedName("masked_output") + protected MessageOutput maskedOutput; + + @SerializedName("masked_input") + protected MessageInput maskedInput; + + @SerializedName("user_id") + protected String userId; + + protected StatelessMessageResponse() {} + + /** + * Gets the output. + * + *

Assistant output to be rendered or processed by the client. + * + * @return the output + */ + public MessageOutput getOutput() { + return output; + } + + /** + * Gets the context. + * + *

Context data for the conversation. You can use this property to access context variables. + * The context is not stored by the assistant; to maintain session state, include the context from + * the response in the next message. + * + * @return the context + */ + public StatelessMessageContext getContext() { + return context; + } + + /** + * Gets the maskedOutput. + * + *

Assistant output to be rendered or processed by the client. All private data is masked or + * removed. + * + * @return the maskedOutput + */ + public MessageOutput getMaskedOutput() { + return maskedOutput; + } + + /** + * Gets the maskedInput. + * + *

An input object that includes the input text. All private data is masked or removed. + * + * @return the maskedInput + */ + public MessageInput getMaskedInput() { + return maskedInput; + } + + /** + * Gets the userId. + * + *

A string value that identifies the user who is interacting with the assistant. The client + * must provide a unique identifier for each individual end user who accesses the application. For + * user-based plans, this user ID is used to identify unique users for billing purposes. This + * string cannot contain carriage return, newline, or tab characters. If no value is specified in + * the input, **user_id** is automatically set to the value of **context.global.session_id**. + * + *

**Note:** This property is the same as the **user_id** property in the global system + * context. + * + * @return the userId + */ + public String getUserId() { + return userId; + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantTest.java index b3622537ab..75355b2b62 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantTest.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantTest.java @@ -49,23 +49,17 @@ import com.ibm.watson.assistant.v2.model.ListReleasesOptions; import com.ibm.watson.assistant.v2.model.LogCollection; import com.ibm.watson.assistant.v2.model.MessageContext; +import com.ibm.watson.assistant.v2.model.MessageContextActionSkill; +import com.ibm.watson.assistant.v2.model.MessageContextDialogSkill; import com.ibm.watson.assistant.v2.model.MessageContextGlobal; -import com.ibm.watson.assistant.v2.model.MessageContextGlobalStateless; import com.ibm.watson.assistant.v2.model.MessageContextGlobalSystem; -import com.ibm.watson.assistant.v2.model.MessageContextSkillAction; -import com.ibm.watson.assistant.v2.model.MessageContextSkillDialog; import com.ibm.watson.assistant.v2.model.MessageContextSkillSystem; import com.ibm.watson.assistant.v2.model.MessageContextSkills; -import com.ibm.watson.assistant.v2.model.MessageContextStateless; import com.ibm.watson.assistant.v2.model.MessageInput; import com.ibm.watson.assistant.v2.model.MessageInputAttachment; import com.ibm.watson.assistant.v2.model.MessageInputOptions; import com.ibm.watson.assistant.v2.model.MessageInputOptionsSpelling; -import com.ibm.watson.assistant.v2.model.MessageInputOptionsStateless; -import com.ibm.watson.assistant.v2.model.MessageInputStateless; import com.ibm.watson.assistant.v2.model.MessageOptions; -import com.ibm.watson.assistant.v2.model.MessageResponse; -import com.ibm.watson.assistant.v2.model.MessageResponseStateless; import com.ibm.watson.assistant.v2.model.MessageStatelessOptions; import com.ibm.watson.assistant.v2.model.Release; import com.ibm.watson.assistant.v2.model.ReleaseCollection; @@ -85,6 +79,14 @@ import com.ibm.watson.assistant.v2.model.SkillImport; import com.ibm.watson.assistant.v2.model.SkillsAsyncRequestStatus; import com.ibm.watson.assistant.v2.model.SkillsExport; +import com.ibm.watson.assistant.v2.model.StatefulMessageResponse; +import com.ibm.watson.assistant.v2.model.StatelessMessageContext; +import com.ibm.watson.assistant.v2.model.StatelessMessageContextGlobal; +import com.ibm.watson.assistant.v2.model.StatelessMessageContextSkills; +import com.ibm.watson.assistant.v2.model.StatelessMessageContextSkillsActionsSkill; +import com.ibm.watson.assistant.v2.model.StatelessMessageInput; +import com.ibm.watson.assistant.v2.model.StatelessMessageInputOptions; +import com.ibm.watson.assistant.v2.model.StatelessMessageResponse; import com.ibm.watson.assistant.v2.model.UpdateEnvironmentOptions; import com.ibm.watson.assistant.v2.model.UpdateSkillOptions; import com.ibm.watson.assistant.v2.utils.TestUtilities; @@ -403,7 +405,7 @@ public void testDeleteSessionNoOptions() throws Throwable { public void testMessageWOptions() throws Throwable { // Register a mock response String mockResponseBody = - "{\"output\": {\"generic\": [{\"response_type\": \"text\", \"text\": \"text\", \"channels\": [{\"channel\": \"channel\"}]}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\", \"turn_events\": [{\"event\": \"action_visited\", \"source\": {\"type\": \"action\", \"action\": \"action\", \"action_title\": \"actionTitle\", \"condition\": \"condition\"}, \"action_start_time\": \"actionStartTime\", \"condition_type\": \"user_defined\", \"reason\": \"intent\", \"result_variable\": \"resultVariable\"}]}, \"user_defined\": {\"anyKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\", \"session_start_time\": \"sessionStartTime\", \"state\": \"state\", \"skip_user_input\": false}, \"session_id\": \"sessionId\"}, \"skills\": {\"main skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}, \"actions skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}, \"action_variables\": {\"anyKey\": \"anyValue\"}, \"skill_variables\": {\"anyKey\": \"anyValue\"}}}, \"integrations\": {\"anyKey\": \"anyValue\"}}, \"user_id\": \"userId\"}"; + "{\"output\": {\"generic\": [{\"response_type\": \"text\", \"text\": \"text\", \"channels\": [{\"channel\": \"channel\"}]}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\", \"turn_events\": [{\"event\": \"action_visited\", \"source\": {\"type\": \"action\", \"action\": \"action\", \"action_title\": \"actionTitle\", \"condition\": \"condition\"}, \"action_start_time\": \"actionStartTime\", \"condition_type\": \"user_defined\", \"reason\": \"intent\", \"result_variable\": \"resultVariable\"}]}, \"user_defined\": {\"anyKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\", \"session_start_time\": \"sessionStartTime\", \"state\": \"state\", \"skip_user_input\": false}, \"session_id\": \"sessionId\"}, \"skills\": {\"main skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}, \"actions skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}, \"action_variables\": {\"anyKey\": \"anyValue\"}, \"skill_variables\": {\"anyKey\": \"anyValue\"}}}, \"integrations\": {\"anyKey\": \"anyValue\"}}, \"user_id\": \"userId\", \"masked_output\": {\"generic\": [{\"response_type\": \"text\", \"text\": \"text\", \"channels\": [{\"channel\": \"channel\"}]}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\", \"turn_events\": [{\"event\": \"action_visited\", \"source\": {\"type\": \"action\", \"action\": \"action\", \"action_title\": \"actionTitle\", \"condition\": \"condition\"}, \"action_start_time\": \"actionStartTime\", \"condition_type\": \"user_defined\", \"reason\": \"intent\", \"result_variable\": \"resultVariable\"}]}, \"user_defined\": {\"anyKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}}, \"masked_input\": {\"message_type\": \"text\", \"text\": \"text\", \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"suggestion_id\": \"suggestionId\", \"attachments\": [{\"url\": \"url\", \"media_type\": \"mediaType\"}], \"analytics\": {\"browser\": \"browser\", \"device\": \"device\", \"pageUrl\": \"pageUrl\"}, \"options\": {\"restart\": false, \"alternate_intents\": false, \"async_callout\": false, \"spelling\": {\"suggestions\": false, \"auto_correct\": false}, \"debug\": false, \"return_context\": false, \"export\": false}}}"; String messagePath = "/v2/assistants/testString/sessions/testString/message"; server.enqueue( new MockResponse() @@ -547,16 +549,16 @@ public void testMessageWOptions() throws Throwable { .add("foo", "testString") .build(); - // Construct an instance of the MessageContextSkillDialog model - MessageContextSkillDialog messageContextSkillDialogModel = - new MessageContextSkillDialog.Builder() + // Construct an instance of the MessageContextDialogSkill model + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) .system(messageContextSkillSystemModel) .build(); - // Construct an instance of the MessageContextSkillAction model - MessageContextSkillAction messageContextSkillActionModel = - new MessageContextSkillAction.Builder() + // Construct an instance of the MessageContextActionSkill model + MessageContextActionSkill messageContextActionSkillModel = + new MessageContextActionSkill.Builder() .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) .system(messageContextSkillSystemModel) .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) @@ -566,8 +568,8 @@ public void testMessageWOptions() throws Throwable { // Construct an instance of the MessageContextSkills model MessageContextSkills messageContextSkillsModel = new MessageContextSkills.Builder() - .mainSkill(messageContextSkillDialogModel) - .actionsSkill(messageContextSkillActionModel) + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(messageContextActionSkillModel) .build(); // Construct an instance of the MessageContext model @@ -589,9 +591,10 @@ public void testMessageWOptions() throws Throwable { .build(); // Invoke message() with a valid options model and verify the result - Response response = assistantService.message(messageOptionsModel).execute(); + Response response = + assistantService.message(messageOptionsModel).execute(); assertNotNull(response); - MessageResponse responseObj = response.getResult(); + StatefulMessageResponse responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -629,7 +632,7 @@ public void testMessageNoOptions() throws Throwable { public void testMessageStatelessWOptions() throws Throwable { // Register a mock response String mockResponseBody = - "{\"output\": {\"generic\": [{\"response_type\": \"text\", \"text\": \"text\", \"channels\": [{\"channel\": \"channel\"}]}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\", \"turn_events\": [{\"event\": \"action_visited\", \"source\": {\"type\": \"action\", \"action\": \"action\", \"action_title\": \"actionTitle\", \"condition\": \"condition\"}, \"action_start_time\": \"actionStartTime\", \"condition_type\": \"user_defined\", \"reason\": \"intent\", \"result_variable\": \"resultVariable\"}]}, \"user_defined\": {\"anyKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\", \"session_start_time\": \"sessionStartTime\", \"state\": \"state\", \"skip_user_input\": false}, \"session_id\": \"sessionId\"}, \"skills\": {\"main skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}, \"actions skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}, \"action_variables\": {\"anyKey\": \"anyValue\"}, \"skill_variables\": {\"anyKey\": \"anyValue\"}}}, \"integrations\": {\"anyKey\": \"anyValue\"}}, \"user_id\": \"userId\"}"; + "{\"output\": {\"generic\": [{\"response_type\": \"text\", \"text\": \"text\", \"channels\": [{\"channel\": \"channel\"}]}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\", \"turn_events\": [{\"event\": \"action_visited\", \"source\": {\"type\": \"action\", \"action\": \"action\", \"action_title\": \"actionTitle\", \"condition\": \"condition\"}, \"action_start_time\": \"actionStartTime\", \"condition_type\": \"user_defined\", \"reason\": \"intent\", \"result_variable\": \"resultVariable\"}]}, \"user_defined\": {\"anyKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\", \"session_start_time\": \"sessionStartTime\", \"state\": \"state\", \"skip_user_input\": false}, \"session_id\": \"sessionId\"}, \"skills\": {\"main skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}, \"actions skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}, \"action_variables\": {\"anyKey\": \"anyValue\"}, \"skill_variables\": {\"anyKey\": \"anyValue\"}, \"private_action_variables\": {\"anyKey\": \"anyValue\"}, \"private_skill_variables\": {\"anyKey\": \"anyValue\"}}}, \"integrations\": {\"anyKey\": \"anyValue\"}}, \"masked_output\": {\"generic\": [{\"response_type\": \"text\", \"text\": \"text\", \"channels\": [{\"channel\": \"channel\"}]}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\", \"turn_events\": [{\"event\": \"action_visited\", \"source\": {\"type\": \"action\", \"action\": \"action\", \"action_title\": \"actionTitle\", \"condition\": \"condition\"}, \"action_start_time\": \"actionStartTime\", \"condition_type\": \"user_defined\", \"reason\": \"intent\", \"result_variable\": \"resultVariable\"}]}, \"user_defined\": {\"anyKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}}, \"masked_input\": {\"message_type\": \"text\", \"text\": \"text\", \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"suggestion_id\": \"suggestionId\", \"attachments\": [{\"url\": \"url\", \"media_type\": \"mediaType\"}], \"analytics\": {\"browser\": \"browser\", \"device\": \"device\", \"pageUrl\": \"pageUrl\"}, \"options\": {\"restart\": false, \"alternate_intents\": false, \"async_callout\": false, \"spelling\": {\"suggestions\": false, \"auto_correct\": false}, \"debug\": false, \"return_context\": false, \"export\": false}}, \"user_id\": \"userId\"}"; String messageStatelessPath = "/v2/assistants/testString/message"; server.enqueue( new MockResponse() @@ -724,9 +727,9 @@ public void testMessageStatelessWOptions() throws Throwable { MessageInputOptionsSpelling messageInputOptionsSpellingModel = new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); - // Construct an instance of the MessageInputOptionsStateless model - MessageInputOptionsStateless messageInputOptionsStatelessModel = - new MessageInputOptionsStateless.Builder() + // Construct an instance of the StatelessMessageInputOptions model + StatelessMessageInputOptions statelessMessageInputOptionsModel = + new StatelessMessageInputOptions.Builder() .restart(false) .alternateIntents(false) .asyncCallout(false) @@ -734,9 +737,9 @@ public void testMessageStatelessWOptions() throws Throwable { .debug(false) .build(); - // Construct an instance of the MessageInputStateless model - MessageInputStateless messageInputStatelessModel = - new MessageInputStateless.Builder() + // Construct an instance of the StatelessMessageInput model + StatelessMessageInput statelessMessageInputModel = + new StatelessMessageInput.Builder() .messageType("text") .text("testString") .intents(java.util.Arrays.asList(runtimeIntentModel)) @@ -744,7 +747,7 @@ public void testMessageStatelessWOptions() throws Throwable { .suggestionId("testString") .attachments(java.util.Arrays.asList(messageInputAttachmentModel)) .analytics(requestAnalyticsModel) - .options(messageInputOptionsStatelessModel) + .options(statelessMessageInputOptionsModel) .build(); // Construct an instance of the MessageContextGlobalSystem model @@ -760,9 +763,9 @@ public void testMessageStatelessWOptions() throws Throwable { .skipUserInput(true) .build(); - // Construct an instance of the MessageContextGlobalStateless model - MessageContextGlobalStateless messageContextGlobalStatelessModel = - new MessageContextGlobalStateless.Builder() + // Construct an instance of the StatelessMessageContextGlobal model + StatelessMessageContextGlobal statelessMessageContextGlobalModel = + new StatelessMessageContextGlobal.Builder() .system(messageContextGlobalSystemModel) .sessionId("testString") .build(); @@ -774,34 +777,36 @@ public void testMessageStatelessWOptions() throws Throwable { .add("foo", "testString") .build(); - // Construct an instance of the MessageContextSkillDialog model - MessageContextSkillDialog messageContextSkillDialogModel = - new MessageContextSkillDialog.Builder() + // Construct an instance of the MessageContextDialogSkill model + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) .system(messageContextSkillSystemModel) .build(); - // Construct an instance of the MessageContextSkillAction model - MessageContextSkillAction messageContextSkillActionModel = - new MessageContextSkillAction.Builder() + // Construct an instance of the StatelessMessageContextSkillsActionsSkill model + StatelessMessageContextSkillsActionsSkill statelessMessageContextSkillsActionsSkillModel = + new StatelessMessageContextSkillsActionsSkill.Builder() .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) .system(messageContextSkillSystemModel) .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateActionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateSkillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) .build(); - // Construct an instance of the MessageContextSkills model - MessageContextSkills messageContextSkillsModel = - new MessageContextSkills.Builder() - .mainSkill(messageContextSkillDialogModel) - .actionsSkill(messageContextSkillActionModel) + // Construct an instance of the StatelessMessageContextSkills model + StatelessMessageContextSkills statelessMessageContextSkillsModel = + new StatelessMessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(statelessMessageContextSkillsActionsSkillModel) .build(); - // Construct an instance of the MessageContextStateless model - MessageContextStateless messageContextStatelessModel = - new MessageContextStateless.Builder() - .global(messageContextGlobalStatelessModel) - .skills(messageContextSkillsModel) + // Construct an instance of the StatelessMessageContext model + StatelessMessageContext statelessMessageContextModel = + new StatelessMessageContext.Builder() + .global(statelessMessageContextGlobalModel) + .skills(statelessMessageContextSkillsModel) .integrations(java.util.Collections.singletonMap("anyKey", "anyValue")) .build(); @@ -809,16 +814,16 @@ public void testMessageStatelessWOptions() throws Throwable { MessageStatelessOptions messageStatelessOptionsModel = new MessageStatelessOptions.Builder() .assistantId("testString") - .input(messageInputStatelessModel) - .context(messageContextStatelessModel) + .input(statelessMessageInputModel) + .context(statelessMessageContextModel) .userId("testString") .build(); // Invoke messageStateless() with a valid options model and verify the result - Response response = + Response response = assistantService.messageStateless(messageStatelessOptionsModel).execute(); assertNotNull(response); - MessageResponseStateless responseObj = response.getResult(); + StatelessMessageResponse responseObj = response.getResult(); assertNotNull(responseObj); // Verify the contents of the request sent to the mock server @@ -917,7 +922,7 @@ public void testBulkClassifyNoOptions() throws Throwable { public void testListLogsWOptions() throws Throwable { // Register a mock response String mockResponseBody = - "{\"logs\": [{\"log_id\": \"logId\", \"request\": {\"input\": {\"message_type\": \"text\", \"text\": \"text\", \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"suggestion_id\": \"suggestionId\", \"attachments\": [{\"url\": \"url\", \"media_type\": \"mediaType\"}], \"analytics\": {\"browser\": \"browser\", \"device\": \"device\", \"pageUrl\": \"pageUrl\"}, \"options\": {\"restart\": false, \"alternate_intents\": false, \"spelling\": {\"suggestions\": false, \"auto_correct\": false}, \"debug\": false, \"return_context\": false, \"export\": false}}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\", \"session_start_time\": \"sessionStartTime\", \"state\": \"state\", \"skip_user_input\": false}, \"session_id\": \"sessionId\"}, \"skills\": {\"main skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}, \"actions skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}, \"action_variables\": {\"anyKey\": \"anyValue\"}, \"skill_variables\": {\"anyKey\": \"anyValue\"}}}, \"integrations\": {\"anyKey\": \"anyValue\"}}, \"user_id\": \"userId\"}, \"response\": {\"output\": {\"generic\": [{\"response_type\": \"text\", \"text\": \"text\", \"channels\": [{\"channel\": \"channel\"}]}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\", \"turn_events\": [{\"event\": \"action_visited\", \"source\": {\"type\": \"action\", \"action\": \"action\", \"action_title\": \"actionTitle\", \"condition\": \"condition\"}, \"action_start_time\": \"actionStartTime\", \"condition_type\": \"user_defined\", \"reason\": \"intent\", \"result_variable\": \"resultVariable\"}]}, \"user_defined\": {\"anyKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\", \"session_start_time\": \"sessionStartTime\", \"state\": \"state\", \"skip_user_input\": false}, \"session_id\": \"sessionId\"}, \"skills\": {\"main skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}, \"actions skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}, \"action_variables\": {\"anyKey\": \"anyValue\"}, \"skill_variables\": {\"anyKey\": \"anyValue\"}}}, \"integrations\": {\"anyKey\": \"anyValue\"}}, \"user_id\": \"userId\"}, \"assistant_id\": \"assistantId\", \"session_id\": \"sessionId\", \"skill_id\": \"skillId\", \"snapshot\": \"snapshot\", \"request_timestamp\": \"requestTimestamp\", \"response_timestamp\": \"responseTimestamp\", \"language\": \"language\", \"customer_id\": \"customerId\"}], \"pagination\": {\"next_url\": \"nextUrl\", \"matched\": 7, \"next_cursor\": \"nextCursor\"}}"; + "{\"logs\": [{\"log_id\": \"logId\", \"request\": {\"input\": {\"message_type\": \"text\", \"text\": \"text\", \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"suggestion_id\": \"suggestionId\", \"attachments\": [{\"url\": \"url\", \"media_type\": \"mediaType\"}], \"analytics\": {\"browser\": \"browser\", \"device\": \"device\", \"pageUrl\": \"pageUrl\"}, \"options\": {\"restart\": false, \"alternate_intents\": false, \"async_callout\": false, \"spelling\": {\"suggestions\": false, \"auto_correct\": false}, \"debug\": false, \"return_context\": false, \"export\": false}}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\", \"session_start_time\": \"sessionStartTime\", \"state\": \"state\", \"skip_user_input\": false}, \"session_id\": \"sessionId\"}, \"skills\": {\"main skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}, \"actions skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}, \"action_variables\": {\"anyKey\": \"anyValue\"}, \"skill_variables\": {\"anyKey\": \"anyValue\"}}}, \"integrations\": {\"anyKey\": \"anyValue\"}}, \"user_id\": \"userId\"}, \"response\": {\"output\": {\"generic\": [{\"response_type\": \"text\", \"text\": \"text\", \"channels\": [{\"channel\": \"channel\"}]}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10, \"skill\": \"skill\"}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}, \"skill\": \"skill\"}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"anyKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\", \"turn_events\": [{\"event\": \"action_visited\", \"source\": {\"type\": \"action\", \"action\": \"action\", \"action_title\": \"actionTitle\", \"condition\": \"condition\"}, \"action_start_time\": \"actionStartTime\", \"condition_type\": \"user_defined\", \"reason\": \"intent\", \"result_variable\": \"resultVariable\"}]}, \"user_defined\": {\"anyKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\", \"session_start_time\": \"sessionStartTime\", \"state\": \"state\", \"skip_user_input\": false}, \"session_id\": \"sessionId\"}, \"skills\": {\"main skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}, \"actions skill\": {\"user_defined\": {\"anyKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}, \"action_variables\": {\"anyKey\": \"anyValue\"}, \"skill_variables\": {\"anyKey\": \"anyValue\"}}}, \"integrations\": {\"anyKey\": \"anyValue\"}}, \"user_id\": \"userId\"}, \"assistant_id\": \"assistantId\", \"session_id\": \"sessionId\", \"skill_id\": \"skillId\", \"snapshot\": \"snapshot\", \"request_timestamp\": \"requestTimestamp\", \"response_timestamp\": \"responseTimestamp\", \"language\": \"language\", \"customer_id\": \"customerId\"}], \"pagination\": {\"next_url\": \"nextUrl\", \"matched\": 7, \"next_cursor\": \"nextCursor\"}}"; String listLogsPath = "/v2/assistants/testString/logs"; server.enqueue( new MockResponse() diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextActionSkillTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextActionSkillTest.java new file mode 100644 index 0000000000..4035301d48 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextActionSkillTest.java @@ -0,0 +1,77 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextActionSkill model. */ +public class MessageContextActionSkillTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextActionSkill() throws Throwable { + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextActionSkill messageContextActionSkillModel = + new MessageContextActionSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals( + messageContextActionSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextActionSkillModel.system(), messageContextSkillSystemModel); + assertEquals( + messageContextActionSkillModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + messageContextActionSkillModel.skillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + String json = TestUtilities.serialize(messageContextActionSkillModel); + + MessageContextActionSkill messageContextActionSkillModelNew = + TestUtilities.deserialize(json, MessageContextActionSkill.class); + assertTrue(messageContextActionSkillModelNew instanceof MessageContextActionSkill); + assertEquals( + messageContextActionSkillModelNew.userDefined().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + messageContextActionSkillModelNew.system().toString(), + messageContextSkillSystemModel.toString()); + assertEquals( + messageContextActionSkillModelNew.actionVariables().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + messageContextActionSkillModelNew.skillVariables().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextDialogSkillTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextDialogSkillTest.java new file mode 100644 index 0000000000..81632a240d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextDialogSkillTest.java @@ -0,0 +1,63 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextDialogSkill model. */ +public class MessageContextDialogSkillTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextDialogSkill() throws Throwable { + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextDialogSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); + + String json = TestUtilities.serialize(messageContextDialogSkillModel); + + MessageContextDialogSkill messageContextDialogSkillModelNew = + TestUtilities.deserialize(json, MessageContextDialogSkill.class); + assertTrue(messageContextDialogSkillModelNew instanceof MessageContextDialogSkill); + assertEquals( + messageContextDialogSkillModelNew.userDefined().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + messageContextDialogSkillModelNew.system().toString(), + messageContextSkillSystemModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillsTest.java index 191b7c07c1..26b7436f4e 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillsTest.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2023. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -38,41 +38,41 @@ public void testMessageContextSkills() throws Throwable { assertEquals(messageContextSkillSystemModel.getState(), "testString"); assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); - MessageContextSkillDialog messageContextSkillDialogModel = - new MessageContextSkillDialog.Builder() + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) .system(messageContextSkillSystemModel) .build(); assertEquals( - messageContextSkillDialogModel.userDefined(), + messageContextDialogSkillModel.userDefined(), java.util.Collections.singletonMap("anyKey", "anyValue")); - assertEquals(messageContextSkillDialogModel.system(), messageContextSkillSystemModel); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); - MessageContextSkillAction messageContextSkillActionModel = - new MessageContextSkillAction.Builder() + MessageContextActionSkill messageContextActionSkillModel = + new MessageContextActionSkill.Builder() .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) .system(messageContextSkillSystemModel) .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) .build(); assertEquals( - messageContextSkillActionModel.userDefined(), + messageContextActionSkillModel.userDefined(), java.util.Collections.singletonMap("anyKey", "anyValue")); - assertEquals(messageContextSkillActionModel.system(), messageContextSkillSystemModel); + assertEquals(messageContextActionSkillModel.system(), messageContextSkillSystemModel); assertEquals( - messageContextSkillActionModel.actionVariables(), + messageContextActionSkillModel.actionVariables(), java.util.Collections.singletonMap("anyKey", "anyValue")); assertEquals( - messageContextSkillActionModel.skillVariables(), + messageContextActionSkillModel.skillVariables(), java.util.Collections.singletonMap("anyKey", "anyValue")); MessageContextSkills messageContextSkillsModel = new MessageContextSkills.Builder() - .mainSkill(messageContextSkillDialogModel) - .actionsSkill(messageContextSkillActionModel) + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(messageContextActionSkillModel) .build(); - assertEquals(messageContextSkillsModel.mainSkill(), messageContextSkillDialogModel); - assertEquals(messageContextSkillsModel.actionsSkill(), messageContextSkillActionModel); + assertEquals(messageContextSkillsModel.mainSkill(), messageContextDialogSkillModel); + assertEquals(messageContextSkillsModel.actionsSkill(), messageContextActionSkillModel); String json = TestUtilities.serialize(messageContextSkillsModel); @@ -81,9 +81,9 @@ public void testMessageContextSkills() throws Throwable { assertTrue(messageContextSkillsModelNew instanceof MessageContextSkills); assertEquals( messageContextSkillsModelNew.mainSkill().toString(), - messageContextSkillDialogModel.toString()); + messageContextDialogSkillModel.toString()); assertEquals( messageContextSkillsModelNew.actionsSkill().toString(), - messageContextSkillActionModel.toString()); + messageContextActionSkillModel.toString()); } } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextTest.java index 810cdc56fa..d2c28bfa9a 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextTest.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020, 2023. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -62,41 +62,41 @@ public void testMessageContext() throws Throwable { assertEquals(messageContextSkillSystemModel.getState(), "testString"); assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); - MessageContextSkillDialog messageContextSkillDialogModel = - new MessageContextSkillDialog.Builder() + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) .system(messageContextSkillSystemModel) .build(); assertEquals( - messageContextSkillDialogModel.userDefined(), + messageContextDialogSkillModel.userDefined(), java.util.Collections.singletonMap("anyKey", "anyValue")); - assertEquals(messageContextSkillDialogModel.system(), messageContextSkillSystemModel); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); - MessageContextSkillAction messageContextSkillActionModel = - new MessageContextSkillAction.Builder() + MessageContextActionSkill messageContextActionSkillModel = + new MessageContextActionSkill.Builder() .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) .system(messageContextSkillSystemModel) .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) .build(); assertEquals( - messageContextSkillActionModel.userDefined(), + messageContextActionSkillModel.userDefined(), java.util.Collections.singletonMap("anyKey", "anyValue")); - assertEquals(messageContextSkillActionModel.system(), messageContextSkillSystemModel); + assertEquals(messageContextActionSkillModel.system(), messageContextSkillSystemModel); assertEquals( - messageContextSkillActionModel.actionVariables(), + messageContextActionSkillModel.actionVariables(), java.util.Collections.singletonMap("anyKey", "anyValue")); assertEquals( - messageContextSkillActionModel.skillVariables(), + messageContextActionSkillModel.skillVariables(), java.util.Collections.singletonMap("anyKey", "anyValue")); MessageContextSkills messageContextSkillsModel = new MessageContextSkills.Builder() - .mainSkill(messageContextSkillDialogModel) - .actionsSkill(messageContextSkillActionModel) + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(messageContextActionSkillModel) .build(); - assertEquals(messageContextSkillsModel.mainSkill(), messageContextSkillDialogModel); - assertEquals(messageContextSkillsModel.actionsSkill(), messageContextSkillActionModel); + assertEquals(messageContextSkillsModel.mainSkill(), messageContextDialogSkillModel); + assertEquals(messageContextSkillsModel.actionsSkill(), messageContextActionSkillModel); MessageContext messageContextModel = new MessageContext.Builder() diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOptionsTest.java index b122413daf..98c0a05015 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOptionsTest.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOptionsTest.java @@ -230,41 +230,41 @@ public void testMessageOptions() throws Throwable { assertEquals(messageContextSkillSystemModel.getState(), "testString"); assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); - MessageContextSkillDialog messageContextSkillDialogModel = - new MessageContextSkillDialog.Builder() + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) .system(messageContextSkillSystemModel) .build(); assertEquals( - messageContextSkillDialogModel.userDefined(), + messageContextDialogSkillModel.userDefined(), java.util.Collections.singletonMap("anyKey", "anyValue")); - assertEquals(messageContextSkillDialogModel.system(), messageContextSkillSystemModel); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); - MessageContextSkillAction messageContextSkillActionModel = - new MessageContextSkillAction.Builder() + MessageContextActionSkill messageContextActionSkillModel = + new MessageContextActionSkill.Builder() .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) .system(messageContextSkillSystemModel) .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) .build(); assertEquals( - messageContextSkillActionModel.userDefined(), + messageContextActionSkillModel.userDefined(), java.util.Collections.singletonMap("anyKey", "anyValue")); - assertEquals(messageContextSkillActionModel.system(), messageContextSkillSystemModel); + assertEquals(messageContextActionSkillModel.system(), messageContextSkillSystemModel); assertEquals( - messageContextSkillActionModel.actionVariables(), + messageContextActionSkillModel.actionVariables(), java.util.Collections.singletonMap("anyKey", "anyValue")); assertEquals( - messageContextSkillActionModel.skillVariables(), + messageContextActionSkillModel.skillVariables(), java.util.Collections.singletonMap("anyKey", "anyValue")); MessageContextSkills messageContextSkillsModel = new MessageContextSkills.Builder() - .mainSkill(messageContextSkillDialogModel) - .actionsSkill(messageContextSkillActionModel) + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(messageContextActionSkillModel) .build(); - assertEquals(messageContextSkillsModel.mainSkill(), messageContextSkillDialogModel); - assertEquals(messageContextSkillsModel.actionsSkill(), messageContextSkillActionModel); + assertEquals(messageContextSkillsModel.mainSkill(), messageContextDialogSkillModel); + assertEquals(messageContextSkillsModel.actionsSkill(), messageContextActionSkillModel); MessageContext messageContextModel = new MessageContext.Builder() diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptionsTest.java index 17c3bbe8eb..f5f927176c 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptionsTest.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptionsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020, 2023. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -159,20 +159,22 @@ public void testMessageStatelessOptions() throws Throwable { assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); - MessageInputOptionsStateless messageInputOptionsStatelessModel = - new MessageInputOptionsStateless.Builder() + StatelessMessageInputOptions statelessMessageInputOptionsModel = + new StatelessMessageInputOptions.Builder() .restart(false) .alternateIntents(false) + .asyncCallout(false) .spelling(messageInputOptionsSpellingModel) .debug(false) .build(); - assertEquals(messageInputOptionsStatelessModel.restart(), Boolean.valueOf(false)); - assertEquals(messageInputOptionsStatelessModel.alternateIntents(), Boolean.valueOf(false)); - assertEquals(messageInputOptionsStatelessModel.spelling(), messageInputOptionsSpellingModel); - assertEquals(messageInputOptionsStatelessModel.debug(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.restart(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.alternateIntents(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.asyncCallout(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(statelessMessageInputOptionsModel.debug(), Boolean.valueOf(false)); - MessageInputStateless messageInputStatelessModel = - new MessageInputStateless.Builder() + StatelessMessageInput statelessMessageInputModel = + new StatelessMessageInput.Builder() .messageType("text") .text("testString") .intents(java.util.Arrays.asList(runtimeIntentModel)) @@ -180,19 +182,19 @@ public void testMessageStatelessOptions() throws Throwable { .suggestionId("testString") .attachments(java.util.Arrays.asList(messageInputAttachmentModel)) .analytics(requestAnalyticsModel) - .options(messageInputOptionsStatelessModel) + .options(statelessMessageInputOptionsModel) .build(); - assertEquals(messageInputStatelessModel.messageType(), "text"); - assertEquals(messageInputStatelessModel.text(), "testString"); - assertEquals(messageInputStatelessModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); + assertEquals(statelessMessageInputModel.messageType(), "text"); + assertEquals(statelessMessageInputModel.text(), "testString"); + assertEquals(statelessMessageInputModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); assertEquals( - messageInputStatelessModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); - assertEquals(messageInputStatelessModel.suggestionId(), "testString"); + statelessMessageInputModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); + assertEquals(statelessMessageInputModel.suggestionId(), "testString"); assertEquals( - messageInputStatelessModel.attachments(), + statelessMessageInputModel.attachments(), java.util.Arrays.asList(messageInputAttachmentModel)); - assertEquals(messageInputStatelessModel.analytics(), requestAnalyticsModel); - assertEquals(messageInputStatelessModel.options(), messageInputOptionsStatelessModel); + assertEquals(statelessMessageInputModel.analytics(), requestAnalyticsModel); + assertEquals(statelessMessageInputModel.options(), statelessMessageInputOptionsModel); MessageContextGlobalSystem messageContextGlobalSystemModel = new MessageContextGlobalSystem.Builder() @@ -214,13 +216,13 @@ public void testMessageStatelessOptions() throws Throwable { assertEquals(messageContextGlobalSystemModel.state(), "testString"); assertEquals(messageContextGlobalSystemModel.skipUserInput(), Boolean.valueOf(true)); - MessageContextGlobalStateless messageContextGlobalStatelessModel = - new MessageContextGlobalStateless.Builder() + StatelessMessageContextGlobal statelessMessageContextGlobalModel = + new StatelessMessageContextGlobal.Builder() .system(messageContextGlobalSystemModel) .sessionId("testString") .build(); - assertEquals(messageContextGlobalStatelessModel.system(), messageContextGlobalSystemModel); - assertEquals(messageContextGlobalStatelessModel.sessionId(), "testString"); + assertEquals(statelessMessageContextGlobalModel.system(), messageContextGlobalSystemModel); + assertEquals(statelessMessageContextGlobalModel.sessionId(), "testString"); MessageContextSkillSystem messageContextSkillSystemModel = new MessageContextSkillSystem.Builder() @@ -230,64 +232,75 @@ public void testMessageStatelessOptions() throws Throwable { assertEquals(messageContextSkillSystemModel.getState(), "testString"); assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); - MessageContextSkillDialog messageContextSkillDialogModel = - new MessageContextSkillDialog.Builder() + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) .system(messageContextSkillSystemModel) .build(); assertEquals( - messageContextSkillDialogModel.userDefined(), + messageContextDialogSkillModel.userDefined(), java.util.Collections.singletonMap("anyKey", "anyValue")); - assertEquals(messageContextSkillDialogModel.system(), messageContextSkillSystemModel); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); - MessageContextSkillAction messageContextSkillActionModel = - new MessageContextSkillAction.Builder() + StatelessMessageContextSkillsActionsSkill statelessMessageContextSkillsActionsSkillModel = + new StatelessMessageContextSkillsActionsSkill.Builder() .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) .system(messageContextSkillSystemModel) .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateActionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateSkillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) .build(); assertEquals( - messageContextSkillActionModel.userDefined(), + statelessMessageContextSkillsActionsSkillModel.userDefined(), java.util.Collections.singletonMap("anyKey", "anyValue")); - assertEquals(messageContextSkillActionModel.system(), messageContextSkillSystemModel); assertEquals( - messageContextSkillActionModel.actionVariables(), + statelessMessageContextSkillsActionsSkillModel.system(), messageContextSkillSystemModel); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.skillVariables(), java.util.Collections.singletonMap("anyKey", "anyValue")); assertEquals( - messageContextSkillActionModel.skillVariables(), + statelessMessageContextSkillsActionsSkillModel.privateActionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.privateSkillVariables(), java.util.Collections.singletonMap("anyKey", "anyValue")); - MessageContextSkills messageContextSkillsModel = - new MessageContextSkills.Builder() - .mainSkill(messageContextSkillDialogModel) - .actionsSkill(messageContextSkillActionModel) + StatelessMessageContextSkills statelessMessageContextSkillsModel = + new StatelessMessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(statelessMessageContextSkillsActionsSkillModel) .build(); - assertEquals(messageContextSkillsModel.mainSkill(), messageContextSkillDialogModel); - assertEquals(messageContextSkillsModel.actionsSkill(), messageContextSkillActionModel); + assertEquals(statelessMessageContextSkillsModel.mainSkill(), messageContextDialogSkillModel); + assertEquals( + statelessMessageContextSkillsModel.actionsSkill(), + statelessMessageContextSkillsActionsSkillModel); - MessageContextStateless messageContextStatelessModel = - new MessageContextStateless.Builder() - .global(messageContextGlobalStatelessModel) - .skills(messageContextSkillsModel) + StatelessMessageContext statelessMessageContextModel = + new StatelessMessageContext.Builder() + .global(statelessMessageContextGlobalModel) + .skills(statelessMessageContextSkillsModel) .integrations(java.util.Collections.singletonMap("anyKey", "anyValue")) .build(); - assertEquals(messageContextStatelessModel.global(), messageContextGlobalStatelessModel); - assertEquals(messageContextStatelessModel.skills(), messageContextSkillsModel); + assertEquals(statelessMessageContextModel.global(), statelessMessageContextGlobalModel); + assertEquals(statelessMessageContextModel.skills(), statelessMessageContextSkillsModel); assertEquals( - messageContextStatelessModel.integrations(), + statelessMessageContextModel.integrations(), java.util.Collections.singletonMap("anyKey", "anyValue")); MessageStatelessOptions messageStatelessOptionsModel = new MessageStatelessOptions.Builder() .assistantId("testString") - .input(messageInputStatelessModel) - .context(messageContextStatelessModel) + .input(statelessMessageInputModel) + .context(statelessMessageContextModel) .userId("testString") .build(); assertEquals(messageStatelessOptionsModel.assistantId(), "testString"); - assertEquals(messageStatelessOptionsModel.input(), messageInputStatelessModel); - assertEquals(messageStatelessOptionsModel.context(), messageContextStatelessModel); + assertEquals(messageStatelessOptionsModel.input(), statelessMessageInputModel); + assertEquals(messageStatelessOptionsModel.context(), statelessMessageContextModel); assertEquals(messageStatelessOptionsModel.userId(), "testString"); } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatefulMessageResponseTest.java similarity index 64% rename from assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageResponseTest.java rename to assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatefulMessageResponseTest.java index d5e49bd02d..e3daeb507b 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageResponseTest.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatefulMessageResponseTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020, 2021. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -22,17 +22,19 @@ import java.util.List; import org.testng.annotations.Test; -/** Unit test class for the MessageResponse model. */ -public class MessageResponseTest { +/** Unit test class for the StatefulMessageResponse model. */ +public class StatefulMessageResponseTest { final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); @Test - public void testMessageResponse() throws Throwable { - MessageResponse messageResponseModel = new MessageResponse(); - assertNull(messageResponseModel.getOutput()); - assertNull(messageResponseModel.getContext()); - assertNull(messageResponseModel.getUserId()); + public void testStatefulMessageResponse() throws Throwable { + StatefulMessageResponse statefulMessageResponseModel = new StatefulMessageResponse(); + assertNull(statefulMessageResponseModel.getOutput()); + assertNull(statefulMessageResponseModel.getContext()); + assertNull(statefulMessageResponseModel.getUserId()); + assertNull(statefulMessageResponseModel.getMaskedOutput()); + assertNull(statefulMessageResponseModel.getMaskedInput()); } } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextGlobalTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextGlobalTest.java new file mode 100644 index 0000000000..bdce29bc37 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextGlobalTest.java @@ -0,0 +1,71 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessMessageContextGlobal model. */ +public class StatelessMessageContextGlobalTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatelessMessageContextGlobal() throws Throwable { + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.sessionStartTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.state(), "testString"); + assertEquals(messageContextGlobalSystemModel.skipUserInput(), Boolean.valueOf(true)); + + StatelessMessageContextGlobal statelessMessageContextGlobalModel = + new StatelessMessageContextGlobal.Builder() + .system(messageContextGlobalSystemModel) + .sessionId("testString") + .build(); + assertEquals(statelessMessageContextGlobalModel.system(), messageContextGlobalSystemModel); + assertEquals(statelessMessageContextGlobalModel.sessionId(), "testString"); + + String json = TestUtilities.serialize(statelessMessageContextGlobalModel); + + StatelessMessageContextGlobal statelessMessageContextGlobalModelNew = + TestUtilities.deserialize(json, StatelessMessageContextGlobal.class); + assertTrue(statelessMessageContextGlobalModelNew instanceof StatelessMessageContextGlobal); + assertEquals( + statelessMessageContextGlobalModelNew.system().toString(), + messageContextGlobalSystemModel.toString()); + assertEquals(statelessMessageContextGlobalModelNew.sessionId(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsActionsSkillTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsActionsSkillTest.java new file mode 100644 index 0000000000..5fc3dc3e2e --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsActionsSkillTest.java @@ -0,0 +1,94 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessMessageContextSkillsActionsSkill model. */ +public class StatelessMessageContextSkillsActionsSkillTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatelessMessageContextSkillsActionsSkill() throws Throwable { + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + StatelessMessageContextSkillsActionsSkill statelessMessageContextSkillsActionsSkillModel = + new StatelessMessageContextSkillsActionsSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateActionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateSkillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.system(), messageContextSkillSystemModel); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.skillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.privateActionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.privateSkillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + String json = TestUtilities.serialize(statelessMessageContextSkillsActionsSkillModel); + + StatelessMessageContextSkillsActionsSkill statelessMessageContextSkillsActionsSkillModelNew = + TestUtilities.deserialize(json, StatelessMessageContextSkillsActionsSkill.class); + assertTrue( + statelessMessageContextSkillsActionsSkillModelNew + instanceof StatelessMessageContextSkillsActionsSkill); + assertEquals( + statelessMessageContextSkillsActionsSkillModelNew.userDefined().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + statelessMessageContextSkillsActionsSkillModelNew.system().toString(), + messageContextSkillSystemModel.toString()); + assertEquals( + statelessMessageContextSkillsActionsSkillModelNew.actionVariables().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + statelessMessageContextSkillsActionsSkillModelNew.skillVariables().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + statelessMessageContextSkillsActionsSkillModelNew.privateActionVariables().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + assertEquals( + statelessMessageContextSkillsActionsSkillModelNew.privateSkillVariables().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsTest.java new file mode 100644 index 0000000000..dae15c1607 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextSkillsTest.java @@ -0,0 +1,100 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessMessageContextSkills model. */ +public class StatelessMessageContextSkillsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatelessMessageContextSkills() throws Throwable { + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextDialogSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); + + StatelessMessageContextSkillsActionsSkill statelessMessageContextSkillsActionsSkillModel = + new StatelessMessageContextSkillsActionsSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateActionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateSkillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.system(), messageContextSkillSystemModel); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.skillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.privateActionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.privateSkillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + StatelessMessageContextSkills statelessMessageContextSkillsModel = + new StatelessMessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(statelessMessageContextSkillsActionsSkillModel) + .build(); + assertEquals(statelessMessageContextSkillsModel.mainSkill(), messageContextDialogSkillModel); + assertEquals( + statelessMessageContextSkillsModel.actionsSkill(), + statelessMessageContextSkillsActionsSkillModel); + + String json = TestUtilities.serialize(statelessMessageContextSkillsModel); + + StatelessMessageContextSkills statelessMessageContextSkillsModelNew = + TestUtilities.deserialize(json, StatelessMessageContextSkills.class); + assertTrue(statelessMessageContextSkillsModelNew instanceof StatelessMessageContextSkills); + assertEquals( + statelessMessageContextSkillsModelNew.mainSkill().toString(), + messageContextDialogSkillModel.toString()); + assertEquals( + statelessMessageContextSkillsModelNew.actionsSkill().toString(), + statelessMessageContextSkillsActionsSkillModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextTest.java new file mode 100644 index 0000000000..c62807dee7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageContextTest.java @@ -0,0 +1,143 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessMessageContext model. */ +public class StatelessMessageContextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatelessMessageContext() throws Throwable { + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .sessionStartTime("testString") + .state("testString") + .skipUserInput(true) + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.sessionStartTime(), "testString"); + assertEquals(messageContextGlobalSystemModel.state(), "testString"); + assertEquals(messageContextGlobalSystemModel.skipUserInput(), Boolean.valueOf(true)); + + StatelessMessageContextGlobal statelessMessageContextGlobalModel = + new StatelessMessageContextGlobal.Builder() + .system(messageContextGlobalSystemModel) + .sessionId("testString") + .build(); + assertEquals(statelessMessageContextGlobalModel.system(), messageContextGlobalSystemModel); + assertEquals(statelessMessageContextGlobalModel.sessionId(), "testString"); + + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextDialogSkill messageContextDialogSkillModel = + new MessageContextDialogSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextDialogSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals(messageContextDialogSkillModel.system(), messageContextSkillSystemModel); + + StatelessMessageContextSkillsActionsSkill statelessMessageContextSkillsActionsSkillModel = + new StatelessMessageContextSkillsActionsSkill.Builder() + .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) + .system(messageContextSkillSystemModel) + .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateActionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .privateSkillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.userDefined(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.system(), messageContextSkillSystemModel); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.actionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.skillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.privateActionVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + assertEquals( + statelessMessageContextSkillsActionsSkillModel.privateSkillVariables(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + StatelessMessageContextSkills statelessMessageContextSkillsModel = + new StatelessMessageContextSkills.Builder() + .mainSkill(messageContextDialogSkillModel) + .actionsSkill(statelessMessageContextSkillsActionsSkillModel) + .build(); + assertEquals(statelessMessageContextSkillsModel.mainSkill(), messageContextDialogSkillModel); + assertEquals( + statelessMessageContextSkillsModel.actionsSkill(), + statelessMessageContextSkillsActionsSkillModel); + + StatelessMessageContext statelessMessageContextModel = + new StatelessMessageContext.Builder() + .global(statelessMessageContextGlobalModel) + .skills(statelessMessageContextSkillsModel) + .integrations(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(statelessMessageContextModel.global(), statelessMessageContextGlobalModel); + assertEquals(statelessMessageContextModel.skills(), statelessMessageContextSkillsModel); + assertEquals( + statelessMessageContextModel.integrations(), + java.util.Collections.singletonMap("anyKey", "anyValue")); + + String json = TestUtilities.serialize(statelessMessageContextModel); + + StatelessMessageContext statelessMessageContextModelNew = + TestUtilities.deserialize(json, StatelessMessageContext.class); + assertTrue(statelessMessageContextModelNew instanceof StatelessMessageContext); + assertEquals( + statelessMessageContextModelNew.global().toString(), + statelessMessageContextGlobalModel.toString()); + assertEquals( + statelessMessageContextModelNew.skills().toString(), + statelessMessageContextSkillsModel.toString()); + assertEquals( + statelessMessageContextModelNew.integrations().toString(), + java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputOptionsTest.java new file mode 100644 index 0000000000..3e2890e2e5 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputOptionsTest.java @@ -0,0 +1,65 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessMessageInputOptions model. */ +public class StatelessMessageInputOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatelessMessageInputOptions() throws Throwable { + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + StatelessMessageInputOptions statelessMessageInputOptionsModel = + new StatelessMessageInputOptions.Builder() + .restart(false) + .alternateIntents(false) + .asyncCallout(false) + .spelling(messageInputOptionsSpellingModel) + .debug(false) + .build(); + assertEquals(statelessMessageInputOptionsModel.restart(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.alternateIntents(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.asyncCallout(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(statelessMessageInputOptionsModel.debug(), Boolean.valueOf(false)); + + String json = TestUtilities.serialize(statelessMessageInputOptionsModel); + + StatelessMessageInputOptions statelessMessageInputOptionsModelNew = + TestUtilities.deserialize(json, StatelessMessageInputOptions.class); + assertTrue(statelessMessageInputOptionsModelNew instanceof StatelessMessageInputOptions); + assertEquals(statelessMessageInputOptionsModelNew.restart(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModelNew.alternateIntents(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModelNew.asyncCallout(), Boolean.valueOf(false)); + assertEquals( + statelessMessageInputOptionsModelNew.spelling().toString(), + messageInputOptionsSpellingModel.toString()); + assertEquals(statelessMessageInputOptionsModelNew.debug(), Boolean.valueOf(false)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageRequestTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputTest.java similarity index 58% rename from assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageRequestTest.java rename to assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputTest.java index 68e998a937..422b9e1d89 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageRequestTest.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageInputTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020, 2023. + * (C) Copyright IBM Corp. 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -22,14 +22,14 @@ import java.util.List; import org.testng.annotations.Test; -/** Unit test class for the MessageRequest model. */ -public class MessageRequestTest { +/** Unit test class for the StatelessMessageInput model. */ +public class StatelessMessageInputTest { final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); @Test - public void testMessageRequest() throws Throwable { + public void testStatelessMessageInput() throws Throwable { RuntimeIntent runtimeIntentModel = new RuntimeIntent.Builder() .intent("testString") @@ -159,139 +159,55 @@ public void testMessageRequest() throws Throwable { assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); - MessageInputOptions messageInputOptionsModel = - new MessageInputOptions.Builder() + StatelessMessageInputOptions statelessMessageInputOptionsModel = + new StatelessMessageInputOptions.Builder() .restart(false) .alternateIntents(false) + .asyncCallout(false) .spelling(messageInputOptionsSpellingModel) .debug(false) - .returnContext(true) - .export(true) .build(); - assertEquals(messageInputOptionsModel.restart(), Boolean.valueOf(false)); - assertEquals(messageInputOptionsModel.alternateIntents(), Boolean.valueOf(false)); - assertEquals(messageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); - assertEquals(messageInputOptionsModel.debug(), Boolean.valueOf(false)); - assertEquals(messageInputOptionsModel.returnContext(), Boolean.valueOf(true)); - assertEquals(messageInputOptionsModel.export(), Boolean.valueOf(true)); - - MessageInput messageInputModel = - new MessageInput.Builder() + assertEquals(statelessMessageInputOptionsModel.restart(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.alternateIntents(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.asyncCallout(), Boolean.valueOf(false)); + assertEquals(statelessMessageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(statelessMessageInputOptionsModel.debug(), Boolean.valueOf(false)); + + StatelessMessageInput statelessMessageInputModel = + new StatelessMessageInput.Builder() .messageType("text") - .text("Hello") + .text("testString") .intents(java.util.Arrays.asList(runtimeIntentModel)) .entities(java.util.Arrays.asList(runtimeEntityModel)) .suggestionId("testString") .attachments(java.util.Arrays.asList(messageInputAttachmentModel)) .analytics(requestAnalyticsModel) - .options(messageInputOptionsModel) + .options(statelessMessageInputOptionsModel) .build(); - assertEquals(messageInputModel.messageType(), "text"); - assertEquals(messageInputModel.text(), "Hello"); - assertEquals(messageInputModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); - assertEquals(messageInputModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); - assertEquals(messageInputModel.suggestionId(), "testString"); + assertEquals(statelessMessageInputModel.messageType(), "text"); + assertEquals(statelessMessageInputModel.text(), "testString"); + assertEquals(statelessMessageInputModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); assertEquals( - messageInputModel.attachments(), java.util.Arrays.asList(messageInputAttachmentModel)); - assertEquals(messageInputModel.analytics(), requestAnalyticsModel); - assertEquals(messageInputModel.options(), messageInputOptionsModel); - - MessageContextGlobalSystem messageContextGlobalSystemModel = - new MessageContextGlobalSystem.Builder() - .timezone("testString") - .userId("my_user_id") - .turnCount(Long.valueOf("26")) - .locale("en-us") - .referenceTime("testString") - .sessionStartTime("testString") - .state("testString") - .skipUserInput(true) - .build(); - assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); - assertEquals(messageContextGlobalSystemModel.userId(), "my_user_id"); - assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); - assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); - assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); - assertEquals(messageContextGlobalSystemModel.sessionStartTime(), "testString"); - assertEquals(messageContextGlobalSystemModel.state(), "testString"); - assertEquals(messageContextGlobalSystemModel.skipUserInput(), Boolean.valueOf(true)); - - MessageContextGlobal messageContextGlobalModel = - new MessageContextGlobal.Builder().system(messageContextGlobalSystemModel).build(); - assertEquals(messageContextGlobalModel.system(), messageContextGlobalSystemModel); - - MessageContextSkillSystem messageContextSkillSystemModel = - new MessageContextSkillSystem.Builder() - .state("testString") - .add("foo", "testString") - .build(); - assertEquals(messageContextSkillSystemModel.getState(), "testString"); - assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); - - MessageContextSkillDialog messageContextSkillDialogModel = - new MessageContextSkillDialog.Builder() - .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) - .system(messageContextSkillSystemModel) - .build(); + statelessMessageInputModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); + assertEquals(statelessMessageInputModel.suggestionId(), "testString"); assertEquals( - messageContextSkillDialogModel.userDefined(), - java.util.Collections.singletonMap("anyKey", "anyValue")); - assertEquals(messageContextSkillDialogModel.system(), messageContextSkillSystemModel); - - MessageContextSkillAction messageContextSkillActionModel = - new MessageContextSkillAction.Builder() - .userDefined(java.util.Collections.singletonMap("anyKey", "anyValue")) - .system(messageContextSkillSystemModel) - .actionVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) - .skillVariables(java.util.Collections.singletonMap("anyKey", "anyValue")) - .build(); + statelessMessageInputModel.attachments(), + java.util.Arrays.asList(messageInputAttachmentModel)); + assertEquals(statelessMessageInputModel.analytics(), requestAnalyticsModel); + assertEquals(statelessMessageInputModel.options(), statelessMessageInputOptionsModel); + + String json = TestUtilities.serialize(statelessMessageInputModel); + + StatelessMessageInput statelessMessageInputModelNew = + TestUtilities.deserialize(json, StatelessMessageInput.class); + assertTrue(statelessMessageInputModelNew instanceof StatelessMessageInput); + assertEquals(statelessMessageInputModelNew.messageType(), "text"); + assertEquals(statelessMessageInputModelNew.text(), "testString"); + assertEquals(statelessMessageInputModelNew.suggestionId(), "testString"); assertEquals( - messageContextSkillActionModel.userDefined(), - java.util.Collections.singletonMap("anyKey", "anyValue")); - assertEquals(messageContextSkillActionModel.system(), messageContextSkillSystemModel); + statelessMessageInputModelNew.analytics().toString(), requestAnalyticsModel.toString()); assertEquals( - messageContextSkillActionModel.actionVariables(), - java.util.Collections.singletonMap("anyKey", "anyValue")); - assertEquals( - messageContextSkillActionModel.skillVariables(), - java.util.Collections.singletonMap("anyKey", "anyValue")); - - MessageContextSkills messageContextSkillsModel = - new MessageContextSkills.Builder() - .mainSkill(messageContextSkillDialogModel) - .actionsSkill(messageContextSkillActionModel) - .build(); - assertEquals(messageContextSkillsModel.mainSkill(), messageContextSkillDialogModel); - assertEquals(messageContextSkillsModel.actionsSkill(), messageContextSkillActionModel); - - MessageContext messageContextModel = - new MessageContext.Builder() - .global(messageContextGlobalModel) - .skills(messageContextSkillsModel) - .integrations(java.util.Collections.singletonMap("anyKey", "anyValue")) - .build(); - assertEquals(messageContextModel.global(), messageContextGlobalModel); - assertEquals(messageContextModel.skills(), messageContextSkillsModel); - assertEquals( - messageContextModel.integrations(), - java.util.Collections.singletonMap("anyKey", "anyValue")); - - MessageRequest messageRequestModel = - new MessageRequest.Builder() - .input(messageInputModel) - .context(messageContextModel) - .userId("testString") - .build(); - assertEquals(messageRequestModel.input(), messageInputModel); - assertEquals(messageRequestModel.context(), messageContextModel); - assertEquals(messageRequestModel.userId(), "testString"); - - String json = TestUtilities.serialize(messageRequestModel); - - MessageRequest messageRequestModelNew = TestUtilities.deserialize(json, MessageRequest.class); - assertTrue(messageRequestModelNew instanceof MessageRequest); - assertEquals(messageRequestModelNew.input().toString(), messageInputModel.toString()); - assertEquals(messageRequestModelNew.context().toString(), messageContextModel.toString()); - assertEquals(messageRequestModelNew.userId(), "testString"); + statelessMessageInputModelNew.options().toString(), + statelessMessageInputOptionsModel.toString()); } } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageResponseTest.java new file mode 100644 index 0000000000..42849b24cc --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/StatelessMessageResponseTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2024. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the StatelessMessageResponse model. */ +public class StatelessMessageResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testStatelessMessageResponse() throws Throwable { + StatelessMessageResponse statelessMessageResponseModel = new StatelessMessageResponse(); + assertNull(statelessMessageResponseModel.getOutput()); + assertNull(statelessMessageResponseModel.getContext()); + assertNull(statelessMessageResponseModel.getMaskedOutput()); + assertNull(statelessMessageResponseModel.getMaskedInput()); + assertNull(statelessMessageResponseModel.getUserId()); + } +}