Search in sources :

Example 11 with CreateDialogNodeOptions

use of com.ibm.watson.assistant.v1.model.CreateDialogNodeOptions 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 12 with CreateDialogNodeOptions

use of com.ibm.watson.assistant.v1.model.CreateDialogNodeOptions in project java-sdk by watson-developer-cloud.

the class AssistantTest method testCreateDialogNodeOptionsBuilder.

/**
 * Test CreateDialogNodeOptions builder.
 */
@Test
public void testCreateDialogNodeOptionsBuilder() {
    String dialogNodeName = "aDialogNode";
    DialogNodeAction action0 = new DialogNodeAction();
    action0.setName("action0");
    action0.setCredentials("credential0");
    DialogNodeAction action1 = new DialogNodeAction();
    action1.setName("action1");
    action1.setCredentials("credential1");
    CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder().workspaceId(WORKSPACE_ID).dialogNode(dialogNodeName).addActions(action0).addActions(action1).digressIn(CreateDialogNodeOptions.DigressIn.RETURNS).digressOut(CreateDialogNodeOptions.DigressOut.ALLOW_ALL).digressOutSlots(CreateDialogNodeOptions.DigressOutSlots.ALLOW_ALL).build();
    assertEquals(createOptions.workspaceId(), WORKSPACE_ID);
    assertEquals(createOptions.dialogNode(), dialogNodeName);
    assertEquals(createOptions.actions().size(), 2);
    assertEquals(createOptions.actions().get(0), action0);
    assertEquals(createOptions.actions().get(0).getCredentials(), "credential0");
    assertEquals(createOptions.actions().get(1), action1);
    assertEquals(createOptions.actions().get(1).getCredentials(), "credential1");
    assertEquals(createOptions.digressIn(), CreateDialogNodeOptions.DigressIn.RETURNS);
    assertEquals(createOptions.digressOut(), CreateDialogNodeOptions.DigressOut.ALLOW_ALL);
    assertEquals(createOptions.digressOutSlots(), CreateDialogNodeOptions.DigressOutSlots.ALLOW_ALL);
}
Also used : DialogNodeAction(com.ibm.watson.developer_cloud.assistant.v1.model.DialogNodeAction) CreateDialogNodeOptions(com.ibm.watson.developer_cloud.assistant.v1.model.CreateDialogNodeOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 13 with CreateDialogNodeOptions

use of com.ibm.watson.assistant.v1.model.CreateDialogNodeOptions in project java-sdk by watson-developer-cloud.

the class ConversationServiceIT method testCreateDialogNode.

/**
 * Test createDialogNode.
 */
@Test
public void testCreateDialogNode() {
    String dialogNodeName = "Test" + UUID.randomUUID().toString();
    String dialogNodeDescription = "Description of " + dialogNodeName;
    CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName).description(dialogNodeDescription).build();
    DialogNode response = service.createDialogNode(createOptions).execute();
    try {
        assertNotNull(response);
        assertNotNull(response.getDialogNodeId());
        assertEquals(response.getDialogNodeId(), dialogNodeName);
        assertNotNull(response.getDescription());
        assertEquals(response.getDescription(), dialogNodeDescription);
    } 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) CreateDialogNodeOptions(com.ibm.watson.developer_cloud.conversation.v1.model.CreateDialogNodeOptions) DialogNode(com.ibm.watson.developer_cloud.conversation.v1.model.DialogNode) UnauthorizedException(com.ibm.watson.developer_cloud.service.exception.UnauthorizedException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) Test(org.junit.Test)

Example 14 with CreateDialogNodeOptions

use of com.ibm.watson.assistant.v1.model.CreateDialogNodeOptions 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 15 with CreateDialogNodeOptions

use of com.ibm.watson.assistant.v1.model.CreateDialogNodeOptions 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

Test (org.junit.Test)14 NotFoundException (com.ibm.watson.developer_cloud.service.exception.NotFoundException)12 UnauthorizedException (com.ibm.watson.developer_cloud.service.exception.UnauthorizedException)12 CreateDialogNodeOptions (com.ibm.watson.developer_cloud.assistant.v1.model.CreateDialogNodeOptions)7 CreateDialogNodeOptions (com.ibm.watson.developer_cloud.conversation.v1.model.CreateDialogNodeOptions)7 DeleteDialogNodeOptions (com.ibm.watson.developer_cloud.assistant.v1.model.DeleteDialogNodeOptions)6 DeleteDialogNodeOptions (com.ibm.watson.developer_cloud.conversation.v1.model.DeleteDialogNodeOptions)6 DialogNode (com.ibm.watson.developer_cloud.assistant.v1.model.DialogNode)4 DialogNode (com.ibm.watson.developer_cloud.conversation.v1.model.DialogNode)4 Date (java.util.Date)4 DialogNode (com.ibm.watson.assistant.v1.model.DialogNode)2 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)2 DialogNodeCollection (com.ibm.watson.developer_cloud.assistant.v1.model.DialogNodeCollection)2 GetDialogNodeOptions (com.ibm.watson.developer_cloud.assistant.v1.model.GetDialogNodeOptions)2 ListDialogNodesOptions (com.ibm.watson.developer_cloud.assistant.v1.model.ListDialogNodesOptions)2 DialogNodeCollection (com.ibm.watson.developer_cloud.conversation.v1.model.DialogNodeCollection)2 GetDialogNodeOptions (com.ibm.watson.developer_cloud.conversation.v1.model.GetDialogNodeOptions)2 ListDialogNodesOptions (com.ibm.watson.developer_cloud.conversation.v1.model.ListDialogNodesOptions)2 HashMap (java.util.HashMap)2 JsonObject (com.google.gson.JsonObject)1