Search in sources :

Example 1 with Vote

use of org.broadinstitute.consent.http.models.Vote in project consent by DataBiosphere.

the class VoteServiceTest method testCreateDataOwnersReviewVotes.

@Test
public void testCreateDataOwnersReviewVotes() {
    Election e = new Election();
    e.setElectionId(1);
    e.setDataSetId(1);
    when(dataSetAssociationDAO.getDataOwnersOfDataSet(anyInt())).thenReturn(Collections.singletonList(1));
    Vote v = new Vote();
    v.setVoteId(1);
    when(voteDAO.insertVote(anyInt(), anyInt(), any())).thenReturn(v.getVoteId());
    when(voteDAO.findVoteById(anyInt())).thenReturn(v);
    when(voteDAO.findVotesByElectionIdAndType(anyInt(), anyString())).thenReturn(Collections.singletonList(v));
    initService();
    List<Vote> votes = service.createDataOwnersReviewVotes(e);
    assertFalse(votes.isEmpty());
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) Election(org.broadinstitute.consent.http.models.Election) Test(org.junit.Test)

Example 2 with Vote

use of org.broadinstitute.consent.http.models.Vote in project consent by DataBiosphere.

the class VoteServiceTest method testChairCreateVotesRP.

@Test
public void testChairCreateVotesRP() {
    setUpUserAndElectionVotes(UserRoles.CHAIRPERSON);
    initService();
    List<Vote> votes = service.createVotes(new Election(), ElectionType.RP, false);
    assertFalse(votes.isEmpty());
    // Should create 2 votes:
    // Chairperson as a chair
    // Chairperson as a dac member
    assertEquals(2, votes.size());
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) Election(org.broadinstitute.consent.http.models.Election) Test(org.junit.Test)

Example 3 with Vote

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

Example 4 with Vote

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

Example 5 with Vote

use of org.broadinstitute.consent.http.models.Vote in project consent by DataBiosphere.

the class VoteServiceTest method testAdvanceVotes.

@Test
public void testAdvanceVotes() {
    Vote v = setUpTestVote(false, false);
    initService();
    try {
        service.advanceVotes(Collections.singletonList(v), true, "New Rationale");
    } catch (Exception e) {
        Assert.fail("Should not error: " + e.getMessage());
    }
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) UnknownIdentifierException(org.broadinstitute.consent.http.exceptions.UnknownIdentifierException) NotFoundException(javax.ws.rs.NotFoundException) Test(org.junit.Test)

Aggregations

Vote (org.broadinstitute.consent.http.models.Vote)135 Test (org.junit.Test)95 Election (org.broadinstitute.consent.http.models.Election)83 User (org.broadinstitute.consent.http.models.User)82 DataSet (org.broadinstitute.consent.http.models.DataSet)57 Consent (org.broadinstitute.consent.http.models.Consent)53 Dac (org.broadinstitute.consent.http.models.Dac)40 DataAccessRequest (org.broadinstitute.consent.http.models.DataAccessRequest)35 ElectionReviewVote (org.broadinstitute.consent.http.models.ElectionReviewVote)29 AuthUser (org.broadinstitute.consent.http.models.AuthUser)28 Response (javax.ws.rs.core.Response)26 UserRole (org.broadinstitute.consent.http.models.UserRole)21 Date (java.util.Date)17 ArrayList (java.util.ArrayList)14 List (java.util.List)12 IOException (java.io.IOException)11 NotFoundException (javax.ws.rs.NotFoundException)11 Collectors (java.util.stream.Collectors)10 ElectionType (org.broadinstitute.consent.http.enumeration.ElectionType)10 DataAccessRequestData (org.broadinstitute.consent.http.models.DataAccessRequestData)10