Search in sources :

Example 1 with UpdateWorkspaceOptions

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

the class ConversationTest method testUpdateWorkspaceOptionsBuilder.

/**
 * Test UpdateWorkspaceOptions builder.
 */
@Test
public void testUpdateWorkspaceOptionsBuilder() {
    String workspaceName = "Builder Test";
    String workspaceDescription = "Description of " + workspaceName;
    String workspaceLanguage = "en";
    // intents
    CreateIntent testIntent = new CreateIntent.Builder("testIntent").build();
    // entities
    CreateEntity testEntity = new CreateEntity.Builder("testEntity").build();
    // counterexamples
    CreateCounterexample testCounterexample = new CreateCounterexample.Builder("testCounterexample").build();
    // dialognodes
    CreateDialogNode testDialogNode = new CreateDialogNode.Builder("dialogNode").build();
    // metadata
    Map<String, Object> workspaceMetadata = new HashMap<String, Object>();
    String metadataValue = "value for " + workspaceName;
    workspaceMetadata.put("key", metadataValue);
    UpdateWorkspaceOptions.Builder builder = new UpdateWorkspaceOptions.Builder(WORKSPACE_ID);
    builder.name(workspaceName);
    builder.description(workspaceDescription);
    builder.language(workspaceLanguage);
    builder.addIntent(testIntent);
    builder.addEntity(testEntity);
    builder.addCounterexample(testCounterexample);
    builder.addDialogNode(testDialogNode);
    builder.metadata(workspaceMetadata);
    UpdateWorkspaceOptions options = builder.build();
    assertEquals(options.name(), workspaceName);
    assertEquals(options.description(), workspaceDescription);
    assertEquals(options.language(), workspaceLanguage);
    assertNotNull(options.intents());
    assertEquals(options.intents().size(), 1);
    assertEquals(options.intents().get(0), testIntent);
    assertNotNull(options.entities());
    assertEquals(options.entities().size(), 1);
    assertEquals(options.entities().get(0), testEntity);
    assertNotNull(options.counterexamples());
    assertEquals(options.counterexamples().size(), 1);
    assertEquals(options.counterexamples().get(0), testCounterexample);
    assertNotNull(options.dialogNodes());
    assertEquals(options.dialogNodes().size(), 1);
    assertEquals(options.dialogNodes().get(0), testDialogNode);
    assertNotNull(options.metadata());
    assertEquals(options.metadata(), workspaceMetadata);
    UpdateWorkspaceOptions.Builder builder2 = options.newBuilder();
    CreateIntent testIntent2 = new CreateIntent.Builder("testIntent2").build();
    CreateEntity testEntity2 = new CreateEntity.Builder("testEntity2").build();
    CreateCounterexample testCounterexample2 = new CreateCounterexample.Builder("testCounterexample2").build();
    CreateDialogNode testDialogNode2 = new CreateDialogNode.Builder("dialogNode2").build();
    builder2.intents(new ArrayList<CreateIntent>());
    builder2.addIntent(testIntent2);
    builder2.entities(new ArrayList<CreateEntity>());
    builder2.addEntity(testEntity2);
    builder2.counterexamples(new ArrayList<CreateCounterexample>());
    builder2.addCounterexample(testCounterexample2);
    builder2.dialogNodes(new ArrayList<CreateDialogNode>());
    builder2.addDialogNode(testDialogNode2);
    UpdateWorkspaceOptions options2 = builder2.build();
    assertNotNull(options2.intents());
    assertEquals(options2.intents().size(), 1);
    assertEquals(options2.intents().get(0), testIntent2);
    assertNotNull(options2.entities());
    assertEquals(options2.entities().size(), 1);
    assertEquals(options2.entities().get(0), testEntity2);
    assertNotNull(options2.counterexamples());
    assertEquals(options2.counterexamples().size(), 1);
    assertEquals(options2.counterexamples().get(0), testCounterexample2);
    assertNotNull(options2.dialogNodes());
    assertEquals(options2.dialogNodes().size(), 1);
    assertEquals(options2.dialogNodes().get(0), testDialogNode2);
}
Also used : CreateEntity(com.ibm.watson.developer_cloud.conversation.v1.model.CreateEntity) UpdateWorkspaceOptions(com.ibm.watson.developer_cloud.conversation.v1.model.UpdateWorkspaceOptions) CreateDialogNode(com.ibm.watson.developer_cloud.conversation.v1.model.CreateDialogNode) HashMap(java.util.HashMap) CreateIntent(com.ibm.watson.developer_cloud.conversation.v1.model.CreateIntent) CreateCounterexample(com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexample) JsonObject(com.google.gson.JsonObject) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 2 with UpdateWorkspaceOptions

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

the class AssistantServiceIT method testUpdateWorkspace.

/**
 * Test updateWorkspace.
 */
@Test
public void testUpdateWorkspace() {
    String workspaceName = "testUpdateWorkspace";
    String workspaceDescription = "Description for testUpdateWorkspace";
    // intents
    CreateIntent intent0 = new CreateIntent.Builder("Hello").build();
    CreateIntent intent1 = new CreateIntent.Builder("Goodbye").build();
    // entities
    CreateEntity entity0 = new CreateEntity.Builder("animal").build();
    CreateEntity entity1 = new CreateEntity.Builder("beverage").build();
    // counterexamples
    CreateCounterexample counterexample0 = new CreateCounterexample.Builder("What are you wearing?").build();
    CreateCounterexample counterexample1 = new CreateCounterexample.Builder("What are you eating?").build();
    CreateWorkspaceOptions createOptions = new CreateWorkspaceOptions.Builder().name(workspaceName).description(workspaceDescription).addIntent(intent0).addIntent(intent1).addEntity(entity0).addEntity(entity1).addCounterexample(counterexample0).addCounterexample(counterexample1).build();
    String workspaceId = null;
    try {
        Workspace createResponse = service.createWorkspace(createOptions).execute();
        assertNotNull(createResponse);
        assertNotNull(createResponse.getWorkspaceId());
        workspaceId = createResponse.getWorkspaceId();
        String counterExampleText = "What are you drinking";
        CreateCounterexample counterexample2 = new CreateCounterexample.Builder(counterExampleText).build();
        UpdateWorkspaceOptions updateOptions = new UpdateWorkspaceOptions.Builder(workspaceId).addCounterexample(counterexample2).append(false).build();
        Workspace updateResponse = service.updateWorkspace(updateOptions).execute();
        assertNotNull(updateResponse);
        GetCounterexampleOptions getOptions = new GetCounterexampleOptions.Builder(workspaceId, counterExampleText).build();
        Counterexample eResponse = service.getCounterexample(getOptions).execute();
        assertNotNull(eResponse);
        assertNotNull(eResponse.getText());
        assertEquals(eResponse.getText(), counterExampleText);
    } catch (Exception ex) {
        fail(ex.getMessage());
    } finally {
        // Clean up
        if (workspaceId != null) {
            DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build();
            service.deleteWorkspace(deleteOptions).execute();
        }
    }
}
Also used : CreateEntity(com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntity) DeleteWorkspaceOptions(com.ibm.watson.developer_cloud.assistant.v1.model.DeleteWorkspaceOptions) UpdateWorkspaceOptions(com.ibm.watson.developer_cloud.assistant.v1.model.UpdateWorkspaceOptions) CreateIntent(com.ibm.watson.developer_cloud.assistant.v1.model.CreateIntent) Counterexample(com.ibm.watson.developer_cloud.assistant.v1.model.Counterexample) CreateCounterexample(com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexample) UnauthorizedException(com.ibm.watson.developer_cloud.service.exception.UnauthorizedException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) CreateCounterexample(com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexample) CreateWorkspaceOptions(com.ibm.watson.developer_cloud.assistant.v1.model.CreateWorkspaceOptions) GetCounterexampleOptions(com.ibm.watson.developer_cloud.assistant.v1.model.GetCounterexampleOptions) Workspace(com.ibm.watson.developer_cloud.assistant.v1.model.Workspace) Test(org.junit.Test)

Example 3 with UpdateWorkspaceOptions

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

the class AssistantTest method testUpdateWorkspaceOptionsBuilder.

/**
 * Test UpdateWorkspaceOptions builder.
 */
@Test
public void testUpdateWorkspaceOptionsBuilder() {
    String workspaceName = "Builder Test";
    String workspaceDescription = "Description of " + workspaceName;
    String workspaceLanguage = "en";
    // intents
    CreateIntent testIntent = new CreateIntent.Builder("testIntent").build();
    // entities
    CreateEntity testEntity = new CreateEntity.Builder("testEntity").build();
    // counterexamples
    CreateCounterexample testCounterexample = new CreateCounterexample.Builder("testCounterexample").build();
    // dialognodes
    CreateDialogNode testDialogNode = new CreateDialogNode.Builder("dialogNode").build();
    // metadata
    Map<String, Object> workspaceMetadata = new HashMap<String, Object>();
    String metadataValue = "value for " + workspaceName;
    workspaceMetadata.put("key", metadataValue);
    UpdateWorkspaceOptions.Builder builder = new UpdateWorkspaceOptions.Builder(WORKSPACE_ID);
    builder.name(workspaceName);
    builder.description(workspaceDescription);
    builder.language(workspaceLanguage);
    builder.addIntent(testIntent);
    builder.addEntity(testEntity);
    builder.addCounterexample(testCounterexample);
    builder.addDialogNode(testDialogNode);
    builder.metadata(workspaceMetadata);
    UpdateWorkspaceOptions options = builder.build();
    assertEquals(options.name(), workspaceName);
    assertEquals(options.description(), workspaceDescription);
    assertEquals(options.language(), workspaceLanguage);
    assertNotNull(options.intents());
    assertEquals(options.intents().size(), 1);
    assertEquals(options.intents().get(0), testIntent);
    assertNotNull(options.entities());
    assertEquals(options.entities().size(), 1);
    assertEquals(options.entities().get(0), testEntity);
    assertNotNull(options.counterexamples());
    assertEquals(options.counterexamples().size(), 1);
    assertEquals(options.counterexamples().get(0), testCounterexample);
    assertNotNull(options.dialogNodes());
    assertEquals(options.dialogNodes().size(), 1);
    assertEquals(options.dialogNodes().get(0), testDialogNode);
    assertNotNull(options.metadata());
    assertEquals(options.metadata(), workspaceMetadata);
    UpdateWorkspaceOptions.Builder builder2 = options.newBuilder();
    CreateIntent testIntent2 = new CreateIntent.Builder("testIntent2").build();
    CreateEntity testEntity2 = new CreateEntity.Builder("testEntity2").build();
    CreateCounterexample testCounterexample2 = new CreateCounterexample.Builder("testCounterexample2").build();
    CreateDialogNode testDialogNode2 = new CreateDialogNode.Builder("dialogNode2").build();
    builder2.intents(new ArrayList<CreateIntent>());
    builder2.addIntent(testIntent2);
    builder2.entities(new ArrayList<CreateEntity>());
    builder2.addEntity(testEntity2);
    builder2.counterexamples(new ArrayList<CreateCounterexample>());
    builder2.addCounterexample(testCounterexample2);
    builder2.dialogNodes(new ArrayList<CreateDialogNode>());
    builder2.addDialogNode(testDialogNode2);
    UpdateWorkspaceOptions options2 = builder2.build();
    assertNotNull(options2.intents());
    assertEquals(options2.intents().size(), 1);
    assertEquals(options2.intents().get(0), testIntent2);
    assertNotNull(options2.entities());
    assertEquals(options2.entities().size(), 1);
    assertEquals(options2.entities().get(0), testEntity2);
    assertNotNull(options2.counterexamples());
    assertEquals(options2.counterexamples().size(), 1);
    assertEquals(options2.counterexamples().get(0), testCounterexample2);
    assertNotNull(options2.dialogNodes());
    assertEquals(options2.dialogNodes().size(), 1);
    assertEquals(options2.dialogNodes().get(0), testDialogNode2);
}
Also used : CreateEntity(com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntity) UpdateWorkspaceOptions(com.ibm.watson.developer_cloud.assistant.v1.model.UpdateWorkspaceOptions) CreateDialogNode(com.ibm.watson.developer_cloud.assistant.v1.model.CreateDialogNode) HashMap(java.util.HashMap) CreateIntent(com.ibm.watson.developer_cloud.assistant.v1.model.CreateIntent) CreateCounterexample(com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexample) JsonObject(com.google.gson.JsonObject) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 4 with UpdateWorkspaceOptions

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

the class ConversationServiceIT method testUpdateWorkspace.

/**
 * Test updateWorkspace.
 */
@Test
public void testUpdateWorkspace() {
    String workspaceName = "testUpdateWorkspace";
    String workspaceDescription = "Description for testUpdateWorkspace";
    // intents
    CreateIntent intent0 = new CreateIntent.Builder("Hello").build();
    CreateIntent intent1 = new CreateIntent.Builder("Goodbye").build();
    // entities
    CreateEntity entity0 = new CreateEntity.Builder("animal").build();
    CreateEntity entity1 = new CreateEntity.Builder("beverage").build();
    // counterexamples
    CreateCounterexample counterexample0 = new CreateCounterexample.Builder("What are you wearing?").build();
    CreateCounterexample counterexample1 = new CreateCounterexample.Builder("What are you eating?").build();
    CreateWorkspaceOptions createOptions = new CreateWorkspaceOptions.Builder().name(workspaceName).description(workspaceDescription).addIntent(intent0).addIntent(intent1).addEntity(entity0).addEntity(entity1).addCounterexample(counterexample0).addCounterexample(counterexample1).build();
    String workspaceId = null;
    try {
        Workspace createResponse = service.createWorkspace(createOptions).execute();
        assertNotNull(createResponse);
        assertNotNull(createResponse.getWorkspaceId());
        workspaceId = createResponse.getWorkspaceId();
        String counterExampleText = "What are you drinking";
        CreateCounterexample counterexample2 = new CreateCounterexample.Builder(counterExampleText).build();
        UpdateWorkspaceOptions updateOptions = new UpdateWorkspaceOptions.Builder(workspaceId).addCounterexample(counterexample2).append(false).build();
        Workspace updateResponse = service.updateWorkspace(updateOptions).execute();
        assertNotNull(updateResponse);
        GetCounterexampleOptions getOptions = new GetCounterexampleOptions.Builder(workspaceId, counterExampleText).build();
        Counterexample eResponse = service.getCounterexample(getOptions).execute();
        assertNotNull(eResponse);
        assertNotNull(eResponse.getText());
        assertEquals(eResponse.getText(), counterExampleText);
    } catch (Exception ex) {
        fail(ex.getMessage());
    } finally {
        // Clean up
        if (workspaceId != null) {
            DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build();
            service.deleteWorkspace(deleteOptions).execute();
        }
    }
}
Also used : CreateEntity(com.ibm.watson.developer_cloud.conversation.v1.model.CreateEntity) DeleteWorkspaceOptions(com.ibm.watson.developer_cloud.conversation.v1.model.DeleteWorkspaceOptions) UpdateWorkspaceOptions(com.ibm.watson.developer_cloud.conversation.v1.model.UpdateWorkspaceOptions) CreateIntent(com.ibm.watson.developer_cloud.conversation.v1.model.CreateIntent) CreateCounterexample(com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexample) Counterexample(com.ibm.watson.developer_cloud.conversation.v1.model.Counterexample) UnauthorizedException(com.ibm.watson.developer_cloud.service.exception.UnauthorizedException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) CreateCounterexample(com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexample) CreateWorkspaceOptions(com.ibm.watson.developer_cloud.conversation.v1.model.CreateWorkspaceOptions) GetCounterexampleOptions(com.ibm.watson.developer_cloud.conversation.v1.model.GetCounterexampleOptions) Workspace(com.ibm.watson.developer_cloud.conversation.v1.model.Workspace) Test(org.junit.Test)

Example 5 with UpdateWorkspaceOptions

use of com.ibm.watson.assistant.v1.model.UpdateWorkspaceOptions 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)

Aggregations

HashMap (java.util.HashMap)4 Test (org.junit.Test)4 JsonObject (com.google.gson.JsonObject)3 Workspace (com.ibm.watson.assistant.v1.model.Workspace)2 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)2 CreateCounterexample (com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexample)2 CreateEntity (com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntity)2 CreateIntent (com.ibm.watson.developer_cloud.assistant.v1.model.CreateIntent)2 UpdateWorkspaceOptions (com.ibm.watson.developer_cloud.assistant.v1.model.UpdateWorkspaceOptions)2 NotFoundException (com.ibm.watson.developer_cloud.service.exception.NotFoundException)2 UnauthorizedException (com.ibm.watson.developer_cloud.service.exception.UnauthorizedException)2 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)1 Counterexample (com.ibm.watson.assistant.v1.model.Counterexample)1 CreateEntity (com.ibm.watson.assistant.v1.model.CreateEntity)1 CreateIntent (com.ibm.watson.assistant.v1.model.CreateIntent)1 CreateValue (com.ibm.watson.assistant.v1.model.CreateValue)1 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