use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class WorkspaceDaoTest method getWorkspacesFromList.
@Test
void getWorkspacesFromList() {
Workspace realWorkspace = defaultWorkspace();
workspaceDao.createWorkspace(realWorkspace);
UUID fakeWorkspaceId = UUID.randomUUID();
List<Workspace> workspaceList = workspaceDao.getWorkspacesMatchingList(ImmutableList.of(realWorkspace.getWorkspaceId(), fakeWorkspaceId), 0, 1);
// The DAO should return all workspaces this user has access to, including realWorkspace but
// not including the fake workspace id.
assertThat(workspaceList, hasItem(equalTo(realWorkspace)));
List<UUID> workspaceIdList = workspaceList.stream().map(Workspace::getWorkspaceId).collect(Collectors.toList());
assertThat(workspaceIdList, not(hasItem(equalTo(fakeWorkspaceId))));
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class WorkspaceDaoTest method listWorkspaceLimitEnforced.
@Test
void listWorkspaceLimitEnforced() {
Workspace firstWorkspace = defaultWorkspace();
workspaceDao.createWorkspace(firstWorkspace);
UUID uuid = UUID.randomUUID();
Workspace secondWorkspace = Workspace.builder().workspaceId(uuid).userFacingId("a" + uuid.toString()).workspaceStage(WorkspaceStage.RAWLS_WORKSPACE).build();
workspaceDao.createWorkspace(secondWorkspace);
List<Workspace> workspaceList = workspaceDao.getWorkspacesMatchingList(ImmutableList.of(firstWorkspace.getWorkspaceId(), secondWorkspace.getWorkspaceId()), 0, 1);
assertThat(workspaceList.size(), equalTo(1));
assertThat(workspaceList.get(0), in(ImmutableList.of(firstWorkspace, secondWorkspace)));
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class CheckSpendProfileStep method doStep.
@Override
public StepResult doStep(FlightContext context) throws InterruptedException, RetryException {
FlightMap workingMap = context.getWorkingMap();
Workspace workspace = workspaceDao.getWorkspace(workspaceUuid);
SpendProfileId spendProfileId = workspace.getSpendProfileId().orElseThrow(() -> MissingSpendProfileException.forWorkspace(workspaceUuid));
SpendProfile spendProfile = spendProfileService.authorizeLinking(spendProfileId, userRequest);
if (spendProfile.billingAccountId().isEmpty()) {
throw NoBillingAccountException.forSpendProfile(spendProfileId);
}
workingMap.put(BILLING_ACCOUNT_ID, spendProfile.billingAccountId());
return StepResult.getStepResultSuccess();
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class AzureTestUtils method createWorkspace.
/**
* Creates a workspace, returning its workspaceUuid.
*/
public UUID createWorkspace(WorkspaceService workspaceService) {
UUID uuid = UUID.randomUUID();
Workspace request = Workspace.builder().workspaceId(uuid).userFacingId("a" + uuid.toString()).workspaceStage(WorkspaceStage.MC_WORKSPACE).build();
return workspaceService.createWorkspace(request, userAccessUtils.defaultUserAuthRequest());
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class CreateWorkspaceStep method doStep.
@Override
public StepResult doStep(FlightContext flightContext) throws RetryException, InterruptedException {
UUID workspaceUuid = workspace.getWorkspaceId();
try {
workspaceDao.createWorkspace(workspace);
} catch (DuplicateWorkspaceException ex) {
// This might be the result of a step re-running, or it might be an ID conflict. We can ignore
// this if the existing workspace matches the one we were about to create, otherwise rethrow.
Workspace existingWorkspace = workspaceDao.getWorkspace(workspaceUuid);
if (!workspace.equals(existingWorkspace)) {
throw ex;
}
}
FlightUtils.setResponse(flightContext, workspaceUuid, HttpStatus.OK);
logger.info("Workspace created with id {}", workspaceUuid);
return StepResult.getStepResultSuccess();
}
Aggregations