Search in sources :

Example 11 with Configuration

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

the class DiscoveryServiceIT method createConfiguration.

private Configuration createConfiguration(CreateConfigurationOptions createOptions) {
    Configuration createResponse = discovery.createConfiguration(createOptions).execute();
    configurationIds.add(createResponse.getConfigurationId());
    return createResponse;
}
Also used : Configuration(com.ibm.watson.developer_cloud.discovery.v1.model.Configuration)

Example 12 with Configuration

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

the class DiscoveryServiceIT method updateDocumentIsSuccessful.

@Test
public void updateDocumentIsSuccessful() {
    Collection collection = createTestCollection();
    String collectionId = collection.getCollectionId();
    DocumentAccepted documentAccepted = createTestDocument("test_document", collectionId);
    uniqueName = UUID.randomUUID().toString();
    Configuration testConfig = createTestConfig();
    String myDocumentJson = "{\"field\":\"value2\"}";
    InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes());
    UpdateDocumentOptions.Builder updateBuilder = new UpdateDocumentOptions.Builder(environmentId, collectionId, documentAccepted.getDocumentId());
    updateBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON);
    updateBuilder.filename("test_file");
    // updateBuilder.configurationId(testConfig.getConfigurationId());
    DocumentAccepted updateResponse = discovery.updateDocument(updateBuilder.build()).execute();
    GetDocumentStatusOptions getOptions = new GetDocumentStatusOptions.Builder(environmentId, collectionId, updateResponse.getDocumentId()).build();
    DocumentStatus getResponse = discovery.getDocumentStatus(getOptions).execute();
    assertTrue(getResponse.getStatus().equals(DocumentStatus.Status.AVAILABLE) || getResponse.getStatus().equals(DocumentStatus.Status.PROCESSING));
}
Also used : DocumentStatus(com.ibm.watson.developer_cloud.discovery.v1.model.DocumentStatus) DocumentAccepted(com.ibm.watson.developer_cloud.discovery.v1.model.DocumentAccepted) UpdateDocumentOptions(com.ibm.watson.developer_cloud.discovery.v1.model.UpdateDocumentOptions) 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) GetDocumentStatusOptions(com.ibm.watson.developer_cloud.discovery.v1.model.GetDocumentStatusOptions) Collection(com.ibm.watson.developer_cloud.discovery.v1.model.Collection) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 13 with Configuration

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

the class DiscoveryServiceIT method deleteCollectionIsSuccessful.

@Test
public void deleteCollectionIsSuccessful() {
    Configuration createConfigResponse = createTestConfig();
    String uniqueCollectionName = uniqueName + "-collection";
    CreateCollectionOptions.Builder createCollectionBuilder = new CreateCollectionOptions.Builder(environmentId, uniqueCollectionName).configurationId(createConfigResponse.getConfigurationId());
    Collection createResponse = createCollection(createCollectionBuilder.build());
    // need to wait for collection to be ready
    DeleteCollectionOptions deleteOptions = new DeleteCollectionOptions.Builder(environmentId, createResponse.getCollectionId()).build();
    deleteCollection(deleteOptions);
}
Also used : 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) DeleteCollectionOptions(com.ibm.watson.developer_cloud.discovery.v1.model.DeleteCollectionOptions) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 14 with Configuration

use of com.ibm.watson.discovery.v1.model.Configuration 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 15 with Configuration

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

the class DiscoveryServiceTest method deleteConfigurationIsSuccessful.

/**
 * Delete configuration is successful.
 *
 * @throws InterruptedException the interrupted exception
 */
@Test
public void deleteConfigurationIsSuccessful() throws InterruptedException {
    server.enqueue(jsonResponse(deleteConfResp));
    DeleteConfigurationOptions deleteRequest = new DeleteConfigurationOptions.Builder(environmentId, configurationId).build();
    DeleteConfigurationResponse response = discoveryService.deleteConfiguration(deleteRequest).execute().getResult();
    RecordedRequest request = server.takeRequest();
    assertEquals(CONF2_PATH, request.getPath());
    assertEquals(DELETE, request.getMethod());
    assertEquals(deleteConfResp.getConfigurationId(), response.getConfigurationId());
    assertEquals(DeleteConfigurationResponse.Status.DELETED, response.getStatus());
    assertNotNull(response.getNotices());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) DeleteConfigurationOptions(com.ibm.watson.discovery.v1.model.DeleteConfigurationOptions) DeleteConfigurationResponse(com.ibm.watson.discovery.v1.model.DeleteConfigurationResponse) WatsonServiceUnitTest(com.ibm.watson.common.WatsonServiceUnitTest)

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