use of com.ibm.watson.discovery.v2.model.ListEnrichmentsOptions in project java-sdk by watson-developer-cloud.
the class DiscoveryTest method testListEnrichmentsWOptions.
@Test
public void testListEnrichmentsWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"enrichments\": [{\"enrichment_id\": \"enrichmentId\", \"name\": \"name\", \"description\": \"description\", \"type\": \"part_of_speech\", \"options\": {\"languages\": [\"languages\"], \"entity_type\": \"entityType\", \"regular_expression\": \"regularExpression\", \"result_field\": \"resultField\"}}]}";
String listEnrichmentsPath = "/v2/projects/testString/enrichments";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the ListEnrichmentsOptions model
ListEnrichmentsOptions listEnrichmentsOptionsModel = new ListEnrichmentsOptions.Builder().projectId("testString").build();
// Invoke operation with valid options model (positive test)
Response<Enrichments> response = discoveryService.listEnrichments(listEnrichmentsOptionsModel).execute();
assertNotNull(response);
Enrichments responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "GET");
// Check query
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
// Get query params
assertEquals(query.get("version"), "testString");
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, listEnrichmentsPath);
}
use of com.ibm.watson.discovery.v2.model.ListEnrichmentsOptions in project java-sdk by watson-developer-cloud.
the class Discovery method listEnrichments.
/**
* List Enrichments.
*
* <p>Lists the enrichments available to this project. The *Part of Speech* and *Sentiment of
* Phrases* enrichments might be listed, but are reserved for internal use only.
*
* @param listEnrichmentsOptions the {@link ListEnrichmentsOptions} containing the options for the
* call
* @return a {@link ServiceCall} with a result of type {@link Enrichments}
*/
public ServiceCall<Enrichments> listEnrichments(ListEnrichmentsOptions listEnrichmentsOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listEnrichmentsOptions, "listEnrichmentsOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("project_id", listEnrichmentsOptions.projectId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/projects/{project_id}/enrichments", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listEnrichments");
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));
ResponseConverter<Enrichments> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Enrichments>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations