Search in sources :

Example 11 with NotFoundException

use of com.ibm.cloud.sdk.core.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.Builder().text("How hot will it be today?").build();
    ClassifyInput input2 = new ClassifyInput.Builder().text("Is it hot outside?").build();
    try {
        ClassifyCollectionOptions classifyOptions = new ClassifyCollectionOptions.Builder().classifierId(preCreatedClassifierId).addClassifyInput(input1).addClassifyInput(input2).build();
        classificationCollection = service.classifyCollection(classifyOptions).execute().getResult();
    } 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());
}
Also used : ClassificationCollection(com.ibm.watson.natural_language_classifier.v1.model.ClassificationCollection) ClassifyCollectionOptions(com.ibm.watson.natural_language_classifier.v1.model.ClassifyCollectionOptions) AssumptionViolatedException(org.junit.AssumptionViolatedException) NotFoundException(com.ibm.cloud.sdk.core.service.exception.NotFoundException) ClassifyInput(com.ibm.watson.natural_language_classifier.v1.model.ClassifyInput) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Aggregations

NotFoundException (com.ibm.cloud.sdk.core.service.exception.NotFoundException)11 Test (org.junit.Test)7 Document (com.ibm.cloud.cloudant.v1.model.Document)4 DocumentResult (com.ibm.cloud.cloudant.v1.model.DocumentResult)3 CreateEntityOptions (com.ibm.watson.assistant.v1.model.CreateEntityOptions)3 WatsonServiceTest (com.ibm.watson.common.WatsonServiceTest)3 AssumptionViolatedException (org.junit.AssumptionViolatedException)3 Cloudant (com.ibm.cloud.cloudant.v1.Cloudant)2 AllDocsResult (com.ibm.cloud.cloudant.v1.model.AllDocsResult)2 DeleteDocumentOptions (com.ibm.cloud.cloudant.v1.model.DeleteDocumentOptions)2 DocsResultRow (com.ibm.cloud.cloudant.v1.model.DocsResultRow)2 GetDocumentOptions (com.ibm.cloud.cloudant.v1.model.GetDocumentOptions)2 PostAllDocsOptions (com.ibm.cloud.cloudant.v1.model.PostAllDocsOptions)2 CreateValueOptions (com.ibm.watson.assistant.v1.model.CreateValueOptions)2 GsonBuilder (com.google.gson.GsonBuilder)1 PostDocumentOptions (com.ibm.cloud.cloudant.v1.model.PostDocumentOptions)1 UnauthorizedException (com.ibm.cloud.sdk.core.service.exception.UnauthorizedException)1 CreateSynonymOptions (com.ibm.watson.assistant.v1.model.CreateSynonymOptions)1 DeleteEntityOptions (com.ibm.watson.assistant.v1.model.DeleteEntityOptions)1 DeleteSynonymOptions (com.ibm.watson.assistant.v1.model.DeleteSynonymOptions)1