Search in sources :

Example 6 with Configuration

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());
}
Also used : CreateConfigurationOptions(com.ibm.watson.developer_cloud.discovery.v1.model.CreateConfigurationOptions) Configuration(com.ibm.watson.developer_cloud.discovery.v1.model.Configuration)

Example 7 with Configuration

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());
}
Also used : TestDocument(com.ibm.watson.developer_cloud.discovery.v1.model.TestDocument) Configuration(com.ibm.watson.developer_cloud.discovery.v1.model.Configuration) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) TestConfigurationInEnvironmentOptions(com.ibm.watson.developer_cloud.discovery.v1.model.TestConfigurationInEnvironmentOptions) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 8 with Configuration

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());
}
Also used : CreateConfigurationOptions(com.ibm.watson.developer_cloud.discovery.v1.model.CreateConfigurationOptions) Configuration(com.ibm.watson.developer_cloud.discovery.v1.model.Configuration) ListConfigurationsResponse(com.ibm.watson.developer_cloud.discovery.v1.model.ListConfigurationsResponse) ListConfigurationsOptions(com.ibm.watson.developer_cloud.discovery.v1.model.ListConfigurationsOptions) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 9 with Configuration

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);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) GetConfigurationOptions(com.ibm.watson.developer_cloud.discovery.v1.model.GetConfigurationOptions) Configuration(com.ibm.watson.developer_cloud.discovery.v1.model.Configuration) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 10 with Configuration

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);
}
Also used : Configuration(com.ibm.watson.developer_cloud.discovery.v1.model.Configuration) DeleteConfigurationOptions(com.ibm.watson.developer_cloud.discovery.v1.model.DeleteConfigurationOptions) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Aggregations

Configuration (com.ibm.watson.developer_cloud.discovery.v1.model.Configuration)27 Test (org.junit.Test)21 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)18 Configuration (com.ibm.watson.discovery.v1.model.Configuration)10 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)10 Collection (com.ibm.watson.developer_cloud.discovery.v1.model.Collection)8 CreateCollectionOptions (com.ibm.watson.developer_cloud.discovery.v1.model.CreateCollectionOptions)8 JsonObject (com.google.gson.JsonObject)7 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)7 CreateConfigurationOptions (com.ibm.watson.developer_cloud.discovery.v1.model.CreateConfigurationOptions)7 HashMap (java.util.HashMap)7 WatsonServiceUnitTest (com.ibm.watson.common.WatsonServiceUnitTest)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 InputStream (java.io.InputStream)5 GetConfigurationOptions (com.ibm.watson.developer_cloud.discovery.v1.model.GetConfigurationOptions)4 Conversions (com.ibm.watson.discovery.v1.model.Conversions)3 CreateConfigurationOptions (com.ibm.watson.discovery.v1.model.CreateConfigurationOptions)3 Enrichment (com.ibm.watson.discovery.v1.model.Enrichment)3 NormalizationOperation (com.ibm.watson.discovery.v1.model.NormalizationOperation)3 Source (com.ibm.watson.discovery.v1.model.Source)3