use of com.ibm.watson.developer_cloud.conversation.v1.model.ListWorkspacesOptions in project java-sdk by watson-developer-cloud.
the class AssistantServiceIT method testListWorkspaces.
/**
* Test listWorkspaces.
*/
@Test
public void testListWorkspaces() {
ListWorkspacesOptions listOptions = new ListWorkspacesOptions.Builder().build();
WorkspaceCollection response = service.listWorkspaces(listOptions).execute();
assertNotNull(response);
assertNotNull(response.getWorkspaces());
assertTrue(response.getWorkspaces().size() > 0);
assertNotNull(response.getPagination());
assertNotNull(response.getPagination().getRefreshUrl());
Workspace wResponse = null;
for (Workspace resp : response.getWorkspaces()) {
if (resp.getWorkspaceId().equals(workspaceId)) {
wResponse = resp;
break;
}
}
assertNotNull(wResponse);
assertNotNull(wResponse.getName());
}
use of com.ibm.watson.developer_cloud.conversation.v1.model.ListWorkspacesOptions in project java-sdk by watson-developer-cloud.
the class ConversationServiceIT method testListWorkspaces.
/**
* Test listWorkspaces.
*/
@Test
public void testListWorkspaces() {
ListWorkspacesOptions listOptions = new ListWorkspacesOptions.Builder().build();
WorkspaceCollection response = service.listWorkspaces(listOptions).execute();
assertNotNull(response);
assertNotNull(response.getWorkspaces());
assertTrue(response.getWorkspaces().size() > 0);
assertNotNull(response.getPagination());
assertNotNull(response.getPagination().getRefreshUrl());
Workspace wResponse = null;
for (Workspace resp : response.getWorkspaces()) {
if (resp.getWorkspaceId().equals(workspaceId)) {
wResponse = resp;
break;
}
}
assertNotNull(wResponse);
assertNotNull(wResponse.getName());
}
use of com.ibm.watson.developer_cloud.conversation.v1.model.ListWorkspacesOptions in project java-sdk by watson-developer-cloud.
the class ConversationServiceIT method testListWorkspacesWithPaging.
/**
* Test listWorkspaces with paging.
*/
@Test
public void testListWorkspacesWithPaging() {
ListWorkspacesOptions listOptions = new ListWorkspacesOptions.Builder().pageLimit(1L).sort("-updated").build();
WorkspaceCollection response = service.listWorkspaces(listOptions).execute();
assertNotNull(response);
assertNotNull(response.getPagination());
assertNotNull(response.getPagination().getRefreshUrl());
assertNotNull(response.getPagination().getNextUrl());
assertNotNull(response.getPagination().getCursor());
boolean found = false;
while (true) {
if (response.getPagination().getCursor() == null) {
break;
}
assertNotNull(response.getWorkspaces());
assertTrue(response.getWorkspaces().size() == 1);
found |= response.getWorkspaces().get(0).getWorkspaceId().equals(workspaceId);
String cursor = response.getPagination().getCursor();
response = service.listWorkspaces(listOptions.newBuilder().cursor(cursor).build()).execute();
}
assertTrue(found);
}
use of com.ibm.watson.developer_cloud.conversation.v1.model.ListWorkspacesOptions in project java-sdk by watson-developer-cloud.
the class AssistantServiceIT method testListWorkspacesWithPaging.
/**
* Test listWorkspaces with paging.
*/
@Test
public void testListWorkspacesWithPaging() {
ListWorkspacesOptions listOptions = new ListWorkspacesOptions.Builder().pageLimit(1L).sort("-updated").build();
WorkspaceCollection response = service.listWorkspaces(listOptions).execute();
assertNotNull(response);
assertNotNull(response.getPagination());
assertNotNull(response.getPagination().getRefreshUrl());
assertNotNull(response.getPagination().getNextUrl());
assertNotNull(response.getPagination().getCursor());
boolean found = false;
while (true) {
if (response.getPagination().getCursor() == null) {
break;
}
assertNotNull(response.getWorkspaces());
assertTrue(response.getWorkspaces().size() == 1);
found |= response.getWorkspaces().get(0).getWorkspaceId().equals(workspaceId);
String cursor = response.getPagination().getCursor();
response = service.listWorkspaces(listOptions.newBuilder().cursor(cursor).build()).execute();
}
assertTrue(found);
}
use of com.ibm.watson.developer_cloud.conversation.v1.model.ListWorkspacesOptions in project java-sdk by watson-developer-cloud.
the class Conversation method listWorkspaces.
/**
* List workspaces.
*
* List the workspaces associated with a Conversation service instance.
*
* @param listWorkspacesOptions the {@link ListWorkspacesOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link WorkspaceCollection}
*/
public ServiceCall<WorkspaceCollection> listWorkspaces(ListWorkspacesOptions listWorkspacesOptions) {
String[] pathSegments = { "v1/workspaces" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query(VERSION, versionDate);
if (listWorkspacesOptions != null) {
if (listWorkspacesOptions.pageLimit() != null) {
builder.query("page_limit", String.valueOf(listWorkspacesOptions.pageLimit()));
}
if (listWorkspacesOptions.includeCount() != null) {
builder.query("include_count", String.valueOf(listWorkspacesOptions.includeCount()));
}
if (listWorkspacesOptions.sort() != null) {
builder.query("sort", listWorkspacesOptions.sort());
}
if (listWorkspacesOptions.cursor() != null) {
builder.query("cursor", listWorkspacesOptions.cursor());
}
if (listWorkspacesOptions.includeAudit() != null) {
builder.query("include_audit", String.valueOf(listWorkspacesOptions.includeAudit()));
}
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(WorkspaceCollection.class));
}
Aggregations