use of com.ibm.watson.discovery.v1.model.Configuration in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method createTestConfig.
private Configuration createTestConfig() {
String uniqueConfigName = uniqueName + "-config";
CreateConfigurationOptions.Builder createBuilder = new CreateConfigurationOptions.Builder(environmentId);
Configuration configuration = getTestConfiguration(DISCOVERY_TEST_CONFIG_FILE);
configuration.setName(uniqueConfigName);
createBuilder.configuration(configuration);
return createConfiguration(createBuilder.build());
}
use of com.ibm.watson.discovery.v1.model.Configuration in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method testConfigurationInEnvironmentIsSuccessful.
// Tests for testConfigurationInEnvironment
@Test
public void testConfigurationInEnvironmentIsSuccessful() {
Configuration testConfig = createTestConfig();
String myDocumentJson = "{\"field\":\"value2\"}";
InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes());
TestConfigurationInEnvironmentOptions options = new TestConfigurationInEnvironmentOptions.Builder(environmentId).configurationId(testConfig.getConfigurationId()).file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON).filename("test_file").build();
TestDocument testResponse = discovery.testConfigurationInEnvironment(options).execute();
assertNotNull(testResponse);
assertEquals(0, testResponse.getNotices().size());
}
use of com.ibm.watson.discovery.v1.model.Configuration in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method getConfigurationsWithFunkyNameIsSuccessful.
@Test
public void getConfigurationsWithFunkyNameIsSuccessful() {
String uniqueConfigName = uniqueName + " with \"funky\" ?x=y&foo=bar ,[x](y) ~!@#$%^&*()-+ {} | ;:<>\\/ chars";
CreateConfigurationOptions.Builder createBuilder = new CreateConfigurationOptions.Builder(environmentId);
Configuration configuration = getTestConfiguration(DISCOVERY_TEST_CONFIG_FILE);
createBuilder.configuration(configuration);
createBuilder.name(uniqueConfigName);
Configuration createResponse = createConfiguration(createBuilder.build());
ListConfigurationsOptions.Builder getBuilder = new ListConfigurationsOptions.Builder(environmentId);
getBuilder.name(uniqueConfigName);
ListConfigurationsResponse getResponse = discovery.listConfigurations(getBuilder.build()).execute();
assertEquals(1, getResponse.getConfigurations().size());
assertEquals(uniqueConfigName, getResponse.getConfigurations().get(0).getName());
}
use of com.ibm.watson.discovery.v1.model.Configuration in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method getConfigurationIsSuccessful.
@Test
public void getConfigurationIsSuccessful() throws InterruptedException {
server.enqueue(jsonResponse(getConfResp));
GetConfigurationOptions getRequest = new GetConfigurationOptions.Builder(environmentId, configurationId).build();
Configuration response = discoveryService.getConfiguration(getRequest).execute();
RecordedRequest request = server.takeRequest();
assertEquals(CONF2_PATH, request.getPath());
assertEquals(GET, request.getMethod());
assertEquals(getConfResp, response);
}
use of com.ibm.watson.discovery.v1.model.Configuration in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method deleteConfigurationIsSuccessful.
@Test
public void deleteConfigurationIsSuccessful() {
Configuration createResponse = createTestConfig();
DeleteConfigurationOptions deleteOptions = new DeleteConfigurationOptions.Builder(environmentId, createResponse.getConfigurationId()).build();
deleteConfiguration(deleteOptions);
}
Aggregations