Search in sources :

Example 1 with GetEnvironmentOptions

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());
}
Also used : GetEnvironmentOptions(com.ibm.watson.developer_cloud.discovery.v1.model.GetEnvironmentOptions) Environment(com.ibm.watson.developer_cloud.discovery.v1.model.Environment) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 2 with GetEnvironmentOptions

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");
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) GetEnvironmentOptions(com.ibm.watson.discovery.v1.model.GetEnvironmentOptions) Environment(com.ibm.watson.discovery.v1.model.Environment) Test(org.testng.annotations.Test)

Example 3 with GetEnvironmentOptions

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();
}
Also used : GetEnvironmentOptions(com.ibm.watson.discovery.v1.model.GetEnvironmentOptions) Environment(com.ibm.watson.discovery.v1.model.Environment) WatsonServiceUnitTest(com.ibm.watson.common.WatsonServiceUnitTest)

Example 4 with GetEnvironmentOptions

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);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) GetEnvironmentOptions(com.ibm.watson.discovery.v1.model.GetEnvironmentOptions) Environment(com.ibm.watson.discovery.v1.model.Environment) WatsonServiceUnitTest(com.ibm.watson.common.WatsonServiceUnitTest)

Example 5 with GetEnvironmentOptions

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);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) GetEnvironmentOptions(com.ibm.watson.developer_cloud.discovery.v1.model.GetEnvironmentOptions) Environment(com.ibm.watson.developer_cloud.discovery.v1.model.Environment) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Aggregations

Environment (com.ibm.watson.developer_cloud.discovery.v1.model.Environment)5 GetEnvironmentOptions (com.ibm.watson.developer_cloud.discovery.v1.model.GetEnvironmentOptions)5 Environment (com.ibm.watson.discovery.v1.model.Environment)5 Test (org.junit.Test)5 GetEnvironmentOptions (com.ibm.watson.discovery.v1.model.GetEnvironmentOptions)4 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)3 WatsonServiceUnitTest (com.ibm.watson.common.WatsonServiceUnitTest)2 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)2 ListEnvironmentsOptions (com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsOptions)2 ListEnvironmentsResponse (com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsResponse)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)1 Authenticator (com.ibm.cloud.sdk.core.security.Authenticator)1 IamAuthenticator (com.ibm.cloud.sdk.core.security.IamAuthenticator)1 AddDocumentOptions (com.ibm.watson.developer_cloud.discovery.v1.model.AddDocumentOptions)1 Collection (com.ibm.watson.developer_cloud.discovery.v1.model.Collection)1 Configuration (com.ibm.watson.developer_cloud.discovery.v1.model.Configuration)1 CreateCollectionOptions (com.ibm.watson.developer_cloud.discovery.v1.model.CreateCollectionOptions)1