use of com.ibm.watson.assistant.v1.model.Entity 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));
}
use of com.ibm.watson.assistant.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class AssistantTest method testCreateEntityWOptions.
// Test the createEntity operation with a valid options model parameter
@Test
public void testCreateEntityWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"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 createEntityPath = "/v1/workspaces/testString/entities";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(201).setBody(mockResponseBody));
// 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 CreateEntityOptions model
CreateEntityOptions createEntityOptionsModel = new CreateEntityOptions.Builder().workspaceId("testString").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))).includeAudit(false).build();
// Invoke createEntity() with a valid options model and verify the result
Response<Entity> response = assistantService.createEntity(createEntityOptionsModel).execute();
assertNotNull(response);
Entity 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, createEntityPath);
// 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 testBulkClassifyWOptions.
// Test the bulkClassify operation with a valid options model parameter
@Test
public void testBulkClassifyWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"output\": [{\"input\": {\"text\": \"text\"}, \"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\"}}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}]}]}";
String bulkClassifyPath = "/v1/workspaces/testString/bulk_classify";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the BulkClassifyUtterance model
BulkClassifyUtterance bulkClassifyUtteranceModel = new BulkClassifyUtterance.Builder().text("testString").build();
// Construct an instance of the BulkClassifyOptions model
BulkClassifyOptions bulkClassifyOptionsModel = new BulkClassifyOptions.Builder().workspaceId("testString").input(new java.util.ArrayList<BulkClassifyUtterance>(java.util.Arrays.asList(bulkClassifyUtteranceModel))).build();
// Invoke bulkClassify() with a valid options model and verify the result
Response<BulkClassifyResponse> response = assistantService.bulkClassify(bulkClassifyOptionsModel).execute();
assertNotNull(response);
BulkClassifyResponse 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, bulkClassifyPath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("version"), "testString");
}
use of com.ibm.watson.assistant.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class AssistantTest method testCreateExampleWOptions.
// Test the createExample operation with a valid options model parameter
@Test
public void testCreateExampleWOptions() 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 createExamplePath = "/v1/workspaces/testString/intents/testString/examples";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(201).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 CreateExampleOptions model
CreateExampleOptions createExampleOptionsModel = new CreateExampleOptions.Builder().workspaceId("testString").intent("testString").text("testString").mentions(new java.util.ArrayList<Mention>(java.util.Arrays.asList(mentionModel))).includeAudit(false).build();
// Invoke createExample() with a valid options model and verify the result
Response<Example> response = assistantService.createExample(createExampleOptionsModel).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, createExamplePath);
// 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 testUpdateSynonymWOptions.
// Test the updateSynonym operation with a valid options model parameter
@Test
public void testUpdateSynonymWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"synonym\": \"synonym\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\"}";
String updateSynonymPath = "/v1/workspaces/testString/entities/testString/values/testString/synonyms/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the UpdateSynonymOptions model
UpdateSynonymOptions updateSynonymOptionsModel = new UpdateSynonymOptions.Builder().workspaceId("testString").entity("testString").value("testString").synonym("testString").newSynonym("testString").includeAudit(false).build();
// Invoke updateSynonym() with a valid options model and verify the result
Response<Synonym> response = assistantService.updateSynonym(updateSynonymOptionsModel).execute();
assertNotNull(response);
Synonym 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, updateSynonymPath);
// 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