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());
}
}
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());
}
}
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");
}
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());
}
}
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());
}
Aggregations