Search in sources :

Example 1 with ListWorkspacesOptions

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());
}
Also used : ListWorkspacesOptions(com.ibm.watson.developer_cloud.assistant.v1.model.ListWorkspacesOptions) WorkspaceCollection(com.ibm.watson.developer_cloud.assistant.v1.model.WorkspaceCollection) Workspace(com.ibm.watson.developer_cloud.assistant.v1.model.Workspace) Test(org.junit.Test)

Example 2 with ListWorkspacesOptions

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());
}
Also used : ListWorkspacesOptions(com.ibm.watson.developer_cloud.conversation.v1.model.ListWorkspacesOptions) WorkspaceCollection(com.ibm.watson.developer_cloud.conversation.v1.model.WorkspaceCollection) Workspace(com.ibm.watson.developer_cloud.conversation.v1.model.Workspace) Test(org.junit.Test)

Example 3 with ListWorkspacesOptions

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);
}
Also used : ListWorkspacesOptions(com.ibm.watson.developer_cloud.conversation.v1.model.ListWorkspacesOptions) WorkspaceCollection(com.ibm.watson.developer_cloud.conversation.v1.model.WorkspaceCollection) Test(org.junit.Test)

Example 4 with ListWorkspacesOptions

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);
}
Also used : ListWorkspacesOptions(com.ibm.watson.developer_cloud.assistant.v1.model.ListWorkspacesOptions) WorkspaceCollection(com.ibm.watson.developer_cloud.assistant.v1.model.WorkspaceCollection) Test(org.junit.Test)

Example 5 with ListWorkspacesOptions

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));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) WorkspaceCollection(com.ibm.watson.developer_cloud.conversation.v1.model.WorkspaceCollection)

Aggregations

Test (org.junit.Test)4 WorkspaceCollection (com.ibm.watson.developer_cloud.conversation.v1.model.WorkspaceCollection)3 ListWorkspacesOptions (com.ibm.watson.developer_cloud.assistant.v1.model.ListWorkspacesOptions)2 WorkspaceCollection (com.ibm.watson.developer_cloud.assistant.v1.model.WorkspaceCollection)2 ListWorkspacesOptions (com.ibm.watson.developer_cloud.conversation.v1.model.ListWorkspacesOptions)2 Workspace (com.ibm.watson.developer_cloud.assistant.v1.model.Workspace)1 Workspace (com.ibm.watson.developer_cloud.conversation.v1.model.Workspace)1 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1