use of com.ibm.watson.developer_cloud.discovery.v1.model.Configuration in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method createCollectionIsSuccessful.
@Test
public void createCollectionIsSuccessful() {
Configuration createConfigResponse = createTestConfig();
String uniqueCollectionName = uniqueName + "-collection";
String uniqueCollectionDescription = "Description of " + uniqueCollectionName;
CreateCollectionOptions.Builder createCollectionBuilder = new CreateCollectionOptions.Builder(environmentId, uniqueCollectionName).configurationId(createConfigResponse.getConfigurationId()).description(uniqueCollectionDescription);
Collection createResponse = createCollection(createCollectionBuilder.build());
assertEquals(createConfigResponse.getConfigurationId(), createResponse.getConfigurationId());
assertEquals(uniqueCollectionName, createResponse.getName());
assertEquals(uniqueCollectionDescription, createResponse.getDescription());
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.Configuration in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method updateConfigurationIsSuccessful.
@Test
public void updateConfigurationIsSuccessful() {
Configuration testConfig = createTestConfig();
Date start = new Date();
String updatedName = testConfig.getName() + UUID.randomUUID().toString();
String updatedDescription = "Description of " + updatedName;
Conversions updatedConversions = new Conversions();
HtmlSettings newHtmlSettings = new HtmlSettings();
newHtmlSettings.setExcludeTagsCompletely(Arrays.asList("table", "h6", "header"));
updatedConversions.setHtml(newHtmlSettings);
NormalizationOperation operation = new NormalizationOperation();
operation.setOperation("foo");
operation.setSourceField("bar");
operation.setDestinationField("baz");
List<NormalizationOperation> updatedNormalizations = 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> updatedEnrichments = Arrays.asList(enrichment);
UpdateConfigurationOptions.Builder updateBuilder = new UpdateConfigurationOptions.Builder(environmentId, testConfig.getConfigurationId());
updateBuilder.name(updatedName);
updateBuilder.description(updatedDescription);
updateBuilder.conversions(updatedConversions);
updateBuilder.normalizations(updatedNormalizations);
updateBuilder.enrichments(updatedEnrichments);
Configuration updatedConfiguration = discovery.updateConfiguration(updateBuilder.build()).execute();
assertEquals(updatedName, updatedConfiguration.getName());
assertEquals(updatedDescription, updatedConfiguration.getDescription());
assertEquals(updatedConversions, updatedConfiguration.getConversions());
assertEquals(updatedNormalizations, updatedConfiguration.getNormalizations());
assertEquals(updatedEnrichments, updatedConfiguration.getEnrichments());
Date now = new Date();
assertTrue(fuzzyBefore(updatedConfiguration.getCreated(), start));
assertTrue(fuzzyBefore(updatedConfiguration.getUpdated(), now));
assertTrue(fuzzyAfter(updatedConfiguration.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 issueNumber518.
@Test
public void issueNumber518() {
String[] operations = new String[] { Operation.MOVE, Operation.COPY, Operation.MERGE, Operation.REMOVE, Operation.REMOVE_NULLS };
String uniqueConfigName = uniqueName + "-config";
CreateConfigurationOptions.Builder createBuilder = new CreateConfigurationOptions.Builder(environmentId);
Configuration configuration = getTestConfiguration(DISCOVERY2_TEST_CONFIG_FILE);
configuration.setName(uniqueConfigName);
createBuilder.configuration(configuration);
Configuration createResponse = createConfiguration(createBuilder.build());
GetConfigurationOptions getOptions = new GetConfigurationOptions.Builder(environmentId, createResponse.getConfigurationId()).build();
Configuration getResponse = discovery.getConfiguration(getOptions).execute();
// verify getResponse deserializes the operations appropriately
for (NormalizationOperation normalization : getResponse.getNormalizations()) {
String operation = normalization.getOperation();
assertEquals(true, Arrays.asList(operations).contains(operation));
}
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.Configuration in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method createConfigurationIsSuccessful.
// Configuration tests
@Test
public void createConfigurationIsSuccessful() throws JsonSyntaxException, JsonIOException, FileNotFoundException, InterruptedException {
server.enqueue(jsonResponse(createConfResp));
CreateConfigurationOptions.Builder createBuilder = new CreateConfigurationOptions.Builder(environmentId);
Configuration configuration = GsonSingleton.getGson().fromJson(new FileReader(DISCOVERY_TEST_CONFIG_FILE), Configuration.class);
createBuilder.configuration(configuration);
createBuilder.name(uniqueConfigName);
Configuration response = discoveryService.createConfiguration(createBuilder.build()).execute();
RecordedRequest request = server.takeRequest();
assertEquals(CONF1_PATH, request.getPath());
assertEquals(POST, request.getMethod());
assertEquals(createConfResp, response);
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.Configuration in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method updateConfigurationIsSuccessful.
@Test
public void updateConfigurationIsSuccessful() throws InterruptedException {
server.enqueue(jsonResponse(updateConfResp));
UpdateConfigurationOptions.Builder updateBuilder = new UpdateConfigurationOptions.Builder(environmentId, configurationId);
Configuration newConf = new Configuration();
newConf.setName("newName");
updateBuilder.configuration(newConf);
Configuration response = discoveryService.updateConfiguration(updateBuilder.build()).execute();
RecordedRequest request = server.takeRequest();
assertEquals(CONF2_PATH, request.getPath());
assertEquals(PUT, request.getMethod());
assertEquals(updateConfResp, response);
}
Aggregations