Search in sources :

Example 26 with Configuration

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

Example 27 with Configuration

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

Example 28 with Configuration

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

Example 29 with Configuration

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());
}
Also used : 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 30 with Configuration

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