Search in sources :

Example 16 with NotFoundException

use of com.ibm.watson.developer_cloud.service.exception.NotFoundException in project java-sdk by watson-developer-cloud.

the class AssistantServiceIT method testDeleteIntent.

/**
 * Test deleteIntent.
 */
@Test
public void testDeleteIntent() {
    // gotta be unique
    String intentName = "Hello" + UUID.randomUUID().toString();
    CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, intentName).build();
    service.createIntent(createOptions).execute();
    DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build();
    service.deleteIntent(deleteOptions).execute();
    try {
        GetIntentOptions getOptions = new GetIntentOptions.Builder(workspaceId, intentName).build();
        service.getIntent(getOptions).execute();
        fail("deleteIntent failed");
    } catch (Exception ex) {
        // Expected result
        assertTrue(ex instanceof NotFoundException);
    }
}
Also used : CreateIntentOptions(com.ibm.watson.developer_cloud.assistant.v1.model.CreateIntentOptions) DeleteIntentOptions(com.ibm.watson.developer_cloud.assistant.v1.model.DeleteIntentOptions) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) GetIntentOptions(com.ibm.watson.developer_cloud.assistant.v1.model.GetIntentOptions) UnauthorizedException(com.ibm.watson.developer_cloud.service.exception.UnauthorizedException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) Test(org.junit.Test)

Example 17 with NotFoundException

use of com.ibm.watson.developer_cloud.service.exception.NotFoundException 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)

Example 18 with NotFoundException

use of com.ibm.watson.developer_cloud.service.exception.NotFoundException in project java-sdk by watson-developer-cloud.

the class ConversationServiceIT method testDeleteWorkspace.

/**
 * Test deleteWorkspace.
 */
@Test
public void testDeleteWorkspace() {
    CreateWorkspaceOptions createOptions = new CreateWorkspaceOptions.Builder().build();
    String workspaceId = null;
    try {
        Workspace response = service.createWorkspace(createOptions).execute();
        assertNotNull(response);
        assertNotNull(response.getWorkspaceId());
        workspaceId = response.getWorkspaceId();
        DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build();
        service.deleteWorkspace(deleteOptions).execute();
        GetWorkspaceOptions getOptions = new GetWorkspaceOptions.Builder(workspaceId).export(true).build();
        service.getWorkspace(getOptions).execute();
    } catch (Exception ex) {
        // Expected result
        assertTrue(ex instanceof NotFoundException);
        workspaceId = null;
    } finally {
        // Clean up
        if (workspaceId != null) {
            DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build();
            service.deleteWorkspace(deleteOptions).execute();
        }
    }
}
Also used : DeleteWorkspaceOptions(com.ibm.watson.developer_cloud.conversation.v1.model.DeleteWorkspaceOptions) CreateWorkspaceOptions(com.ibm.watson.developer_cloud.conversation.v1.model.CreateWorkspaceOptions) 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) Workspace(com.ibm.watson.developer_cloud.conversation.v1.model.Workspace) GetWorkspaceOptions(com.ibm.watson.developer_cloud.conversation.v1.model.GetWorkspaceOptions) Test(org.junit.Test)

Example 19 with NotFoundException

use of com.ibm.watson.developer_cloud.service.exception.NotFoundException in project java-sdk by watson-developer-cloud.

the class EntitiesIT method testDeleteEntity.

/**
 * Test deleteEntity.
 */
@Test
public void testDeleteEntity() {
    // gotta be unique
    String entity = "Hello" + UUID.randomUUID().toString();
    CreateEntityOptions options = new CreateEntityOptions.Builder(workspaceId, entity).build();
    Entity response = service.createEntity(options).execute();
    try {
        assertNotNull(response);
        assertNotNull(response.getEntityName());
        assertEquals(response.getEntityName(), entity);
        assertNull(response.getDescription());
        assertNull(response.getMetadata());
        assertTrue(response.isFuzzyMatch() == null || response.isFuzzyMatch().equals(Boolean.FALSE));
    } catch (Exception ex) {
        DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build();
        service.deleteEntity(deleteOptions).execute();
        fail(ex.getMessage());
    }
    DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build();
    service.deleteEntity(deleteOptions).execute();
    try {
        GetEntityOptions getOptions = new GetEntityOptions.Builder(workspaceId, entity).build();
        service.getEntity(getOptions).execute();
        fail("deleteEntity failed");
    } catch (Exception ex) {
        // Expected result
        assertTrue(ex instanceof NotFoundException);
    }
}
Also used : Entity(com.ibm.watson.developer_cloud.conversation.v1.model.Entity) CreateEntityOptions(com.ibm.watson.developer_cloud.conversation.v1.model.CreateEntityOptions) DeleteEntityOptions(com.ibm.watson.developer_cloud.conversation.v1.model.DeleteEntityOptions) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) GetEntityOptions(com.ibm.watson.developer_cloud.conversation.v1.model.GetEntityOptions) Test(org.junit.Test)

Example 20 with NotFoundException

use of com.ibm.watson.developer_cloud.service.exception.NotFoundException in project java-sdk by watson-developer-cloud.

the class SynonymsIT method testDeleteSynonym.

/**
 * Test deleteSynonym.
 */
@Test
public void testDeleteSynonym() {
    String entity = "beverage";
    String entityValue = "orange juice";
    String synonym = "OJ";
    try {
        CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build();
        service.createEntity(createOptions).execute();
    } catch (Exception ex) {
        // Exception is okay if is for Unique Violation
        assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation"));
    }
    try {
        CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build();
        service.createValue(createOptions).execute();
    } catch (Exception ex) {
        // Exception is okay if is for Unique Violation
        assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation"));
    }
    CreateSynonymOptions createOptions = new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym).build();
    Synonym response = service.createSynonym(createOptions).execute();
    try {
        assertNotNull(response);
        assertNotNull(response.getSynonymText());
        assertEquals(response.getSynonymText(), synonym);
    } catch (Exception ex) {
        DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym).build();
        service.deleteSynonym(deleteOptions).execute();
        fail(ex.getMessage());
    }
    DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder().workspaceId(workspaceId).entity(entity).value(entityValue).synonym(synonym).build();
    service.deleteSynonym(deleteOptions).execute();
    try {
        GetSynonymOptions getOptions = new GetSynonymOptions.Builder(workspaceId, entity, entityValue, synonym).build();
        service.getSynonym(getOptions).execute();
        fail("deleteSynonym failed");
    } catch (Exception ex) {
        // Expected result
        assertTrue(ex instanceof NotFoundException);
    }
}
Also used : DeleteSynonymOptions(com.ibm.watson.developer_cloud.conversation.v1.model.DeleteSynonymOptions) CreateEntityOptions(com.ibm.watson.developer_cloud.conversation.v1.model.CreateEntityOptions) CreateValueOptions(com.ibm.watson.developer_cloud.conversation.v1.model.CreateValueOptions) GetSynonymOptions(com.ibm.watson.developer_cloud.conversation.v1.model.GetSynonymOptions) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) CreateSynonymOptions(com.ibm.watson.developer_cloud.conversation.v1.model.CreateSynonymOptions) Synonym(com.ibm.watson.developer_cloud.conversation.v1.model.Synonym) Test(org.junit.Test)

Aggregations

NotFoundException (com.ibm.watson.developer_cloud.service.exception.NotFoundException)22 Test (org.junit.Test)22 UnauthorizedException (com.ibm.watson.developer_cloud.service.exception.UnauthorizedException)13 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)3 CreateEntityOptions (com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntityOptions)3 CreateEntityOptions (com.ibm.watson.developer_cloud.conversation.v1.model.CreateEntityOptions)3 CreateCounterexampleOptions (com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexampleOptions)2 CreateValueOptions (com.ibm.watson.developer_cloud.assistant.v1.model.CreateValueOptions)2 DeleteCounterexampleOptions (com.ibm.watson.developer_cloud.assistant.v1.model.DeleteCounterexampleOptions)2 CreateCounterexampleOptions (com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexampleOptions)2 CreateValueOptions (com.ibm.watson.developer_cloud.conversation.v1.model.CreateValueOptions)2 DeleteCounterexampleOptions (com.ibm.watson.developer_cloud.conversation.v1.model.DeleteCounterexampleOptions)2 AssumptionViolatedException (org.junit.AssumptionViolatedException)2 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 Counterexample (com.ibm.watson.developer_cloud.assistant.v1.model.Counterexample)1 CounterexampleCollection (com.ibm.watson.developer_cloud.assistant.v1.model.CounterexampleCollection)1 CreateCounterexample (com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexample)1 CreateDialogNodeOptions (com.ibm.watson.developer_cloud.assistant.v1.model.CreateDialogNodeOptions)1 CreateExampleOptions (com.ibm.watson.developer_cloud.assistant.v1.model.CreateExampleOptions)1 CreateIntentOptions (com.ibm.watson.developer_cloud.assistant.v1.model.CreateIntentOptions)1