Search in sources :

Example 26 with Consent

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());
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) ElectionReviewVote(org.broadinstitute.consent.http.models.ElectionReviewVote) User(org.broadinstitute.consent.http.models.User) Consent(org.broadinstitute.consent.http.models.Consent) DataSet(org.broadinstitute.consent.http.models.DataSet) Dac(org.broadinstitute.consent.http.models.Dac) Election(org.broadinstitute.consent.http.models.Election) Test(org.junit.Test)

Example 27 with Consent

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());
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) ElectionReviewVote(org.broadinstitute.consent.http.models.ElectionReviewVote) User(org.broadinstitute.consent.http.models.User) Consent(org.broadinstitute.consent.http.models.Consent) DataSet(org.broadinstitute.consent.http.models.DataSet) Election(org.broadinstitute.consent.http.models.Election) Test(org.junit.Test)

Example 28 with Consent

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);
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) ElectionReviewVote(org.broadinstitute.consent.http.models.ElectionReviewVote) User(org.broadinstitute.consent.http.models.User) DataSet(org.broadinstitute.consent.http.models.DataSet) Consent(org.broadinstitute.consent.http.models.Consent) Dac(org.broadinstitute.consent.http.models.Dac) Election(org.broadinstitute.consent.http.models.Election) Test(org.junit.Test)

Example 29 with Consent

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));
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) ElectionReviewVote(org.broadinstitute.consent.http.models.ElectionReviewVote) User(org.broadinstitute.consent.http.models.User) DataSet(org.broadinstitute.consent.http.models.DataSet) Consent(org.broadinstitute.consent.http.models.Consent) Dac(org.broadinstitute.consent.http.models.Dac) Election(org.broadinstitute.consent.http.models.Election) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 30 with Consent

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);
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) ElectionReviewVote(org.broadinstitute.consent.http.models.ElectionReviewVote) User(org.broadinstitute.consent.http.models.User) Consent(org.broadinstitute.consent.http.models.Consent) DataSet(org.broadinstitute.consent.http.models.DataSet) Dac(org.broadinstitute.consent.http.models.Dac) Election(org.broadinstitute.consent.http.models.Election) Test(org.junit.Test)

Aggregations

Consent (org.broadinstitute.consent.http.models.Consent)163 Test (org.junit.Test)127 DataSet (org.broadinstitute.consent.http.models.DataSet)86 Election (org.broadinstitute.consent.http.models.Election)72 Dac (org.broadinstitute.consent.http.models.Dac)61 User (org.broadinstitute.consent.http.models.User)56 Vote (org.broadinstitute.consent.http.models.Vote)48 ElectionReviewVote (org.broadinstitute.consent.http.models.ElectionReviewVote)32 Response (javax.ws.rs.core.Response)31 Date (java.util.Date)25 DataAccessRequest (org.broadinstitute.consent.http.models.DataAccessRequest)23 UnknownIdentifierException (org.broadinstitute.consent.http.exceptions.UnknownIdentifierException)13 NotFoundException (javax.ws.rs.NotFoundException)12 AuthUser (org.broadinstitute.consent.http.models.AuthUser)12 IOException (java.io.IOException)8 DatasetDTO (org.broadinstitute.consent.http.models.dto.DatasetDTO)8 ArrayList (java.util.ArrayList)7 File (java.io.File)6 Timestamp (java.sql.Timestamp)6 List (java.util.List)6