Search in sources :

Example 1 with UFWorkspace

use of bio.terra.cli.serialization.userfacing.UFWorkspace in project terra-cli by DataBiosphere.

the class Describe method execute.

/**
 * Describe the current workspace.
 */
@Override
protected void execute() {
    workspaceOption.overrideIfSpecified();
    formatOption.printReturnValue(new UFWorkspace(Context.requireWorkspace()), this::printText);
}
Also used : UFWorkspace(bio.terra.cli.serialization.userfacing.UFWorkspace) WorkspaceOverride(bio.terra.cli.command.shared.options.WorkspaceOverride)

Example 2 with UFWorkspace

use of bio.terra.cli.serialization.userfacing.UFWorkspace in project terra-cli by DataBiosphere.

the class Update method execute.

/**
 * Update the mutable properties of an existing workspace.
 */
@Override
protected void execute() {
    workspaceOption.overrideIfSpecified();
    Workspace updatedWorkspace = Context.requireWorkspace().update(argGroup.displayName, argGroup.description);
    formatOption.printReturnValue(new UFWorkspace(updatedWorkspace), this::printText);
}
Also used : UFWorkspace(bio.terra.cli.serialization.userfacing.UFWorkspace) Workspace(bio.terra.cli.businessobject.Workspace) UFWorkspace(bio.terra.cli.serialization.userfacing.UFWorkspace) WorkspaceOverride(bio.terra.cli.command.shared.options.WorkspaceOverride)

Example 3 with UFWorkspace

use of bio.terra.cli.serialization.userfacing.UFWorkspace in project terra-cli by DataBiosphere.

the class WorkspaceOverride method matchingCurrentWorkspace.

@Test
@DisplayName("workspace commands ignore workspace override when it matches current workspace")
void matchingCurrentWorkspace() throws IOException {
    workspaceCreator.login();
    // `terra workspace create`
    UFWorkspace workspace3 = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "create");
    // `terra workspace set --id=$id3`
    TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + workspace3.id);
    // `terra workspace update --name=$newName --description=$newDescription --workspace=$id3`
    String newName = "workspace3_name_NEW";
    String newDescription = "workspace3 description NEW";
    TestCommand.runCommandExpectSuccess("workspace", "update", "--name=" + newName, "--description=" + newDescription, "--workspace=" + workspace3.id);
    // Check that current workspace status is updated, despite the --workspace flag.
    // `terra status`
    UFStatus status = TestCommand.runAndParseCommandExpectSuccess(UFStatus.class, "status");
    assertEquals(newName, status.workspace.name);
    assertEquals(newDescription, status.workspace.description);
    // `terra workspace delete --workspace=$id3`
    TestCommand.runCommandExpectSuccess("workspace", "delete", "--workspace=" + workspace3.id, "--quiet");
    // Confirm current workspace status was cleared, despite the --workspace flag.
    UFStatus clearedStatus = TestCommand.runAndParseCommandExpectSuccess(UFStatus.class, "status");
    assertNull(clearedStatus.workspace);
}
Also used : UFStatus(bio.terra.cli.serialization.userfacing.UFStatus) UFWorkspace(bio.terra.cli.serialization.userfacing.UFWorkspace) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with UFWorkspace

use of bio.terra.cli.serialization.userfacing.UFWorkspace in project terra-cli by DataBiosphere.

the class WorkspaceOverride method workspace.

@Test
@DisplayName("workspace commands respect workspace override")
void workspace() throws IOException {
    workspaceCreator.login();
    // `terra workspace create`
    UFWorkspace workspace3 = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "create");
    // `terra workspace set --id=$id1`
    TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + workspace1.id);
    // `terra workspace update --name=$newName --description=$newDescription --workspace=$id3`
    String newName = "workspace3_name_NEW";
    String newDescription = "workspace3 description NEW";
    TestCommand.runCommandExpectSuccess("workspace", "update", "--name=" + newName, "--description=" + newDescription, "--workspace=" + workspace3.id);
    // check that the workspace 3 description has been updated, and the workspace 1 has not
    // `terra workspace describe --workspace=$id3`
    UFWorkspace workspaceDescribe = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "describe", "--workspace=" + workspace3.id);
    assertEquals(newName, workspaceDescribe.name, "workspace 3 name matches update");
    assertEquals(newDescription, workspaceDescribe.description, "workspace 3 description matches update");
    // `terra workspace describe`
    workspaceDescribe = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "describe");
    assertEquals(workspace1.name, workspaceDescribe.name, "workspace 1 name matches create");
    assertEquals(workspace1.description, workspaceDescribe.description, "workspace 1 description matches create");
    // check the workspace 3 has been deleted, and workspace 1 has not
    // `terra workspace delete --workspace=$id3`
    TestCommand.runCommandExpectSuccess("workspace", "delete", "--workspace=" + workspace3.id, "--quiet");
    // `terra workspace list`
    List<UFWorkspaceLight> matchingWorkspaces = listWorkspacesWithId(workspace3.id);
    assertEquals(0, matchingWorkspaces.size(), "deleted workspace 3 is not included in list");
    // `terra workspace list`
    matchingWorkspaces = listWorkspacesWithId(workspace1.id);
    assertEquals(1, matchingWorkspaces.size(), "workspace 1 is still included in list");
}
Also used : UFWorkspaceLight(bio.terra.cli.serialization.userfacing.UFWorkspaceLight) UFWorkspace(bio.terra.cli.serialization.userfacing.UFWorkspace) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 5 with UFWorkspace

use of bio.terra.cli.serialization.userfacing.UFWorkspace in project terra-cli by DataBiosphere.

the class WorkspaceSetDeferLogin method setupOnce.

@BeforeAll
protected void setupOnce() throws Exception {
    super.setupOnce();
    // `terra workspace create --format=json`
    UFWorkspace createWorkspace = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "create");
    sharedWorkspaceId = createWorkspace.id;
    workspaceSharee = TestUser.chooseTestUserWhoIsNot(workspaceCreator);
    // `terra workspace add-user --email=$sharee --role=READER`
    TestCommand.runCommandExpectSuccess("workspace", "add-user", "--email=" + workspaceSharee.email, "--role=READER");
}
Also used : UFWorkspace(bio.terra.cli.serialization.userfacing.UFWorkspace) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

UFWorkspace (bio.terra.cli.serialization.userfacing.UFWorkspace)31 DisplayName (org.junit.jupiter.api.DisplayName)21 Test (org.junit.jupiter.api.Test)21 UFStatus (bio.terra.cli.serialization.userfacing.UFStatus)8 TestUser (harness.TestUser)7 Workspace (bio.terra.cli.businessobject.Workspace)5 UFWorkspaceLight (bio.terra.cli.serialization.userfacing.UFWorkspaceLight)5 WorkspaceOverride (bio.terra.cli.command.shared.options.WorkspaceOverride)4 TestCommand (harness.TestCommand)4 UFBqDataset (bio.terra.cli.serialization.userfacing.resource.UFBqDataset)3 UFGcsObject (bio.terra.cli.serialization.userfacing.resource.UFGcsObject)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 Matchers.emptyString (org.hamcrest.Matchers.emptyString)3 UFAuthStatus (bio.terra.cli.serialization.userfacing.UFAuthStatus)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2 Result (harness.TestCommand.Result)2 IOException (java.io.IOException)2 List (java.util.List)2 Optional (java.util.Optional)2 UUID (java.util.UUID)2