Search in sources :

Example 1 with UpdateCounterexampleOptions

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

the class ConversationServiceIT method testUpdateCounterexample.

/**
 * Test updateCounterexample.
 */
@Test
public void testUpdateCounterexample() {
    // gotta be unique
    String counterExampleText = "Make me a " + UUID.randomUUID().toString() + " sandwich";
    // gotta be unique
    String counterExampleText2 = "Make me a " + UUID.randomUUID().toString() + " sandwich";
    CreateCounterexampleOptions createOptions = new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText).build();
    service.createCounterexample(createOptions).execute();
    try {
        UpdateCounterexampleOptions updateOptions = new UpdateCounterexampleOptions.Builder(workspaceId, counterExampleText).newText(counterExampleText2).build();
        Counterexample response = service.updateCounterexample(updateOptions).execute();
        assertNotNull(response);
        assertNotNull(response.getText());
        assertEquals(response.getText(), counterExampleText2);
    } catch (Exception ex) {
        fail(ex.getMessage());
    } finally {
        // Clean up
        DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText2).build();
        service.deleteCounterexample(deleteOptions).execute();
    }
}
Also used : CreateCounterexampleOptions(com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexampleOptions) UpdateCounterexampleOptions(com.ibm.watson.developer_cloud.conversation.v1.model.UpdateCounterexampleOptions) DeleteCounterexampleOptions(com.ibm.watson.developer_cloud.conversation.v1.model.DeleteCounterexampleOptions) CreateCounterexample(com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexample) Counterexample(com.ibm.watson.developer_cloud.conversation.v1.model.Counterexample) UnauthorizedException(com.ibm.watson.developer_cloud.service.exception.UnauthorizedException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) Test(org.junit.Test)

Example 2 with UpdateCounterexampleOptions

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

the class AssistantServiceIT method testUpdateCounterexample.

/**
 * Test updateCounterexample.
 */
@Test
public void testUpdateCounterexample() {
    // gotta be unique
    String counterExampleText = "Make me a " + UUID.randomUUID().toString() + " sandwich";
    // gotta be unique
    String counterExampleText2 = "Make me a " + UUID.randomUUID().toString() + " sandwich";
    CreateCounterexampleOptions createOptions = new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText).build();
    service.createCounterexample(createOptions).execute();
    try {
        UpdateCounterexampleOptions updateOptions = new UpdateCounterexampleOptions.Builder(workspaceId, counterExampleText).newText(counterExampleText2).build();
        Counterexample response = service.updateCounterexample(updateOptions).execute();
        assertNotNull(response);
        assertNotNull(response.getText());
        assertEquals(response.getText(), counterExampleText2);
    } catch (Exception ex) {
        fail(ex.getMessage());
    } finally {
        // Clean up
        DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText2).build();
        service.deleteCounterexample(deleteOptions).execute();
    }
}
Also used : CreateCounterexampleOptions(com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexampleOptions) UpdateCounterexampleOptions(com.ibm.watson.developer_cloud.assistant.v1.model.UpdateCounterexampleOptions) DeleteCounterexampleOptions(com.ibm.watson.developer_cloud.assistant.v1.model.DeleteCounterexampleOptions) Counterexample(com.ibm.watson.developer_cloud.assistant.v1.model.Counterexample) CreateCounterexample(com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexample) UnauthorizedException(com.ibm.watson.developer_cloud.service.exception.UnauthorizedException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) Test(org.junit.Test)

Example 3 with UpdateCounterexampleOptions

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

the class Conversation method updateCounterexample.

/**
 * Update counterexample.
 *
 * Update the text of a counterexample. Counterexamples are examples that have been marked as irrelevant input.
 *
 * @param updateCounterexampleOptions the {@link UpdateCounterexampleOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Counterexample}
 */
public ServiceCall<Counterexample> updateCounterexample(UpdateCounterexampleOptions updateCounterexampleOptions) {
    Validator.notNull(updateCounterexampleOptions, "updateCounterexampleOptions cannot be null");
    String[] pathSegments = { "v1/workspaces", "counterexamples" };
    String[] pathParameters = { updateCounterexampleOptions.workspaceId(), updateCounterexampleOptions.text() };
    RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    final JsonObject contentJson = new JsonObject();
    if (updateCounterexampleOptions.newText() != null) {
        contentJson.addProperty("text", updateCounterexampleOptions.newText());
    }
    builder.bodyJson(contentJson);
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Counterexample.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) JsonObject(com.google.gson.JsonObject) Counterexample(com.ibm.watson.developer_cloud.conversation.v1.model.Counterexample)

Aggregations

Counterexample (com.ibm.watson.developer_cloud.conversation.v1.model.Counterexample)2 NotFoundException (com.ibm.watson.developer_cloud.service.exception.NotFoundException)2 UnauthorizedException (com.ibm.watson.developer_cloud.service.exception.UnauthorizedException)2 Test (org.junit.Test)2 JsonObject (com.google.gson.JsonObject)1 Counterexample (com.ibm.watson.developer_cloud.assistant.v1.model.Counterexample)1 CreateCounterexample (com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexample)1 CreateCounterexampleOptions (com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexampleOptions)1 DeleteCounterexampleOptions (com.ibm.watson.developer_cloud.assistant.v1.model.DeleteCounterexampleOptions)1 UpdateCounterexampleOptions (com.ibm.watson.developer_cloud.assistant.v1.model.UpdateCounterexampleOptions)1 CreateCounterexample (com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexample)1 CreateCounterexampleOptions (com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexampleOptions)1 DeleteCounterexampleOptions (com.ibm.watson.developer_cloud.conversation.v1.model.DeleteCounterexampleOptions)1 UpdateCounterexampleOptions (com.ibm.watson.developer_cloud.conversation.v1.model.UpdateCounterexampleOptions)1 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1