use of com.ibm.watson.developer_cloud.assistant.v1.model.UpdateDialogNodeOptions in project java-sdk by watson-developer-cloud.
the class ConversationServiceIT method testUpdateDialogNode.
/**
* Test updateDialogNode.
*/
@Test
public void testUpdateDialogNode() {
String dialogNodeName = "Test" + UUID.randomUUID().toString();
String dialogNodeDescription = "Description of " + dialogNodeName;
CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName).description(dialogNodeDescription).build();
service.createDialogNode(createOptions).execute();
String dialogNodeName2 = "Test2" + UUID.randomUUID().toString();
try {
String dialogNodeDescription2 = "Updated description of " + dialogNodeName;
UpdateDialogNodeOptions updateOptions = new UpdateDialogNodeOptions.Builder().workspaceId(workspaceId).dialogNode(dialogNodeName).newDialogNode(dialogNodeName2).newDescription(dialogNodeDescription2).build();
DialogNode response = service.updateDialogNode(updateOptions).execute();
assertNotNull(response);
assertNotNull(response.getDialogNodeId());
assertEquals(response.getDialogNodeId(), dialogNodeName2);
assertNotNull(response.getDescription());
assertEquals(response.getDescription(), dialogNodeDescription2);
} catch (Exception ex) {
fail(ex.getMessage());
} finally {
// Clean up
DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName2).build();
service.deleteDialogNode(deleteOptions).execute();
}
}
use of com.ibm.watson.developer_cloud.assistant.v1.model.UpdateDialogNodeOptions in project java-sdk by watson-developer-cloud.
the class AssistantServiceIT method testUpdateDialogNode.
/**
* Test updateDialogNode.
*/
@Test
public void testUpdateDialogNode() {
String dialogNodeName = "Test" + UUID.randomUUID().toString();
String dialogNodeDescription = "Description of " + dialogNodeName;
CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName).description(dialogNodeDescription).build();
service.createDialogNode(createOptions).execute();
String dialogNodeName2 = "Test2" + UUID.randomUUID().toString();
try {
String dialogNodeDescription2 = "Updated description of " + dialogNodeName;
UpdateDialogNodeOptions updateOptions = new UpdateDialogNodeOptions.Builder().workspaceId(workspaceId).dialogNode(dialogNodeName).newDialogNode(dialogNodeName2).newDescription(dialogNodeDescription2).build();
DialogNode response = service.updateDialogNode(updateOptions).execute();
assertNotNull(response);
assertNotNull(response.getDialogNodeId());
assertEquals(response.getDialogNodeId(), dialogNodeName2);
assertNotNull(response.getDescription());
assertEquals(response.getDescription(), dialogNodeDescription2);
} catch (Exception ex) {
fail(ex.getMessage());
} finally {
// Clean up
DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName2).build();
service.deleteDialogNode(deleteOptions).execute();
}
}
use of com.ibm.watson.developer_cloud.assistant.v1.model.UpdateDialogNodeOptions in project java-sdk by watson-developer-cloud.
the class AssistantTest method testUpdateDialogNodeOptionsBuilder.
/**
* Test UpdateDialogNodeOptions builder.
*/
@Test
public void testUpdateDialogNodeOptionsBuilder() {
String dialogNodeName = "aDialogNode";
String newDialogNodeName = "renamedDialogNode";
DialogNodeAction action0 = new DialogNodeAction();
action0.setName("action0");
action0.setCredentials("credential0");
DialogNodeAction action1 = new DialogNodeAction();
action1.setName("action1");
action1.setCredentials("credential1");
UpdateDialogNodeOptions updateOptions = new UpdateDialogNodeOptions.Builder().workspaceId(WORKSPACE_ID).dialogNode(dialogNodeName).newDialogNode(newDialogNodeName).addNewActions(action0).addNewActions(action1).newDigressIn(UpdateDialogNodeOptions.NewDigressIn.RETURNS).newDigressOut(UpdateDialogNodeOptions.NewDigressOut.ALLOW_ALL).newDigressOutSlots(UpdateDialogNodeOptions.NewDigressOutSlots.ALLOW_ALL).build();
assertEquals(updateOptions.workspaceId(), WORKSPACE_ID);
assertEquals(updateOptions.dialogNode(), dialogNodeName);
assertEquals(updateOptions.newActions().size(), 2);
assertEquals(updateOptions.newActions().get(0), action0);
assertEquals(updateOptions.newActions().get(0).getCredentials(), "credential0");
assertEquals(updateOptions.newActions().get(1), action1);
assertEquals(updateOptions.newActions().get(1).getCredentials(), "credential1");
assertEquals(updateOptions.newDigressIn(), UpdateDialogNodeOptions.NewDigressIn.RETURNS);
assertEquals(updateOptions.newDigressOut(), UpdateDialogNodeOptions.NewDigressOut.ALLOW_ALL);
assertEquals(updateOptions.newDigressOutSlots(), UpdateDialogNodeOptions.NewDigressOutSlots.ALLOW_ALL);
}
use of com.ibm.watson.developer_cloud.assistant.v1.model.UpdateDialogNodeOptions in project java-sdk by watson-developer-cloud.
the class ConversationTest method testUpdateDialogNodeOptionsBuilder.
/**
* Test UpdateDialogNodeOptions builder.
*/
@Test
public void testUpdateDialogNodeOptionsBuilder() {
String dialogNodeName = "aDialogNode";
String newDialogNodeName = "renamedDialogNode";
DialogNodeAction action0 = new DialogNodeAction();
action0.setName("action0");
action0.setCredentials("credential0");
DialogNodeAction action1 = new DialogNodeAction();
action1.setName("action1");
action1.setCredentials("credential1");
UpdateDialogNodeOptions updateOptions = new UpdateDialogNodeOptions.Builder().workspaceId(WORKSPACE_ID).dialogNode(dialogNodeName).newDialogNode(newDialogNodeName).addNewActions(action0).addNewActions(action1).build();
assertEquals(updateOptions.workspaceId(), WORKSPACE_ID);
assertEquals(updateOptions.dialogNode(), dialogNodeName);
assertEquals(updateOptions.newActions().size(), 2);
assertEquals(updateOptions.newActions().get(0), action0);
assertEquals(updateOptions.newActions().get(0).getCredentials(), "credential0");
assertEquals(updateOptions.newActions().get(1), action1);
assertEquals(updateOptions.newActions().get(1).getCredentials(), "credential1");
}
use of com.ibm.watson.developer_cloud.assistant.v1.model.UpdateDialogNodeOptions in project java-sdk by watson-developer-cloud.
the class Assistant method updateDialogNode.
/**
* Update dialog node.
*
* Update an existing dialog node with new or modified data. This operation is limited to 500 requests per 30 minutes.
* For more information, see **Rate limiting**.
*
* @param updateDialogNodeOptions the {@link UpdateDialogNodeOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link DialogNode}
*/
public ServiceCall<DialogNode> updateDialogNode(UpdateDialogNodeOptions updateDialogNodeOptions) {
Validator.notNull(updateDialogNodeOptions, "updateDialogNodeOptions cannot be null");
String[] pathSegments = { "v1/workspaces", "dialog_nodes" };
String[] pathParameters = { updateDialogNodeOptions.workspaceId(), updateDialogNodeOptions.dialogNode() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
final JsonObject contentJson = new JsonObject();
if (updateDialogNodeOptions.nodeType() != null) {
contentJson.addProperty("type", updateDialogNodeOptions.nodeType());
}
if (updateDialogNodeOptions.newActions() != null) {
contentJson.add("actions", GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newActions()));
}
if (updateDialogNodeOptions.newConditions() != null) {
contentJson.addProperty("conditions", updateDialogNodeOptions.newConditions());
}
if (updateDialogNodeOptions.newContext() != null) {
contentJson.add("context", GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newContext()));
}
if (updateDialogNodeOptions.newPreviousSibling() != null) {
contentJson.addProperty("previous_sibling", updateDialogNodeOptions.newPreviousSibling());
}
if (updateDialogNodeOptions.newVariable() != null) {
contentJson.addProperty("variable", updateDialogNodeOptions.newVariable());
}
if (updateDialogNodeOptions.newMetadata() != null) {
contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newMetadata()));
}
if (updateDialogNodeOptions.newTitle() != null) {
contentJson.addProperty("title", updateDialogNodeOptions.newTitle());
}
if (updateDialogNodeOptions.newDescription() != null) {
contentJson.addProperty("description", updateDialogNodeOptions.newDescription());
}
if (updateDialogNodeOptions.newDigressOut() != null) {
contentJson.addProperty("digress_out", updateDialogNodeOptions.newDigressOut());
}
if (updateDialogNodeOptions.newEventName() != null) {
contentJson.addProperty("event_name", updateDialogNodeOptions.newEventName());
}
if (updateDialogNodeOptions.newDigressOutSlots() != null) {
contentJson.addProperty("digress_out_slots", updateDialogNodeOptions.newDigressOutSlots());
}
if (updateDialogNodeOptions.newNextStep() != null) {
contentJson.add("next_step", GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newNextStep()));
}
if (updateDialogNodeOptions.newDigressIn() != null) {
contentJson.addProperty("digress_in", updateDialogNodeOptions.newDigressIn());
}
if (updateDialogNodeOptions.newOutput() != null) {
contentJson.add("output", GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newOutput()));
}
if (updateDialogNodeOptions.newParent() != null) {
contentJson.addProperty("parent", updateDialogNodeOptions.newParent());
}
if (updateDialogNodeOptions.newDialogNode() != null) {
contentJson.addProperty("dialog_node", updateDialogNodeOptions.newDialogNode());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DialogNode.class));
}
Aggregations