use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method deleteAllCollectionTrainingDataIsSuccessful.
/**
* Delete all collection training data is successful.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void deleteAllCollectionTrainingDataIsSuccessful() throws InterruptedException {
MockResponse desiredResponse = new MockResponse().setResponseCode(204);
server.enqueue(desiredResponse);
DeleteAllTrainingDataOptions deleteRequest = new DeleteAllTrainingDataOptions.Builder(environmentId, collectionId).build();
discoveryService.deleteAllTrainingData(deleteRequest).execute().getResult();
RecordedRequest request = server.takeRequest();
assertEquals(TRAINING1_PATH, request.getPath());
assertEquals(DELETE, request.getMethod());
}
use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method deleteCollectionIsSuccessful.
/**
* Delete collection is successful.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void deleteCollectionIsSuccessful() throws InterruptedException {
server.enqueue(jsonResponse(deleteCollResp));
DeleteCollectionOptions deleteRequest = new DeleteCollectionOptions.Builder(environmentId, collectionId).build();
DeleteCollectionResponse response = discoveryService.deleteCollection(deleteRequest).execute().getResult();
RecordedRequest request = server.takeRequest();
assertEquals(COLL2_PATH, request.getPath());
assertEquals(DELETE, request.getMethod());
assertEquals(DeleteCollectionResponse.Status.DELETED, response.getStatus());
assertEquals(deleteCollResp.getCollectionId(), response.getCollectionId());
}
use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryTest method testUpdateCollectionWOptions.
// Test the updateCollection operation with a valid options model parameter
@Test
public void testUpdateCollectionWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"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 updateCollectionPath = "/v1/environments/testString/collections/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(201).setBody(mockResponseBody));
// Construct an instance of the UpdateCollectionOptions model
UpdateCollectionOptions updateCollectionOptionsModel = new UpdateCollectionOptions.Builder().environmentId("testString").collectionId("testString").name("testString").description("testString").configurationId("testString").build();
// Invoke updateCollection() with a valid options model and verify the result
Response<Collection> response = discoveryService.updateCollection(updateCollectionOptionsModel).execute();
assertNotNull(response);
Collection 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(), "PUT");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, updateCollectionPath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("version"), "testString");
}
use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryTest method testCreateCollectionWOptions.
// Test the createCollection operation with a valid options model parameter
@Test
public void testCreateCollectionWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"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 createCollectionPath = "/v1/environments/testString/collections";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(201).setBody(mockResponseBody));
// Construct an instance of the CreateCollectionOptions model
CreateCollectionOptions createCollectionOptionsModel = new CreateCollectionOptions.Builder().environmentId("testString").name("testString").description("testString").configurationId("testString").language("en").build();
// Invoke createCollection() with a valid options model and verify the result
Response<Collection> response = discoveryService.createCollection(createCollectionOptionsModel).execute();
assertNotNull(response);
Collection 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(), "POST");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, createCollectionPath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("version"), "testString");
}
use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryTest method testGetCollectionWOptions.
// Test the getCollection operation with a valid options model parameter
@Test
public void testGetCollectionWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"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 getCollectionPath = "/v1/environments/testString/collections/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the GetCollectionOptions model
GetCollectionOptions getCollectionOptionsModel = new GetCollectionOptions.Builder().environmentId("testString").collectionId("testString").build();
// Invoke getCollection() with a valid options model and verify the result
Response<Collection> response = discoveryService.getCollection(getCollectionOptionsModel).execute();
assertNotNull(response);
Collection 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, getCollectionPath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("version"), "testString");
}
Aggregations