use of com.ibm.watson.discovery.v1.model.GetEnvironmentOptions in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method getEnvironmentIsSuccessful.
@Test
public void getEnvironmentIsSuccessful() {
GetEnvironmentOptions getOptions = new GetEnvironmentOptions.Builder(environmentId).build();
Environment getResponse = discovery.getEnvironment(getOptions).execute();
assertEquals(environmentId, getResponse.getEnvironmentId());
}
use of com.ibm.watson.discovery.v1.model.GetEnvironmentOptions in project java-sdk by watson-developer-cloud.
the class DiscoveryTest method testGetEnvironmentWOptions.
// Test the getEnvironment operation with a valid options model parameter
@Test
public void testGetEnvironmentWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"environment_id\": \"environmentId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"status\": \"active\", \"read_only\": true, \"size\": \"LT\", \"requested_size\": \"requestedSize\", \"index_capacity\": {\"documents\": {\"available\": 9, \"maximum_allowed\": 14}, \"disk_usage\": {\"used_bytes\": 9, \"maximum_allowed_bytes\": 19}, \"collections\": {\"available\": 9, \"maximum_allowed\": 14}}, \"search_status\": {\"scope\": \"scope\", \"status\": \"NO_DATA\", \"status_description\": \"statusDescription\", \"last_trained\": \"2019-01-01\"}}";
String getEnvironmentPath = "/v1/environments/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the GetEnvironmentOptions model
GetEnvironmentOptions getEnvironmentOptionsModel = new GetEnvironmentOptions.Builder().environmentId("testString").build();
// Invoke getEnvironment() with a valid options model and verify the result
Response<Environment> response = discoveryService.getEnvironment(getEnvironmentOptionsModel).execute();
assertNotNull(response);
Environment 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, getEnvironmentPath);
// 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.GetEnvironmentOptions in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method getEnvironmentFails1.
/**
* Gets the environment fails 1.
*/
@Test(expected = IllegalArgumentException.class)
public void getEnvironmentFails1() {
GetEnvironmentOptions getRequest = new GetEnvironmentOptions.Builder().build();
@SuppressWarnings("unused") Environment response = discoveryService.getEnvironment(getRequest).execute().getResult();
}
use of com.ibm.watson.discovery.v1.model.GetEnvironmentOptions in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method getEnvironmentIsSuccessful.
/**
* Gets the environment is successful.
*
* @throws InterruptedException the interrupted exception
*/
// Environment tests
@Test
public void getEnvironmentIsSuccessful() throws InterruptedException {
server.enqueue(jsonResponse(envResp));
GetEnvironmentOptions getRequest = new GetEnvironmentOptions.Builder(environmentId).build();
Environment response = discoveryService.getEnvironment(getRequest).execute().getResult();
final RecordedRequest request = server.takeRequest();
assertEquals(ENV1_PATH, request.getPath());
assertEquals(GET, request.getMethod());
assertEquals(envResp, response);
}
use of com.ibm.watson.discovery.v1.model.GetEnvironmentOptions in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method getEnvironmentIsSuccessful.
// Environment tests
@Test
public void getEnvironmentIsSuccessful() throws InterruptedException {
server.enqueue(jsonResponse(envResp));
GetEnvironmentOptions getRequest = new GetEnvironmentOptions.Builder(environmentId).build();
Environment response = discoveryService.getEnvironment(getRequest).execute();
final RecordedRequest request = server.takeRequest();
assertEquals(ENV1_PATH, request.getPath());
assertEquals(GET, request.getMethod());
assertEquals(envResp, response);
}
Aggregations