use of org.broadinstitute.consent.http.models.Consent in project consent by DataBiosphere.
the class VoteDAOTest method testFindVotesByElectionIdAndDACUserIds.
@Test
public void testFindVotesByElectionIdAndDACUserIds() {
User user = createUserWithRole(UserRoles.CHAIRPERSON.getRoleId());
Dac dac = createDac();
Consent consent = createConsent(dac.getDacId());
DataSet dataset = createDataset();
Election election = createAccessElection(consent.getConsentId(), dataset.getDataSetId());
Vote vote = createDacVote(user.getDacUserId(), election.getElectionId());
List<Vote> foundVotes = voteDAO.findVotesByElectionIdAndDACUserIds(election.getElectionId(), Collections.singletonList(user.getDacUserId()));
assertNotNull(foundVotes);
assertFalse(foundVotes.isEmpty());
assertEquals(vote.getVoteId(), foundVotes.get(0).getVoteId());
}
use of org.broadinstitute.consent.http.models.Consent in project consent by DataBiosphere.
the class VoteDAOTest method testFindVotesByReferenceId.
@Test
public void testFindVotesByReferenceId() {
User user = createUserWithRole(UserRoles.CHAIRPERSON.getRoleId());
Consent consent = createConsent(null);
DataSet dataset = createDataset();
Election election = createAccessElection(consent.getConsentId(), dataset.getDataSetId());
Vote vote = createDacVote(user.getDacUserId(), election.getElectionId());
List<Vote> votes = voteDAO.findVotesByReferenceId(election.getReferenceId());
Assert.assertFalse(votes.isEmpty());
Assert.assertEquals(vote.getVoteId(), votes.get(0).getVoteId());
}
use of org.broadinstitute.consent.http.models.Consent in project consent by DataBiosphere.
the class VoteDAOTest method testRemoveVotesByIds.
@Test
public void testRemoveVotesByIds() {
User user = createUserWithRole(UserRoles.CHAIRPERSON.getRoleId());
DataSet dataset = createDataset();
Dac dac = createDac();
Consent consent = createConsent(dac.getDacId());
Election election = createAccessElection(consent.getConsentId(), dataset.getDataSetId());
Vote vote = createDacVote(user.getDacUserId(), election.getElectionId());
voteDAO.removeVotesByIds(Collections.singletonList(vote.getVoteId()));
Vote v = voteDAO.findVoteById(vote.getVoteId());
assertNull(v);
}
use of org.broadinstitute.consent.http.models.Consent in project consent by DataBiosphere.
the class VoteDAOTest method testUpdateVote.
@Test
public void testUpdateVote() {
User user = createUser();
DataSet dataset = createDataset();
Dac dac = createDac();
Consent consent = createConsent(dac.getDacId());
Election election = createAccessElection(consent.getConsentId(), dataset.getDataSetId());
Vote v = createDacVote(user.getDacUserId(), election.getElectionId());
String rationale = "rationale";
Date now = new Date();
voteDAO.updateVote(true, rationale, now, v.getVoteId(), true, election.getElectionId(), now, true);
Vote vote = voteDAO.findVoteById(v.getVoteId());
Assert.assertTrue(vote.getVote());
Assert.assertTrue(vote.getHasConcerns());
Assert.assertTrue(vote.getIsReminderSent());
Assert.assertEquals(vote.getRationale(), rationale);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Assert.assertEquals(sdf.format(vote.getCreateDate()), sdf.format(now));
Assert.assertEquals(sdf.format(vote.getUpdateDate()), sdf.format(now));
}
use of org.broadinstitute.consent.http.models.Consent in project consent by DataBiosphere.
the class VoteDAOTest method testDeleteVoteById.
@Test
public void testDeleteVoteById() {
User user = createUserWithRole(UserRoles.CHAIRPERSON.getRoleId());
Dac dac = createDac();
Consent consent = createConsent(dac.getDacId());
DataSet dataset = createDataset();
Election election = createAccessElection(consent.getConsentId(), dataset.getDataSetId());
Vote vote = createDacVote(user.getDacUserId(), election.getElectionId());
voteDAO.deleteVoteById(vote.getVoteId());
Vote foundVote = voteDAO.findVoteById(vote.getVoteId());
assertNull(foundVote);
}
Aggregations