use of com.ibm.watson.developer_cloud.discovery.v1.model.environment.Environment in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method setupClass.
@BeforeClass
public static void setupClass() throws Exception {
// get the properties
dummyTest = new DiscoveryServiceIT();
String username = dummyTest.getProperty("discovery.username");
Assume.assumeFalse("config.properties doesn't have valid credentials.", (username == null) || username.equals(PLACEHOLDER));
dummyTest.setup();
ListEnvironmentsOptions listOptions = new ListEnvironmentsOptions.Builder().build();
ListEnvironmentsResponse listResponse = dummyTest.discovery.listEnvironments(listOptions).execute();
for (Environment environment : listResponse.getEnvironments()) {
// look for an existing environment that isn't read only
if (!environment.isReadOnly()) {
environmentId = environment.getEnvironmentId();
break;
}
}
if (environmentId == null) {
// no environment found, create a new one (assuming we are a FREE plan)
String environmentName = "watson_developer_cloud_test_environment";
CreateEnvironmentOptions createOptions = new CreateEnvironmentOptions.Builder().name(environmentName).size(FREE).build();
Environment createResponse = dummyTest.discovery.createEnvironment(createOptions).execute();
environmentId = createResponse.getEnvironmentId();
WaitFor.Condition environmentReady = new EnvironmentReady(dummyTest.discovery, environmentId);
WaitFor.waitFor(environmentReady, 30, TimeUnit.SECONDS, 500);
}
collectionId = dummyTest.setupTestDocuments();
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.environment.Environment 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.developer_cloud.discovery.v1.model.environment.Environment in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method createEnvironmentIsSuccessful.
// Deleted test for listEnvironments with null name as this does not fail in the current SDK
@Test
public void createEnvironmentIsSuccessful() throws InterruptedException {
server.enqueue(jsonResponse(createEnvResp));
CreateEnvironmentOptions.Builder createRequestBuilder = new CreateEnvironmentOptions.Builder().name(environmentName).size(THREE);
createRequestBuilder.description(environmentDesc);
Environment response = discoveryService.createEnvironment(createRequestBuilder.build()).execute();
RecordedRequest request = server.takeRequest();
assertEquals(ENV2_PATH, request.getPath());
assertEquals(POST, request.getMethod());
assertEquals(createEnvResp, response);
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.environment.Environment in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method listEnvironmentsHasNewsEnvironment.
@Test
public void listEnvironmentsHasNewsEnvironment() {
ListEnvironmentsOptions listOptions = new ListEnvironmentsOptions.Builder().build();
ListEnvironmentsResponse listResponse = discovery.listEnvironments(listOptions).execute();
boolean foundNews = false;
for (Environment environment : listResponse.getEnvironments()) {
if (environment.isReadOnly()) {
foundNews = true;
break;
}
}
assertTrue(foundNews);
}
use of com.ibm.watson.developer_cloud.discovery.v1.model.environment.Environment in project java-sdk by watson-developer-cloud.
the class Discovery method getEnvironment.
/**
* Get environment info.
*
* @param getEnvironmentOptions the {@link GetEnvironmentOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Environment}
*/
public ServiceCall<Environment> getEnvironment(GetEnvironmentOptions getEnvironmentOptions) {
Validator.notNull(getEnvironmentOptions, "getEnvironmentOptions cannot be null");
String[] pathSegments = { "v1/environments" };
String[] pathParameters = { getEnvironmentOptions.environmentId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Environment.class));
}
Aggregations