Search in sources :

Example 1 with TrainingDataSet

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

the class DiscoveryServiceIT method deleteTrainingDataQueryIsSuccessful.

@Test
public void deleteTrainingDataQueryIsSuccessful() {
    TrainingQuery query = createTestQuery(collectionId, "Query" + UUID.randomUUID().toString());
    String queryId = query.getQueryId();
    ListTrainingDataOptions.Builder listBuilder = new ListTrainingDataOptions.Builder(environmentId, collectionId);
    TrainingDataSet trainingData = discovery.listTrainingData(listBuilder.build()).execute();
    List<TrainingQuery> queryList = trainingData.getQueries();
    boolean doesQueryExist = false;
    for (TrainingQuery q : queryList) {
        if (q.getQueryId().equals(queryId)) {
            doesQueryExist = true;
            break;
        }
    }
    assertTrue(doesQueryExist);
    DeleteTrainingDataOptions.Builder deleteBuilder = new DeleteTrainingDataOptions.Builder(environmentId, collectionId, queryId);
    discovery.deleteTrainingData(deleteBuilder.build()).execute();
    listBuilder = new ListTrainingDataOptions.Builder(environmentId, collectionId);
    trainingData = discovery.listTrainingData(listBuilder.build()).execute();
    queryList = trainingData.getQueries();
    doesQueryExist = false;
    for (TrainingQuery q : queryList) {
        if (q.getQueryId().equals(queryId)) {
            doesQueryExist = true;
            break;
        }
    }
    assertFalse(doesQueryExist);
}
Also used : ListTrainingDataOptions(com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingDataOptions) TrainingDataSet(com.ibm.watson.developer_cloud.discovery.v1.model.TrainingDataSet) DeleteTrainingDataOptions(com.ibm.watson.developer_cloud.discovery.v1.model.DeleteTrainingDataOptions) TrainingQuery(com.ibm.watson.developer_cloud.discovery.v1.model.TrainingQuery) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 2 with TrainingDataSet

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

the class DiscoveryServiceTest method listTrainingDataIsSuccessful.

@Test
public void listTrainingDataIsSuccessful() throws InterruptedException {
    server.enqueue(jsonResponse(listTrainingDataResp));
    ListTrainingDataOptions getRequest = new ListTrainingDataOptions.Builder(environmentId, collectionId).build();
    TrainingDataSet response = discoveryService.listTrainingData(getRequest).execute();
    RecordedRequest request = server.takeRequest();
    assertEquals(TRAINING1_PATH, request.getPath());
    assertEquals(GET, request.getMethod());
    assertEquals(listTrainingDataResp, response);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ListTrainingDataOptions(com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingDataOptions) TrainingDataSet(com.ibm.watson.developer_cloud.discovery.v1.model.TrainingDataSet) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 3 with TrainingDataSet

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

the class DiscoveryServiceIT method deleteAllCollectionTrainingDataIsSuccessful.

@Test
public void deleteAllCollectionTrainingDataIsSuccessful() {
    String collId = setupTestQueries(collectionId);
    DeleteAllTrainingDataOptions.Builder deleteBuilder = new DeleteAllTrainingDataOptions.Builder(environmentId, collId);
    discovery.deleteAllTrainingData(deleteBuilder.build()).execute();
    ListTrainingDataOptions.Builder listBuilder = new ListTrainingDataOptions.Builder(environmentId, collId);
    TrainingDataSet trainingData = discovery.listTrainingData(listBuilder.build()).execute();
    assertEquals(trainingData.getQueries().size(), 0);
}
Also used : ListTrainingDataOptions(com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingDataOptions) DeleteAllTrainingDataOptions(com.ibm.watson.developer_cloud.discovery.v1.model.DeleteAllTrainingDataOptions) TrainingDataSet(com.ibm.watson.developer_cloud.discovery.v1.model.TrainingDataSet) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 4 with TrainingDataSet

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

the class Discovery method listTrainingData.

/**
 * Lists the training data for this collection.
 *
 * @param listTrainingDataOptions the {@link ListTrainingDataOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link TrainingDataSet}
 */
public ServiceCall<TrainingDataSet> listTrainingData(ListTrainingDataOptions listTrainingDataOptions) {
    Validator.notNull(listTrainingDataOptions, "listTrainingDataOptions cannot be null");
    String[] pathSegments = { "v1/environments", "collections", "training_data" };
    String[] pathParameters = { listTrainingDataOptions.environmentId(), listTrainingDataOptions.collectionId() };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingDataSet.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) TrainingDataSet(com.ibm.watson.developer_cloud.discovery.v1.model.TrainingDataSet)

Aggregations

TrainingDataSet (com.ibm.watson.developer_cloud.discovery.v1.model.TrainingDataSet)4 ListTrainingDataOptions (com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingDataOptions)3 Test (org.junit.Test)3 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)2 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 DeleteAllTrainingDataOptions (com.ibm.watson.developer_cloud.discovery.v1.model.DeleteAllTrainingDataOptions)1 DeleteTrainingDataOptions (com.ibm.watson.developer_cloud.discovery.v1.model.DeleteTrainingDataOptions)1 TrainingQuery (com.ibm.watson.developer_cloud.discovery.v1.model.TrainingQuery)1 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1