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;
}
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));
}
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);
}
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));
}
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());
}
Aggregations