use of com.ibm.watson.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);
}
use of com.ibm.watson.discovery.v1.model.ListCollectionsOptions in project java-sdk by watson-developer-cloud.
the class DiscoveryTest method testListCollectionsWOptions.
// Test the listCollections operation with a valid options model parameter
@Test
public void testListCollectionsWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"collections\": [{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"status\": \"active\", \"configuration_id\": \"configurationId\", \"language\": \"language\", \"document_counts\": {\"available\": 9, \"processing\": 10, \"failed\": 6, \"pending\": 7}, \"disk_usage\": {\"used_bytes\": 9}, \"training_status\": {\"total_examples\": 13, \"available\": false, \"processing\": true, \"minimum_queries_added\": false, \"minimum_examples_added\": true, \"sufficient_label_diversity\": true, \"notices\": 7, \"successfully_trained\": \"2019-01-01T12:00:00.000Z\", \"data_updated\": \"2019-01-01T12:00:00.000Z\"}, \"crawl_status\": {\"source_crawl\": {\"status\": \"running\", \"next_crawl\": \"2019-01-01T12:00:00.000Z\"}}, \"smart_document_understanding\": {\"enabled\": true, \"total_annotated_pages\": 19, \"total_pages\": 10, \"total_documents\": 14, \"custom_fields\": {\"defined\": 7, \"maximum_allowed\": 14}}}]}";
String listCollectionsPath = "/v1/environments/testString/collections";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the ListCollectionsOptions model
ListCollectionsOptions listCollectionsOptionsModel = new ListCollectionsOptions.Builder().environmentId("testString").name("testString").build();
// Invoke listCollections() with a valid options model and verify the result
Response<ListCollectionsResponse> response = discoveryService.listCollections(listCollectionsOptionsModel).execute();
assertNotNull(response);
ListCollectionsResponse 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, listCollectionsPath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("version"), "testString");
assertEquals(query.get("name"), "testString");
}
use of com.ibm.watson.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());
}
use of com.ibm.watson.discovery.v1.model.ListCollectionsOptions in project java-sdk by watson-developer-cloud.
the class DiscoveryTest method testListCollectionsWOptions.
@Test
public void testListCollectionsWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"collections\": [{\"collection_id\": \"collectionId\", \"name\": \"name\"}]}";
String listCollectionsPath = "/v2/projects/testString/collections";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the ListCollectionsOptions model
ListCollectionsOptions listCollectionsOptionsModel = new ListCollectionsOptions.Builder().projectId("testString").build();
// Invoke operation with valid options model (positive test)
Response<ListCollectionsResponse> response = discoveryService.listCollections(listCollectionsOptionsModel).execute();
assertNotNull(response);
ListCollectionsResponse 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, listCollectionsPath);
}
use of com.ibm.watson.discovery.v1.model.ListCollectionsOptions in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method getCollectionsIsSuccessful.
/**
* Gets the collections is successful.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void getCollectionsIsSuccessful() throws InterruptedException {
server.enqueue(jsonResponse(getCollsResp));
ListCollectionsOptions getRequest = new ListCollectionsOptions.Builder(environmentId).build();
ListCollectionsResponse response = discoveryService.listCollections(getRequest).execute().getResult();
RecordedRequest request = server.takeRequest();
assertEquals(COLL1_PATH, request.getPath());
assertEquals(GET, request.getMethod());
assertEquals(getCollsResp, response);
}
Aggregations