use of com.ibm.watson.developer_cloud.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method issueNumber659.
/* Issue 659: creating a collection does not use the configuration id */
@Test
public void issueNumber659() {
String uniqueConfigName = UUID.randomUUID().toString() + "-config";
Configuration testConfiguration = getTestConfiguration(DISCOVERY_TEST_CONFIG_FILE);
CreateConfigurationOptions configOptions = new CreateConfigurationOptions.Builder(environmentId).configuration(testConfiguration).name(uniqueConfigName).build();
Configuration configuration = discovery.createConfiguration(configOptions).execute();
configurationIds.add(configuration.getConfigurationId());
String uniqueCollectionName = UUID.randomUUID().toString() + "-collection";
CreateCollectionOptions collectionOptions = new CreateCollectionOptions.Builder(environmentId, uniqueCollectionName).configurationId(configuration.getConfigurationId()).build();
Collection collection = discovery.createCollection(collectionOptions).execute();
collectionIds.add(collection.getCollectionId());
assertEquals(collection.getConfigurationId(), configuration.getConfigurationId());
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method createCollectionWithMinimalParametersIsSuccessful.
@Test
public void createCollectionWithMinimalParametersIsSuccessful() {
String uniqueCollectionName = uniqueName + "-collection";
CreateCollectionOptions createOptions = new CreateCollectionOptions.Builder(environmentId, uniqueCollectionName).build();
Collection createResponse = createCollection(createOptions);
assertNotNull(createResponse.getCollectionId());
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method createTestCollection.
private Collection createTestCollection() {
Configuration createConfigResponse = createTestConfig();
String uniqueCollectionName = uniqueName + "-collection";
CreateCollectionOptions.Builder createCollectionBuilder = new CreateCollectionOptions.Builder(environmentId, uniqueCollectionName).configurationId(createConfigResponse.getConfigurationId());
Collection createResponse = createCollection(createCollectionBuilder.build());
return createResponse;
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method createCollection.
private Collection createCollection(CreateCollectionOptions createOptions) {
Collection createResponse = discovery.createCollection(createOptions).execute();
collectionIds.add(createResponse.getCollectionId());
return createResponse;
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method addDocumentIsSuccessful.
@SuppressWarnings("deprecation")
@Test
public void addDocumentIsSuccessful() {
Collection collection = createTestCollection();
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());
}
Aggregations