use of com.ibm.watson.developer_cloud.service.exception.NotFoundException in project java-sdk by watson-developer-cloud.
the class NaturalLanguageClassifierIT method dClassify.
/**
* Test classify. Use the pre created classifier to avoid waiting for availability
*/
@Test
public void dClassify() {
Classification classification = null;
try {
ClassifyOptions classifyOptions = new ClassifyOptions.Builder().classifierId(preCreatedClassifierId).text("is it hot outside?").build();
classification = service.classify(classifyOptions).execute();
} catch (NotFoundException e) {
// The build should not fail here, because this is out of our control.
throw new AssumptionViolatedException(e.getMessage(), e);
}
assertNotNull(classification);
assertEquals("temperature", classification.getTopClass());
}
use of com.ibm.watson.developer_cloud.service.exception.NotFoundException in project java-sdk by watson-developer-cloud.
the class NaturalLanguageClassifierIT method fClassifyCollection.
/**
* Test classifyCollection. Use the pre created classifier to avoid waiting for availability
*/
@Test
public void fClassifyCollection() {
ClassificationCollection classificationCollection = null;
ClassifyInput input1 = new ClassifyInput();
input1.setText("How hot will it be today?");
ClassifyInput input2 = new ClassifyInput();
input2.setText("Is it hot outside?");
try {
ClassifyCollectionOptions classifyOptions = new ClassifyCollectionOptions.Builder().classifierId(preCreatedClassifierId).addClassifyInput(input1).addClassifyInput(input2).build();
classificationCollection = service.classifyCollection(classifyOptions).execute();
} catch (NotFoundException e) {
// The build should not fail here, because this is out of our control.
throw new AssumptionViolatedException(e.getMessage(), e);
}
assertNotNull(classificationCollection);
assertEquals("temperature", classificationCollection.getCollection().get(0).getTopClass());
assertEquals("temperature", classificationCollection.getCollection().get(1).getTopClass());
}
use of com.ibm.watson.developer_cloud.service.exception.NotFoundException in project java-sdk by watson-developer-cloud.
the class ConversationServiceIT 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);
}
}
use of com.ibm.watson.developer_cloud.service.exception.NotFoundException in project java-sdk by watson-developer-cloud.
the class ConversationServiceIT 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);
}
}
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);
}
}
Aggregations