use of com.ibm.watson.assistant.v1.model.EntityMentionCollection in project java-sdk by watson-developer-cloud.
the class AssistantTest method testListMentionsWOptions.
// Test the listMentions operation with a valid options model parameter
@Test
public void testListMentionsWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"examples\": [{\"text\": \"text\", \"intent\": \"intent\", \"location\": [8]}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}";
String listMentionsPath = "/v1/workspaces/testString/entities/testString/mentions";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the ListMentionsOptions model
ListMentionsOptions listMentionsOptionsModel = new ListMentionsOptions.Builder().workspaceId("testString").entity("testString").export(false).includeAudit(false).build();
// Invoke listMentions() with a valid options model and verify the result
Response<EntityMentionCollection> response = assistantService.listMentions(listMentionsOptionsModel).execute();
assertNotNull(response);
EntityMentionCollection 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, listMentionsPath);
// 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.EntityMentionCollection in project java-sdk by watson-developer-cloud.
the class Assistant method listMentions.
/**
* List entity mentions.
*
* <p>List mentions for a contextual entity. An entity mention is an occurrence of a contextual
* entity in the context of an intent user input example.
*
* @param listMentionsOptions the {@link ListMentionsOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link EntityMentionCollection}
*/
public ServiceCall<EntityMentionCollection> listMentions(ListMentionsOptions listMentionsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listMentionsOptions, "listMentionsOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("workspace_id", listMentionsOptions.workspaceId());
pathParamsMap.put("entity", listMentionsOptions.entity());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}/mentions", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listMentions");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("version", String.valueOf(this.version));
if (listMentionsOptions.export() != null) {
builder.query("export", String.valueOf(listMentionsOptions.export()));
}
if (listMentionsOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(listMentionsOptions.includeAudit()));
}
ResponseConverter<EntityMentionCollection> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<EntityMentionCollection>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations