Search in sources :

Example 1 with WorkspaceDescriptionList

use of bio.terra.workspace.model.WorkspaceDescriptionList in project terra-workspace-manager by DataBiosphere.

the class ListWorkspaces method doUserJourney.

@Override
protected void doUserJourney(TestUserSpecification testUser, WorkspaceApi firstUserApi) throws Exception {
    // For the sake of listing "all" of a user's workspaces we must have a maximum upper limit. Test
    // users are expected to never have permanent workspaces, so this should be more than
    // sufficient.
    int MAX_USER_WORKSPACES = 10000;
    // While test users should not have any permanent workspaces, they may have some entries from
    // previous failures or other tests running in parallel. We therefore cannot assume they only
    // have 3 workspaces.
    WorkspaceDescriptionList workspaceList = firstUserApi.listWorkspaces(/*offset=*/
    0, /*limit=*/
    MAX_USER_WORKSPACES);
    List<UUID> workspaceIdList = workspaceList.getWorkspaces().stream().map(WorkspaceDescription::getId).collect(Collectors.toList());
    assertThat(workspaceIdList, hasItems(getWorkspaceId(), workspaceId2, workspaceId3));
    // Next, cover the same set of workspaces across 3 pages.
    int pageSize = MAX_USER_WORKSPACES / 3;
    List<WorkspaceDescription> callResults = new ArrayList<>();
    callResults.addAll(firstUserApi.listWorkspaces(/*offset=*/
    0, /*limit=*/
    pageSize).getWorkspaces());
    callResults.addAll(firstUserApi.listWorkspaces(/*offset=*/
    pageSize, /*limit=*/
    pageSize).getWorkspaces());
    // pageSize may not be divisible by 3, so cover all remaining workspaces here instead.
    callResults.addAll(firstUserApi.listWorkspaces(/*offset=*/
    pageSize * 2, /*limit=*/
    (MAX_USER_WORKSPACES - 2 * pageSize)).getWorkspaces());
    List<UUID> callResultIdList = callResults.stream().map(WorkspaceDescription::getId).collect(Collectors.toList());
    assertThat(callResultIdList, hasItems(getWorkspaceId(), workspaceId2, workspaceId3));
    // Validate that a different user will not see any of these workspaces.
    WorkspaceDescriptionList secondUserResult = secondUserApi.listWorkspaces(0, MAX_USER_WORKSPACES);
    List<UUID> secondCallResultList = secondUserResult.getWorkspaces().stream().map(WorkspaceDescription::getId).collect(Collectors.toList());
    assertThat(secondCallResultList, not(hasItem(getWorkspaceId())));
    assertThat(secondCallResultList, not(hasItem(workspaceId2)));
    assertThat(secondCallResultList, not(hasItem(workspaceId3)));
}
Also used : WorkspaceDescription(bio.terra.workspace.model.WorkspaceDescription) ArrayList(java.util.ArrayList) UUID(java.util.UUID) WorkspaceDescriptionList(bio.terra.workspace.model.WorkspaceDescriptionList)

Aggregations

WorkspaceDescription (bio.terra.workspace.model.WorkspaceDescription)1 WorkspaceDescriptionList (bio.terra.workspace.model.WorkspaceDescriptionList)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1