Search in sources :

Example 1 with ListCollectionFieldsResponse

use of com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse in project java-sdk by watson-developer-cloud.

the class DiscoveryServiceTest method listfieldsCollectionIsSuccessful.

// no updateCollection yet?
@Test
public void listfieldsCollectionIsSuccessful() throws InterruptedException {
    server.enqueue(jsonResponse(listfieldsCollResp));
    ListCollectionFieldsOptions getRequest = new ListCollectionFieldsOptions.Builder(environmentId, collectionId).build();
    ListCollectionFieldsResponse response = discoveryService.listCollectionFields(getRequest).execute();
    RecordedRequest request = server.takeRequest();
    assertEquals(COLL3_PATH, request.getPath());
    assertEquals(GET, request.getMethod());
    assertEquals(listfieldsCollResp, response);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ListCollectionFieldsOptions(com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsOptions) ListCollectionFieldsResponse(com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 2 with ListCollectionFieldsResponse

use of com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse in project java-sdk by watson-developer-cloud.

the class Discovery method listCollectionFields.

/**
 * List unique fields.
 *
 * Gets a list of the unique fields (and their types) stored in the index.
 *
 * @param listCollectionFieldsOptions the {@link ListCollectionFieldsOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link ListCollectionFieldsResponse}
 */
public ServiceCall<ListCollectionFieldsResponse> listCollectionFields(ListCollectionFieldsOptions listCollectionFieldsOptions) {
    Validator.notNull(listCollectionFieldsOptions, "listCollectionFieldsOptions cannot be null");
    String[] pathSegments = { "v1/environments", "collections", "fields" };
    String[] pathParameters = { listCollectionFieldsOptions.environmentId(), listCollectionFieldsOptions.collectionId() };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListCollectionFieldsResponse.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) ListCollectionFieldsResponse(com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse)

Example 3 with ListCollectionFieldsResponse

use of com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse in project java-sdk by watson-developer-cloud.

the class DiscoveryServiceIT method getCollectionFieldsIsSuccessful.

@Ignore
@Test
public void getCollectionFieldsIsSuccessful() {
    Collection collection = createTestCollection();
    String collectionId = collection.getCollectionId();
    createTestDocument("test_document", collectionId);
    ListCollectionFieldsOptions getOptions = new ListCollectionFieldsOptions.Builder(environmentId, collectionId).build();
    ListCollectionFieldsResponse getResponse = discovery.listCollectionFields(getOptions).execute();
    assertFalse(getResponse.getFields().isEmpty());
}
Also used : ListCollectionFieldsOptions(com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsOptions) Collection(com.ibm.watson.developer_cloud.discovery.v1.model.Collection) ListCollectionFieldsResponse(com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse) Ignore(org.junit.Ignore) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 4 with ListCollectionFieldsResponse

use of com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse in project java-sdk by watson-developer-cloud.

the class DiscoveryServiceTest method listFieldsIsSuccessful.

@Test
public void listFieldsIsSuccessful() throws InterruptedException {
    server.enqueue(jsonResponse(listFieldsResp));
    ListFieldsOptions.Builder builder = new ListFieldsOptions.Builder(environmentId, new ArrayList<>(Arrays.asList(collectionId)));
    ListCollectionFieldsResponse response = discoveryService.listFields(builder.build()).execute();
    RecordedRequest request = server.takeRequest();
    assertEquals(FIELD_PATH, request.getPath());
    assertEquals(GET, request.getMethod());
    assertEquals(listFieldsResp, response);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ListCollectionFieldsResponse(com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse) ListFieldsOptions(com.ibm.watson.developer_cloud.discovery.v1.model.ListFieldsOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 5 with ListCollectionFieldsResponse

use of com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse in project java-sdk by watson-developer-cloud.

the class Discovery method listFields.

/**
 * List fields in specified collections.
 *
 * Gets a list of the unique fields (and their types) stored in the indexes of the specified collections.
 *
 * @param listFieldsOptions the {@link ListFieldsOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link ListCollectionFieldsResponse}
 */
public ServiceCall<ListCollectionFieldsResponse> listFields(ListFieldsOptions listFieldsOptions) {
    Validator.notNull(listFieldsOptions, "listFieldsOptions cannot be null");
    String[] pathSegments = { "v1/environments", "fields" };
    String[] pathParameters = { listFieldsOptions.environmentId() };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    builder.query("collection_ids", RequestUtils.join(listFieldsOptions.collectionIds(), ","));
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListCollectionFieldsResponse.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) ListCollectionFieldsResponse(com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse)

Aggregations

ListCollectionFieldsResponse (com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse)5 Test (org.junit.Test)3 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)2 ListCollectionFieldsOptions (com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsOptions)2 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)2 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)1 Collection (com.ibm.watson.developer_cloud.discovery.v1.model.Collection)1 ListFieldsOptions (com.ibm.watson.developer_cloud.discovery.v1.model.ListFieldsOptions)1 Ignore (org.junit.Ignore)1