Search in sources :

Example 6 with CreateCounterexampleOptions

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

the class ConversationServiceIT method testDeleteCounterexample.

/**
 * Test deleteCounterexample.
 */
@Test
public void testDeleteCounterexample() {
    // gotta be unique
    String counterExampleText = "Make me a " + UUID.randomUUID().toString() + " sandwich";
    CreateCounterexampleOptions createOptions = new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText).build();
    service.createCounterexample(createOptions).execute();
    DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText).build();
    service.deleteCounterexample(deleteOptions).execute();
    try {
        GetCounterexampleOptions getOptions = new GetCounterexampleOptions.Builder(workspaceId, counterExampleText).build();
        service.getCounterexample(getOptions).execute();
        fail("deleteCounterexample failed");
    } catch (Exception ex) {
        // Expected result
        assertTrue(ex instanceof NotFoundException);
    }
}
Also used : CreateCounterexampleOptions(com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexampleOptions) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) DeleteCounterexampleOptions(com.ibm.watson.developer_cloud.conversation.v1.model.DeleteCounterexampleOptions) GetCounterexampleOptions(com.ibm.watson.developer_cloud.conversation.v1.model.GetCounterexampleOptions) UnauthorizedException(com.ibm.watson.developer_cloud.service.exception.UnauthorizedException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) Test(org.junit.Test)

Example 7 with CreateCounterexampleOptions

use of com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexampleOptions 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 8 with CreateCounterexampleOptions

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

the class ConversationServiceIT method testCreateCounterexample.

/**
 * Test createCounterexample.
 */
@Test
public void testCreateCounterexample() {
    // gotta be unique
    String counterExampleText = "Make me a " + UUID.randomUUID().toString() + " sandwich";
    CreateCounterexampleOptions createOptions = new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText).build();
    Counterexample response = service.createCounterexample(createOptions).execute();
    try {
        assertNotNull(response);
        assertNotNull(response.getText());
        assertEquals(response.getText(), counterExampleText);
    } catch (Exception ex) {
        fail(ex.getMessage());
    } finally {
        // Clean up
        DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText).build();
        service.deleteCounterexample(deleteOptions).execute();
    }
}
Also used : CreateCounterexampleOptions(com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexampleOptions) 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 9 with CreateCounterexampleOptions

use of com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexampleOptions 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 10 with CreateCounterexampleOptions

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

the class AssistantServiceIT method testDeleteCounterexample.

/**
 * Test deleteCounterexample.
 */
@Test
public void testDeleteCounterexample() {
    // gotta be unique
    String counterExampleText = "Make me a " + UUID.randomUUID().toString() + " sandwich";
    CreateCounterexampleOptions createOptions = new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText).build();
    service.createCounterexample(createOptions).execute();
    DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText).build();
    service.deleteCounterexample(deleteOptions).execute();
    try {
        GetCounterexampleOptions getOptions = new GetCounterexampleOptions.Builder(workspaceId, counterExampleText).build();
        service.getCounterexample(getOptions).execute();
        fail("deleteCounterexample failed");
    } catch (Exception ex) {
        // Expected result
        assertTrue(ex instanceof NotFoundException);
    }
}
Also used : CreateCounterexampleOptions(com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexampleOptions) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) DeleteCounterexampleOptions(com.ibm.watson.developer_cloud.assistant.v1.model.DeleteCounterexampleOptions) GetCounterexampleOptions(com.ibm.watson.developer_cloud.assistant.v1.model.GetCounterexampleOptions) 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)12 UnauthorizedException (com.ibm.watson.developer_cloud.service.exception.UnauthorizedException)12 Test (org.junit.Test)12 CreateCounterexampleOptions (com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexampleOptions)6 DeleteCounterexampleOptions (com.ibm.watson.developer_cloud.assistant.v1.model.DeleteCounterexampleOptions)6 CreateCounterexampleOptions (com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexampleOptions)6 DeleteCounterexampleOptions (com.ibm.watson.developer_cloud.conversation.v1.model.DeleteCounterexampleOptions)6 Counterexample (com.ibm.watson.developer_cloud.conversation.v1.model.Counterexample)5 Counterexample (com.ibm.watson.developer_cloud.assistant.v1.model.Counterexample)4 CreateCounterexample (com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexample)4 CreateCounterexample (com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexample)4 Date (java.util.Date)4 CounterexampleCollection (com.ibm.watson.developer_cloud.assistant.v1.model.CounterexampleCollection)2 GetCounterexampleOptions (com.ibm.watson.developer_cloud.assistant.v1.model.GetCounterexampleOptions)2 ListCounterexamplesOptions (com.ibm.watson.developer_cloud.assistant.v1.model.ListCounterexamplesOptions)2 CounterexampleCollection (com.ibm.watson.developer_cloud.conversation.v1.model.CounterexampleCollection)2 GetCounterexampleOptions (com.ibm.watson.developer_cloud.conversation.v1.model.GetCounterexampleOptions)2 ListCounterexamplesOptions (com.ibm.watson.developer_cloud.conversation.v1.model.ListCounterexamplesOptions)2 JsonObject (com.google.gson.JsonObject)1 UpdateCounterexampleOptions (com.ibm.watson.developer_cloud.assistant.v1.model.UpdateCounterexampleOptions)1