use of org.broadinstitute.consent.http.models.DataAccessRequestManage in project consent by DataBiosphere.
the class DataAccessRequestResourceTest method testDescribeManageDataAccessRequestsV2_WithRole.
@Test
public void testDescribeManageDataAccessRequestsV2_WithRole() {
User researcher = new User();
researcher.setDacUserId(1);
researcher.setRoles(Arrays.asList(new UserRole(5, UserRoles.RESEARCHER.getRoleName())));
when(userService.findUserByEmail(any())).thenReturn(researcher);
DataAccessRequest dar = generateDataAccessRequest();
DataAccessRequestManage manage = new DataAccessRequestManage();
manage.setDar(dar);
when(dataAccessRequestService.describeDataAccessRequestManageV2(any(), any())).thenReturn(Collections.singletonList(manage));
resource = new DataAccessRequestResource(dataAccessRequestService, userService, consentService, electionService);
Response response = resource.describeManageDataAccessRequestsV2(authUser, Optional.of("Researcher"));
assertEquals(HttpStatusCodes.STATUS_CODE_OK, response.getStatus());
}
use of org.broadinstitute.consent.http.models.DataAccessRequestManage in project consent by DataBiosphere.
the class DataAccessRequestResourceVersion2 method getDraftManageDataAccessRequests.
@GET
@Produces("application/json")
@Path("/draft/manage")
@RolesAllowed(RESEARCHER)
public Response getDraftManageDataAccessRequests(@Auth AuthUser authUser) {
try {
User user = findUserByEmail(authUser.getEmail());
List<DataAccessRequestManage> partials = dataAccessRequestService.getDraftDataAccessRequestManage(user.getDacUserId());
return Response.ok().entity(partials).build();
} catch (Exception e) {
return createExceptionResponse(e);
}
}
use of org.broadinstitute.consent.http.models.DataAccessRequestManage in project consent by DataBiosphere.
the class DataAccessRequestServiceTest method testDescribeDataAccessRequestManageV2_SO.
@Test
public void testDescribeDataAccessRequestManageV2_SO() {
User user = new User();
user.setInstitutionId(1);
user.setRoles(new ArrayList<>());
user.getRoles().add(new UserRole(7, UserRoles.SIGNINGOFFICIAL.getRoleName()));
Integer genericId = 1;
DataAccessRequest dar = generateDataAccessRequest();
dar.setData(new DataAccessRequestData());
dar.getData().setDatasetIds(Collections.singletonList(genericId));
when(dataAccessRequestDAO.findAllDataAccessRequestsForInstitution(any())).thenReturn(Collections.singletonList(dar));
Election e = new Election();
e.setReferenceId(dar.getReferenceId());
e.setElectionId(genericId);
when(electionDAO.findLastElectionsByReferenceIdsAndType(any(), any())).thenReturn(Collections.singletonList(e));
Vote v = new Vote();
v.setVoteId(genericId);
v.setElectionId(e.getElectionId());
when(voteDAO.findVotesByElectionIds(any())).thenReturn(Collections.singletonList(v));
Dac d = new Dac();
d.setDacId(genericId);
d.addDatasetId(genericId);
when(dacDAO.findDacsForDatasetIds(any())).thenReturn(Collections.singleton(d));
initService();
List<DataAccessRequestManage> manages = service.describeDataAccessRequestManageV2(user, UserRoles.SIGNINGOFFICIAL);
assertNotNull(manages);
assertFalse(manages.isEmpty());
assertEquals(dar.getReferenceId(), manages.get(0).getDar().getReferenceId());
assertEquals(1, manages.size());
assertEquals(e.getElectionId(), manages.get(0).getElection().getElectionId());
assertEquals(d.getDacId(), manages.get(0).getDac().getDacId());
assertFalse(manages.get(0).getVotes().isEmpty());
}
use of org.broadinstitute.consent.http.models.DataAccessRequestManage in project consent by DataBiosphere.
the class DataAccessRequestServiceTest method getDraftDataAccessRequestManage_NullUserId.
@Test
public void getDraftDataAccessRequestManage_NullUserId() {
DataAccessRequest dar = new DataAccessRequest();
dar.setReferenceId("referenceId");
dar.setUserId(1);
DataAccessRequestData data = new DataAccessRequestData();
data.setDatasetIds(Arrays.asList(361));
dar.setData(data);
when(dataAccessRequestDAO.findAllDraftDataAccessRequests()).thenReturn(Arrays.asList(dar));
initService();
List<DataAccessRequestManage> darManages = service.getDraftDataAccessRequestManage(null);
assertEquals(1, darManages.size());
}
use of org.broadinstitute.consent.http.models.DataAccessRequestManage in project consent by DataBiosphere.
the class DataAccessRequestResourceTest method testDescribeManageDataAccessRequestsV2.
@Test
public void testDescribeManageDataAccessRequestsV2() {
User user = new User();
user.setRoles(Collections.singletonList(new UserRole(4, UserRoles.ADMIN.getRoleName())));
DataAccessRequest dar = generateDataAccessRequest();
DataAccessRequestManage manage = new DataAccessRequestManage();
manage.setDar(dar);
when(userService.findUserByEmail(any())).thenReturn(user);
when(dataAccessRequestService.describeDataAccessRequestManageV2(any(), any())).thenReturn(Collections.singletonList(manage));
resource = new DataAccessRequestResource(dataAccessRequestService, userService, consentService, electionService);
Response response = resource.describeManageDataAccessRequestsV2(authUser, Optional.empty());
assertEquals(HttpStatusCodes.STATUS_CODE_OK, response.getStatus());
}
Aggregations