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();
}
}
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();
}
}
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));
}
Aggregations