Search in sources :

Example 1 with ListCollectionsResponse

use of com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsResponse 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 ListCollectionsResponse

use of com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsResponse 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 ListCollectionsResponse

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

the class DiscoveryServiceIT method getCollectionsByNameIsSuccessful.

@Test
public void getCollectionsByNameIsSuccessful() {
    Configuration createConfigResponse = createTestConfig();
    String uniqueCollectionName = uniqueName + "-collection";
    CreateCollectionOptions.Builder createCollectionBuilder = new CreateCollectionOptions.Builder(environmentId, uniqueCollectionName).configurationId(createConfigResponse.getConfigurationId());
    createCollection(createCollectionBuilder.build());
    ListCollectionsOptions.Builder getBuilder = new ListCollectionsOptions.Builder(environmentId);
    getBuilder.name(uniqueCollectionName);
    ListCollectionsResponse getResponse = discovery.listCollections(getBuilder.build()).execute();
    assertEquals(1, getResponse.getCollections().size());
    assertEquals(uniqueCollectionName, getResponse.getCollections().get(0).getName());
}
Also used : ListCollectionsOptions(com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsOptions) Configuration(com.ibm.watson.developer_cloud.discovery.v1.model.Configuration) CreateCollectionOptions(com.ibm.watson.developer_cloud.discovery.v1.model.CreateCollectionOptions) ListCollectionsResponse(com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsResponse) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 4 with ListCollectionsResponse

use of com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsResponse 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)4 ListCollectionsOptions (com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsOptions)3 Test (org.junit.Test)3 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)2 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 Configuration (com.ibm.watson.developer_cloud.discovery.v1.model.Configuration)1 CreateCollectionOptions (com.ibm.watson.developer_cloud.discovery.v1.model.CreateCollectionOptions)1 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1