Search in sources :

Example 6 with Configuration

use of com.ibm.watson.developer_cloud.discovery.v1.model.configuration.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.developer_cloud.discovery.v1.model.configuration.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.developer_cloud.discovery.v1.model.configuration.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.developer_cloud.discovery.v1.model.configuration.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.developer_cloud.discovery.v1.model.configuration.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 Collection (com.ibm.watson.developer_cloud.discovery.v1.model.Collection)8 CreateCollectionOptions (com.ibm.watson.developer_cloud.discovery.v1.model.CreateCollectionOptions)8 CreateConfigurationOptions (com.ibm.watson.developer_cloud.discovery.v1.model.CreateConfigurationOptions)7 ByteArrayInputStream (java.io.ByteArrayInputStream)5 InputStream (java.io.InputStream)5 GetConfigurationOptions (com.ibm.watson.developer_cloud.discovery.v1.model.GetConfigurationOptions)4 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)4 JsonObject (com.google.gson.JsonObject)3 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)3 ListConfigurationsOptions (com.ibm.watson.developer_cloud.discovery.v1.model.ListConfigurationsOptions)3 ListConfigurationsResponse (com.ibm.watson.developer_cloud.discovery.v1.model.ListConfigurationsResponse)3 NormalizationOperation (com.ibm.watson.developer_cloud.discovery.v1.model.NormalizationOperation)3 TestDocument (com.ibm.watson.developer_cloud.discovery.v1.model.TestDocument)3 FileInputStream (java.io.FileInputStream)3 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)3 Conversions (com.ibm.watson.developer_cloud.discovery.v1.model.Conversions)2 DeleteCollectionOptions (com.ibm.watson.developer_cloud.discovery.v1.model.DeleteCollectionOptions)2