Search in sources :

Example 1 with ResponseGenericChannel

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

the class AssistantTest method testCreateWorkspaceWOptions.

// Test the createWorkspace operation with a valid options model parameter
@Test
public void testCreateWorkspaceWOptions() throws Throwable {
    // Register a mock response
    String mockResponseBody = "{\"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"workspace_id\": \"workspaceId\", \"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"video\", \"source\": \"source\", \"title\": \"title\", \"description\": \"description\", \"channels\": [{\"channel\": \"chat\"}], \"channel_options\": {\"mapKey\": \"anyValue\"}, \"alt_text\": \"altText\"}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"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\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"learning_opt_out\": false, \"system_settings\": {\"tooling\": {\"store_generic_responses\": false}, \"disambiguation\": {\"prompt\": \"prompt\", \"none_of_the_above_prompt\": \"noneOfTheAbovePrompt\", \"enabled\": false, \"sensitivity\": \"auto\", \"randomize\": false, \"max_suggestions\": 1, \"suggestion_text_policy\": \"suggestionTextPolicy\"}, \"human_agent_assist\": {\"mapKey\": \"anyValue\"}, \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"system_entities\": {\"enabled\": false}, \"off_topic\": {\"enabled\": false}}, \"status\": \"Non Existent\", \"webhooks\": [{\"url\": \"url\", \"name\": \"name\", \"headers\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"values\": [{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}]}";
    String createWorkspacePath = "/v1/workspaces";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(201).setBody(mockResponseBody));
    // Construct an instance of the ResponseGenericChannel model
    ResponseGenericChannel responseGenericChannelModel = new ResponseGenericChannel.Builder().channel("chat").build();
    // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo model
    DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo dialogNodeOutputGenericModel = new DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.Builder().responseType("video").source("testString").title("testString").description("testString").channels(new java.util.ArrayList<ResponseGenericChannel>(java.util.Arrays.asList(responseGenericChannelModel))).channelOptions(new java.util.HashMap<String, Object>() {

        {
            put("foo", "testString");
        }
    }).altText("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 DialogNode model
    DialogNode dialogNodeModel = new DialogNode.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(false).build();
    // Construct an instance of the Counterexample model
    Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build();
    // Construct an instance of the WorkspaceSystemSettingsTooling model
    WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build();
    // Construct an instance of the WorkspaceSystemSettingsDisambiguation model
    WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = new WorkspaceSystemSettingsDisambiguation.Builder().prompt("testString").noneOfTheAbovePrompt("testString").enabled(false).sensitivity("auto").randomize(true).maxSuggestions(Long.valueOf("1")).suggestionTextPolicy("testString").build();
    // Construct an instance of the WorkspaceSystemSettingsSystemEntities model
    WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = new WorkspaceSystemSettingsSystemEntities.Builder().enabled(false).build();
    // Construct an instance of the WorkspaceSystemSettingsOffTopic model
    WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = new WorkspaceSystemSettingsOffTopic.Builder().enabled(false).build();
    // Construct an instance of the WorkspaceSystemSettings model
    WorkspaceSystemSettings workspaceSystemSettingsModel = new WorkspaceSystemSettings.Builder().tooling(workspaceSystemSettingsToolingModel).disambiguation(workspaceSystemSettingsDisambiguationModel).humanAgentAssist(new java.util.HashMap<String, Object>() {

        {
            put("foo", "testString");
        }
    }).spellingSuggestions(false).spellingAutoCorrect(false).systemEntities(workspaceSystemSettingsSystemEntitiesModel).offTopic(workspaceSystemSettingsOffTopicModel).add("foo", "testString").build();
    // Construct an instance of the WebhookHeader model
    WebhookHeader webhookHeaderModel = new WebhookHeader.Builder().name("testString").value("testString").build();
    // Construct an instance of the Webhook model
    Webhook webhookModel = new Webhook.Builder().url("testString").name("testString").headers(new java.util.ArrayList<WebhookHeader>(java.util.Arrays.asList(webhookHeaderModel))).build();
    // Construct an instance of the Mention model
    Mention mentionModel = new Mention.Builder().entity("testString").location(new java.util.ArrayList<Long>(java.util.Arrays.asList(Long.valueOf("26")))).build();
    // Construct an instance of the Example model
    Example exampleModel = new Example.Builder().text("testString").mentions(new java.util.ArrayList<Mention>(java.util.Arrays.asList(mentionModel))).build();
    // Construct an instance of the CreateIntent model
    CreateIntent createIntentModel = new CreateIntent.Builder().intent("testString").description("testString").examples(new java.util.ArrayList<Example>(java.util.Arrays.asList(exampleModel))).build();
    // Construct an instance of the CreateValue model
    CreateValue createValueModel = new CreateValue.Builder().value("testString").metadata(new java.util.HashMap<String, Object>() {

        {
            put("foo", "testString");
        }
    }).type("synonyms").synonyms(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).patterns(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).build();
    // Construct an instance of the CreateEntity model
    CreateEntity createEntityModel = new CreateEntity.Builder().entity("testString").description("testString").metadata(new java.util.HashMap<String, Object>() {

        {
            put("foo", "testString");
        }
    }).fuzzyMatch(true).values(new java.util.ArrayList<CreateValue>(java.util.Arrays.asList(createValueModel))).build();
    // Construct an instance of the CreateWorkspaceOptions model
    CreateWorkspaceOptions createWorkspaceOptionsModel = new CreateWorkspaceOptions.Builder().name("testString").description("testString").language("testString").dialogNodes(new java.util.ArrayList<DialogNode>(java.util.Arrays.asList(dialogNodeModel))).counterexamples(new java.util.ArrayList<Counterexample>(java.util.Arrays.asList(counterexampleModel))).metadata(new java.util.HashMap<String, Object>() {

        {
            put("foo", "testString");
        }
    }).learningOptOut(false).systemSettings(workspaceSystemSettingsModel).webhooks(new java.util.ArrayList<Webhook>(java.util.Arrays.asList(webhookModel))).intents(new java.util.ArrayList<CreateIntent>(java.util.Arrays.asList(createIntentModel))).entities(new java.util.ArrayList<CreateEntity>(java.util.Arrays.asList(createEntityModel))).includeAudit(false).build();
    // Invoke createWorkspace() with a valid options model and verify the result
    Response<Workspace> response = assistantService.createWorkspace(createWorkspaceOptionsModel).execute();
    assertNotNull(response);
    Workspace responseObj = response.getResult();
    assertNotNull(responseObj);
    // Verify the contents of the request sent to the mock server
    RecordedRequest request = server.takeRequest();
    assertNotNull(request);
    assertEquals(request.getMethod(), "POST");
    // Verify request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, createWorkspacePath);
    // Verify query params
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNotNull(query);
    assertEquals(query.get("version"), "testString");
    assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false));
}
Also used : DialogNodeOutputGeneric(com.ibm.watson.assistant.v1.model.DialogNodeOutputGeneric) CreateEntity(com.ibm.watson.assistant.v1.model.CreateEntity) HashMap(java.util.HashMap) Counterexample(com.ibm.watson.assistant.v1.model.Counterexample) Mention(com.ibm.watson.assistant.v1.model.Mention) Example(com.ibm.watson.assistant.v1.model.Example) CreateWorkspaceOptions(com.ibm.watson.assistant.v1.model.CreateWorkspaceOptions) DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo(com.ibm.watson.assistant.v1.model.DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo) MockResponse(okhttp3.mockwebserver.MockResponse) CreateIntent(com.ibm.watson.assistant.v1.model.CreateIntent) DialogNodeContext(com.ibm.watson.assistant.v1.model.DialogNodeContext) WorkspaceSystemSettingsTooling(com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsTooling) Map(java.util.Map) HashMap(java.util.HashMap) CreateValue(com.ibm.watson.assistant.v1.model.CreateValue) ResponseGenericChannel(com.ibm.watson.assistant.v1.model.ResponseGenericChannel) DialogNode(com.ibm.watson.assistant.v1.model.DialogNode) WorkspaceSystemSettings(com.ibm.watson.assistant.v1.model.WorkspaceSystemSettings) DialogNodeOutput(com.ibm.watson.assistant.v1.model.DialogNodeOutput) DialogNodeNextStep(com.ibm.watson.assistant.v1.model.DialogNodeNextStep) DialogNodeOutputModifiers(com.ibm.watson.assistant.v1.model.DialogNodeOutputModifiers) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) WorkspaceSystemSettingsDisambiguation(com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsDisambiguation) DialogNodeAction(com.ibm.watson.assistant.v1.model.DialogNodeAction) WebhookHeader(com.ibm.watson.assistant.v1.model.WebhookHeader) WorkspaceSystemSettingsSystemEntities(com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsSystemEntities) WorkspaceSystemSettingsOffTopic(com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsOffTopic) Webhook(com.ibm.watson.assistant.v1.model.Webhook) Workspace(com.ibm.watson.assistant.v1.model.Workspace) Test(org.testng.annotations.Test)

Example 2 with ResponseGenericChannel

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

the class AssistantTest method testUpdateDialogNodeWOptions.

// Test the updateDialogNode operation with a valid options model parameter
@Test
public void testUpdateDialogNodeWOptions() throws Throwable {
    // Register a mock response
    String mockResponseBody = "{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"video\", \"source\": \"source\", \"title\": \"title\", \"description\": \"description\", \"channels\": [{\"channel\": \"chat\"}], \"channel_options\": {\"mapKey\": \"anyValue\"}, \"alt_text\": \"altText\"}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"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\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}";
    String updateDialogNodePath = "/v1/workspaces/testString/dialog_nodes/testString";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    // Construct an instance of the ResponseGenericChannel model
    ResponseGenericChannel responseGenericChannelModel = new ResponseGenericChannel.Builder().channel("chat").build();
    // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo model
    DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo dialogNodeOutputGenericModel = new DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.Builder().responseType("video").source("testString").title("testString").description("testString").channels(new java.util.ArrayList<ResponseGenericChannel>(java.util.Arrays.asList(responseGenericChannelModel))).channelOptions(new java.util.HashMap<String, Object>() {

        {
            put("foo", "testString");
        }
    }).altText("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 UpdateDialogNodeOptions model
    UpdateDialogNodeOptions updateDialogNodeOptionsModel = new UpdateDialogNodeOptions.Builder().workspaceId("testString").dialogNode("testString").newDialogNode("testString").newDescription("testString").newConditions("testString").newParent("testString").newPreviousSibling("testString").newOutput(dialogNodeOutputModel).newContext(dialogNodeContextModel).newMetadata(new java.util.HashMap<String, Object>() {

        {
            put("foo", "testString");
        }
    }).newNextStep(dialogNodeNextStepModel).newTitle("testString").newType("standard").newEventName("focus").newVariable("testString").newActions(new java.util.ArrayList<DialogNodeAction>(java.util.Arrays.asList(dialogNodeActionModel))).newDigressIn("not_available").newDigressOut("allow_returning").newDigressOutSlots("not_allowed").newUserLabel("testString").newDisambiguationOptOut(false).includeAudit(false).build();
    // Invoke updateDialogNode() with a valid options model and verify the result
    Response<DialogNode> response = assistantService.updateDialogNode(updateDialogNodeOptionsModel).execute();
    assertNotNull(response);
    DialogNode responseObj = response.getResult();
    assertNotNull(responseObj);
    // Verify the contents of the request sent to the mock server
    RecordedRequest request = server.takeRequest();
    assertNotNull(request);
    assertEquals(request.getMethod(), "POST");
    // Verify request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, updateDialogNodePath);
    // Verify query params
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNotNull(query);
    assertEquals(query.get("version"), "testString");
    assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false));
}
Also used : DialogNodeOutputGeneric(com.ibm.watson.assistant.v1.model.DialogNodeOutputGeneric) HashMap(java.util.HashMap) ResponseGenericChannel(com.ibm.watson.assistant.v1.model.ResponseGenericChannel) 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) DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo(com.ibm.watson.assistant.v1.model.DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) DialogNodeAction(com.ibm.watson.assistant.v1.model.DialogNodeAction) DialogNodeContext(com.ibm.watson.assistant.v1.model.DialogNodeContext) Map(java.util.Map) HashMap(java.util.HashMap) UpdateDialogNodeOptions(com.ibm.watson.assistant.v1.model.UpdateDialogNodeOptions) Test(org.testng.annotations.Test)

Example 3 with ResponseGenericChannel

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

the class AssistantTest method testUpdateWorkspaceWOptions.

// Test the updateWorkspace operation with a valid options model parameter
@Test
public void testUpdateWorkspaceWOptions() throws Throwable {
    // Register a mock response
    String mockResponseBody = "{\"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"workspace_id\": \"workspaceId\", \"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"video\", \"source\": \"source\", \"title\": \"title\", \"description\": \"description\", \"channels\": [{\"channel\": \"chat\"}], \"channel_options\": {\"mapKey\": \"anyValue\"}, \"alt_text\": \"altText\"}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"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\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"learning_opt_out\": false, \"system_settings\": {\"tooling\": {\"store_generic_responses\": false}, \"disambiguation\": {\"prompt\": \"prompt\", \"none_of_the_above_prompt\": \"noneOfTheAbovePrompt\", \"enabled\": false, \"sensitivity\": \"auto\", \"randomize\": false, \"max_suggestions\": 1, \"suggestion_text_policy\": \"suggestionTextPolicy\"}, \"human_agent_assist\": {\"mapKey\": \"anyValue\"}, \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"system_entities\": {\"enabled\": false}, \"off_topic\": {\"enabled\": false}}, \"status\": \"Non Existent\", \"webhooks\": [{\"url\": \"url\", \"name\": \"name\", \"headers\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}], \"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"values\": [{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}]}]}";
    String updateWorkspacePath = "/v1/workspaces/testString";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    // Construct an instance of the ResponseGenericChannel model
    ResponseGenericChannel responseGenericChannelModel = new ResponseGenericChannel.Builder().channel("chat").build();
    // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo model
    DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo dialogNodeOutputGenericModel = new DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.Builder().responseType("video").source("testString").title("testString").description("testString").channels(new java.util.ArrayList<ResponseGenericChannel>(java.util.Arrays.asList(responseGenericChannelModel))).channelOptions(new java.util.HashMap<String, Object>() {

        {
            put("foo", "testString");
        }
    }).altText("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 DialogNode model
    DialogNode dialogNodeModel = new DialogNode.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(false).build();
    // Construct an instance of the Counterexample model
    Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build();
    // Construct an instance of the WorkspaceSystemSettingsTooling model
    WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build();
    // Construct an instance of the WorkspaceSystemSettingsDisambiguation model
    WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = new WorkspaceSystemSettingsDisambiguation.Builder().prompt("testString").noneOfTheAbovePrompt("testString").enabled(false).sensitivity("auto").randomize(true).maxSuggestions(Long.valueOf("1")).suggestionTextPolicy("testString").build();
    // Construct an instance of the WorkspaceSystemSettingsSystemEntities model
    WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = new WorkspaceSystemSettingsSystemEntities.Builder().enabled(false).build();
    // Construct an instance of the WorkspaceSystemSettingsOffTopic model
    WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = new WorkspaceSystemSettingsOffTopic.Builder().enabled(false).build();
    // Construct an instance of the WorkspaceSystemSettings model
    WorkspaceSystemSettings workspaceSystemSettingsModel = new WorkspaceSystemSettings.Builder().tooling(workspaceSystemSettingsToolingModel).disambiguation(workspaceSystemSettingsDisambiguationModel).humanAgentAssist(new java.util.HashMap<String, Object>() {

        {
            put("foo", "testString");
        }
    }).spellingSuggestions(false).spellingAutoCorrect(false).systemEntities(workspaceSystemSettingsSystemEntitiesModel).offTopic(workspaceSystemSettingsOffTopicModel).add("foo", "testString").build();
    // Construct an instance of the WebhookHeader model
    WebhookHeader webhookHeaderModel = new WebhookHeader.Builder().name("testString").value("testString").build();
    // Construct an instance of the Webhook model
    Webhook webhookModel = new Webhook.Builder().url("testString").name("testString").headers(new java.util.ArrayList<WebhookHeader>(java.util.Arrays.asList(webhookHeaderModel))).build();
    // Construct an instance of the Mention model
    Mention mentionModel = new Mention.Builder().entity("testString").location(new java.util.ArrayList<Long>(java.util.Arrays.asList(Long.valueOf("26")))).build();
    // Construct an instance of the Example model
    Example exampleModel = new Example.Builder().text("testString").mentions(new java.util.ArrayList<Mention>(java.util.Arrays.asList(mentionModel))).build();
    // Construct an instance of the CreateIntent model
    CreateIntent createIntentModel = new CreateIntent.Builder().intent("testString").description("testString").examples(new java.util.ArrayList<Example>(java.util.Arrays.asList(exampleModel))).build();
    // Construct an instance of the CreateValue model
    CreateValue createValueModel = new CreateValue.Builder().value("testString").metadata(new java.util.HashMap<String, Object>() {

        {
            put("foo", "testString");
        }
    }).type("synonyms").synonyms(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).patterns(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).build();
    // Construct an instance of the CreateEntity model
    CreateEntity createEntityModel = new CreateEntity.Builder().entity("testString").description("testString").metadata(new java.util.HashMap<String, Object>() {

        {
            put("foo", "testString");
        }
    }).fuzzyMatch(true).values(new java.util.ArrayList<CreateValue>(java.util.Arrays.asList(createValueModel))).build();
    // Construct an instance of the UpdateWorkspaceOptions model
    UpdateWorkspaceOptions updateWorkspaceOptionsModel = new UpdateWorkspaceOptions.Builder().workspaceId("testString").name("testString").description("testString").language("testString").dialogNodes(new java.util.ArrayList<DialogNode>(java.util.Arrays.asList(dialogNodeModel))).counterexamples(new java.util.ArrayList<Counterexample>(java.util.Arrays.asList(counterexampleModel))).metadata(new java.util.HashMap<String, Object>() {

        {
            put("foo", "testString");
        }
    }).learningOptOut(false).systemSettings(workspaceSystemSettingsModel).webhooks(new java.util.ArrayList<Webhook>(java.util.Arrays.asList(webhookModel))).intents(new java.util.ArrayList<CreateIntent>(java.util.Arrays.asList(createIntentModel))).entities(new java.util.ArrayList<CreateEntity>(java.util.Arrays.asList(createEntityModel))).append(false).includeAudit(false).build();
    // Invoke updateWorkspace() with a valid options model and verify the result
    Response<Workspace> response = assistantService.updateWorkspace(updateWorkspaceOptionsModel).execute();
    assertNotNull(response);
    Workspace responseObj = response.getResult();
    assertNotNull(responseObj);
    // Verify the contents of the request sent to the mock server
    RecordedRequest request = server.takeRequest();
    assertNotNull(request);
    assertEquals(request.getMethod(), "POST");
    // Verify request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, updateWorkspacePath);
    // Verify query params
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNotNull(query);
    assertEquals(query.get("version"), "testString");
    assertEquals(Boolean.valueOf(query.get("append")), Boolean.valueOf(false));
    assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false));
}
Also used : DialogNodeOutputGeneric(com.ibm.watson.assistant.v1.model.DialogNodeOutputGeneric) CreateEntity(com.ibm.watson.assistant.v1.model.CreateEntity) HashMap(java.util.HashMap) Counterexample(com.ibm.watson.assistant.v1.model.Counterexample) Mention(com.ibm.watson.assistant.v1.model.Mention) Example(com.ibm.watson.assistant.v1.model.Example) DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo(com.ibm.watson.assistant.v1.model.DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo) MockResponse(okhttp3.mockwebserver.MockResponse) CreateIntent(com.ibm.watson.assistant.v1.model.CreateIntent) DialogNodeContext(com.ibm.watson.assistant.v1.model.DialogNodeContext) WorkspaceSystemSettingsTooling(com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsTooling) Map(java.util.Map) HashMap(java.util.HashMap) CreateValue(com.ibm.watson.assistant.v1.model.CreateValue) ResponseGenericChannel(com.ibm.watson.assistant.v1.model.ResponseGenericChannel) DialogNode(com.ibm.watson.assistant.v1.model.DialogNode) WorkspaceSystemSettings(com.ibm.watson.assistant.v1.model.WorkspaceSystemSettings) DialogNodeOutput(com.ibm.watson.assistant.v1.model.DialogNodeOutput) DialogNodeNextStep(com.ibm.watson.assistant.v1.model.DialogNodeNextStep) DialogNodeOutputModifiers(com.ibm.watson.assistant.v1.model.DialogNodeOutputModifiers) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) WorkspaceSystemSettingsDisambiguation(com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsDisambiguation) UpdateWorkspaceOptions(com.ibm.watson.assistant.v1.model.UpdateWorkspaceOptions) DialogNodeAction(com.ibm.watson.assistant.v1.model.DialogNodeAction) WebhookHeader(com.ibm.watson.assistant.v1.model.WebhookHeader) WorkspaceSystemSettingsSystemEntities(com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsSystemEntities) WorkspaceSystemSettingsOffTopic(com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsOffTopic) Webhook(com.ibm.watson.assistant.v1.model.Webhook) Workspace(com.ibm.watson.assistant.v1.model.Workspace) Test(org.testng.annotations.Test)

Example 4 with ResponseGenericChannel

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

the class AssistantTest method testMessageWOptions.

// Test the message operation with a valid options model parameter
@Test
public void testMessageWOptions() throws Throwable {
    // Register a mock response
    String mockResponseBody = "{\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"alternate_intents\": false, \"context\": {\"conversation_id\": \"conversationId\", \"system\": {\"mapKey\": \"anyValue\"}, \"metadata\": {\"deployment\": \"deployment\", \"user_id\": \"userId\"}}, \"output\": {\"nodes_visited\": [\"nodesVisited\"], \"nodes_visited_details\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"msg\": \"msg\", \"code\": \"code\", \"source\": {\"type\": \"dialog_node\", \"dialog_node\": \"dialogNode\"}}], \"generic\": [{\"response_type\": \"option\", \"title\": \"title\", \"description\": \"description\", \"preference\": \"dropdown\", \"options\": [{\"label\": \"label\", \"value\": {\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}]}}], \"channels\": [{\"channel\": \"chat\"}]}]}, \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"user_id\": \"userId\"}";
    String messagePath = "/v1/workspaces/testString/message";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
    // Construct an instance of the MessageInput model
    MessageInput messageInputModel = new MessageInput.Builder().text("testString").spellingSuggestions(false).spellingAutoCorrect(false).add("foo", "testString").build();
    // Construct an instance of the RuntimeIntent model
    RuntimeIntent runtimeIntentModel = new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build();
    // Construct an instance of the CaptureGroup model
    CaptureGroup captureGroupModel = new CaptureGroup.Builder().group("testString").location(new java.util.ArrayList<Long>(java.util.Arrays.asList(Long.valueOf("26")))).build();
    // Construct an instance of the RuntimeEntityInterpretation model
    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();
    // Construct an instance of the RuntimeEntityAlternative model
    RuntimeEntityAlternative runtimeEntityAlternativeModel = new RuntimeEntityAlternative.Builder().value("testString").confidence(Double.valueOf("72.5")).build();
    // Construct an instance of the RuntimeEntityRole model
    RuntimeEntityRole runtimeEntityRoleModel = new RuntimeEntityRole.Builder().type("date_from").build();
    // Construct an instance of the RuntimeEntity model
    RuntimeEntity runtimeEntityModel = new RuntimeEntity.Builder().entity("testString").location(new java.util.ArrayList<Long>(java.util.Arrays.asList(Long.valueOf("26")))).value("testString").confidence(Double.valueOf("72.5")).groups(new java.util.ArrayList<CaptureGroup>(java.util.Arrays.asList(captureGroupModel))).interpretation(runtimeEntityInterpretationModel).alternatives(new java.util.ArrayList<RuntimeEntityAlternative>(java.util.Arrays.asList(runtimeEntityAlternativeModel))).role(runtimeEntityRoleModel).build();
    // Construct an instance of the MessageContextMetadata model
    MessageContextMetadata messageContextMetadataModel = new MessageContextMetadata.Builder().deployment("testString").userId("testString").build();
    // Construct an instance of the Context model
    Context contextModel = new Context.Builder().conversationId("testString").system(new java.util.HashMap<String, Object>() {

        {
            put("foo", "testString");
        }
    }).metadata(messageContextMetadataModel).add("foo", "testString").build();
    // Construct an instance of the DialogNodeVisitedDetails model
    DialogNodeVisitedDetails dialogNodeVisitedDetailsModel = new DialogNodeVisitedDetails.Builder().dialogNode("testString").title("testString").conditions("testString").build();
    // Construct an instance of the LogMessageSource model
    LogMessageSource logMessageSourceModel = new LogMessageSource.Builder().type("dialog_node").dialogNode("testString").build();
    // Construct an instance of the LogMessage model
    LogMessage logMessageModel = new LogMessage.Builder().level("info").msg("testString").code("testString").source(logMessageSourceModel).build();
    // Construct an instance of the DialogNodeOutputOptionsElementValue model
    DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModel = new DialogNodeOutputOptionsElementValue.Builder().input(messageInputModel).intents(new java.util.ArrayList<RuntimeIntent>(java.util.Arrays.asList(runtimeIntentModel))).entities(new java.util.ArrayList<RuntimeEntity>(java.util.Arrays.asList(runtimeEntityModel))).build();
    // Construct an instance of the DialogNodeOutputOptionsElement model
    DialogNodeOutputOptionsElement dialogNodeOutputOptionsElementModel = new DialogNodeOutputOptionsElement.Builder().label("testString").value(dialogNodeOutputOptionsElementValueModel).build();
    // Construct an instance of the ResponseGenericChannel model
    ResponseGenericChannel responseGenericChannelModel = new ResponseGenericChannel.Builder().channel("chat").build();
    // Construct an instance of the RuntimeResponseGenericRuntimeResponseTypeOption model
    RuntimeResponseGenericRuntimeResponseTypeOption runtimeResponseGenericModel = new RuntimeResponseGenericRuntimeResponseTypeOption.Builder().responseType("option").title("testString").description("testString").preference("dropdown").options(new java.util.ArrayList<DialogNodeOutputOptionsElement>(java.util.Arrays.asList(dialogNodeOutputOptionsElementModel))).channels(new java.util.ArrayList<ResponseGenericChannel>(java.util.Arrays.asList(responseGenericChannelModel))).build();
    // Construct an instance of the OutputData model
    OutputData outputDataModel = new OutputData.Builder().nodesVisited(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).nodesVisitedDetails(new java.util.ArrayList<DialogNodeVisitedDetails>(java.util.Arrays.asList(dialogNodeVisitedDetailsModel))).logMessages(new java.util.ArrayList<LogMessage>(java.util.Arrays.asList(logMessageModel))).generic(new java.util.ArrayList<RuntimeResponseGeneric>(java.util.Arrays.asList(runtimeResponseGenericModel))).add("foo", "testString").build();
    // Construct an instance of the MessageOptions model
    MessageOptions messageOptionsModel = new MessageOptions.Builder().workspaceId("testString").input(messageInputModel).intents(new java.util.ArrayList<RuntimeIntent>(java.util.Arrays.asList(runtimeIntentModel))).entities(new java.util.ArrayList<RuntimeEntity>(java.util.Arrays.asList(runtimeEntityModel))).alternateIntents(false).context(contextModel).output(outputDataModel).userId("testString").nodesVisitedDetails(false).build();
    // Invoke message() with a valid options model and verify the result
    Response<MessageResponse> response = assistantService.message(messageOptionsModel).execute();
    assertNotNull(response);
    MessageResponse responseObj = response.getResult();
    assertNotNull(responseObj);
    // Verify the contents of the request sent to the mock server
    RecordedRequest request = server.takeRequest();
    assertNotNull(request);
    assertEquals(request.getMethod(), "POST");
    // Verify request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, messagePath);
    // Verify query params
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNotNull(query);
    assertEquals(query.get("version"), "testString");
    assertEquals(Boolean.valueOf(query.get("nodes_visited_details")), Boolean.valueOf(false));
}
Also used : RuntimeResponseGenericRuntimeResponseTypeOption(com.ibm.watson.assistant.v1.model.RuntimeResponseGenericRuntimeResponseTypeOption) HashMap(java.util.HashMap) DialogNodeOutputOptionsElementValue(com.ibm.watson.assistant.v1.model.DialogNodeOutputOptionsElementValue) LogMessageSource(com.ibm.watson.assistant.v1.model.LogMessageSource) MessageContextMetadata(com.ibm.watson.assistant.v1.model.MessageContextMetadata) DialogNodeVisitedDetails(com.ibm.watson.assistant.v1.model.DialogNodeVisitedDetails) MockResponse(okhttp3.mockwebserver.MockResponse) DialogNodeOutputOptionsElement(com.ibm.watson.assistant.v1.model.DialogNodeOutputOptionsElement) RuntimeIntent(com.ibm.watson.assistant.v1.model.RuntimeIntent) MessageResponse(com.ibm.watson.assistant.v1.model.MessageResponse) RuntimeEntityRole(com.ibm.watson.assistant.v1.model.RuntimeEntityRole) RuntimeResponseGeneric(com.ibm.watson.assistant.v1.model.RuntimeResponseGeneric) OutputData(com.ibm.watson.assistant.v1.model.OutputData) RuntimeEntityAlternative(com.ibm.watson.assistant.v1.model.RuntimeEntityAlternative) RuntimeEntity(com.ibm.watson.assistant.v1.model.RuntimeEntity) CaptureGroup(com.ibm.watson.assistant.v1.model.CaptureGroup) ResponseGenericChannel(com.ibm.watson.assistant.v1.model.ResponseGenericChannel) MessageInput(com.ibm.watson.assistant.v1.model.MessageInput) MessageOptions(com.ibm.watson.assistant.v1.model.MessageOptions) DialogNodeContext(com.ibm.watson.assistant.v1.model.DialogNodeContext) Context(com.ibm.watson.assistant.v1.model.Context) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) RuntimeEntityInterpretation(com.ibm.watson.assistant.v1.model.RuntimeEntityInterpretation) LogMessage(com.ibm.watson.assistant.v1.model.LogMessage) Test(org.testng.annotations.Test)

Example 5 with ResponseGenericChannel

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

the class AssistantTest method testCreateDialogNodeWOptions.

// Test the createDialogNode operation with a valid options model parameter
@Test
public void testCreateDialogNodeWOptions() throws Throwable {
    // Register a mock response
    String mockResponseBody = "{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"video\", \"source\": \"source\", \"title\": \"title\", \"description\": \"description\", \"channels\": [{\"channel\": \"chat\"}], \"channel_options\": {\"mapKey\": \"anyValue\"}, \"alt_text\": \"altText\"}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": true}}, \"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\": false, \"disabled\": true, \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}";
    String createDialogNodePath = "/v1/workspaces/testString/dialog_nodes";
    server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(201).setBody(mockResponseBody));
    // Construct an instance of the ResponseGenericChannel model
    ResponseGenericChannel responseGenericChannelModel = new ResponseGenericChannel.Builder().channel("chat").build();
    // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo model
    DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo dialogNodeOutputGenericModel = new DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo.Builder().responseType("video").source("testString").title("testString").description("testString").channels(new java.util.ArrayList<ResponseGenericChannel>(java.util.Arrays.asList(responseGenericChannelModel))).channelOptions(new java.util.HashMap<String, Object>() {

        {
            put("foo", "testString");
        }
    }).altText("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 CreateDialogNodeOptions model
    CreateDialogNodeOptions createDialogNodeOptionsModel = new CreateDialogNodeOptions.Builder().workspaceId("testString").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(false).includeAudit(false).build();
    // Invoke createDialogNode() with a valid options model and verify the result
    Response<DialogNode> response = assistantService.createDialogNode(createDialogNodeOptionsModel).execute();
    assertNotNull(response);
    DialogNode responseObj = response.getResult();
    assertNotNull(responseObj);
    // Verify the contents of the request sent to the mock server
    RecordedRequest request = server.takeRequest();
    assertNotNull(request);
    assertEquals(request.getMethod(), "POST");
    // Verify request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, createDialogNodePath);
    // Verify query params
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNotNull(query);
    assertEquals(query.get("version"), "testString");
    assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false));
}
Also used : DialogNodeOutputGeneric(com.ibm.watson.assistant.v1.model.DialogNodeOutputGeneric) HashMap(java.util.HashMap) ResponseGenericChannel(com.ibm.watson.assistant.v1.model.ResponseGenericChannel) 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) DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo(com.ibm.watson.assistant.v1.model.DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) DialogNodeAction(com.ibm.watson.assistant.v1.model.DialogNodeAction) CreateDialogNodeOptions(com.ibm.watson.assistant.v1.model.CreateDialogNodeOptions) DialogNodeContext(com.ibm.watson.assistant.v1.model.DialogNodeContext) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Aggregations

DialogNodeContext (com.ibm.watson.assistant.v1.model.DialogNodeContext)5 ResponseGenericChannel (com.ibm.watson.assistant.v1.model.ResponseGenericChannel)5 HashMap (java.util.HashMap)5 MockResponse (okhttp3.mockwebserver.MockResponse)5 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)5 Test (org.testng.annotations.Test)5 DialogNode (com.ibm.watson.assistant.v1.model.DialogNode)4 DialogNodeAction (com.ibm.watson.assistant.v1.model.DialogNodeAction)4 DialogNodeNextStep (com.ibm.watson.assistant.v1.model.DialogNodeNextStep)4 DialogNodeOutput (com.ibm.watson.assistant.v1.model.DialogNodeOutput)4 DialogNodeOutputGeneric (com.ibm.watson.assistant.v1.model.DialogNodeOutputGeneric)4 DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo (com.ibm.watson.assistant.v1.model.DialogNodeOutputGenericDialogNodeOutputResponseTypeVideo)4 DialogNodeOutputModifiers (com.ibm.watson.assistant.v1.model.DialogNodeOutputModifiers)4 Map (java.util.Map)4 Counterexample (com.ibm.watson.assistant.v1.model.Counterexample)2 CreateEntity (com.ibm.watson.assistant.v1.model.CreateEntity)2 CreateIntent (com.ibm.watson.assistant.v1.model.CreateIntent)2 CreateValue (com.ibm.watson.assistant.v1.model.CreateValue)2 Example (com.ibm.watson.assistant.v1.model.Example)2 Mention (com.ibm.watson.assistant.v1.model.Mention)2