Search in sources :

Example 1 with ListCollectionsOptions

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

the class DiscoveryServiceTest method getCollectionsIsSuccessful.

@Test
public void getCollectionsIsSuccessful() throws InterruptedException {
    server.enqueue(jsonResponse(getCollsResp));
    ListCollectionsOptions getRequest = new ListCollectionsOptions.Builder(environmentId).build();
    ListCollectionsResponse response = discoveryService.listCollections(getRequest).execute();
    RecordedRequest request = server.takeRequest();
    assertEquals(COLL1_PATH, request.getPath());
    assertEquals(GET, request.getMethod());
    assertEquals(getCollsResp, response);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ListCollectionsOptions(com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsOptions) ListCollectionsResponse(com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsResponse) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 2 with ListCollectionsOptions

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

the class DiscoveryServiceIT method listCollectionsIsSuccessful.

// Collections
@Test
public void listCollectionsIsSuccessful() {
    createTestCollection();
    ListCollectionsOptions listOptions = new ListCollectionsOptions.Builder(environmentId).build();
    ListCollectionsResponse listResponse = discovery.listCollections(listOptions).execute();
    assertFalse(listResponse.getCollections().isEmpty());
}
Also used : ListCollectionsOptions(com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsOptions) ListCollectionsResponse(com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsResponse) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 3 with ListCollectionsOptions

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

the class Discovery method listCollections.

/**
 * List collections.
 *
 * Lists existing collections for the service instance.
 *
 * @param listCollectionsOptions the {@link ListCollectionsOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link ListCollectionsResponse}
 */
public ServiceCall<ListCollectionsResponse> listCollections(ListCollectionsOptions listCollectionsOptions) {
    Validator.notNull(listCollectionsOptions, "listCollectionsOptions cannot be null");
    String[] pathSegments = { "v1/environments", "collections" };
    String[] pathParameters = { listCollectionsOptions.environmentId() };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    if (listCollectionsOptions.name() != null) {
        builder.query("name", listCollectionsOptions.name());
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListCollectionsResponse.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) ListCollectionsResponse(com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsResponse)

Aggregations

ListCollectionsResponse (com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsResponse)3 ListCollectionsOptions (com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsOptions)2 Test (org.junit.Test)2 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)1 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1