use of com.ibm.watson.discovery.v1.model.Environment in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method updateEnvironmentIsSuccessful.
/**
* Update environment is successful.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void updateEnvironmentIsSuccessful() throws InterruptedException {
server.enqueue(jsonResponse(updateEnvResp));
UpdateEnvironmentOptions updateOptions = new UpdateEnvironmentOptions.Builder(environmentId).name(environmentName).description(environmentDesc).size(UpdateEnvironmentOptions.Size.L).build();
assertEquals(environmentId, updateOptions.environmentId());
assertEquals(environmentName, updateOptions.name());
assertEquals(environmentDesc, updateOptions.description());
assertEquals(UpdateEnvironmentOptions.Size.L, updateOptions.size());
Environment response = discoveryService.updateEnvironment(updateOptions).execute().getResult();
RecordedRequest request = server.takeRequest();
assertEquals(ENV1_PATH, request.getPath());
assertEquals(PUT, request.getMethod());
assertEquals(updateEnvResp, response);
}
use of com.ibm.watson.discovery.v1.model.Environment 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.Environment in project java-sdk by watson-developer-cloud.
the class DiscoveryTest method testUpdateEnvironmentWOptions.
// Test the updateEnvironment operation with a valid options model parameter
@Test
public void testUpdateEnvironmentWOptions() 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 updateEnvironmentPath = "/v1/environments/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the UpdateEnvironmentOptions model
UpdateEnvironmentOptions updateEnvironmentOptionsModel = new UpdateEnvironmentOptions.Builder().environmentId("testString").name("testString").description("testString").size("S").build();
// Invoke updateEnvironment() with a valid options model and verify the result
Response<Environment> response = discoveryService.updateEnvironment(updateEnvironmentOptionsModel).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(), "PUT");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, updateEnvironmentPath);
// 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.Environment 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.Environment 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);
}
Aggregations