use of com.ibm.watson.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.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.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);
}
use of com.ibm.watson.discovery.v1.model.Configuration in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method getConfigurationsByNameIsSuccessful.
@Test
public void getConfigurationsByNameIsSuccessful() {
Configuration createResponse = createTestConfig();
ListConfigurationsOptions.Builder getBuilder = new ListConfigurationsOptions.Builder(environmentId);
getBuilder.name(createResponse.getName());
ListConfigurationsResponse getResponse = discovery.listConfigurations(getBuilder.build()).execute();
assertEquals(1, getResponse.getConfigurations().size());
assertEquals(createResponse.getName(), getResponse.getConfigurations().get(0).getName());
}
use of com.ibm.watson.discovery.v1.model.Configuration in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method updateCollectionIsSuccessful.
@Test
public void updateCollectionIsSuccessful() {
String uniqueCollectionName = uniqueName + "-collection";
CreateCollectionOptions createOptions = new CreateCollectionOptions.Builder(environmentId, uniqueCollectionName).build();
Collection collection = createCollection(createOptions);
assertNotNull(collection.getCollectionId());
Configuration testConfig = createTestConfig();
String updatedCollectionName = UUID.randomUUID().toString() + "-collection";
String updatedCollectionDescription = "Description for " + updatedCollectionName;
UpdateCollectionOptions.Builder updateBuilder = new UpdateCollectionOptions.Builder(environmentId, collection.getCollectionId());
updateBuilder.name(updatedCollectionName);
updateBuilder.description(updatedCollectionDescription);
updateBuilder.configurationId(testConfig.getConfigurationId());
Collection updatedCollection = discovery.updateCollection(updateBuilder.build()).execute();
assertEquals(updatedCollectionName, updatedCollection.getName());
assertEquals(updatedCollectionDescription, updatedCollection.getDescription());
assertEquals(testConfig.getConfigurationId(), updatedCollection.getConfigurationId());
}
Aggregations