use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class VisualRecognitionIT method testCollectionOperations.
/**
* Test collection operations.
*/
@Test
public void testCollectionOperations() {
String testCollectionId = null;
try {
// test create
String newCollectionName = "java-sdk-test-collection";
String newCollectionDescription = "Collection for integration testing of the Visual Recognition v4 service in" + " the Java SDK";
CreateCollectionOptions createCollectionOptions = new CreateCollectionOptions.Builder().name(newCollectionName).description(newCollectionDescription).build();
Collection newCollection = service.createCollection(createCollectionOptions).execute().getResult();
assertNotNull(newCollection);
assertEquals(newCollectionName, newCollection.getName());
assertEquals(newCollectionDescription, newCollection.getDescription());
// test get
testCollectionId = newCollection.getCollectionId();
GetCollectionOptions getCollectionOptions = new GetCollectionOptions.Builder().collectionId(testCollectionId).build();
Collection retrievedCollection = service.getCollection(getCollectionOptions).execute().getResult();
assertNotNull(retrievedCollection);
assertEquals(newCollection.getCollectionId(), retrievedCollection.getCollectionId());
// test update
String updatedDescription = "Collection with an updated description, still for testing in the Java SDK.";
UpdateCollectionOptions updateCollectionOptions = new UpdateCollectionOptions.Builder().collectionId(testCollectionId).description(updatedDescription).build();
Collection updatedCollection = service.updateCollection(updateCollectionOptions).execute().getResult();
assertNotNull(updatedCollection);
assertEquals(updatedDescription, updatedCollection.getDescription());
} finally {
if (testCollectionId != null) {
// test delete
DeleteCollectionOptions deleteCollectionOptions = new DeleteCollectionOptions.Builder().collectionId(testCollectionId).build();
service.deleteCollection(deleteCollectionOptions).execute();
// test list
CollectionsList collectionsList = service.listCollections().execute().getResult();
assertNotNull(collectionsList);
for (Collection collection : collectionsList.getCollections()) {
assertFalse(collection.getCollectionId().equals(testCollectionId));
}
}
}
}
use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class VisualRecognitionIT method createTestCollection.
private String createTestCollection() {
String testCollectionName = "java-sdk-test-collection";
String testCollectionDescription = "Collection for integration testing of the Visual Recognition v4 service in " + "the Java SDK";
CreateCollectionOptions createCollectionOptions = new CreateCollectionOptions.Builder().name(testCollectionName).description(testCollectionDescription).build();
Collection newCollection = service.createCollection(createCollectionOptions).execute().getResult();
String testCollectionId = newCollection.getCollectionId();
return testCollectionId;
}
Aggregations