Search in sources :

Example 1 with DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill

use of com.ibm.watson.assistant.v1.model.DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill in project java-sdk by watson-developer-cloud.

the class AssistantTest method testUpdateDialogNodeNullableWOptions.

@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<DialogNodeOutputGeneric>(java.util.Arrays.asList(dialogNodeOutputGenericModel))).integrations(new java.util.HashMap<String, Map<String, Object>>() {

        {
            put("foo", new java.util.HashMap<String, Object>() {

                {
                    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<String, Map<String, Object>>() {

        {
            put("foo", new java.util.HashMap<String, Object>() {

                {
                    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<String, Object>() {

        {
            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<String, Object>() {

        {
            put("foo", "testString");
        }
    }).nextStep(dialogNodeNextStepModel).title("testString").type("standard").eventName("focus").variable("testString").actions(new java.util.ArrayList<DialogNodeAction>(java.util.Arrays.asList(dialogNodeActionModel))).digressIn("not_available").digressOut("allow_returning").digressOutSlots("not_allowed").userLabel("testString").disambiguationOptOut(true).build();
    Map<String, Object> 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<DialogNode> 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<String, String> 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);
}
Also used : DialogNodeOutputGeneric(com.ibm.watson.assistant.v1.model.DialogNodeOutputGeneric) HashMap(java.util.HashMap) UpdateDialogNode(com.ibm.watson.assistant.v1.model.UpdateDialogNode) DialogNode(com.ibm.watson.assistant.v1.model.DialogNode) DialogNodeOutput(com.ibm.watson.assistant.v1.model.DialogNodeOutput) DialogNodeNextStep(com.ibm.watson.assistant.v1.model.DialogNodeNextStep) DialogNodeOutputModifiers(com.ibm.watson.assistant.v1.model.DialogNodeOutputModifiers) UpdateDialogNodeNullableOptions(com.ibm.watson.assistant.v1.model.UpdateDialogNodeNullableOptions) UpdateDialogNode(com.ibm.watson.assistant.v1.model.UpdateDialogNode) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) DialogNodeAction(com.ibm.watson.assistant.v1.model.DialogNodeAction) DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill(com.ibm.watson.assistant.v1.model.DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill) DialogNodeContext(com.ibm.watson.assistant.v1.model.DialogNodeContext) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Aggregations

DialogNode (com.ibm.watson.assistant.v1.model.DialogNode)1 DialogNodeAction (com.ibm.watson.assistant.v1.model.DialogNodeAction)1 DialogNodeContext (com.ibm.watson.assistant.v1.model.DialogNodeContext)1 DialogNodeNextStep (com.ibm.watson.assistant.v1.model.DialogNodeNextStep)1 DialogNodeOutput (com.ibm.watson.assistant.v1.model.DialogNodeOutput)1 DialogNodeOutputGeneric (com.ibm.watson.assistant.v1.model.DialogNodeOutputGeneric)1 DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill (com.ibm.watson.assistant.v1.model.DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill)1 DialogNodeOutputModifiers (com.ibm.watson.assistant.v1.model.DialogNodeOutputModifiers)1 UpdateDialogNode (com.ibm.watson.assistant.v1.model.UpdateDialogNode)1 UpdateDialogNodeNullableOptions (com.ibm.watson.assistant.v1.model.UpdateDialogNodeNullableOptions)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 Test (org.testng.annotations.Test)1