use of com.ibm.watson.visual_recognition.v3.model.ClassifyOptions in project java-sdk by watson-developer-cloud.
the class NaturalLanguageClassifierTest method testClassify.
/**
* Test classify.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testClassify() throws InterruptedException {
final JsonObject contentJson = new JsonObject();
contentJson.addProperty(TEXT, classification.getText());
final String path = String.format(CLASSIFY_PATH, classifierId);
server.enqueue(jsonResponse(classification));
ClassifyOptions classifyOptions = new ClassifyOptions.Builder().classifierId(classifierId).text(classification.getText()).build();
final Classification result = service.classify(classifyOptions).execute();
final RecordedRequest request = server.takeRequest();
assertEquals(path, request.getPath());
assertEquals("POST", request.getMethod());
assertEquals(contentJson.toString(), request.getBody().readUtf8());
assertEquals(classification, result);
}
use of com.ibm.watson.visual_recognition.v3.model.ClassifyOptions in project java-sdk by watson-developer-cloud.
the class VisualRecognitionIT method testClassifyImagesFromUrl.
/**
* Test classify images from url.
*/
@Test
public void testClassifyImagesFromUrl() {
ClassifyOptions options = new ClassifyOptions.Builder().url(IMAGE_URL).build();
ClassifiedImages result = service.classify(options).execute();
assertClassifyImage(result, options);
}
use of com.ibm.watson.visual_recognition.v3.model.ClassifyOptions in project java-sdk by watson-developer-cloud.
the class VisualRecognitionIT method testClassifyImagesFromFile.
/**
* Test classify images from zip file.
*/
@Test
public void testClassifyImagesFromFile() throws FileNotFoundException {
File images = new File(IMAGE_FILE);
ClassifyOptions options = new ClassifyOptions.Builder().imagesFile(images).build();
ClassifiedImages result = service.classify(options).execute();
assertClassifyImage(result, options);
}
use of com.ibm.watson.visual_recognition.v3.model.ClassifyOptions in project java-sdk by watson-developer-cloud.
the class VisualRecognitionIT method testClassifyImagesFromUrlUsingParameters.
/**
* Test classify images from url using the deprecated parameters option.
*/
@Test
public void testClassifyImagesFromUrlUsingParameters() {
String parameters = "{\"url\":\"" + IMAGE_URL + "\"}";
ClassifyOptions options = new ClassifyOptions.Builder().parameters(parameters).build();
ClassifiedImages result = service.classify(options).execute();
assertClassifyImage(result, options);
}
use of com.ibm.watson.visual_recognition.v3.model.ClassifyOptions in project java-sdk by watson-developer-cloud.
the class VisualRecognitionIT method testClassifyImagesFromBytes.
/**
* Test classify a single jpg image.
*
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
public void testClassifyImagesFromBytes() throws IOException {
InputStream imagesStream = new FileInputStream(SINGLE_IMAGE_FILE);
ClassifyOptions options = new ClassifyOptions.Builder().imagesFile(imagesStream).imagesFilename("car.png").build();
ClassifiedImages result = service.classify(options).execute();
assertClassifyImage(result, options);
}
Aggregations