Search in sources :

Example 1 with DeleteTrainingQueryOptions

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

the class DiscoveryTest method testDeleteTrainingQueryWOptions.

@Test
public void testDeleteTrainingQueryWOptions() throws Throwable {
    // Schedule some responses.
    String mockResponseBody = "";
    String deleteTrainingQueryPath = "/v2/projects/testString/training_data/queries/testString";
    server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody));
    constructClientService();
    // Construct an instance of the DeleteTrainingQueryOptions model
    DeleteTrainingQueryOptions deleteTrainingQueryOptionsModel = new DeleteTrainingQueryOptions.Builder().projectId("testString").queryId("testString").build();
    // Invoke operation with valid options model (positive test)
    Response<Void> response = discoveryService.deleteTrainingQuery(deleteTrainingQueryOptionsModel).execute();
    assertNotNull(response);
    Void responseObj = response.getResult();
    // Response does not have a return type. Check that the result is null.
    assertNull(responseObj);
    // Verify the contents of the request
    RecordedRequest request = server.takeRequest();
    assertNotNull(request);
    assertEquals(request.getMethod(), "DELETE");
    // 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, deleteTrainingQueryPath);
}
Also used : DeleteTrainingQueryOptions(com.ibm.watson.discovery.v2.model.DeleteTrainingQueryOptions) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) Test(org.testng.annotations.Test)

Aggregations

DeleteTrainingQueryOptions (com.ibm.watson.discovery.v2.model.DeleteTrainingQueryOptions)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 Test (org.testng.annotations.Test)1