diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextStateless.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextStateless.java deleted file mode 100644 index aa4bc86c1d..0000000000 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextStateless.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2020, 2023. - * - * 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; - -/** MessageContextStateless. */ -public class MessageContextStateless extends GenericModel { - - protected MessageContextGlobalStateless global; - protected MessageContextSkills skills; - protected Map integrations; - - /** Builder. */ - public static class Builder { - private MessageContextGlobalStateless global; - private MessageContextSkills skills; - private Map integrations; - - /** - * Instantiates a new Builder from an existing MessageContextStateless instance. - * - * @param messageContextStateless the instance to initialize the Builder with - */ - private Builder(MessageContextStateless messageContextStateless) { - this.global = messageContextStateless.global; - this.skills = messageContextStateless.skills; - this.integrations = messageContextStateless.integrations; - } - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Builds a MessageContextStateless. - * - * @return the new MessageContextStateless instance - */ - public MessageContextStateless build() { - return new MessageContextStateless(this); - } - - /** - * Set the global. - * - * @param global the global - * @return the MessageContextStateless builder - */ - public Builder global(MessageContextGlobalStateless global) { - this.global = global; - return this; - } - - /** - * Set the skills. - * - * @param skills the skills - * @return the MessageContextStateless builder - */ - public Builder skills(MessageContextSkills skills) { - this.skills = skills; - return this; - } - - /** - * Set the integrations. - * - * @param integrations the integrations - * @return the MessageContextStateless builder - */ - public Builder integrations(Map integrations) { - this.integrations = integrations; - return this; - } - } - - protected MessageContextStateless() {} - - protected MessageContextStateless(Builder builder) { - global = builder.global; - skills = builder.skills; - integrations = builder.integrations; - } - - /** - * New builder. - * - * @return a MessageContextStateless 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 MessageContextGlobalStateless global() { - return global; - } - - /** - * Gets the skills. - * - *

Context data specific to particular skills used by the assistant. - * - * @return the skills - */ - public MessageContextSkills 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/MessageInputOptionsStateless.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsStateless.java deleted file mode 100644 index 30a1422889..0000000000 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsStateless.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2020, 2023. - * - * 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 MessageInputOptionsStateless 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 MessageInputOptionsStateless instance. - * - * @param messageInputOptionsStateless the instance to initialize the Builder with - */ - private Builder(MessageInputOptionsStateless messageInputOptionsStateless) { - this.restart = messageInputOptionsStateless.restart; - this.alternateIntents = messageInputOptionsStateless.alternateIntents; - this.asyncCallout = messageInputOptions.asyncCallout; - this.spelling = messageInputOptionsStateless.spelling; - this.debug = messageInputOptionsStateless.debug; - } - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Builds a MessageInputOptionsStateless. - * - * @return the new MessageInputOptionsStateless instance - */ - public MessageInputOptionsStateless build() { - return new MessageInputOptionsStateless(this); - } - - /** - * Set the restart. - * - * @param restart the restart - * @return the MessageInputOptionsStateless builder - */ - public Builder restart(Boolean restart) { - this.restart = restart; - return this; - } - - /** - * Set the alternateIntents. - * - * @param alternateIntents the alternateIntents - * @return the MessageInputOptionsStateless builder - */ - public Builder alternateIntents(Boolean alternateIntents) { - this.alternateIntents = alternateIntents; - return this; - } - - /** - * Set the asyncCallout. - * - * @param asyncCallout the asyncCallout - * @return the MessageInputOptions builder - */ - public Builder asyncCallout(Boolean asyncCallout) { - this.asyncCallout = asyncCallout; - return this; - } - - /** - * Set the spelling. - * - * @param spelling the spelling - * @return the MessageInputOptionsStateless builder - */ - public Builder spelling(MessageInputOptionsSpelling spelling) { - this.spelling = spelling; - return this; - } - - /** - * Set the debug. - * - * @param debug the debug - * @return the MessageInputOptionsStateless builder - */ - public Builder debug(Boolean debug) { - this.debug = debug; - return this; - } - } - - protected MessageInputOptionsStateless() {} - - protected MessageInputOptionsStateless(Builder builder) { - restart = builder.restart; - alternateIntents = builder.alternateIntents; - asyncCallout = builder.asyncCallout; - spelling = builder.spelling; - debug = builder.debug; - } - - /** - * New builder. - * - * @return a MessageInputOptionsStateless 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/MessageInputStateless.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputStateless.java deleted file mode 100644 index 5deb04e2da..0000000000 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputStateless.java +++ /dev/null @@ -1,348 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2020, 2023. - * - * 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 MessageInputStateless 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 MessageInputOptionsStateless 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 MessageInputOptionsStateless options; - - /** - * Instantiates a new Builder from an existing MessageInputStateless instance. - * - * @param messageInputStateless the instance to initialize the Builder with - */ - private Builder(MessageInputStateless messageInputStateless) { - this.messageType = messageInputStateless.messageType; - this.text = messageInputStateless.text; - this.intents = messageInputStateless.intents; - this.entities = messageInputStateless.entities; - this.suggestionId = messageInputStateless.suggestionId; - this.attachments = messageInputStateless.attachments; - this.analytics = messageInputStateless.analytics; - this.options = messageInputStateless.options; - } - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Builds a MessageInputStateless. - * - * @return the new MessageInputStateless instance - */ - public MessageInputStateless build() { - return new MessageInputStateless(this); - } - - /** - * Adds an intent to intents. - * - * @param intent the new intent - * @return the MessageInputStateless 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 an entity to entities. - * - * @param entity the new entity - * @return the MessageInputStateless 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 an attachments to attachments. - * - * @param attachments the new attachments - * @return the MessageInputStateless 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 MessageInputStateless builder - */ - public Builder messageType(String messageType) { - this.messageType = messageType; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the MessageInputStateless 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 MessageInputStateless 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 MessageInputStateless builder - */ - public Builder entities(List entities) { - this.entities = entities; - return this; - } - - /** - * Set the suggestionId. - * - * @param suggestionId the suggestionId - * @return the MessageInputStateless 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 MessageInputStateless builder - */ - public Builder attachments(List attachments) { - this.attachments = attachments; - return this; - } - - /** - * Set the analytics. - * - * @param analytics the analytics - * @return the MessageInputStateless builder - */ - public Builder analytics(RequestAnalytics analytics) { - this.analytics = analytics; - return this; - } - - /** - * Set the options. - * - * @param options the options - * @return the MessageInputStateless builder - */ - public Builder options(MessageInputOptionsStateless options) { - this.options = options; - return this; - } - } - - protected MessageInputStateless() {} - - protected MessageInputStateless(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 MessageInputStateless 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 MessageInputOptionsStateless options() { - return options; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageResponseStateless.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageResponseStateless.java deleted file mode 100644 index af04b7bcba..0000000000 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageResponseStateless.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2020, 2023. - * - * 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 Watson Assistant service. */ -public class MessageResponseStateless extends GenericModel { - - protected MessageOutput output; - protected MessageContextStateless context; - - @SerializedName("user_id") - protected String userId; - - protected MessageResponseStateless() {} - - /** - * 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 MessageContextStateless 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; - } -} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java index 00232b9ff0..d23ea45d49 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java @@ -41,8 +41,16 @@ public class AssistantServiceIT extends AssistantServiceTest { @Before public void setUp() throws Exception { super.setUp(); - this.service = getService(); - this.assistantId = getAssistantId(); + String apikey = + "azE6dXNyXzExM2E2YmIzLTE2YzktMzZhOS1iN2EzLTU4MzdhYWNlMDVhNTpsbEE5a1g5clptbS9pT1NuVnR2bkM2bk9vNHZqWWNvaWdYVFkvN0VhbmpNPTpXU2hq"; + String url = "https://iam.platform.saas.ibm.com"; + Authenticator authenticator = new MCSPAuthenticator.Builder().apikey(apikey).url(url).build(); + this.service = new Assistant("2019-07-12", authenticator); + this.service.setServiceUrl( + "https://api.us-east-1.aws.watsonassistant.ibm.com/instances/20240205-1648-4024-4028-2e47043df2f9"); + this.assistantId = "555f34ff-fd9f-4395-a4cc-5e2c8bbce535"; + // this.service = getService(); + // this.assistantId = getAssistantId(); } /** Test send messages. */ @@ -75,7 +83,7 @@ public void testSendMessages() { .input(input) .context(context) .build(); - MessageResponse messageResponse = service.message(messageOptions).execute().getResult(); + StatefulMessageResponse messageResponse = service.message(messageOptions).execute().getResult(); // message assertions List genericResponses = messageResponse.getOutput().getGeneric(); @@ -114,15 +122,15 @@ public void testSendMessageStateless() { String sessionId = sessionResponse.getSessionId(); final List messages = Arrays.asList("Hello"); - MessageContextStateless context = new MessageContextStateless.Builder().build(); + StatelessMessageContext context = new StatelessMessageContext.Builder().build(); try { // send messages for (String message : messages) { - MessageInputOptionsStateless inputOptions = - new MessageInputOptionsStateless.Builder().debug(true).build(); - MessageInputStateless input = - new MessageInputStateless.Builder() + StatelessMessageInputOptions inputOptions = + new StatelessMessageInputOptions.Builder().debug(true).build(); + StatelessMessageInput input = + new StatelessMessageInput.Builder() .text(message) .messageType(MessageInput.MessageType.TEXT) .options(inputOptions) @@ -133,7 +141,7 @@ public void testSendMessageStateless() { .input(input) .context(context) .build(); - MessageResponseStateless messageResponse = + StatelessMessageResponse messageResponse = service.messageStateless(messageOptions).execute().getResult(); // message assertions @@ -174,7 +182,7 @@ public void testListLogs() { LogCollection logCollection = service.listLogs(builder.build()).execute().getResult(); assertNotNull(logCollection); - assertTrue(logCollection.getLogs().get(0).getRequest().input().text().contains("Hello")); + assertTrue(logCollection.getLogs().get(0).getRequest().getInput().text().contains("Hello")); assertTrue(logCollection.getLogs().get(0).getLanguage().equals("en")); } @@ -222,7 +230,7 @@ public void testRuntimeResponseGenericRuntimeResponseTypeChannelTransfer() { .input(input) .context(context) .build(); - MessageResponse response = service.message(messageOptions).execute().getResult(); + StatefulMessageResponse response = service.message(messageOptions).execute().getResult(); RuntimeResponseGenericRuntimeResponseTypeChannelTransfer runtimeResponseGenericRuntimeResponseTypeChannelTransfer = diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextStatelessTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextStatelessTest.java deleted file mode 100644 index 53fce3722e..0000000000 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextStatelessTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2020, 2023. - * - * 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 MessageContextStateless model. */ -public class MessageContextStatelessTest { - final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); - final List mockListFileWithMetadata = - TestUtilities.creatMockListFileWithMetadata(); - - @Test - public void testMessageContextStateless() 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)); - - MessageContextGlobalStateless messageContextGlobalStatelessModel = - new MessageContextGlobalStateless.Builder() - .system(messageContextGlobalSystemModel) - .sessionId("testString") - .build(); - assertEquals(messageContextGlobalStatelessModel.system(), messageContextGlobalSystemModel); - assertEquals(messageContextGlobalStatelessModel.sessionId(), "testString"); - - 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(); - 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(); - assertEquals( - messageContextSkillActionModel.userDefined(), - java.util.Collections.singletonMap("anyKey", "anyValue")); - assertEquals(messageContextSkillActionModel.system(), messageContextSkillSystemModel); - 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); - - MessageContextStateless messageContextStatelessModel = - new MessageContextStateless.Builder() - .global(messageContextGlobalStatelessModel) - .skills(messageContextSkillsModel) - .integrations(java.util.Collections.singletonMap("anyKey", "anyValue")) - .build(); - assertEquals(messageContextStatelessModel.global(), messageContextGlobalStatelessModel); - assertEquals(messageContextStatelessModel.skills(), messageContextSkillsModel); - assertEquals( - messageContextStatelessModel.integrations(), - java.util.Collections.singletonMap("anyKey", "anyValue")); - - String json = TestUtilities.serialize(messageContextStatelessModel); - - MessageContextStateless messageContextStatelessModelNew = - TestUtilities.deserialize(json, MessageContextStateless.class); - assertTrue(messageContextStatelessModelNew instanceof MessageContextStateless); - assertEquals( - messageContextStatelessModelNew.global().toString(), - messageContextGlobalStatelessModel.toString()); - assertEquals( - messageContextStatelessModelNew.skills().toString(), messageContextSkillsModel.toString()); - assertEquals( - messageContextStatelessModelNew.integrations().toString(), - java.util.Collections.singletonMap("anyKey", "anyValue").toString()); - } -} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsStatelessTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsStatelessTest.java deleted file mode 100644 index 98810c9509..0000000000 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsStatelessTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2020, 2021. - * - * 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 MessageInputOptionsStateless model. */ -public class MessageInputOptionsStatelessTest { - final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); - final List mockListFileWithMetadata = - TestUtilities.creatMockListFileWithMetadata(); - - @Test - public void testMessageInputOptionsStateless() throws Throwable { - MessageInputOptionsSpelling messageInputOptionsSpellingModel = - new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); - assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); - assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); - - MessageInputOptionsStateless messageInputOptionsStatelessModel = - new MessageInputOptionsStateless.Builder() - .restart(false) - .alternateIntents(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)); - - String json = TestUtilities.serialize(messageInputOptionsStatelessModel); - - MessageInputOptionsStateless messageInputOptionsStatelessModelNew = - TestUtilities.deserialize(json, MessageInputOptionsStateless.class); - assertTrue(messageInputOptionsStatelessModelNew instanceof MessageInputOptionsStateless); - assertEquals(messageInputOptionsStatelessModelNew.restart(), Boolean.valueOf(false)); - assertEquals(messageInputOptionsStatelessModelNew.alternateIntents(), Boolean.valueOf(false)); - assertEquals( - messageInputOptionsStatelessModelNew.spelling().toString(), - messageInputOptionsSpellingModel.toString()); - assertEquals(messageInputOptionsStatelessModelNew.debug(), Boolean.valueOf(false)); - } -} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputStatelessTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputStatelessTest.java deleted file mode 100644 index c763abf73e..0000000000 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputStatelessTest.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2020, 2023. - * - * 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 MessageInputStateless model. */ -public class MessageInputStatelessTest { - final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); - final List mockListFileWithMetadata = - TestUtilities.creatMockListFileWithMetadata(); - - @Test - public void testMessageInputStateless() throws Throwable { - RuntimeIntent runtimeIntentModel = - new RuntimeIntent.Builder() - .intent("testString") - .confidence(Double.valueOf("72.5")) - .skill("testString") - .build(); - assertEquals(runtimeIntentModel.intent(), "testString"); - assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); - assertEquals(runtimeIntentModel.skill(), "testString"); - - CaptureGroup captureGroupModel = - new CaptureGroup.Builder() - .group("testString") - .location(java.util.Arrays.asList(Long.valueOf("26"))) - .build(); - assertEquals(captureGroupModel.group(), "testString"); - assertEquals(captureGroupModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); - - RuntimeEntityInterpretation runtimeEntityInterpretationModel = - new RuntimeEntityInterpretation.Builder() - .calendarType("testString") - .datetimeLink("testString") - .festival("testString") - .granularity("day") - .rangeLink("testString") - .rangeModifier("testString") - .relativeDay(Double.valueOf("72.5")) - .relativeMonth(Double.valueOf("72.5")) - .relativeWeek(Double.valueOf("72.5")) - .relativeWeekend(Double.valueOf("72.5")) - .relativeYear(Double.valueOf("72.5")) - .specificDay(Double.valueOf("72.5")) - .specificDayOfWeek("testString") - .specificMonth(Double.valueOf("72.5")) - .specificQuarter(Double.valueOf("72.5")) - .specificYear(Double.valueOf("72.5")) - .numericValue(Double.valueOf("72.5")) - .subtype("testString") - .partOfDay("testString") - .relativeHour(Double.valueOf("72.5")) - .relativeMinute(Double.valueOf("72.5")) - .relativeSecond(Double.valueOf("72.5")) - .specificHour(Double.valueOf("72.5")) - .specificMinute(Double.valueOf("72.5")) - .specificSecond(Double.valueOf("72.5")) - .timezone("testString") - .build(); - assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); - assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); - assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); - assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); - assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); - assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); - assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); - assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); - assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); - assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); - assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); - - RuntimeEntityAlternative runtimeEntityAlternativeModel = - new RuntimeEntityAlternative.Builder() - .value("testString") - .confidence(Double.valueOf("72.5")) - .build(); - assertEquals(runtimeEntityAlternativeModel.value(), "testString"); - assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); - - RuntimeEntityRole runtimeEntityRoleModel = - new RuntimeEntityRole.Builder().type("date_from").build(); - assertEquals(runtimeEntityRoleModel.type(), "date_from"); - - RuntimeEntity runtimeEntityModel = - new RuntimeEntity.Builder() - .entity("testString") - .location(java.util.Arrays.asList(Long.valueOf("26"))) - .value("testString") - .confidence(Double.valueOf("72.5")) - .groups(java.util.Arrays.asList(captureGroupModel)) - .interpretation(runtimeEntityInterpretationModel) - .alternatives(java.util.Arrays.asList(runtimeEntityAlternativeModel)) - .role(runtimeEntityRoleModel) - .skill("testString") - .build(); - assertEquals(runtimeEntityModel.entity(), "testString"); - assertEquals(runtimeEntityModel.location(), java.util.Arrays.asList(Long.valueOf("26"))); - assertEquals(runtimeEntityModel.value(), "testString"); - assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); - assertEquals(runtimeEntityModel.groups(), java.util.Arrays.asList(captureGroupModel)); - assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); - assertEquals( - runtimeEntityModel.alternatives(), java.util.Arrays.asList(runtimeEntityAlternativeModel)); - assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); - assertEquals(runtimeEntityModel.skill(), "testString"); - - MessageInputAttachment messageInputAttachmentModel = - new MessageInputAttachment.Builder().url("testString").mediaType("testString").build(); - assertEquals(messageInputAttachmentModel.url(), "testString"); - assertEquals(messageInputAttachmentModel.mediaType(), "testString"); - - RequestAnalytics requestAnalyticsModel = - new RequestAnalytics.Builder() - .browser("testString") - .device("testString") - .pageUrl("testString") - .build(); - assertEquals(requestAnalyticsModel.browser(), "testString"); - assertEquals(requestAnalyticsModel.device(), "testString"); - assertEquals(requestAnalyticsModel.pageUrl(), "testString"); - - MessageInputOptionsSpelling messageInputOptionsSpellingModel = - new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); - assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); - assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); - - MessageInputOptionsStateless messageInputOptionsStatelessModel = - new MessageInputOptionsStateless.Builder() - .restart(false) - .alternateIntents(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)); - - MessageInputStateless messageInputStatelessModel = - new MessageInputStateless.Builder() - .messageType("text") - .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(messageInputOptionsStatelessModel) - .build(); - assertEquals(messageInputStatelessModel.messageType(), "text"); - assertEquals(messageInputStatelessModel.text(), "testString"); - assertEquals(messageInputStatelessModel.intents(), java.util.Arrays.asList(runtimeIntentModel)); - assertEquals( - messageInputStatelessModel.entities(), java.util.Arrays.asList(runtimeEntityModel)); - assertEquals(messageInputStatelessModel.suggestionId(), "testString"); - assertEquals( - messageInputStatelessModel.attachments(), - java.util.Arrays.asList(messageInputAttachmentModel)); - assertEquals(messageInputStatelessModel.analytics(), requestAnalyticsModel); - assertEquals(messageInputStatelessModel.options(), messageInputOptionsStatelessModel); - - String json = TestUtilities.serialize(messageInputStatelessModel); - - MessageInputStateless messageInputStatelessModelNew = - TestUtilities.deserialize(json, MessageInputStateless.class); - assertTrue(messageInputStatelessModelNew instanceof MessageInputStateless); - assertEquals(messageInputStatelessModelNew.messageType(), "text"); - assertEquals(messageInputStatelessModelNew.text(), "testString"); - assertEquals(messageInputStatelessModelNew.suggestionId(), "testString"); - assertEquals( - messageInputStatelessModelNew.analytics().toString(), requestAnalyticsModel.toString()); - assertEquals( - messageInputStatelessModelNew.options().toString(), - messageInputOptionsStatelessModel.toString()); - } -} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageResponseStatelessTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageResponseStatelessTest.java deleted file mode 100644 index 96dbbbd967..0000000000 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageResponseStatelessTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2020, 2021. - * - * 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 MessageResponseStateless model. */ -public class MessageResponseStatelessTest { - final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); - final List mockListFileWithMetadata = - TestUtilities.creatMockListFileWithMetadata(); - - @Test - public void testMessageResponseStateless() throws Throwable { - MessageResponseStateless messageResponseStatelessModel = new MessageResponseStateless(); - assertNull(messageResponseStatelessModel.getOutput()); - assertNull(messageResponseStatelessModel.getContext()); - assertNull(messageResponseStatelessModel.getUserId()); - } -}