use of com.ibm.watson.developer_cloud.discovery.v1.model.Configuration 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.Configuration in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method createConfigurationIsSuccessful.
@Test
public void createConfigurationIsSuccessful() {
Date start = new Date();
String uniqueConfigName = uniqueName + "-config";
String description = "Description of " + uniqueConfigName;
Conversions conversions = new Conversions();
HtmlSettings htmlSettings = new HtmlSettings();
htmlSettings.setExcludeTagsCompletely(Arrays.asList("table", "h6", "header"));
conversions.setHtml(htmlSettings);
NormalizationOperation operation = new NormalizationOperation();
operation.setOperation("foo");
operation.setSourceField("bar");
operation.setDestinationField("baz");
List<NormalizationOperation> normalizations = Arrays.asList(operation);
Enrichment enrichment = new Enrichment();
enrichment.setSourceField("foo");
enrichment.setDestinationField("bar");
enrichment.setEnrichmentName("baz");
enrichment.setDescription("Erich foo to bar with baz");
enrichment.setIgnoreDownstreamErrors(true);
enrichment.setOverwrite(false);
NluEnrichmentSentiment sentiment = new NluEnrichmentSentiment.Builder().document(true).build();
NluEnrichmentEmotion emotion = new NluEnrichmentEmotion.Builder().document(true).build();
NluEnrichmentEntities entities = new NluEnrichmentEntities.Builder().emotion(true).sentiment(true).model("WhatComesAfterQux").build();
NluEnrichmentKeywords keywords = new NluEnrichmentKeywords.Builder().emotion(true).sentiment(true).build();
NluEnrichmentSemanticRoles semanticRoles = new NluEnrichmentSemanticRoles.Builder().entities(true).build();
NluEnrichmentFeatures features = new NluEnrichmentFeatures.Builder().sentiment(sentiment).emotion(emotion).entities(entities).keywords(keywords).semanticRoles(semanticRoles).build();
EnrichmentOptions options = new EnrichmentOptions.Builder().features(features).build();
enrichment.setOptions(options);
List<Enrichment> enrichments = Arrays.asList(enrichment);
CreateConfigurationOptions createOptions = new CreateConfigurationOptions.Builder().environmentId(environmentId).name(uniqueConfigName).description(description).conversions(conversions).normalizations(normalizations).enrichments(enrichments).build();
Configuration createResponse = createConfiguration(createOptions);
assertEquals(uniqueConfigName, createResponse.getName());
assertEquals(description, createResponse.getDescription());
assertEquals(conversions, createResponse.getConversions());
assertEquals(normalizations, createResponse.getNormalizations());
assertEquals(enrichments, createResponse.getEnrichments());
Date now = new Date();
assertTrue(fuzzyBefore(createResponse.getCreated(), now));
assertTrue(fuzzyAfter(createResponse.getCreated(), start));
assertTrue(fuzzyBefore(createResponse.getUpdated(), now));
assertTrue(fuzzyAfter(createResponse.getUpdated(), start));
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.Configuration 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.Configuration in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method getConfigurationIsSuccessful.
@Test
public void getConfigurationIsSuccessful() {
Configuration createResponse = createTestConfig();
GetConfigurationOptions getOptions = new GetConfigurationOptions.Builder(environmentId, createResponse.getConfigurationId()).build();
Configuration getResponse = discovery.getConfiguration(getOptions).execute();
assertEquals(createResponse.getName(), getResponse.getName());
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.Configuration in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method testConfigurationInEnvironmentWithAllOptionsIsSuccessful.
@Test
public void testConfigurationInEnvironmentWithAllOptionsIsSuccessful() {
Configuration testConfig = createTestConfig();
String myDocumentJson = "{\"field\":\"value2\"}";
InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes());
JsonObject myMetadata = new JsonObject();
myMetadata.add("foo", new JsonPrimitive("bar"));
TestConfigurationInEnvironmentOptions.Builder builder = new TestConfigurationInEnvironmentOptions.Builder();
builder.environmentId(environmentId);
builder.configurationId(testConfig.getConfigurationId());
builder.step(TestConfigurationInEnvironmentOptions.Step.HTML_OUTPUT);
builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
builder.filename("test_file");
builder.metadata(myMetadata.toString());
TestDocument testResponse = discovery.testConfigurationInEnvironment(builder.build()).execute();
assertNotNull(testResponse);
assertEquals(0, testResponse.getNotices().size());
}
Aggregations