use of com.ibm.watson.discovery.v1.model.DeleteConfigurationResponse 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());
}
use of com.ibm.watson.discovery.v1.model.DeleteConfigurationResponse in project java-sdk by watson-developer-cloud.
the class DiscoveryTest method testDeleteConfigurationWOptions.
// Test the deleteConfiguration operation with a valid options model parameter
@Test
public void testDeleteConfigurationWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"configuration_id\": \"configurationId\", \"status\": \"deleted\", \"notices\": [{\"notice_id\": \"noticeId\", \"created\": \"2019-01-01T12:00:00.000Z\", \"document_id\": \"documentId\", \"query_id\": \"queryId\", \"severity\": \"warning\", \"step\": \"step\", \"description\": \"description\"}]}";
String deleteConfigurationPath = "/v1/environments/testString/configurations/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the DeleteConfigurationOptions model
DeleteConfigurationOptions deleteConfigurationOptionsModel = new DeleteConfigurationOptions.Builder().environmentId("testString").configurationId("testString").build();
// Invoke deleteConfiguration() with a valid options model and verify the result
Response<DeleteConfigurationResponse> response = discoveryService.deleteConfiguration(deleteConfigurationOptionsModel).execute();
assertNotNull(response);
DeleteConfigurationResponse responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request sent to the mock server
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "DELETE");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, deleteConfigurationPath);
// Verify query params
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("version"), "testString");
}
use of com.ibm.watson.discovery.v1.model.DeleteConfigurationResponse in project java-sdk by watson-developer-cloud.
the class Discovery method deleteConfiguration.
/**
* Delete a configuration.
*
* <p>The deletion is performed unconditionally. A configuration deletion request succeeds even if
* the configuration is referenced by a collection or document ingestion. However, documents that
* have already been submitted for processing continue to use the deleted configuration. Documents
* are always processed with a snapshot of the configuration as it existed at the time the
* document was submitted.
*
* @param deleteConfigurationOptions the {@link DeleteConfigurationOptions} containing the options
* for the call
* @return a {@link ServiceCall} with a result of type {@link DeleteConfigurationResponse}
*/
public ServiceCall<DeleteConfigurationResponse> deleteConfiguration(DeleteConfigurationOptions deleteConfigurationOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteConfigurationOptions, "deleteConfigurationOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("environment_id", deleteConfigurationOptions.environmentId());
pathParamsMap.put("configuration_id", deleteConfigurationOptions.configurationId());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/configurations/{configuration_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteConfiguration");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("version", String.valueOf(this.version));
ResponseConverter<DeleteConfigurationResponse> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DeleteConfigurationResponse>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations