Search in sources :

Example 6 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.assistant.v1.model.Entity) CreateEntityOptions(com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntityOptions) DeleteEntityOptions(com.ibm.watson.developer_cloud.assistant.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.assistant.v1.model.GetEntityOptions) Test(org.junit.Test)

Example 7 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.assistant.v1.model.DeleteSynonymOptions) CreateEntityOptions(com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntityOptions) CreateValueOptions(com.ibm.watson.developer_cloud.assistant.v1.model.CreateValueOptions) GetSynonymOptions(com.ibm.watson.developer_cloud.assistant.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.assistant.v1.model.CreateSynonymOptions) Synonym(com.ibm.watson.developer_cloud.assistant.v1.model.Synonym) Test(org.junit.Test)

Example 8 with NotFoundException

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

the class ValuesIT method testDeleteValue.

/**
 * Test deleteValue.
 */
@Test
public void testDeleteValue() {
    String entity = "beverage";
    String entityValue = "coffee" + UUID.randomUUID().toString();
    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"));
    }
    CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build();
    Value response = service.createValue(createOptions).execute();
    try {
        assertNotNull(response);
        assertNotNull(response.getValueText());
        assertEquals(response.getValueText(), entityValue);
        assertNull(response.getMetadata());
    } catch (Exception ex) {
        // Clean up
        DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue).build();
        service.deleteValue(deleteOptions).execute();
        fail(ex.getMessage());
    }
    DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder().workspaceId(workspaceId).entity(entity).value(entityValue).build();
    service.deleteValue(deleteOptions).execute();
    try {
        GetValueOptions getOptions = new GetValueOptions.Builder(workspaceId, entity, entityValue).build();
        service.getValue(getOptions).execute();
        fail("deleteValue failed");
    } catch (Exception ex) {
        // Expected result
        assertTrue(ex instanceof NotFoundException);
    }
}
Also used : GetValueOptions(com.ibm.watson.developer_cloud.assistant.v1.model.GetValueOptions) CreateEntityOptions(com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntityOptions) DeleteValueOptions(com.ibm.watson.developer_cloud.assistant.v1.model.DeleteValueOptions) CreateValueOptions(com.ibm.watson.developer_cloud.assistant.v1.model.CreateValueOptions) Value(com.ibm.watson.developer_cloud.assistant.v1.model.Value) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) NotFoundException(com.ibm.watson.developer_cloud.service.exception.NotFoundException) Test(org.junit.Test)

Example 9 with NotFoundException

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

the class AssistantServiceIT method testDeleteExample.

/**
 * Test deleteExample.
 */
@Test
public void testDeleteExample() {
    createExampleIntent();
    // gotta be unique
    String exampleText = "Howdy " + UUID.randomUUID().toString();
    CreateExampleOptions createOptions = new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build();
    service.createExample(createOptions).execute();
    DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build();
    service.deleteExample(deleteOptions).execute();
    try {
        GetExampleOptions getOptions = new GetExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build();
        service.getExample(getOptions).execute();
        fail("deleteCounterexample failed");
    } catch (Exception ex) {
        // Expected result
        assertTrue(ex instanceof NotFoundException);
    }
}
Also used : CreateExampleOptions(com.ibm.watson.developer_cloud.assistant.v1.model.CreateExampleOptions) GetExampleOptions(com.ibm.watson.developer_cloud.assistant.v1.model.GetExampleOptions) DeleteExampleOptions(com.ibm.watson.developer_cloud.assistant.v1.model.DeleteExampleOptions) 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 10 with NotFoundException

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

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