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);
}
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);
}
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();
}
Aggregations