use of com.ibm.watson.discovery.v1.model.ListGatewaysOptions in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method testListGatewaysOptions.
/**
* Test list gateways options.
*/
@Test
public void testListGatewaysOptions() {
ListGatewaysOptions listGatewaysOptions = new ListGatewaysOptions.Builder().environmentId(environmentId).build();
assertEquals(environmentId, listGatewaysOptions.environmentId());
}
use of com.ibm.watson.discovery.v1.model.ListGatewaysOptions in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method testListGateways.
/**
* Test list gateways.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testListGateways() throws InterruptedException {
server.enqueue(jsonResponse(listGatewaysResponse));
ListGatewaysOptions listGatewaysOptions = new ListGatewaysOptions.Builder().environmentId(environmentId).build();
GatewayList response = discoveryService.listGateways(listGatewaysOptions).execute().getResult();
RecordedRequest request = server.takeRequest();
assertEquals(GET, request.getMethod());
assertEquals(listGatewaysResponse, response);
}
use of com.ibm.watson.discovery.v1.model.ListGatewaysOptions in project java-sdk by watson-developer-cloud.
the class DiscoveryTest method testListGatewaysWOptions.
// Test the listGateways operation with a valid options model parameter
@Test
public void testListGatewaysWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"gateways\": [{\"gateway_id\": \"gatewayId\", \"name\": \"name\", \"status\": \"connected\", \"token\": \"token\", \"token_id\": \"tokenId\"}]}";
String listGatewaysPath = "/v1/environments/testString/gateways";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the ListGatewaysOptions model
ListGatewaysOptions listGatewaysOptionsModel = new ListGatewaysOptions.Builder().environmentId("testString").build();
// Invoke listGateways() with a valid options model and verify the result
Response<GatewayList> response = discoveryService.listGateways(listGatewaysOptionsModel).execute();
assertNotNull(response);
GatewayList 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(), "GET");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, listGatewaysPath);
// 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.ListGatewaysOptions in project java-sdk by watson-developer-cloud.
the class Discovery method listGateways.
/**
* List Gateways.
*
* <p>List the currently configured gateways.
*
* @param listGatewaysOptions the {@link ListGatewaysOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link GatewayList}
*/
public ServiceCall<GatewayList> listGateways(ListGatewaysOptions listGatewaysOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(listGatewaysOptions, "listGatewaysOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("environment_id", listGatewaysOptions.environmentId());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/gateways", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listGateways");
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<GatewayList> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<GatewayList>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations