use of com.ibm.watson.assistant.v1.model.Entity in project java-sdk by watson-developer-cloud.
the class AssistantTest method testListEntitiesWOptions.
// Test the listEntities operation with a valid options model parameter
@Test
public void testListEntitiesWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"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\"}]}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}";
String listEntitiesPath = "/v1/workspaces/testString/entities";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the ListEntitiesOptions model
ListEntitiesOptions listEntitiesOptionsModel = new ListEntitiesOptions.Builder().workspaceId("testString").export(false).pageLimit(Long.valueOf("26")).includeCount(false).sort("entity").cursor("testString").includeAudit(false).build();
// Invoke listEntities() with a valid options model and verify the result
Response<EntityCollection> response = assistantService.listEntities(listEntitiesOptionsModel).execute();
assertNotNull(response);
EntityCollection 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, listEntitiesPath);
// 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"), "entity");
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 testDeleteValueWOptions.
// Test the deleteValue operation with a valid options model parameter
@Test
public void testDeleteValueWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "";
String deleteValuePath = "/v1/workspaces/testString/entities/testString/values/testString";
server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the DeleteValueOptions model
DeleteValueOptions deleteValueOptionsModel = new DeleteValueOptions.Builder().workspaceId("testString").entity("testString").value("testString").build();
// Invoke deleteValue() with a valid options model and verify the result
Response<Void> response = assistantService.deleteValue(deleteValueOptionsModel).execute();
assertNotNull(response);
Void responseObj = response.getResult();
assertNull(responseObj);
// Verify the contents of the request sent to the mock server
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "DELETE");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, deleteValuePath);
// 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 testListValuesWOptions.
// Test the listValues operation with a valid options model parameter
@Test
public void testListValuesWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"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\"}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}";
String listValuesPath = "/v1/workspaces/testString/entities/testString/values";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the ListValuesOptions model
ListValuesOptions listValuesOptionsModel = new ListValuesOptions.Builder().workspaceId("testString").entity("testString").export(false).pageLimit(Long.valueOf("26")).includeCount(false).sort("value").cursor("testString").includeAudit(false).build();
// Invoke listValues() with a valid options model and verify the result
Response<ValueCollection> response = assistantService.listValues(listValuesOptionsModel).execute();
assertNotNull(response);
ValueCollection 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, listValuesPath);
// 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"), "value");
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 testGetEntityWOptions.
// Test the getEntity operation with a valid options model parameter
@Test
public void testGetEntityWOptions() 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 getEntityPath = "/v1/workspaces/testString/entities/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the GetEntityOptions model
GetEntityOptions getEntityOptionsModel = new GetEntityOptions.Builder().workspaceId("testString").entity("testString").export(false).includeAudit(false).build();
// Invoke getEntity() with a valid options model and verify the result
Response<Entity> response = assistantService.getEntity(getEntityOptionsModel).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(), "GET");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, getEntityPath);
// 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 testUpdateValueWOptions.
// Test the updateValue operation with a valid options model parameter
@Test
public void testUpdateValueWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"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 updateValuePath = "/v1/workspaces/testString/entities/testString/values/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the UpdateValueOptions model
UpdateValueOptions updateValueOptionsModel = new UpdateValueOptions.Builder().workspaceId("testString").entity("testString").value("testString").newValue("testString").newMetadata(new java.util.HashMap<String, Object>() {
{
put("foo", "testString");
}
}).newType("synonyms").newSynonyms(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).newPatterns(new java.util.ArrayList<String>(java.util.Arrays.asList("testString"))).append(false).includeAudit(false).build();
// Invoke updateValue() with a valid options model and verify the result
Response<Value> response = assistantService.updateValue(updateValueOptionsModel).execute();
assertNotNull(response);
Value 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, updateValuePath);
// 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));
}
Aggregations