use of com.ibm.watson.discovery.v1.model.GatewayDelete in project java-sdk by watson-developer-cloud.
the class DiscoveryTest method testDeleteGatewayWOptions.
// Test the deleteGateway operation with a valid options model parameter
@Test
public void testDeleteGatewayWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"gateway_id\": \"gatewayId\", \"status\": \"status\"}";
String deleteGatewayPath = "/v1/environments/testString/gateways/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the DeleteGatewayOptions model
DeleteGatewayOptions deleteGatewayOptionsModel = new DeleteGatewayOptions.Builder().environmentId("testString").gatewayId("testString").build();
// Invoke deleteGateway() with a valid options model and verify the result
Response<GatewayDelete> response = discoveryService.deleteGateway(deleteGatewayOptionsModel).execute();
assertNotNull(response);
GatewayDelete 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, deleteGatewayPath);
// 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.GatewayDelete in project java-sdk by watson-developer-cloud.
the class Discovery method deleteGateway.
/**
* Delete Gateway.
*
* <p>Delete the specified gateway configuration.
*
* @param deleteGatewayOptions the {@link DeleteGatewayOptions} containing the options for the
* call
* @return a {@link ServiceCall} with a result of type {@link GatewayDelete}
*/
public ServiceCall<GatewayDelete> deleteGateway(DeleteGatewayOptions deleteGatewayOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteGatewayOptions, "deleteGatewayOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("environment_id", deleteGatewayOptions.environmentId());
pathParamsMap.put("gateway_id", deleteGatewayOptions.gatewayId());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/gateways/{gateway_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteGateway");
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<GatewayDelete> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<GatewayDelete>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.discovery.v1.model.GatewayDelete in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method testDeleteGateway.
/**
* Test delete gateway.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testDeleteGateway() throws InterruptedException {
server.enqueue(jsonResponse(deleteGatewayResponse));
String gatewayId = "gateway_id";
DeleteGatewayOptions deleteGatewayOptions = new DeleteGatewayOptions.Builder().environmentId(environmentId).gatewayId(gatewayId).build();
GatewayDelete response = discoveryService.deleteGateway(deleteGatewayOptions).execute().getResult();
RecordedRequest request = server.takeRequest();
assertEquals(DELETE, request.getMethod());
assertEquals(deleteGatewayResponse.getGatewayId(), response.getGatewayId());
assertEquals(deleteGatewayResponse.getStatus(), response.getStatus());
}
Aggregations