Search in sources :

Example 1 with GetDialogNodeOptions

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

the class Conversation method getDialogNode.

/**
 * Get dialog node.
 *
 * Get information about a dialog node.
 *
 * @param getDialogNodeOptions the {@link GetDialogNodeOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link DialogNode}
 */
public ServiceCall<DialogNode> getDialogNode(GetDialogNodeOptions getDialogNodeOptions) {
    Validator.notNull(getDialogNodeOptions, "getDialogNodeOptions cannot be null");
    String[] pathSegments = { "v1/workspaces", "dialog_nodes" };
    String[] pathParameters = { getDialogNodeOptions.workspaceId(), getDialogNodeOptions.dialogNode() };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    if (getDialogNodeOptions.includeAudit() != null) {
        builder.query("include_audit", String.valueOf(getDialogNodeOptions.includeAudit()));
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DialogNode.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) DialogNode(com.ibm.watson.developer_cloud.conversation.v1.model.DialogNode)

Example 2 with GetDialogNodeOptions

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

the class AssistantServiceIT method testDeleteDialogNode.

/**
 * Test deleteDialogNode.
 */
@Test
public void testDeleteDialogNode() {
    // gotta be unique
    String dialogNodeName = "Test" + UUID.randomUUID().toString();
    CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName).build();
    service.createDialogNode(createOptions).execute();
    DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build();
    service.deleteDialogNode(deleteOptions).execute();
    try {
        GetDialogNodeOptions getOptions = new GetDialogNodeOptions.Builder(workspaceId, dialogNodeName).build();
        service.getDialogNode(getOptions).execute();
        fail("deleteDialogNode failed");
    } catch (Exception ex) {
        // Expected result
        assertTrue(ex instanceof NotFoundException);
    }
}
Also used : DeleteDialogNodeOptions(com.ibm.watson.developer_cloud.assistant.v1.model.DeleteDialogNodeOptions) GetDialogNodeOptions(com.ibm.watson.developer_cloud.assistant.v1.model.GetDialogNodeOptions) CreateDialogNodeOptions(com.ibm.watson.developer_cloud.assistant.v1.model.CreateDialogNodeOptions) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) 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 GetDialogNodeOptions

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

the class AssistantServiceIT method testGetDialogNode.

/**
 * Test getDialogNode.
 */
@Test
public void testGetDialogNode() {
    String dialogNodeName = "Test" + UUID.randomUUID().toString();
    String dialogNodeDescription = "Description of " + dialogNodeName;
    Date start = new Date();
    CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName).description(dialogNodeDescription).build();
    service.createDialogNode(createOptions).execute();
    try {
        GetDialogNodeOptions getOptions = new GetDialogNodeOptions.Builder().workspaceId(workspaceId).dialogNode(dialogNodeName).includeAudit(true).build();
        DialogNode response = service.getDialogNode(getOptions).execute();
        assertNotNull(response);
        assertNotNull(response.getDialogNodeId());
        assertEquals(response.getDialogNodeId(), dialogNodeName);
        assertNotNull(response.getDescription());
        assertEquals(response.getDescription(), dialogNodeDescription);
        assertNotNull(response.getCreated());
        assertNotNull(response.getUpdated());
        Date now = new Date();
        assertTrue(fuzzyBefore(response.getCreated(), now));
        assertTrue(fuzzyAfter(response.getCreated(), start));
        assertTrue(fuzzyBefore(response.getUpdated(), now));
        assertTrue(fuzzyAfter(response.getUpdated(), start));
    } catch (Exception ex) {
        fail(ex.getMessage());
    } finally {
        // Clean up
        DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build();
        service.deleteDialogNode(deleteOptions).execute();
    }
}
Also used : DeleteDialogNodeOptions(com.ibm.watson.developer_cloud.assistant.v1.model.DeleteDialogNodeOptions) GetDialogNodeOptions(com.ibm.watson.developer_cloud.assistant.v1.model.GetDialogNodeOptions) CreateDialogNodeOptions(com.ibm.watson.developer_cloud.assistant.v1.model.CreateDialogNodeOptions) DialogNode(com.ibm.watson.developer_cloud.assistant.v1.model.DialogNode) Date(java.util.Date) UnauthorizedException(com.ibm.watson.developer_cloud.service.exception.UnauthorizedException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) Test(org.junit.Test)

Example 4 with GetDialogNodeOptions

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

the class ConversationServiceIT method testGetDialogNode.

/**
 * Test getDialogNode.
 */
@Test
public void testGetDialogNode() {
    String dialogNodeName = "Test" + UUID.randomUUID().toString();
    String dialogNodeDescription = "Description of " + dialogNodeName;
    Date start = new Date();
    CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName).description(dialogNodeDescription).build();
    service.createDialogNode(createOptions).execute();
    try {
        GetDialogNodeOptions getOptions = new GetDialogNodeOptions.Builder().workspaceId(workspaceId).dialogNode(dialogNodeName).includeAudit(true).build();
        DialogNode response = service.getDialogNode(getOptions).execute();
        assertNotNull(response);
        assertNotNull(response.getDialogNodeId());
        assertEquals(response.getDialogNodeId(), dialogNodeName);
        assertNotNull(response.getDescription());
        assertEquals(response.getDescription(), dialogNodeDescription);
        assertNotNull(response.getCreated());
        assertNotNull(response.getUpdated());
        Date now = new Date();
        assertTrue(fuzzyBefore(response.getCreated(), now));
        assertTrue(fuzzyAfter(response.getCreated(), start));
        assertTrue(fuzzyBefore(response.getUpdated(), now));
        assertTrue(fuzzyAfter(response.getUpdated(), start));
    } catch (Exception ex) {
        fail(ex.getMessage());
    } finally {
        // Clean up
        DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build();
        service.deleteDialogNode(deleteOptions).execute();
    }
}
Also used : DeleteDialogNodeOptions(com.ibm.watson.developer_cloud.conversation.v1.model.DeleteDialogNodeOptions) GetDialogNodeOptions(com.ibm.watson.developer_cloud.conversation.v1.model.GetDialogNodeOptions) CreateDialogNodeOptions(com.ibm.watson.developer_cloud.conversation.v1.model.CreateDialogNodeOptions) DialogNode(com.ibm.watson.developer_cloud.conversation.v1.model.DialogNode) Date(java.util.Date) UnauthorizedException(com.ibm.watson.developer_cloud.service.exception.UnauthorizedException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) Test(org.junit.Test)

Example 5 with GetDialogNodeOptions

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

the class ConversationServiceIT method testDeleteDialogNode.

/**
 * Test deleteDialogNode.
 */
@Test
public void testDeleteDialogNode() {
    // gotta be unique
    String dialogNodeName = "Test" + UUID.randomUUID().toString();
    CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName).build();
    service.createDialogNode(createOptions).execute();
    DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build();
    service.deleteDialogNode(deleteOptions).execute();
    try {
        GetDialogNodeOptions getOptions = new GetDialogNodeOptions.Builder(workspaceId, dialogNodeName).build();
        service.getDialogNode(getOptions).execute();
        fail("deleteDialogNode failed");
    } catch (Exception ex) {
        // Expected result
        assertTrue(ex instanceof NotFoundException);
    }
}
Also used : DeleteDialogNodeOptions(com.ibm.watson.developer_cloud.conversation.v1.model.DeleteDialogNodeOptions) GetDialogNodeOptions(com.ibm.watson.developer_cloud.conversation.v1.model.GetDialogNodeOptions) CreateDialogNodeOptions(com.ibm.watson.developer_cloud.conversation.v1.model.CreateDialogNodeOptions) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) UnauthorizedException(com.ibm.watson.developer_cloud.service.exception.UnauthorizedException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) Test(org.junit.Test)

Aggregations

NotFoundException (com.ibm.watson.developer_cloud.service.exception.NotFoundException)4 UnauthorizedException (com.ibm.watson.developer_cloud.service.exception.UnauthorizedException)4 Test (org.junit.Test)4 CreateDialogNodeOptions (com.ibm.watson.developer_cloud.assistant.v1.model.CreateDialogNodeOptions)2 DeleteDialogNodeOptions (com.ibm.watson.developer_cloud.assistant.v1.model.DeleteDialogNodeOptions)2 GetDialogNodeOptions (com.ibm.watson.developer_cloud.assistant.v1.model.GetDialogNodeOptions)2 CreateDialogNodeOptions (com.ibm.watson.developer_cloud.conversation.v1.model.CreateDialogNodeOptions)2 DeleteDialogNodeOptions (com.ibm.watson.developer_cloud.conversation.v1.model.DeleteDialogNodeOptions)2 DialogNode (com.ibm.watson.developer_cloud.conversation.v1.model.DialogNode)2 GetDialogNodeOptions (com.ibm.watson.developer_cloud.conversation.v1.model.GetDialogNodeOptions)2 Date (java.util.Date)2 DialogNode (com.ibm.watson.developer_cloud.assistant.v1.model.DialogNode)1 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1