Search in sources :

Example 1 with ResearchPurposeReviewRequest

use of org.pmiops.workbench.model.ResearchPurposeReviewRequest in project workbench by all-of-us.

the class WorkspacesControllerTest method testListForApproval.

@Test
public void testListForApproval() throws Exception {
    List<Workspace> forApproval = workspacesController.getWorkspacesForReview().getBody().getItems();
    assertThat(forApproval).isEmpty();
    Workspace ws;
    ResearchPurpose researchPurpose;
    String nameForRequested = "requestedButNotApprovedYet";
    // requested approval, but not approved
    ws = createDefaultWorkspace();
    ws.setName(nameForRequested);
    researchPurpose = ws.getResearchPurpose();
    researchPurpose.setApproved(null);
    researchPurpose.setTimeReviewed(null);
    stubGetWorkspace(ws.getNamespace(), ws.getName().toLowerCase(), LOGGED_IN_USER_EMAIL, WorkspaceAccessLevel.OWNER);
    workspacesController.createWorkspace(ws);
    // already approved
    ws = createDefaultWorkspace();
    ws.setName("alreadyApproved");
    stubGetWorkspace(ws.getNamespace(), ws.getName().toLowerCase(), LOGGED_IN_USER_EMAIL, WorkspaceAccessLevel.OWNER);
    researchPurpose = ws.getResearchPurpose();
    ws = workspacesController.createWorkspace(ws).getBody();
    ResearchPurposeReviewRequest request = new ResearchPurposeReviewRequest();
    request.setApproved(true);
    workspacesController.reviewWorkspace(ws.getNamespace(), ws.getId(), request);
    // no approval requested
    ws = createDefaultWorkspace();
    ws.setName("noApprovalRequested");
    researchPurpose = ws.getResearchPurpose();
    researchPurpose.setReviewRequested(false);
    researchPurpose.setTimeRequested(null);
    researchPurpose.setApproved(null);
    researchPurpose.setTimeReviewed(null);
    stubGetWorkspace(ws.getNamespace(), ws.getName().toLowerCase(), LOGGED_IN_USER_EMAIL, WorkspaceAccessLevel.OWNER);
    ws = workspacesController.createWorkspace(ws).getBody();
    forApproval = workspacesController.getWorkspacesForReview().getBody().getItems();
    assertThat(forApproval.size()).isEqualTo(1);
    ws = forApproval.get(0);
    assertThat(ws.getName()).isEqualTo(nameForRequested);
}
Also used : ResearchPurposeReviewRequest(org.pmiops.workbench.model.ResearchPurposeReviewRequest) Matchers.anyString(org.mockito.Matchers.anyString) Workspace(org.pmiops.workbench.model.Workspace) ResearchPurpose(org.pmiops.workbench.model.ResearchPurpose) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 2 with ResearchPurposeReviewRequest

use of org.pmiops.workbench.model.ResearchPurposeReviewRequest in project workbench by all-of-us.

the class WorkspacesControllerTest method testRejectAfterApproveThrows.

@Test(expected = BadRequestException.class)
public void testRejectAfterApproveThrows() throws Exception {
    Workspace ws = createDefaultWorkspace();
    ResearchPurpose researchPurpose = ws.getResearchPurpose();
    workspacesController.createWorkspace(ws);
    ResearchPurposeReviewRequest request = new ResearchPurposeReviewRequest();
    request.setApproved(true);
    workspacesController.reviewWorkspace(ws.getNamespace(), ws.getName(), request);
    request.setApproved(false);
    workspacesController.reviewWorkspace(ws.getNamespace(), ws.getName(), request);
}
Also used : ResearchPurposeReviewRequest(org.pmiops.workbench.model.ResearchPurposeReviewRequest) Workspace(org.pmiops.workbench.model.Workspace) ResearchPurpose(org.pmiops.workbench.model.ResearchPurpose) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 3 with ResearchPurposeReviewRequest

use of org.pmiops.workbench.model.ResearchPurposeReviewRequest in project workbench by all-of-us.

the class WorkspacesControllerTest method testApproveWorkspace.

@Test
public void testApproveWorkspace() throws Exception {
    Workspace ws = createDefaultWorkspace();
    ResearchPurpose researchPurpose = ws.getResearchPurpose();
    researchPurpose.setApproved(null);
    researchPurpose.setTimeReviewed(null);
    workspacesController.createWorkspace(ws);
    ResearchPurposeReviewRequest request = new ResearchPurposeReviewRequest();
    request.setApproved(true);
    workspacesController.reviewWorkspace(ws.getNamespace(), ws.getName(), request);
    stubGetWorkspace(ws.getNamespace(), ws.getName(), ws.getCreator(), WorkspaceAccessLevel.OWNER);
    ws = workspacesController.getWorkspace(ws.getNamespace(), ws.getName()).getBody().getWorkspace();
    researchPurpose = ws.getResearchPurpose();
    assertThat(researchPurpose.getApproved()).isTrue();
}
Also used : ResearchPurposeReviewRequest(org.pmiops.workbench.model.ResearchPurposeReviewRequest) Workspace(org.pmiops.workbench.model.Workspace) ResearchPurpose(org.pmiops.workbench.model.ResearchPurpose) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 ResearchPurpose (org.pmiops.workbench.model.ResearchPurpose)3 ResearchPurposeReviewRequest (org.pmiops.workbench.model.ResearchPurposeReviewRequest)3 Workspace (org.pmiops.workbench.model.Workspace)3 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)3 Matchers.anyString (org.mockito.Matchers.anyString)1