use of org.broadinstitute.consent.http.models.Dac in project consent by DataBiosphere.
the class MetricsServiceTest method initializeMetricsDAOCalls.
private void initializeMetricsDAOCalls(int darCount, int datasetCount) {
when(darDAO.findAllDataAccessRequests()).thenReturn(generateDars(darCount));
when(dataSetDAO.findDatasetsByIdList(any())).thenReturn(generateDatasets(datasetCount));
when(electionDAO.findLastElectionsByReferenceIds(any())).thenReturn(Collections.emptyList());
when(matchDAO.findMatchesForPurposeIds(any())).thenReturn(Collections.emptyList());
when(electionDAO.findAllDacsForElectionIds(any())).thenReturn(Collections.emptyList());
Dac dac = generateDac();
when(dacService.findAllDacsWithMembers()).thenReturn(Collections.singletonList(dac));
List<DatasetDTO> datasetDTOS = generateDatasetDTO(datasetCount);
when(dataSetDAO.findDatasetsWithDacs()).thenReturn(new HashSet<>(datasetDTOS));
}
use of org.broadinstitute.consent.http.models.Dac in project consent by DataBiosphere.
the class DarCollectionServiceDAOTest method setUpDarCollectionWithDacDataset.
private DarCollection setUpDarCollectionWithDacDataset() {
Dac dac = createDac();
createUserWithRoleInDac(UserRoles.CHAIRPERSON.getRoleId(), dac.getDacId());
createUserWithRoleInDac(UserRoles.MEMBER.getRoleId(), dac.getDacId());
Consent consent = createConsent(dac.getDacId());
DataSet dataset = createDataset();
createAssociation(consent.getConsentId(), dataset.getDataSetId());
DarCollection collection = createDarCollectionWithSingleDataAccessRequest();
DataAccessRequest dar = collection.getDars().values().stream().findFirst().orElse(null);
assertNotNull(dar);
assertNotNull(dar.getData());
dar.getData().setDatasetIds(List.of(dataset.getDataSetId()));
Date now = new Date();
dataAccessRequestDAO.updateDataByReferenceIdVersion2(dar.getReferenceId(), dar.getUserId(), now, now, now, dar.getData());
return darCollectionDAO.findDARCollectionByReferenceId(dar.getReferenceId());
}
use of org.broadinstitute.consent.http.models.Dac in project consent by DataBiosphere.
the class DataAccessRequestServiceTest method testDescribeDataAccessRequestManageV2.
@Test
public void testDescribeDataAccessRequestManageV2() {
User user = new User();
Integer genericId = 1;
DataAccessRequest dar = generateDataAccessRequest();
dar.setData(new DataAccessRequestData());
dar.getData().setDatasetIds(Collections.singletonList(genericId));
when(dataAccessRequestDAO.findAllDataAccessRequests()).thenReturn(Collections.singletonList(dar));
when(dacService.filterDataAccessRequestsByDac(any(), 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.ADMIN);
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.Dac in project consent by DataBiosphere.
the class DataAccessRequestServiceTest method testDescribeDataAccessRequestManageV2_Researcher.
@Test
public void testDescribeDataAccessRequestManageV2_Researcher() {
User user = new User();
user.setRoles(Arrays.asList(new UserRole(5, UserRoles.RESEARCHER.getRoleName())));
Integer genericId = 1;
DataAccessRequest dar = generateDataAccessRequest();
dar.setData(new DataAccessRequestData());
dar.getData().setDatasetIds(Collections.singletonList(genericId));
when(dataAccessRequestDAO.findAllDarsByUserId(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.RESEARCHER);
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.Dac in project consent by DataBiosphere.
the class DacServiceTest method testRemoveDacMember.
@Test
public void testRemoveDacMember() {
Role role = new Role(UserRoles.MEMBER.getRoleId(), UserRoles.MEMBER.getRoleName());
Dac dac = getDacs().get(0);
User member = getDacUsers().get(1);
dac.setChairpersons(Collections.singletonList(getDacUsers().get(0)));
dac.setMembers(Collections.singletonList(member));
doNothing().when(dacDAO).removeDacMember(anyInt());
doNothing().when(voteService).deleteOpenDacVotesForUser(any(), any());
initService();
try {
service.removeDacMember(role, member, dac);
} catch (Exception e) {
Assert.fail();
}
verify(dacDAO, atLeastOnce()).removeDacMember(anyInt());
verify(voteService, atLeastOnce()).deleteOpenDacVotesForUser(any(), any());
}
Aggregations