use of com.ibm.watson.assistant.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class AssistantTest method testListIntentsWOptions.
// Test the listIntents operation with a valid options model parameter
@Test
public void testListIntentsWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"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\"}]}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}";
String listIntentsPath = "/v1/workspaces/testString/intents";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the ListIntentsOptions model
ListIntentsOptions listIntentsOptionsModel = new ListIntentsOptions.Builder().workspaceId("testString").export(false).pageLimit(Long.valueOf("26")).includeCount(false).sort("intent").cursor("testString").includeAudit(false).build();
// Invoke listIntents() with a valid options model and verify the result
Response<IntentCollection> response = assistantService.listIntents(listIntentsOptionsModel).execute();
assertNotNull(response);
IntentCollection 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(), "GET");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, listIntentsPath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("version"), "testString");
assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(false));
assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("26"));
assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(false));
assertEquals(query.get("sort"), "intent");
assertEquals(query.get("cursor"), "testString");
assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false));
}
use of com.ibm.watson.assistant.v1.model.Entity 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));
}
use of com.ibm.watson.assistant.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class AssistantTest method testListExamplesWOptions.
// Test the listExamples operation with a valid options model parameter
@Test
public void testListExamplesWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}";
String listExamplesPath = "/v1/workspaces/testString/intents/testString/examples";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the ListExamplesOptions model
ListExamplesOptions listExamplesOptionsModel = new ListExamplesOptions.Builder().workspaceId("testString").intent("testString").pageLimit(Long.valueOf("26")).includeCount(false).sort("text").cursor("testString").includeAudit(false).build();
// Invoke listExamples() with a valid options model and verify the result
Response<ExampleCollection> response = assistantService.listExamples(listExamplesOptionsModel).execute();
assertNotNull(response);
ExampleCollection 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(), "GET");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, listExamplesPath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("version"), "testString");
assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("26"));
assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(false));
assertEquals(query.get("sort"), "text");
assertEquals(query.get("cursor"), "testString");
assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false));
}
use of com.ibm.watson.assistant.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class AssistantTest method testGetIntentWOptions.
// Test the getIntent operation with a valid options model parameter
@Test
public void testGetIntentWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"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\"}]}";
String getIntentPath = "/v1/workspaces/testString/intents/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the GetIntentOptions model
GetIntentOptions getIntentOptionsModel = new GetIntentOptions.Builder().workspaceId("testString").intent("testString").export(false).includeAudit(false).build();
// Invoke getIntent() with a valid options model and verify the result
Response<Intent> response = assistantService.getIntent(getIntentOptionsModel).execute();
assertNotNull(response);
Intent 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(), "GET");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, getIntentPath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("version"), "testString");
assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(false));
assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(false));
}
use of com.ibm.watson.assistant.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class AssistantTest method testUpdateExampleWOptions.
// Test the updateExample operation with a valid options model parameter
@Test
public void testUpdateExampleWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}";
String updateExamplePath = "/v1/workspaces/testString/intents/testString/examples/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// 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 UpdateExampleOptions model
UpdateExampleOptions updateExampleOptionsModel = new UpdateExampleOptions.Builder().workspaceId("testString").intent("testString").text("testString").newText("testString").newMentions(new java.util.ArrayList<Mention>(java.util.Arrays.asList(mentionModel))).includeAudit(false).build();
// Invoke updateExample() with a valid options model and verify the result
Response<Example> response = assistantService.updateExample(updateExampleOptionsModel).execute();
assertNotNull(response);
Example 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, updateExamplePath);
// 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));
}
Aggregations