use of com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.CreateClassifierOptions in project java-sdk by watson-developer-cloud.
the class NaturalLanguageClassifierTest method testNullTrainingDataFile.
/**
* Test null training data file.
*/
@Test(expected = FileNotFoundException.class)
public void testNullTrainingDataFile() throws FileNotFoundException {
server.enqueue(jsonResponse(classifier));
File metadata = new File(RESOURCE + "metadata.json");
File trainingData = new File(RESOURCE + "notfound.txt");
CreateClassifierOptions createOptions = new CreateClassifierOptions.Builder().metadata(metadata).trainingData(trainingData).trainingDataFilename("notfound.txt").build();
service.createClassifier(createOptions).execute();
}
use of com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.CreateClassifierOptions in project java-sdk by watson-developer-cloud.
the class VisualRecognitionTest method testCreateClassifier.
/**
* Test create classifier.
*
* @throws IOException Signals that an I/O exception has occurred.
* @throws InterruptedException the interrupted exception
*/
@Test
public void testCreateClassifier() throws IOException, InterruptedException {
Classifier mockResponse = loadFixture(FIXTURE_CLASSIFIER, Classifier.class);
server.enqueue(new MockResponse().setBody(mockResponse.toString()));
// execute request
File positiveImages = new File(IMAGE_FILE);
File negativeImages = new File(IMAGE_FILE);
String class1 = "class1";
CreateClassifierOptions options = new CreateClassifierOptions.Builder().name(class1).addClass(class1, positiveImages).negativeExamples(negativeImages).build();
Classifier serviceResponse = service.createClassifier(options).execute();
// first request
RecordedRequest request = server.takeRequest();
String path = PATH_CLASSIFIERS + "?" + VERSION_DATE + "=2016-05-20&api_key=" + API_KEY;
assertEquals(path, request.getPath());
assertEquals("POST", request.getMethod());
String body = request.getBody().readUtf8();
String contentDisposition = "Content-Disposition: form-data; name=\"class1_positive_examples\"; filename=\"test.zip\"";
assertTrue(body.contains(contentDisposition));
assertTrue(body.contains("Content-Disposition: form-data; name=\"name\""));
assertEquals(serviceResponse, mockResponse);
}
Aggregations