From 90e3ea5c7f9036c096721724320e7f4000b91325 Mon Sep 17 00:00:00 2001 From: Kevin Kowalski Date: Wed, 21 Apr 2021 13:46:56 -0500 Subject: [PATCH 1/5] feat(assistant-v1): add updateDialogNodeNullable as a new function --- .../ibm/watson/assistant/v1/Assistant.java | 46 ++ .../assistant/v1/model/UpdateDialogNode.java | 724 ++++++++++++++++++ .../UpdateDialogNodeNullableOptions.java | 182 +++++ 3 files changed, 952 insertions(+) create mode 100644 assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNode.java create mode 100644 assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeNullableOptions.java diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/Assistant.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/Assistant.java index a5c299e207f..c508fdbcfb2 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/Assistant.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/Assistant.java @@ -80,6 +80,7 @@ import com.ibm.watson.assistant.v1.model.Synonym; import com.ibm.watson.assistant.v1.model.SynonymCollection; import com.ibm.watson.assistant.v1.model.UpdateCounterexampleOptions; +import com.ibm.watson.assistant.v1.model.UpdateDialogNodeNullableOptions; import com.ibm.watson.assistant.v1.model.UpdateDialogNodeOptions; import com.ibm.watson.assistant.v1.model.UpdateEntityOptions; import com.ibm.watson.assistant.v1.model.UpdateExampleOptions; @@ -2289,6 +2290,51 @@ public ServiceCall updateDialogNode(UpdateDialogNodeOptions updateDi return createServiceCall(builder.build(), responseConverter); } + /** + * Update dialog node. + * + *

Update an existing dialog node with new or modified data. + * + *

If you want to update multiple dialog nodes with a single API call, consider using the + * **[Update workspace](#update-workspace)** method instead. + * + * @param UpdateDialogNodeNullableOptions the {@link UpdateDialogNodeNullableOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link DialogNode} + */ + public ServiceCall updateDialogNodeNullable( + UpdateDialogNodeNullableOptions UpdateDialogNodeNullableOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + UpdateDialogNodeNullableOptions, "UpdateDialogNodeNullableOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", UpdateDialogNodeNullableOptions.workspaceId()); + pathParamsMap.put("dialog_node", UpdateDialogNodeNullableOptions.dialogNode()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/dialog_nodes/{dialog_node}", + pathParamsMap)); + Map sdkHeaders = + SdkCommon.getSdkHeaders("conversation", "v1", "testUpdateDialogNode"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (UpdateDialogNodeNullableOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(UpdateDialogNodeNullableOptions.includeAudit())); + } + builder.bodyContent( + com.ibm.cloud.sdk.core.util.GsonSingleton.getGsonWithSerializeNulls() + .toJson(UpdateDialogNodeNullableOptions.body()), + "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + /** * Delete dialog node. * diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNode.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNode.java new file mode 100644 index 00000000000..08df4eac52f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNode.java @@ -0,0 +1,724 @@ +/* + * (C) Copyright IBM Corp. 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.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** UpdateDialogNode. */ +public class UpdateDialogNode extends GenericModel { + + /** How the dialog node is processed. */ + public interface Type { + /** standard. */ + String STANDARD = "standard"; + /** event_handler. */ + String EVENT_HANDLER = "event_handler"; + /** frame. */ + String FRAME = "frame"; + /** slot. */ + String SLOT = "slot"; + /** response_condition. */ + String RESPONSE_CONDITION = "response_condition"; + /** folder. */ + String FOLDER = "folder"; + } + + /** How an `event_handler` node is processed. */ + public interface EventName { + /** focus. */ + String FOCUS = "focus"; + /** input. */ + String INPUT = "input"; + /** filled. */ + String FILLED = "filled"; + /** validate. */ + String VALIDATE = "validate"; + /** filled_multiple. */ + String FILLED_MULTIPLE = "filled_multiple"; + /** generic. */ + String GENERIC = "generic"; + /** nomatch. */ + String NOMATCH = "nomatch"; + /** nomatch_responses_depleted. */ + String NOMATCH_RESPONSES_DEPLETED = "nomatch_responses_depleted"; + /** digression_return_prompt. */ + String DIGRESSION_RETURN_PROMPT = "digression_return_prompt"; + } + + /** Whether this top-level dialog node can be digressed into. */ + public interface DigressIn { + /** not_available. */ + String NOT_AVAILABLE = "not_available"; + /** returns. */ + String RETURNS = "returns"; + /** does_not_return. */ + String DOES_NOT_RETURN = "does_not_return"; + } + + /** Whether this dialog node can be returned to after a digression. */ + public interface DigressOut { + /** allow_returning. */ + String ALLOW_RETURNING = "allow_returning"; + /** allow_all. */ + String ALLOW_ALL = "allow_all"; + /** allow_all_never_return. */ + String ALLOW_ALL_NEVER_RETURN = "allow_all_never_return"; + } + + /** Whether the user can digress to top-level nodes while filling out slots. */ + public interface DigressOutSlots { + /** not_allowed. */ + String NOT_ALLOWED = "not_allowed"; + /** allow_returning. */ + String ALLOW_RETURNING = "allow_returning"; + /** allow_all. */ + String ALLOW_ALL = "allow_all"; + } + + @SerializedName("dialog_node") + protected String dialogNode; + + protected String description; + protected String conditions; + protected String parent; + + @SerializedName("previous_sibling") + protected String previousSibling; + + protected DialogNodeOutput output; + protected DialogNodeContext context; + protected Map metadata; + + @SerializedName("next_step") + protected DialogNodeNextStep nextStep; + + protected String title; + protected String type; + + @SerializedName("event_name") + protected String eventName; + + protected String variable; + protected List actions; + + @SerializedName("digress_in") + protected String digressIn; + + @SerializedName("digress_out") + protected String digressOut; + + @SerializedName("digress_out_slots") + protected String digressOutSlots; + + @SerializedName("user_label") + protected String userLabel; + + @SerializedName("disambiguation_opt_out") + protected Boolean disambiguationOptOut; + + protected Boolean disabled; + protected Date created; + protected Date updated; + + /** Builder. */ + public static class Builder { + private String dialogNode; + private String description; + private String conditions; + private String parent; + private String previousSibling; + private DialogNodeOutput output; + private DialogNodeContext context; + private Map metadata; + private DialogNodeNextStep nextStep; + private String title; + private String type; + private String eventName; + private String variable; + private List actions; + private String digressIn; + private String digressOut; + private String digressOutSlots; + private String userLabel; + private Boolean disambiguationOptOut; + + private Builder(UpdateDialogNode updateDialogNode) { + this.dialogNode = updateDialogNode.dialogNode; + this.description = updateDialogNode.description; + this.conditions = updateDialogNode.conditions; + this.parent = updateDialogNode.parent; + this.previousSibling = updateDialogNode.previousSibling; + this.output = updateDialogNode.output; + this.context = updateDialogNode.context; + this.metadata = updateDialogNode.metadata; + this.nextStep = updateDialogNode.nextStep; + this.title = updateDialogNode.title; + this.type = updateDialogNode.type; + this.eventName = updateDialogNode.eventName; + this.variable = updateDialogNode.variable; + this.actions = updateDialogNode.actions; + this.digressIn = updateDialogNode.digressIn; + this.digressOut = updateDialogNode.digressOut; + this.digressOutSlots = updateDialogNode.digressOutSlots; + this.userLabel = updateDialogNode.userLabel; + this.disambiguationOptOut = updateDialogNode.disambiguationOptOut; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a UpdateDialogNode. + * + * @return the new UpdateDialogNode instance + */ + public UpdateDialogNode build() { + return new UpdateDialogNode(this); + } + + /** + * Adds an actions to actions. + * + * @param actions the new actions + * @return the UpdateDialogNode builder + */ + public Builder addActions(DialogNodeAction actions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(actions, "actions cannot be null"); + if (this.actions == null) { + this.actions = new ArrayList(); + } + this.actions.add(actions); + return this; + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the UpdateDialogNode builder + */ + public Builder dialogNode(String dialogNode) { + this.dialogNode = dialogNode; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateDialogNode builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the conditions. + * + * @param conditions the conditions + * @return the UpdateDialogNode builder + */ + public Builder conditions(String conditions) { + this.conditions = conditions; + return this; + } + + /** + * Set the parent. + * + * @param parent the parent + * @return the UpdateDialogNode builder + */ + public Builder parent(String parent) { + this.parent = parent; + return this; + } + + /** + * Set the previousSibling. + * + * @param previousSibling the previousSibling + * @return the UpdateDialogNode builder + */ + public Builder previousSibling(String previousSibling) { + this.previousSibling = previousSibling; + return this; + } + + /** + * Set the output. + * + * @param output the output + * @return the UpdateDialogNode builder + */ + public Builder output(DialogNodeOutput output) { + this.output = output; + return this; + } + + /** + * Set the context. + * + * @param context the context + * @return the UpdateDialogNode builder + */ + public Builder context(DialogNodeContext context) { + this.context = context; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the UpdateDialogNode builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the nextStep. + * + * @param nextStep the nextStep + * @return the UpdateDialogNode builder + */ + public Builder nextStep(DialogNodeNextStep nextStep) { + this.nextStep = nextStep; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the UpdateDialogNode builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the UpdateDialogNode builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the eventName. + * + * @param eventName the eventName + * @return the UpdateDialogNode builder + */ + public Builder eventName(String eventName) { + this.eventName = eventName; + return this; + } + + /** + * Set the variable. + * + * @param variable the variable + * @return the UpdateDialogNode builder + */ + public Builder variable(String variable) { + this.variable = variable; + return this; + } + + /** + * Set the actions. Existing actions will be replaced. + * + * @param actions the actions + * @return the UpdateDialogNode builder + */ + public Builder actions(List actions) { + this.actions = actions; + return this; + } + + /** + * Set the digressIn. + * + * @param digressIn the digressIn + * @return the UpdateDialogNode builder + */ + public Builder digressIn(String digressIn) { + this.digressIn = digressIn; + return this; + } + + /** + * Set the digressOut. + * + * @param digressOut the digressOut + * @return the UpdateDialogNode builder + */ + public Builder digressOut(String digressOut) { + this.digressOut = digressOut; + return this; + } + + /** + * Set the digressOutSlots. + * + * @param digressOutSlots the digressOutSlots + * @return the UpdateDialogNode builder + */ + public Builder digressOutSlots(String digressOutSlots) { + this.digressOutSlots = digressOutSlots; + return this; + } + + /** + * Set the userLabel. + * + * @param userLabel the userLabel + * @return the UpdateDialogNode builder + */ + public Builder userLabel(String userLabel) { + this.userLabel = userLabel; + return this; + } + + /** + * Set the disambiguationOptOut. + * + * @param disambiguationOptOut the disambiguationOptOut + * @return the UpdateDialogNode builder + */ + public Builder disambiguationOptOut(Boolean disambiguationOptOut) { + this.disambiguationOptOut = disambiguationOptOut; + return this; + } + } + + protected UpdateDialogNode(Builder builder) { + dialogNode = builder.dialogNode; + description = builder.description; + conditions = builder.conditions; + parent = builder.parent; + previousSibling = builder.previousSibling; + output = builder.output; + context = builder.context; + metadata = builder.metadata; + nextStep = builder.nextStep; + title = builder.title; + type = builder.type; + eventName = builder.eventName; + variable = builder.variable; + actions = builder.actions; + digressIn = builder.digressIn; + digressOut = builder.digressOut; + digressOutSlots = builder.digressOutSlots; + userLabel = builder.userLabel; + disambiguationOptOut = builder.disambiguationOptOut; + } + + /** + * New builder. + * + * @return a UpdateDialogNode builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the dialogNode. + * + *

The unique ID of the dialog node. This is an internal identifier used to refer to the dialog + * node from other dialog nodes and in the diagnostic information included with message responses. + * + *

This string can contain only Unicode alphanumeric, space, underscore, hyphen, and dot + * characters. + * + * @return the dialogNode + */ + public String dialogNode() { + return dialogNode; + } + + /** + * Gets the description. + * + *

The description of the dialog node. This string cannot contain carriage return, newline, or + * tab characters. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the conditions. + * + *

The condition that will trigger the dialog node. This string cannot contain carriage return, + * newline, or tab characters. + * + * @return the conditions + */ + public String conditions() { + return conditions; + } + + /** + * Gets the parent. + * + *

The unique ID of the parent dialog node. This property is omitted if the dialog node has no + * parent. + * + * @return the parent + */ + public String parent() { + return parent; + } + + /** + * Gets the previousSibling. + * + *

The unique ID of the previous sibling dialog node. This property is omitted if the dialog + * node has no previous sibling. + * + * @return the previousSibling + */ + public String previousSibling() { + return previousSibling; + } + + /** + * Gets the output. + * + *

The output of the dialog node. For more information about how to specify dialog node output, + * see the + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-overview#dialog-overview-responses). + * + * @return the output + */ + public DialogNodeOutput output() { + return output; + } + + /** + * Gets the context. + * + *

The context for the dialog node. + * + * @return the context + */ + public DialogNodeContext context() { + return context; + } + + /** + * Gets the metadata. + * + *

The metadata for the dialog node. + * + * @return the metadata + */ + public Map metadata() { + return metadata; + } + + /** + * Gets the nextStep. + * + *

The next step to execute following this dialog node. + * + * @return the nextStep + */ + public DialogNodeNextStep nextStep() { + return nextStep; + } + + /** + * Gets the title. + * + *

A human-readable name for the dialog node. If the node is included in disambiguation, this + * title is used to populate the **label** property of the corresponding suggestion in the + * `suggestion` response type (unless it is overridden by the **user_label** property). The title + * is also used to populate the **topic** property in the `connect_to_agent` response type. + * + *

This string can contain only Unicode alphanumeric, space, underscore, hyphen, and dot + * characters. + * + * @return the title + */ + public String title() { + return title; + } + + /** + * Gets the type. + * + *

How the dialog node is processed. + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the eventName. + * + *

How an `event_handler` node is processed. + * + * @return the eventName + */ + public String eventName() { + return eventName; + } + + /** + * Gets the variable. + * + *

The location in the dialog context where output is stored. + * + * @return the variable + */ + public String variable() { + return variable; + } + + /** + * Gets the actions. + * + *

An array of objects describing any actions to be invoked by the dialog node. + * + * @return the actions + */ + public List actions() { + return actions; + } + + /** + * Gets the digressIn. + * + *

Whether this top-level dialog node can be digressed into. + * + * @return the digressIn + */ + public String digressIn() { + return digressIn; + } + + /** + * Gets the digressOut. + * + *

Whether this dialog node can be returned to after a digression. + * + * @return the digressOut + */ + public String digressOut() { + return digressOut; + } + + /** + * Gets the digressOutSlots. + * + *

Whether the user can digress to top-level nodes while filling out slots. + * + * @return the digressOutSlots + */ + public String digressOutSlots() { + return digressOutSlots; + } + + /** + * Gets the userLabel. + * + *

A label that can be displayed externally to describe the purpose of the node to users. If + * set, this label is used to identify the node in disambiguation responses (overriding the value + * of the **title** property). + * + * @return the userLabel + */ + public String userLabel() { + return userLabel; + } + + /** + * Gets the disambiguationOptOut. + * + *

Whether the dialog node should be excluded from disambiguation suggestions. Valid only when + * **type**=`standard` or `frame`. + * + * @return the disambiguationOptOut + */ + public Boolean disambiguationOptOut() { + return disambiguationOptOut; + } + + /** + * Gets the disabled. + * + *

For internal use only. + * + * @return the disabled + */ + public Boolean disabled() { + return disabled; + } + + /** + * Gets the created. + * + *

The timestamp for creation of the object. + * + * @return the created + */ + public Date created() { + return created; + } + + /** + * Gets the updated. + * + *

The timestamp for the most recent update to the object. + * + * @return the updated + */ + public Date updated() { + return updated; + } + + /** + * Construct a JSON merge-patch from the UpdateDialogNode. + * + *

Note that properties of the UpdateDialogNode with null values are not represented in the + * constructed JSON merge-patch object, but can be explicitly set afterward to signify a property + * delete. + * + * @return a JSON merge-patch for the UpdateDialogNode + */ + public Map asPatch() { + return GsonSingleton.getGsonWithSerializeNulls().fromJson(this.toString(), Map.class); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeNullableOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeNullableOptions.java new file mode 100644 index 00000000000..57eed59c1e8 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeNullableOptions.java @@ -0,0 +1,182 @@ +/* + * (C) Copyright IBM Corp. 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.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** The updateDialogNodeNullable options. */ +public class UpdateDialogNodeNullableOptions extends GenericModel { + + protected String workspaceId; + protected String dialogNode; + protected Map body; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String dialogNode; + private Map body; + private Boolean includeAudit; + + private Builder(UpdateDialogNodeNullableOptions updateDialogNodeNullableOptions) { + this.workspaceId = updateDialogNodeNullableOptions.workspaceId; + this.dialogNode = updateDialogNodeNullableOptions.dialogNode; + this.body = updateDialogNodeNullableOptions.body; + this.includeAudit = updateDialogNodeNullableOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param dialogNode the dialogNode + * @param body the body + */ + public Builder(String workspaceId, String dialogNode, Map body) { + this.workspaceId = workspaceId; + this.dialogNode = dialogNode; + this.body = body; + } + + /** + * Builds a UpdateDialogNodeNullableOptions. + * + * @return the new UpdateDialogNodeNullableOptions instance + */ + public UpdateDialogNodeNullableOptions build() { + return new UpdateDialogNodeNullableOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the UpdateDialogNodeNullableOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the UpdateDialogNodeNullableOptions builder + */ + public Builder dialogNode(String dialogNode) { + this.dialogNode = dialogNode; + return this; + } + + /** + * Set the body. + * + * @param body the body + * @return the UpdateDialogNodeNullableOptions builder + */ + public Builder body(Map body) { + this.body = body; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the UpdateDialogNodeNullableOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected UpdateDialogNodeNullableOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.dialogNode, "dialogNode cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.body, "body cannot be null"); + workspaceId = builder.workspaceId; + dialogNode = builder.dialogNode; + body = builder.body; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a UpdateDialogNodeNullableOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the workspaceId. + * + *

Unique identifier of the workspace. + * + * @return the workspaceId + */ + public String workspaceId() { + return workspaceId; + } + + /** + * Gets the dialogNode. + * + *

The dialog node ID (for example, `node_1_1479323581900`). + * + * @return the dialogNode + */ + public String dialogNode() { + return dialogNode; + } + + /** + * Gets the body. + * + *

The updated content of the dialog node. + * + *

Any elements included in the new data will completely replace the equivalent existing + * elements, including all subelements. (Previously existing subelements are not retained unless + * they are also included in the new data.) For example, if you update the actions for a dialog + * node, the previously existing actions are discarded and replaced with the new actions specified + * in the update. + * + * @return the body + */ + public Map body() { + return body; + } + + /** + * Gets the includeAudit. + * + *

Whether to include the audit properties (`created` and `updated` timestamps) in the + * response. + * + * @return the includeAudit + */ + public Boolean includeAudit() { + return includeAudit; + } +} + From 0dc76aa671ddb01daa34ea1013b3e7b552307187 Mon Sep 17 00:00:00 2001 From: Kevin Kowalski Date: Wed, 21 Apr 2021 13:47:37 -0500 Subject: [PATCH 2/5] test(assistant-v1): add integration test for updateDialogNodeNullable --- .../assistant/v1/AssistantServiceIT.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceIT.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceIT.java index c1752440080..c37aa888a14 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceIT.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceIT.java @@ -1753,6 +1753,58 @@ public void testUpdateDialogNode() { } } + /** Test updateDialogNodeNullable. */ + @Test + public void testUpdateDialogNodeNullable() { + String dialogNodeName = "Test" + UUID.randomUUID().toString(); + String dialogNodeDescription = "Description of " + dialogNodeName; + + DialogNodeNextStep dialogNodeNextStep = new DialogNodeNextStep.Builder() + .behavior(DialogNodeNextStep.Behavior.SKIP_USER_INPUT) + .build(); + CreateDialogNodeOptions createOptions = + new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName) + .description(dialogNodeDescription) + .nextStep(dialogNodeNextStep) + .build(); + service.createDialogNode(createOptions).execute().getResult(); + + String dialogNodeName2 = "Test2" + UUID.randomUUID().toString(); + + try { + String dialogNodeDescription2 = "Updated description of " + dialogNodeName; + + UpdateDialogNode updateDialogNode = new UpdateDialogNode.Builder() + .description(dialogNodeDescription2) + .nextStep(null) + .dialogNode(dialogNodeName2) + .build(); + Map body = updateDialogNode.asPatch(); + body.put("next_step", null); + + UpdateDialogNodeNullableOptions updateDialogNodeNullableOptions = + new UpdateDialogNodeNullableOptions.Builder() + .workspaceId(workspaceId) + .dialogNode(dialogNodeName) + .body(body) + .build(); + DialogNode response = service.updateDialogNodeNullable(updateDialogNodeNullableOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.dialogNode()); + assertEquals(response.dialogNode(), dialogNodeName2); + assertNotNull(response.description()); + assertEquals(response.description(), dialogNodeDescription2); + assertNull(response.nextStep()); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteDialogNodeOptions deleteOptions = + new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName2).build(); + service.deleteDialogNode(deleteOptions).execute(); + } + } + /** Test deleteUserData. */ @Test public void testDeleteUserData() { From 9718770e48ff048b76a74ad18221766a8bc7a64d Mon Sep 17 00:00:00 2001 From: Kevin Kowalski Date: Wed, 21 Apr 2021 13:48:09 -0500 Subject: [PATCH 3/5] test(assistant-v1): add unit tests for updateDialogNodeNullable --- .../watson/assistant/v1/AssistantTest.java | 171 ++++++++ .../UpdateDialogNodeNullableOptionsTest.java | 61 +++ .../v1/model/UpdateDialogNodeTest.java | 366 ++++++++++++++++++ 3 files changed, 598 insertions(+) create mode 100644 assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeNullableOptionsTest.java create mode 100644 assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeTest.java diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantTest.java index 9a394f6898f..ac6cd661e05 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantTest.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantTest.java @@ -101,6 +101,8 @@ import com.ibm.watson.assistant.v1.model.Synonym; import com.ibm.watson.assistant.v1.model.SynonymCollection; import com.ibm.watson.assistant.v1.model.UpdateCounterexampleOptions; +import com.ibm.watson.assistant.v1.model.UpdateDialogNode; +import com.ibm.watson.assistant.v1.model.UpdateDialogNodeNullableOptions; import com.ibm.watson.assistant.v1.model.UpdateDialogNodeOptions; import com.ibm.watson.assistant.v1.model.UpdateEntityOptions; import com.ibm.watson.assistant.v1.model.UpdateExampleOptions; @@ -3767,6 +3769,175 @@ public void testListAllLogsNoOptions() throws Throwable { assistantService.listAllLogs(null).execute(); } + @Test + public void testUpdateDialogNodeNullableWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"search_skill\", \"query\": \"query\", \"query_type\": \"natural_language\", \"filter\": \"filter\", \"discovery_version\": \"discoveryVersion\", \"channels\": [{\"channel\": \"chat\"}]}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": false}}, \"context\": {\"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}}, \"metadata\": {\"mapKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": true, \"disabled\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String updateDialogNodeNullablePath = "/v1/workspaces/testString/dialog_nodes/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill + // model + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + + // Construct an instance of the DialogNodeOutputModifiers model + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + + // Construct an instance of the DialogNodeOutput model + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeContext model + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeNextStep model + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + + // Construct an instance of the DialogNodeAction model + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); + + // Construct an instance of the UpdateDialogNode model + UpdateDialogNode updateDialogNodeModel = + new UpdateDialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeActionModel))) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(true) + .build(); + Map updateDialogNodeModelAsPatch = updateDialogNodeModel.asPatch(); + + // Construct an instance of the UpdateDialogNodeNullableOptions model + UpdateDialogNodeNullableOptions updateDialogNodeNullableOptionsModel = + new UpdateDialogNodeNullableOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .body(updateDialogNodeModelAsPatch) + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.updateDialogNodeNullable(updateDialogNodeNullableOptionsModel).execute(); + assertNotNull(response); + DialogNode responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateDialogNodeNullablePath); + } + + // Test the updateDialogNodeNullable operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDialogNodeNullableNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.updateDialogNodeNullable(null).execute(); + } + @Test public void testDeleteUserDataWOptions() throws Throwable { // Schedule some responses. diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeNullableOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeNullableOptionsTest.java new file mode 100644 index 00000000000..1add8d46f9a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeNullableOptionsTest.java @@ -0,0 +1,61 @@ +/* + * (C) Copyright IBM Corp. 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.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateDialogNodeNullableOptions model. */ +public class UpdateDialogNodeNullableOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateDialogNodeNullableOptions() throws Throwable { + UpdateDialogNodeNullableOptions updateDialogNodeNullableOptionsModel = + new UpdateDialogNodeNullableOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .body( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .includeAudit(true) + .build(); + assertEquals(updateDialogNodeNullableOptionsModel.workspaceId(), "testString"); + assertEquals(updateDialogNodeNullableOptionsModel.dialogNode(), "testString"); + assertEquals( + updateDialogNodeNullableOptionsModel.body(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(updateDialogNodeNullableOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDialogNodeNullableOptionsError() throws Throwable { + new UpdateDialogNodeNullableOptions.Builder().build(); + } +} \ No newline at end of file diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeTest.java new file mode 100644 index 00000000000..126da595251 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeTest.java @@ -0,0 +1,366 @@ +/* + * (C) Copyright IBM Corp. 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.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateDialogNode model. */ +public class UpdateDialogNodeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateDialogNode() throws Throwable { + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "search_skill"); + assertEquals(dialogNodeOutputGenericModel.query(), "testString"); + assertEquals(dialogNodeOutputGenericModel.queryType(), "natural_language"); + assertEquals(dialogNodeOutputGenericModel.filter(), "testString"); + assertEquals(dialogNodeOutputGenericModel.discoveryVersion(), "testString"); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + UpdateDialogNode updateDialogNodeModel = + new UpdateDialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeActionModel))) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(true) + .build(); + assertEquals(updateDialogNodeModel.dialogNode(), "testString"); + assertEquals(updateDialogNodeModel.description(), "testString"); + assertEquals(updateDialogNodeModel.conditions(), "testString"); + assertEquals(updateDialogNodeModel.parent(), "testString"); + assertEquals(updateDialogNodeModel.previousSibling(), "testString"); + assertEquals(updateDialogNodeModel.output(), dialogNodeOutputModel); + assertEquals(updateDialogNodeModel.context(), dialogNodeContextModel); + assertEquals( + updateDialogNodeModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(updateDialogNodeModel.nextStep(), dialogNodeNextStepModel); + assertEquals(updateDialogNodeModel.title(), "testString"); + assertEquals(updateDialogNodeModel.type(), "standard"); + assertEquals(updateDialogNodeModel.eventName(), "focus"); + assertEquals(updateDialogNodeModel.variable(), "testString"); + assertEquals( + updateDialogNodeModel.actions(), + new java.util.ArrayList(java.util.Arrays.asList(dialogNodeActionModel))); + assertEquals(updateDialogNodeModel.digressIn(), "not_available"); + assertEquals(updateDialogNodeModel.digressOut(), "allow_returning"); + assertEquals(updateDialogNodeModel.digressOutSlots(), "not_allowed"); + assertEquals(updateDialogNodeModel.userLabel(), "testString"); + assertEquals(updateDialogNodeModel.disambiguationOptOut(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(updateDialogNodeModel); + + UpdateDialogNode updateDialogNodeModelNew = + TestUtilities.deserialize(json, UpdateDialogNode.class); + assertTrue(updateDialogNodeModelNew instanceof UpdateDialogNode); + assertEquals(updateDialogNodeModelNew.dialogNode(), "testString"); + assertEquals(updateDialogNodeModelNew.description(), "testString"); + assertEquals(updateDialogNodeModelNew.conditions(), "testString"); + assertEquals(updateDialogNodeModelNew.parent(), "testString"); + assertEquals(updateDialogNodeModelNew.previousSibling(), "testString"); + assertEquals(updateDialogNodeModelNew.output().toString(), dialogNodeOutputModel.toString()); + assertEquals(updateDialogNodeModelNew.context().toString(), dialogNodeContextModel.toString()); + assertEquals( + updateDialogNodeModelNew.nextStep().toString(), dialogNodeNextStepModel.toString()); + assertEquals(updateDialogNodeModelNew.title(), "testString"); + assertEquals(updateDialogNodeModelNew.type(), "standard"); + assertEquals(updateDialogNodeModelNew.eventName(), "focus"); + assertEquals(updateDialogNodeModelNew.variable(), "testString"); + assertEquals(updateDialogNodeModelNew.digressIn(), "not_available"); + assertEquals(updateDialogNodeModelNew.digressOut(), "allow_returning"); + assertEquals(updateDialogNodeModelNew.digressOutSlots(), "not_allowed"); + assertEquals(updateDialogNodeModelNew.userLabel(), "testString"); + assertEquals(updateDialogNodeModelNew.disambiguationOptOut(), Boolean.valueOf(true)); + } + + @Test + public void testUpdateDialogNodeNullable() throws Throwable { + + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); + + UpdateDialogNode updateDialogNodeModel = + new UpdateDialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeActionModel))) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(true) + .build(); + + Map mergePatch = updateDialogNodeModel.asPatch(); + + assertEquals(mergePatch.get("dialog_node"), "testString"); + assertEquals(mergePatch.get("description"), "testString"); + assertEquals(mergePatch.get("conditions"), "testString"); + assertEquals(mergePatch.get("parent"), "testString"); + assertEquals(mergePatch.get("previous_sibling"), "testString"); + assertTrue(mergePatch.containsKey("output")); + assertTrue(mergePatch.containsKey("context")); + assertTrue(mergePatch.containsKey("metadata")); + assertTrue(mergePatch.containsKey("next_step")); + assertEquals(mergePatch.get("title"), "testString"); + assertEquals(mergePatch.get("type"), "standard"); + assertEquals(mergePatch.get("event_name"), "focus"); + assertEquals(mergePatch.get("variable"), "testString"); + assertTrue(mergePatch.containsKey("actions")); + assertEquals(mergePatch.get("digress_in"), "not_available"); + assertEquals(mergePatch.get("digress_out"), "allow_returning"); + assertEquals(mergePatch.get("digress_out_slots"), "not_allowed"); + assertEquals(mergePatch.get("user_label"), "testString"); + assertTrue(mergePatch.containsKey("disambiguation_opt_out")); + } +} \ No newline at end of file From dc0a023d6b1f6748134d584f71dc804494ade737 Mon Sep 17 00:00:00 2001 From: Kevin Kowalski Date: Thu, 22 Apr 2021 10:09:39 -0500 Subject: [PATCH 4/5] fix(assistant-v1): override toString method to allow null values --- .../com/ibm/watson/assistant/v1/model/UpdateDialogNode.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNode.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNode.java index 08df4eac52f..68ea6392c24 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNode.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNode.java @@ -721,4 +721,8 @@ public Date updated() { public Map asPatch() { return GsonSingleton.getGsonWithSerializeNulls().fromJson(this.toString(), Map.class); } + + public String toString() { + return GsonSingleton.getGsonWithSerializeNulls().toJson(this); + } } From 03566d8e4854c62634859b7d43c5158f1f242c32 Mon Sep 17 00:00:00 2001 From: Kevin Kowalski Date: Thu, 22 Apr 2021 10:10:47 -0500 Subject: [PATCH 5/5] test(assistant-v1): remove unnecessary line --- .../java/com/ibm/watson/assistant/v1/AssistantServiceIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceIT.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceIT.java index c37aa888a14..e1a383d8437 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceIT.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceIT.java @@ -1780,7 +1780,6 @@ public void testUpdateDialogNodeNullable() { .dialogNode(dialogNodeName2) .build(); Map body = updateDialogNode.asPatch(); - body.put("next_step", null); UpdateDialogNodeNullableOptions updateDialogNodeNullableOptions = new UpdateDialogNodeNullableOptions.Builder()