Search in sources :

Example 11 with Vote

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

the class VoteServiceTest method testUpdateRationaleByVoteIds.

@Test
public void testUpdateRationaleByVoteIds() {
    doNothing().when(voteDAO).updateRationaleByVoteIds(any(), any());
    when(electionDAO.findElectionsByIds(any())).thenReturn(List.of());
    Vote v = setUpTestVote(true, true);
    when(voteDAO.findVoteById(anyInt())).thenReturn(v);
    initService();
    try {
        service.updateRationaleByVoteIds(List.of(1), "rationale");
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) NotFoundException(javax.ws.rs.NotFoundException) UnknownIdentifierException(org.broadinstitute.consent.http.exceptions.UnknownIdentifierException) Test(org.junit.Test)

Example 12 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) NotFoundException(javax.ws.rs.NotFoundException) UnknownIdentifierException(org.broadinstitute.consent.http.exceptions.UnknownIdentifierException) Test(org.junit.Test)

Example 13 with Vote

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

the class VoteServiceTest method testUpdateVotesWithValue_MultipleElectionsDifferentStatuses.

@Test(expected = IllegalArgumentException.class)
public void testUpdateVotesWithValue_MultipleElectionsDifferentStatuses() throws Exception {
    when(electionDAO.findElectionsByIds(any())).thenReturn(List.of());
    Vote v = setUpTestVote(true, true);
    when(voteDAO.findVoteById(anyInt())).thenReturn(v);
    when(voteServiceDAO.updateVotesWithValue(any(), anyBoolean(), any())).thenReturn(List.of(v));
    Election openAccessElection = new Election();
    openAccessElection.setElectionType(ElectionType.DATA_ACCESS.getValue());
    openAccessElection.setStatus(ElectionStatus.OPEN.getValue());
    Election closedAccessElection = new Election();
    closedAccessElection.setElectionType(ElectionType.DATA_ACCESS.getValue());
    closedAccessElection.setStatus(ElectionStatus.CLOSED.getValue());
    Election canceledAccessElection = new Election();
    canceledAccessElection.setElectionType(ElectionType.DATA_ACCESS.getValue());
    canceledAccessElection.setStatus(ElectionStatus.CANCELED.getValue());
    when(electionDAO.findElectionsByIds(any())).thenReturn(List.of(openAccessElection, closedAccessElection, canceledAccessElection));
    initService();
    service.updateVotesWithValue(List.of(v), true, "rationale");
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) Election(org.broadinstitute.consent.http.models.Election) Test(org.junit.Test)

Example 14 with Vote

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

the class VoteServiceTest method testUpdateVotesWithValue_NoRationale.

@Test
public void testUpdateVotesWithValue_NoRationale() throws Exception {
    when(electionDAO.findElectionsByIds(any())).thenReturn(List.of());
    Vote v = setUpTestVote(true, true);
    when(voteDAO.findVoteById(anyInt())).thenReturn(v);
    when(voteServiceDAO.updateVotesWithValue(any(), anyBoolean(), any())).thenReturn(List.of(v));
    Election accessElection = new Election();
    accessElection.setElectionType(ElectionType.DATA_ACCESS.getValue());
    accessElection.setStatus(ElectionStatus.OPEN.getValue());
    Election rpElection = new Election();
    rpElection.setElectionType(ElectionType.RP.getValue());
    rpElection.setStatus(ElectionStatus.OPEN.getValue());
    when(electionDAO.findElectionsByIds(any())).thenReturn(List.of(accessElection, rpElection));
    initService();
    try {
        service.updateVotesWithValue(List.of(v), true, null);
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) Election(org.broadinstitute.consent.http.models.Election) NotFoundException(javax.ws.rs.NotFoundException) UnknownIdentifierException(org.broadinstitute.consent.http.exceptions.UnknownIdentifierException) Test(org.junit.Test)

Example 15 with Vote

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

the class VoteServiceTest method testDescribeDataOwnerVote.

@Test
public void testDescribeDataOwnerVote() {
    Vote v = setUpTestVote(false, false);
    when(voteDAO.findVotesByReferenceIdTypeAndUser("test", 1, VoteType.DATA_OWNER.getValue())).thenReturn(v);
    initService();
    Vote vote = service.describeDataOwnerVote("test", 1);
    assertNotNull(vote);
    assertEquals(v.getVoteId(), vote.getVoteId());
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) Test(org.junit.Test)

Aggregations

Vote (org.broadinstitute.consent.http.models.Vote)167 Test (org.junit.Test)124 Election (org.broadinstitute.consent.http.models.Election)105 User (org.broadinstitute.consent.http.models.User)90 Dataset (org.broadinstitute.consent.http.models.Dataset)59 Consent (org.broadinstitute.consent.http.models.Consent)57 Dac (org.broadinstitute.consent.http.models.Dac)45 DataAccessRequest (org.broadinstitute.consent.http.models.DataAccessRequest)45 Response (javax.ws.rs.core.Response)37 AuthUser (org.broadinstitute.consent.http.models.AuthUser)30 ElectionReviewVote (org.broadinstitute.consent.http.models.ElectionReviewVote)30 UserRole (org.broadinstitute.consent.http.models.UserRole)25 Date (java.util.Date)21 NotFoundException (javax.ws.rs.NotFoundException)18 List (java.util.List)16 ArrayList (java.util.ArrayList)14 Collectors (java.util.stream.Collectors)14 ElectionType (org.broadinstitute.consent.http.enumeration.ElectionType)14 DarCollection (org.broadinstitute.consent.http.models.DarCollection)14 DataAccessRequestData (org.broadinstitute.consent.http.models.DataAccessRequestData)14