Search in sources :

Example 1 with GetConfigurationOptions

use of com.ibm.watson.developer_cloud.discovery.v1.model.GetConfigurationOptions in project java-sdk by watson-developer-cloud.

the class DiscoveryServiceIT method getConfigurationIsSuccessful.

@Test
public void getConfigurationIsSuccessful() {
    Configuration createResponse = createTestConfig();
    GetConfigurationOptions getOptions = new GetConfigurationOptions.Builder(environmentId, createResponse.getConfigurationId()).build();
    Configuration getResponse = discovery.getConfiguration(getOptions).execute();
    assertEquals(createResponse.getName(), getResponse.getName());
}
Also used : Configuration(com.ibm.watson.developer_cloud.discovery.v1.model.Configuration) GetConfigurationOptions(com.ibm.watson.developer_cloud.discovery.v1.model.GetConfigurationOptions) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 2 with GetConfigurationOptions

use of com.ibm.watson.developer_cloud.discovery.v1.model.GetConfigurationOptions 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 3 with GetConfigurationOptions

use of com.ibm.watson.developer_cloud.discovery.v1.model.GetConfigurationOptions in project java-sdk by watson-developer-cloud.

the class Discovery method getConfiguration.

/**
 * Get configuration details.
 *
 * @param getConfigurationOptions the {@link GetConfigurationOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link Configuration}
 */
public ServiceCall<Configuration> getConfiguration(GetConfigurationOptions getConfigurationOptions) {
    Validator.notNull(getConfigurationOptions, "getConfigurationOptions cannot be null");
    String[] pathSegments = { "v1/environments", "configurations" };
    String[] pathParameters = { getConfigurationOptions.environmentId(), getConfigurationOptions.configurationId() };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Configuration.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) Configuration(com.ibm.watson.developer_cloud.discovery.v1.model.Configuration)

Example 4 with GetConfigurationOptions

use of com.ibm.watson.developer_cloud.discovery.v1.model.GetConfigurationOptions 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 5 with GetConfigurationOptions

use of com.ibm.watson.developer_cloud.discovery.v1.model.GetConfigurationOptions in project java-sdk by watson-developer-cloud.

the class DiscoveryServiceIT method issueNumber517.

// Tests for reported issues
@Test
public void issueNumber517() {
    String uniqueConfigName = uniqueName + "-config";
    CreateConfigurationOptions.Builder createBuilder = new CreateConfigurationOptions.Builder(environmentId);
    Configuration configuration = getTestConfiguration(DISCOVERY1_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();
    // returned config should have some json data
    assertEquals(1, getResponse.getConversions().getJsonNormalizations().size());
}
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) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Aggregations

Configuration (com.ibm.watson.developer_cloud.discovery.v1.model.Configuration)5 GetConfigurationOptions (com.ibm.watson.developer_cloud.discovery.v1.model.GetConfigurationOptions)4 Test (org.junit.Test)4 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)3 CreateConfigurationOptions (com.ibm.watson.developer_cloud.discovery.v1.model.CreateConfigurationOptions)2 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 NormalizationOperation (com.ibm.watson.developer_cloud.discovery.v1.model.NormalizationOperation)1 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1