Search in sources :

Example 1 with DeleteAllTrainingDataOptions

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

the class DiscoveryTest method testDeleteAllTrainingDataWOptions.

// Test the deleteAllTrainingData operation with a valid options model parameter
@Test
public void testDeleteAllTrainingDataWOptions() throws Throwable {
    // Register a mock response
    String mockResponseBody = "";
    String deleteAllTrainingDataPath = "/v1/environments/testString/collections/testString/training_data";
    server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody));
    // Construct an instance of the DeleteAllTrainingDataOptions model
    DeleteAllTrainingDataOptions deleteAllTrainingDataOptionsModel = new DeleteAllTrainingDataOptions.Builder().environmentId("testString").collectionId("testString").build();
    // Invoke deleteAllTrainingData() with a valid options model and verify the result
    Response<Void> response = discoveryService.deleteAllTrainingData(deleteAllTrainingDataOptionsModel).execute();
    assertNotNull(response);
    Void responseObj = response.getResult();
    assertNull(responseObj);
    // Verify the contents of the request sent to the mock server
    RecordedRequest request = server.takeRequest();
    assertNotNull(request);
    assertEquals(request.getMethod(), "DELETE");
    // Verify request path
    String parsedPath = TestUtilities.parseReqPath(request);
    assertEquals(parsedPath, deleteAllTrainingDataPath);
    // Verify query params
    Map<String, String> query = TestUtilities.parseQueryString(request);
    assertNotNull(query);
    assertEquals(query.get("version"), "testString");
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) DeleteAllTrainingDataOptions(com.ibm.watson.discovery.v1.model.DeleteAllTrainingDataOptions) Test(org.testng.annotations.Test)

Example 2 with DeleteAllTrainingDataOptions

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

the class DiscoveryServiceTest method deleteAllCollectionTrainingDataIsSuccessful.

@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();
    RecordedRequest request = server.takeRequest();
    assertEquals(TRAINING1_PATH, request.getPath());
    assertEquals(DELETE, request.getMethod());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) DeleteAllTrainingDataOptions(com.ibm.watson.developer_cloud.discovery.v1.model.DeleteAllTrainingDataOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 3 with DeleteAllTrainingDataOptions

use of com.ibm.watson.discovery.v1.model.DeleteAllTrainingDataOptions 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());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) DeleteAllTrainingDataOptions(com.ibm.watson.discovery.v1.model.DeleteAllTrainingDataOptions) WatsonServiceUnitTest(com.ibm.watson.common.WatsonServiceUnitTest)

Aggregations

MockResponse (okhttp3.mockwebserver.MockResponse)3 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)3 DeleteAllTrainingDataOptions (com.ibm.watson.discovery.v1.model.DeleteAllTrainingDataOptions)2 WatsonServiceUnitTest (com.ibm.watson.common.WatsonServiceUnitTest)1 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 DeleteAllTrainingDataOptions (com.ibm.watson.developer_cloud.discovery.v1.model.DeleteAllTrainingDataOptions)1 Test (org.junit.Test)1 Test (org.testng.annotations.Test)1