use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method getCollectionFieldsIsSuccessful.
@Ignore
@Test
public void getCollectionFieldsIsSuccessful() {
Collection collection = createTestCollection();
String collectionId = collection.getCollectionId();
createTestDocument("test_document", collectionId);
ListCollectionFieldsOptions getOptions = new ListCollectionFieldsOptions.Builder(environmentId, collectionId).build();
ListCollectionFieldsResponse getResponse = discovery.listCollectionFields(getOptions).execute();
assertFalse(getResponse.getFields().isEmpty());
}
use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method addDocumentWithConfigurationIsSuccessful.
@Test
public void addDocumentWithConfigurationIsSuccessful() {
Collection collection = createTestCollection();
uniqueName = UUID.randomUUID().toString();
String myDocumentJson = "{\"field\":\"value\"}";
InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes());
AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder();
builder.environmentId(environmentId);
builder.collectionId(collection.getCollectionId());
builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
builder.filename("test_file");
DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute();
assertFalse(createResponse.getDocumentId().isEmpty());
assertNull(createResponse.getNotices());
}
use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method deleteDocumentIsSuccessful.
@Test
public void deleteDocumentIsSuccessful() {
Collection collection = createTestCollection();
String collectionId = collection.getCollectionId();
DocumentAccepted documentAccepted = createTestDocument("test_document", collectionId);
DeleteDocumentOptions deleteOptions = new DeleteDocumentOptions.Builder(environmentId, collectionId, documentAccepted.getDocumentId()).build();
discovery.deleteDocument(deleteOptions).execute();
}
use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method createCollectionIsSuccessful.
// Collection tests
@Test
public void createCollectionIsSuccessful() throws InterruptedException {
server.enqueue(jsonResponse(createCollResp));
CreateCollectionOptions.Builder createCollectionBuilder = new CreateCollectionOptions.Builder(environmentId, uniqueCollectionName).configurationId(configurationId);
Collection response = discoveryService.createCollection(createCollectionBuilder.build()).execute();
RecordedRequest request = server.takeRequest();
assertEquals(COLL1_PATH, request.getPath());
assertEquals(POST, request.getMethod());
assertEquals(createCollResp, response);
}
use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method getCollectionIsSuccessful.
@Test
public void getCollectionIsSuccessful() throws InterruptedException {
server.enqueue(jsonResponse(getCollResp));
GetCollectionOptions getRequest = new GetCollectionOptions.Builder(environmentId, collectionId).build();
Collection response = discoveryService.getCollection(getRequest).execute();
RecordedRequest request = server.takeRequest();
assertEquals(COLL2_PATH, request.getPath());
assertEquals(GET, request.getMethod());
assertEquals(getCollResp, response);
}
Aggregations