Skip to content

Commit 2407d9c

Browse files
committed
test(assistant-v1): add updateDialogNode nullable unit tests
1 parent 1db29e9 commit 2407d9c

File tree

1 file changed

+171
-0
lines changed

1 file changed

+171
-0
lines changed

assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantTest.java

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@
103103
import com.ibm.watson.assistant.v1.model.Synonym;
104104
import com.ibm.watson.assistant.v1.model.SynonymCollection;
105105
import com.ibm.watson.assistant.v1.model.UpdateCounterexampleOptions;
106+
import com.ibm.watson.assistant.v1.model.UpdateDialogNode;
107+
import com.ibm.watson.assistant.v1.model.UpdateDialogNodeNullableOptions;
106108
import com.ibm.watson.assistant.v1.model.UpdateDialogNodeOptions;
107109
import com.ibm.watson.assistant.v1.model.UpdateEntityOptions;
108110
import com.ibm.watson.assistant.v1.model.UpdateExampleOptions;
@@ -3815,6 +3817,175 @@ public void testListAllLogsNoOptions() throws Throwable {
38153817
assistantService.listAllLogs(null).execute();
38163818
}
38173819

3820+
@Test
3821+
public void testUpdateDialogNodeNullableWOptions() throws Throwable {
3822+
// Schedule some responses.
3823+
String mockResponseBody =
3824+
"{\"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\"}";
3825+
String updateDialogNodeNullablePath = "/v1/workspaces/testString/dialog_nodes/testString";
3826+
3827+
server.enqueue(
3828+
new MockResponse()
3829+
.setHeader("Content-type", "application/json")
3830+
.setResponseCode(200)
3831+
.setBody(mockResponseBody));
3832+
3833+
constructClientService();
3834+
3835+
// Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill
3836+
// model
3837+
DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel =
3838+
new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder()
3839+
.responseType("search_skill")
3840+
.query("testString")
3841+
.queryType("natural_language")
3842+
.filter("testString")
3843+
.discoveryVersion("testString")
3844+
.build();
3845+
3846+
// Construct an instance of the DialogNodeOutputModifiers model
3847+
DialogNodeOutputModifiers dialogNodeOutputModifiersModel =
3848+
new DialogNodeOutputModifiers.Builder().overwrite(true).build();
3849+
3850+
// Construct an instance of the DialogNodeOutput model
3851+
DialogNodeOutput dialogNodeOutputModel =
3852+
new DialogNodeOutput.Builder()
3853+
.generic(
3854+
new java.util.ArrayList<DialogNodeOutputGeneric>(
3855+
java.util.Arrays.asList(dialogNodeOutputGenericModel)))
3856+
.integrations(
3857+
new java.util.HashMap<String, Map<String, Object>>() {
3858+
{
3859+
put(
3860+
"foo",
3861+
new java.util.HashMap<String, Object>() {
3862+
{
3863+
put("foo", "testString");
3864+
}
3865+
});
3866+
}
3867+
})
3868+
.modifiers(dialogNodeOutputModifiersModel)
3869+
.add("foo", "testString")
3870+
.build();
3871+
3872+
// Construct an instance of the DialogNodeContext model
3873+
DialogNodeContext dialogNodeContextModel =
3874+
new DialogNodeContext.Builder()
3875+
.integrations(
3876+
new java.util.HashMap<String, Map<String, Object>>() {
3877+
{
3878+
put(
3879+
"foo",
3880+
new java.util.HashMap<String, Object>() {
3881+
{
3882+
put("foo", "testString");
3883+
}
3884+
});
3885+
}
3886+
})
3887+
.add("foo", "testString")
3888+
.build();
3889+
3890+
// Construct an instance of the DialogNodeNextStep model
3891+
DialogNodeNextStep dialogNodeNextStepModel =
3892+
new DialogNodeNextStep.Builder()
3893+
.behavior("get_user_input")
3894+
.dialogNode("testString")
3895+
.selector("condition")
3896+
.build();
3897+
3898+
// Construct an instance of the DialogNodeAction model
3899+
DialogNodeAction dialogNodeActionModel =
3900+
new DialogNodeAction.Builder()
3901+
.name("testString")
3902+
.type("client")
3903+
.parameters(
3904+
new java.util.HashMap<String, Object>() {
3905+
{
3906+
put("foo", "testString");
3907+
}
3908+
})
3909+
.resultVariable("testString")
3910+
.credentials("testString")
3911+
.build();
3912+
3913+
// Construct an instance of the UpdateDialogNode model
3914+
UpdateDialogNode updateDialogNodeModel =
3915+
new UpdateDialogNode.Builder()
3916+
.dialogNode("testString")
3917+
.description("testString")
3918+
.conditions("testString")
3919+
.parent("testString")
3920+
.previousSibling("testString")
3921+
.output(dialogNodeOutputModel)
3922+
.context(dialogNodeContextModel)
3923+
.metadata(
3924+
new java.util.HashMap<String, Object>() {
3925+
{
3926+
put("foo", "testString");
3927+
}
3928+
})
3929+
.nextStep(dialogNodeNextStepModel)
3930+
.title("testString")
3931+
.type("standard")
3932+
.eventName("focus")
3933+
.variable("testString")
3934+
.actions(
3935+
new java.util.ArrayList<DialogNodeAction>(
3936+
java.util.Arrays.asList(dialogNodeActionModel)))
3937+
.digressIn("not_available")
3938+
.digressOut("allow_returning")
3939+
.digressOutSlots("not_allowed")
3940+
.userLabel("testString")
3941+
.disambiguationOptOut(true)
3942+
.build();
3943+
Map<String, Object> updateDialogNodeModelAsPatch = updateDialogNodeModel.asPatch();
3944+
3945+
// Construct an instance of the UpdateDialogNodeNullableOptions model
3946+
UpdateDialogNodeNullableOptions updateDialogNodeNullableOptionsModel =
3947+
new UpdateDialogNodeNullableOptions.Builder()
3948+
.workspaceId("testString")
3949+
.dialogNode("testString")
3950+
.body(updateDialogNodeModelAsPatch)
3951+
.includeAudit(true)
3952+
.build();
3953+
3954+
// Invoke operation with valid options model (positive test)
3955+
Response<DialogNode> response =
3956+
assistantService.updateDialogNodeNullable(updateDialogNodeNullableOptionsModel).execute();
3957+
assertNotNull(response);
3958+
DialogNode responseObj = response.getResult();
3959+
assertNotNull(responseObj);
3960+
3961+
// Verify the contents of the request
3962+
RecordedRequest request = server.takeRequest();
3963+
assertNotNull(request);
3964+
assertEquals(request.getMethod(), "POST");
3965+
3966+
// Check query
3967+
Map<String, String> query = TestUtilities.parseQueryString(request);
3968+
assertNotNull(query);
3969+
// Get query params
3970+
assertEquals(query.get("version"), "testString");
3971+
assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true));
3972+
// Check request path
3973+
String parsedPath = TestUtilities.parseReqPath(request);
3974+
assertEquals(parsedPath, updateDialogNodeNullablePath);
3975+
}
3976+
3977+
// Test the updateDialogNodeNullable operation with null options model parameter
3978+
@Test(expectedExceptions = IllegalArgumentException.class)
3979+
public void testUpdateDialogNodeNullableNoOptions() throws Throwable {
3980+
// construct the service
3981+
constructClientService();
3982+
3983+
server.enqueue(new MockResponse());
3984+
3985+
// Invoke operation with null options model (negative test)
3986+
assistantService.updateDialogNodeNullable(null).execute();
3987+
}
3988+
38183989
@Test
38193990
public void testDeleteUserDataWOptions() throws Throwable {
38203991
// Schedule some responses.

0 commit comments

Comments
 (0)