use of org.broadinstitute.consent.http.models.Vote in project consent by DataBiosphere.
the class VoteServiceTest method testMemberCreateVotesDataAccessManualReview.
@Test
public void testMemberCreateVotesDataAccessManualReview() {
setUpUserAndElectionVotes(UserRoles.MEMBER);
initService();
List<Vote> votes = service.createVotes(new Election(), ElectionType.DATA_ACCESS, false);
assertFalse(votes.isEmpty());
// Should create 1 member vote
assertEquals(1, votes.size());
}
use of org.broadinstitute.consent.http.models.Vote in project consent by DataBiosphere.
the class VoteServiceTest method testUpdateVote_ByReferenceId.
@Test
public void testUpdateVote_ByReferenceId() {
Vote v = setUpTestVote(false, false);
when(voteDAO.checkVoteById("test", v.getVoteId())).thenReturn(v.getVoteId());
when(electionDAO.getOpenElectionIdByReferenceId("test")).thenReturn(1);
initService();
Vote vote = service.updateVote(v, v.getVoteId(), "test");
assertNotNull(vote);
}
use of org.broadinstitute.consent.http.models.Vote in project consent by DataBiosphere.
the class VoteServiceTest method testMemberCreateVotesDataAccess.
@Test
public void testMemberCreateVotesDataAccess() {
setUpUserAndElectionVotes(UserRoles.MEMBER);
initService();
List<Vote> votes = service.createVotes(new Election(), ElectionType.DATA_ACCESS, false);
assertFalse(votes.isEmpty());
// Should create 1 member vote
assertEquals(1, votes.size());
}
use of org.broadinstitute.consent.http.models.Vote in project consent by DataBiosphere.
the class VoteServiceTest method testNotifyResearchersOfDarApproval_2Dars_2Collections.
@Test
public void testNotifyResearchersOfDarApproval_2Dars_2Collections() throws Exception {
String referenceId1 = UUID.randomUUID().toString();
String referenceId2 = UUID.randomUUID().toString();
Vote v1 = new Vote();
v1.setVote(true);
v1.setType(VoteType.FINAL.getValue());
v1.setElectionId(1);
v1.setDacUserId(1);
Vote v2 = new Vote();
v2.setVote(true);
v2.setType(VoteType.FINAL.getValue());
v2.setElectionId(2);
v2.setDacUserId(1);
Dataset d1 = new Dataset();
d1.setDataSetId(1);
d1.setName(RandomStringUtils.random(50, true, false));
d1.setAlias(1);
d1.setDataUse(new DataUseBuilder().setGeneralUse(false).setCommercialUse(true).build());
Dataset d2 = new Dataset();
d2.setDataSetId(2);
d2.setName(RandomStringUtils.random(50, true, false));
d2.setAlias(2);
d2.setDataUse(new DataUseBuilder().setGeneralUse(false).setHmbResearch(true).build());
Election e1 = new Election();
e1.setElectionId(1);
e1.setReferenceId(referenceId1);
e1.setElectionType(ElectionType.DATA_ACCESS.getValue());
e1.setDataSetId(1);
Election e2 = new Election();
e2.setElectionId(2);
e2.setReferenceId(referenceId2);
e2.setElectionType(ElectionType.DATA_ACCESS.getValue());
e2.setDataSetId(2);
DataAccessRequest dar1 = new DataAccessRequest();
DataAccessRequestData data1 = new DataAccessRequestData();
data1.setDatasetIds(List.of(d1.getDataSetId()));
dar1.setCollectionId(1);
dar1.setData(data1);
dar1.setReferenceId(referenceId1);
DataAccessRequest dar2 = new DataAccessRequest();
DataAccessRequestData data2 = new DataAccessRequestData();
data2.setDatasetIds(List.of(d2.getDataSetId()));
dar2.setCollectionId(2);
dar2.setData(data2);
dar2.setReferenceId(referenceId2);
DarCollection c1 = new DarCollection();
c1.setDarCollectionId(1);
c1.addDar(dar1);
c1.setDarCode("DAR-CODE-1");
DarCollection c2 = new DarCollection();
c2.setDarCollectionId(2);
c2.addDar(dar2);
c2.setDarCode("DAR-CODE-2");
when(electionDAO.findElectionsByIds(any())).thenReturn(List.of(e1, e2));
when(dataAccessRequestDAO.findByReferenceIds(any())).thenReturn(List.of(dar1, dar2));
when(darCollectionDAO.findDARCollectionByCollectionIds(any())).thenReturn(List.of(c1, c2));
when(datasetDAO.findDatasetsByIdList(any())).thenReturn(List.of(d1, d2));
spy(emailNotifierService);
initService();
service.notifyResearchersOfDarApproval(List.of(v1, v2));
// Since we have 2 collections with different DAR/Datasets, we should be sending 2 emails
verify(emailNotifierService, times(2)).sendResearcherDarApproved(any(), any(), anyList(), any());
}
use of org.broadinstitute.consent.http.models.Vote in project consent by DataBiosphere.
the class VoteServiceTest method testNotifyResearchersOfDarApproval_2Dars_1Collection.
@Test
public void testNotifyResearchersOfDarApproval_2Dars_1Collection() throws Exception {
String referenceId1 = UUID.randomUUID().toString();
String referenceId2 = UUID.randomUUID().toString();
Vote v1 = new Vote();
v1.setVote(true);
v1.setType(VoteType.FINAL.getValue());
v1.setElectionId(1);
v1.setDacUserId(1);
Vote v2 = new Vote();
v2.setVote(true);
v2.setType(VoteType.FINAL.getValue());
v2.setElectionId(2);
v2.setDacUserId(1);
Dataset d1 = new Dataset();
d1.setDataSetId(1);
d1.setName(RandomStringUtils.random(50, true, false));
d1.setAlias(1);
d1.setDataUse(new DataUseBuilder().setGeneralUse(false).setCommercialUse(true).build());
Dataset d2 = new Dataset();
d2.setDataSetId(2);
d2.setName(RandomStringUtils.random(50, true, false));
d2.setAlias(2);
d2.setDataUse(new DataUseBuilder().setGeneralUse(false).setHmbResearch(true).build());
Election e1 = new Election();
e1.setElectionId(1);
e1.setReferenceId(referenceId1);
e1.setElectionType(ElectionType.DATA_ACCESS.getValue());
e1.setDataSetId(1);
Election e2 = new Election();
e2.setElectionId(2);
e2.setReferenceId(referenceId2);
e2.setElectionType(ElectionType.DATA_ACCESS.getValue());
e2.setDataSetId(2);
DataAccessRequest dar1 = new DataAccessRequest();
DataAccessRequestData data1 = new DataAccessRequestData();
data1.setDatasetIds(List.of(d1.getDataSetId()));
dar1.setCollectionId(1);
dar1.setData(data1);
dar1.setReferenceId(referenceId1);
DataAccessRequest dar2 = new DataAccessRequest();
DataAccessRequestData data2 = new DataAccessRequestData();
data2.setDatasetIds(List.of(d2.getDataSetId()));
dar2.setCollectionId(1);
dar2.setData(data2);
dar2.setReferenceId(referenceId2);
DarCollection c = new DarCollection();
c.setDarCollectionId(1);
c.addDar(dar1);
c.addDar(dar2);
c.setDarCode("DAR-CODE");
when(electionDAO.findElectionsByIds(any())).thenReturn(List.of(e1, e2));
when(dataAccessRequestDAO.findByReferenceIds(any())).thenReturn(List.of(dar1, dar2));
when(darCollectionDAO.findDARCollectionByCollectionIds(any())).thenReturn(List.of(c));
when(datasetDAO.findDatasetsByIdList(any())).thenReturn(List.of(d1, d2));
spy(emailNotifierService);
initService();
service.notifyResearchersOfDarApproval(List.of(v1, v2));
// Since we have 1 collection with different DAR/Datasets, we should be sending 1 email
verify(emailNotifierService, times(1)).sendResearcherDarApproved(any(), any(), anyList(), any());
}
Aggregations