Search in sources :

Example 16 with Environment

use of com.ibm.watson.discovery.v1.model.Environment 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)

Example 17 with Environment

use of com.ibm.watson.discovery.v1.model.Environment in project java-sdk by watson-developer-cloud.

the class DiscoveryServiceTest method getEnvironmentFails1.

@Test(expected = IllegalArgumentException.class)
public void getEnvironmentFails1() {
    GetEnvironmentOptions getRequest = new GetEnvironmentOptions.Builder().build();
    @SuppressWarnings("unused") Environment response = discoveryService.getEnvironment(getRequest).execute();
}
Also used : 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)

Example 18 with Environment

use of com.ibm.watson.discovery.v1.model.Environment in project java-sdk by watson-developer-cloud.

the class DiscoveryServiceIT method createEnvironmentIsSuccessful.

@Test
@Ignore("Only 1 BYOD environment allowed per service instance, so we cannot create more")
public void createEnvironmentIsSuccessful() {
    String environmentName = uniqueName + "-environment";
    CreateEnvironmentOptions createOptions = new CreateEnvironmentOptions.Builder().name(environmentName).size(FREE).build();
    Environment createResponse = createEnvironment(createOptions);
    assertEquals(environmentName, createResponse.getName());
}
Also used : CreateEnvironmentOptions(com.ibm.watson.developer_cloud.discovery.v1.model.CreateEnvironmentOptions) Environment(com.ibm.watson.developer_cloud.discovery.v1.model.Environment) Ignore(org.junit.Ignore) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 19 with Environment

use of com.ibm.watson.discovery.v1.model.Environment in project java-sdk by watson-developer-cloud.

the class DiscoveryServiceIT method deleteEnvironmentIsSuccessful.

@Test
@Ignore("Only 1 BYOD environment allowed per service instance, so do not delete it")
public void deleteEnvironmentIsSuccessful() {
    String environmentName = uniqueName + "-environment";
    CreateEnvironmentOptions createOptions = new CreateEnvironmentOptions.Builder().name(environmentName).size(FREE).build();
    Environment createResponse = createEnvironment(createOptions);
    DeleteEnvironmentOptions deleteOptions = new DeleteEnvironmentOptions.Builder(createResponse.getEnvironmentId()).build();
    deleteEnvironment(deleteOptions);
}
Also used : CreateEnvironmentOptions(com.ibm.watson.developer_cloud.discovery.v1.model.CreateEnvironmentOptions) Environment(com.ibm.watson.developer_cloud.discovery.v1.model.Environment) DeleteEnvironmentOptions(com.ibm.watson.developer_cloud.discovery.v1.model.DeleteEnvironmentOptions) Ignore(org.junit.Ignore) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 20 with Environment

use of com.ibm.watson.discovery.v1.model.Environment in project java-sdk by watson-developer-cloud.

the class DiscoveryServiceIT method updateEnvironmentIsSuccessful.

@Test
@Ignore("Only 1 BYOD environment allowed per service instance, so we cannot create more")
public void updateEnvironmentIsSuccessful() {
    String environmentName = uniqueName + "-environment";
    CreateEnvironmentOptions createOptions = new CreateEnvironmentOptions.Builder().name(environmentName).size(FREE).build();
    Environment createResponse = createEnvironment(createOptions);
    String randomDescription = UUID.randomUUID().toString() + " appbuilder tests";
    UpdateEnvironmentOptions.Builder updateBuilder = new UpdateEnvironmentOptions.Builder(createResponse.getEnvironmentId()).name(environmentName);
    updateBuilder.description(randomDescription);
    Environment updateResponse = discovery.updateEnvironment(updateBuilder.build()).execute();
    assertEquals(randomDescription, updateResponse.getDescription());
}
Also used : UpdateEnvironmentOptions(com.ibm.watson.developer_cloud.discovery.v1.model.UpdateEnvironmentOptions) CreateEnvironmentOptions(com.ibm.watson.developer_cloud.discovery.v1.model.CreateEnvironmentOptions) Environment(com.ibm.watson.developer_cloud.discovery.v1.model.Environment) Ignore(org.junit.Ignore) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Aggregations

Environment (com.ibm.watson.developer_cloud.discovery.v1.model.Environment)15 Environment (com.ibm.watson.discovery.v1.model.Environment)12 Test (org.junit.Test)11 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)10 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)7 CreateEnvironmentOptions (com.ibm.watson.developer_cloud.discovery.v1.model.CreateEnvironmentOptions)6 WatsonServiceUnitTest (com.ibm.watson.common.WatsonServiceUnitTest)5 GetEnvironmentOptions (com.ibm.watson.developer_cloud.discovery.v1.model.GetEnvironmentOptions)5 JsonObject (com.google.gson.JsonObject)4 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)4 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)4 ListEnvironmentsOptions (com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsOptions)4 ListEnvironmentsResponse (com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsResponse)4 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)3 CreateEnvironmentOptions (com.ibm.watson.discovery.v1.model.CreateEnvironmentOptions)3 DeleteEnvironmentResponse (com.ibm.watson.discovery.v1.model.DeleteEnvironmentResponse)3 GetEnvironmentOptions (com.ibm.watson.discovery.v1.model.GetEnvironmentOptions)3 Ignore (org.junit.Ignore)3 UpdateEnvironmentOptions (com.ibm.watson.developer_cloud.discovery.v1.model.UpdateEnvironmentOptions)2 Collection (com.ibm.watson.discovery.v1.model.Collection)2