|
101 | 101 | import com.ibm.watson.assistant.v1.model.Synonym; |
102 | 102 | import com.ibm.watson.assistant.v1.model.SynonymCollection; |
103 | 103 | import com.ibm.watson.assistant.v1.model.UpdateCounterexampleOptions; |
| 104 | +import com.ibm.watson.assistant.v1.model.UpdateDialogNode; |
| 105 | +import com.ibm.watson.assistant.v1.model.UpdateDialogNodeNullableOptions; |
104 | 106 | import com.ibm.watson.assistant.v1.model.UpdateDialogNodeOptions; |
105 | 107 | import com.ibm.watson.assistant.v1.model.UpdateEntityOptions; |
106 | 108 | import com.ibm.watson.assistant.v1.model.UpdateExampleOptions; |
@@ -3767,6 +3769,175 @@ public void testListAllLogsNoOptions() throws Throwable { |
3767 | 3769 | assistantService.listAllLogs(null).execute(); |
3768 | 3770 | } |
3769 | 3771 |
|
| 3772 | + @Test |
| 3773 | + public void testUpdateDialogNodeNullableWOptions() throws Throwable { |
| 3774 | + // Schedule some responses. |
| 3775 | + String mockResponseBody = |
| 3776 | + "{\"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\"}"; |
| 3777 | + String updateDialogNodeNullablePath = "/v1/workspaces/testString/dialog_nodes/testString"; |
| 3778 | + |
| 3779 | + server.enqueue( |
| 3780 | + new MockResponse() |
| 3781 | + .setHeader("Content-type", "application/json") |
| 3782 | + .setResponseCode(200) |
| 3783 | + .setBody(mockResponseBody)); |
| 3784 | + |
| 3785 | + constructClientService(); |
| 3786 | + |
| 3787 | + // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill |
| 3788 | + // model |
| 3789 | + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = |
| 3790 | + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() |
| 3791 | + .responseType("search_skill") |
| 3792 | + .query("testString") |
| 3793 | + .queryType("natural_language") |
| 3794 | + .filter("testString") |
| 3795 | + .discoveryVersion("testString") |
| 3796 | + .build(); |
| 3797 | + |
| 3798 | + // Construct an instance of the DialogNodeOutputModifiers model |
| 3799 | + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = |
| 3800 | + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); |
| 3801 | + |
| 3802 | + // Construct an instance of the DialogNodeOutput model |
| 3803 | + DialogNodeOutput dialogNodeOutputModel = |
| 3804 | + new DialogNodeOutput.Builder() |
| 3805 | + .generic( |
| 3806 | + new java.util.ArrayList<DialogNodeOutputGeneric>( |
| 3807 | + java.util.Arrays.asList(dialogNodeOutputGenericModel))) |
| 3808 | + .integrations( |
| 3809 | + new java.util.HashMap<String, Map<String, Object>>() { |
| 3810 | + { |
| 3811 | + put( |
| 3812 | + "foo", |
| 3813 | + new java.util.HashMap<String, Object>() { |
| 3814 | + { |
| 3815 | + put("foo", "testString"); |
| 3816 | + } |
| 3817 | + }); |
| 3818 | + } |
| 3819 | + }) |
| 3820 | + .modifiers(dialogNodeOutputModifiersModel) |
| 3821 | + .add("foo", "testString") |
| 3822 | + .build(); |
| 3823 | + |
| 3824 | + // Construct an instance of the DialogNodeContext model |
| 3825 | + DialogNodeContext dialogNodeContextModel = |
| 3826 | + new DialogNodeContext.Builder() |
| 3827 | + .integrations( |
| 3828 | + new java.util.HashMap<String, Map<String, Object>>() { |
| 3829 | + { |
| 3830 | + put( |
| 3831 | + "foo", |
| 3832 | + new java.util.HashMap<String, Object>() { |
| 3833 | + { |
| 3834 | + put("foo", "testString"); |
| 3835 | + } |
| 3836 | + }); |
| 3837 | + } |
| 3838 | + }) |
| 3839 | + .add("foo", "testString") |
| 3840 | + .build(); |
| 3841 | + |
| 3842 | + // Construct an instance of the DialogNodeNextStep model |
| 3843 | + DialogNodeNextStep dialogNodeNextStepModel = |
| 3844 | + new DialogNodeNextStep.Builder() |
| 3845 | + .behavior("get_user_input") |
| 3846 | + .dialogNode("testString") |
| 3847 | + .selector("condition") |
| 3848 | + .build(); |
| 3849 | + |
| 3850 | + // Construct an instance of the DialogNodeAction model |
| 3851 | + DialogNodeAction dialogNodeActionModel = |
| 3852 | + new DialogNodeAction.Builder() |
| 3853 | + .name("testString") |
| 3854 | + .type("client") |
| 3855 | + .parameters( |
| 3856 | + new java.util.HashMap<String, Object>() { |
| 3857 | + { |
| 3858 | + put("foo", "testString"); |
| 3859 | + } |
| 3860 | + }) |
| 3861 | + .resultVariable("testString") |
| 3862 | + .credentials("testString") |
| 3863 | + .build(); |
| 3864 | + |
| 3865 | + // Construct an instance of the UpdateDialogNode model |
| 3866 | + UpdateDialogNode updateDialogNodeModel = |
| 3867 | + new UpdateDialogNode.Builder() |
| 3868 | + .dialogNode("testString") |
| 3869 | + .description("testString") |
| 3870 | + .conditions("testString") |
| 3871 | + .parent("testString") |
| 3872 | + .previousSibling("testString") |
| 3873 | + .output(dialogNodeOutputModel) |
| 3874 | + .context(dialogNodeContextModel) |
| 3875 | + .metadata( |
| 3876 | + new java.util.HashMap<String, Object>() { |
| 3877 | + { |
| 3878 | + put("foo", "testString"); |
| 3879 | + } |
| 3880 | + }) |
| 3881 | + .nextStep(dialogNodeNextStepModel) |
| 3882 | + .title("testString") |
| 3883 | + .type("standard") |
| 3884 | + .eventName("focus") |
| 3885 | + .variable("testString") |
| 3886 | + .actions( |
| 3887 | + new java.util.ArrayList<DialogNodeAction>( |
| 3888 | + java.util.Arrays.asList(dialogNodeActionModel))) |
| 3889 | + .digressIn("not_available") |
| 3890 | + .digressOut("allow_returning") |
| 3891 | + .digressOutSlots("not_allowed") |
| 3892 | + .userLabel("testString") |
| 3893 | + .disambiguationOptOut(true) |
| 3894 | + .build(); |
| 3895 | + Map<String, Object> updateDialogNodeModelAsPatch = updateDialogNodeModel.asPatch(); |
| 3896 | + |
| 3897 | + // Construct an instance of the UpdateDialogNodeNullableOptions model |
| 3898 | + UpdateDialogNodeNullableOptions updateDialogNodeNullableOptionsModel = |
| 3899 | + new UpdateDialogNodeNullableOptions.Builder() |
| 3900 | + .workspaceId("testString") |
| 3901 | + .dialogNode("testString") |
| 3902 | + .body(updateDialogNodeModelAsPatch) |
| 3903 | + .includeAudit(true) |
| 3904 | + .build(); |
| 3905 | + |
| 3906 | + // Invoke operation with valid options model (positive test) |
| 3907 | + Response<DialogNode> response = |
| 3908 | + assistantService.updateDialogNodeNullable(updateDialogNodeNullableOptionsModel).execute(); |
| 3909 | + assertNotNull(response); |
| 3910 | + DialogNode responseObj = response.getResult(); |
| 3911 | + assertNotNull(responseObj); |
| 3912 | + |
| 3913 | + // Verify the contents of the request |
| 3914 | + RecordedRequest request = server.takeRequest(); |
| 3915 | + assertNotNull(request); |
| 3916 | + assertEquals(request.getMethod(), "POST"); |
| 3917 | + |
| 3918 | + // Check query |
| 3919 | + Map<String, String> query = TestUtilities.parseQueryString(request); |
| 3920 | + assertNotNull(query); |
| 3921 | + // Get query params |
| 3922 | + assertEquals(query.get("version"), "testString"); |
| 3923 | + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); |
| 3924 | + // Check request path |
| 3925 | + String parsedPath = TestUtilities.parseReqPath(request); |
| 3926 | + assertEquals(parsedPath, updateDialogNodeNullablePath); |
| 3927 | + } |
| 3928 | + |
| 3929 | + // Test the updateDialogNodeNullable operation with null options model parameter |
| 3930 | + @Test(expectedExceptions = IllegalArgumentException.class) |
| 3931 | + public void testUpdateDialogNodeNullableNoOptions() throws Throwable { |
| 3932 | + // construct the service |
| 3933 | + constructClientService(); |
| 3934 | + |
| 3935 | + server.enqueue(new MockResponse()); |
| 3936 | + |
| 3937 | + // Invoke operation with null options model (negative test) |
| 3938 | + assistantService.updateDialogNodeNullable(null).execute(); |
| 3939 | + } |
| 3940 | + |
3770 | 3941 | @Test |
3771 | 3942 | public void testDeleteUserDataWOptions() throws Throwable { |
3772 | 3943 | // Schedule some responses. |
|
0 commit comments