use of org.broadinstitute.consent.http.models.Dataset in project consent by DataBiosphere.
the class VoteServiceDAOTest method testUpdateVotesWithValue_MultipleVotes.
@Test
public void testUpdateVotesWithValue_MultipleVotes() throws Exception {
User user = createUser();
DataAccessRequest dar = createDataAccessRequestV3();
DataSet dataset = createDataset();
Election election = createAccessElection(dar.getReferenceId(), dataset.getDataSetId());
Vote vote1 = createDacVote(user.getDacUserId(), election.getElectionId());
Vote vote2 = createDacVote(user.getDacUserId(), election.getElectionId());
Vote vote3 = createDacVote(user.getDacUserId(), election.getElectionId());
String rationale = "rationale";
initService();
List<Vote> votes = serviceDAO.updateVotesWithValue(List.of(vote1, vote2, vote3), true, rationale);
assertNotNull(votes);
assertFalse(votes.isEmpty());
List<Integer> requestVoteIds = Stream.of(vote1, vote2, vote3).map(Vote::getVoteId).collect(Collectors.toList());
votes.forEach(v -> {
assertTrue(v.getVote());
assertEquals(rationale, v.getRationale());
assertTrue(requestVoteIds.contains(v.getVoteId()));
});
}
use of org.broadinstitute.consent.http.models.Dataset in project consent by DataBiosphere.
the class VoteServiceDAOTest method testUpdateVotesWithValue_RPElectionWithStatus.
private void testUpdateVotesWithValue_RPElectionWithStatus(ElectionStatus status) throws Exception {
User user = createUser();
DataAccessRequest dar = createDataAccessRequestV3();
DataSet dataset = createDataset();
Election election = createRPElection(dar.getReferenceId(), dataset.getDataSetId());
changeElectionStatus(election, status);
Vote vote = createDacVote(user.getDacUserId(), election.getElectionId());
String rationale = "rationale";
initService();
List<Vote> votes = serviceDAO.updateVotesWithValue(List.of(vote), true, rationale);
assertNotNull(votes);
assertFalse(votes.isEmpty());
assertTrue(votes.get(0).getVote());
assertEquals(rationale, votes.get(0).getRationale());
assertEquals(vote.getVoteId(), votes.get(0).getVoteId());
}
use of org.broadinstitute.consent.http.models.Dataset in project consent by DataBiosphere.
the class VoteServiceDAOTest method testUpdateVotesWithValue_NoRationale.
@Test
public void testUpdateVotesWithValue_NoRationale() throws Exception {
User user = createUser();
DataAccessRequest dar = createDataAccessRequestV3();
DataSet dataset = createDataset();
Election election = createAccessElection(dar.getReferenceId(), dataset.getDataSetId());
Vote vote = createFinalVote(user.getDacUserId(), election.getElectionId());
initService();
List<Vote> votes = serviceDAO.updateVotesWithValue(List.of(vote), true, null);
assertNotNull(votes);
assertFalse(votes.isEmpty());
assertTrue(votes.get(0).getVote());
assertNull(votes.get(0).getRationale());
assertEquals(vote.getVoteId(), votes.get(0).getVoteId());
}
use of org.broadinstitute.consent.http.models.Dataset in project consent by DataBiosphere.
the class VoteServiceDAOTest method testUpdateVotesWithValue_MultipleElectionsDifferentStatuses.
@Test(expected = IllegalArgumentException.class)
public void testUpdateVotesWithValue_MultipleElectionsDifferentStatuses() throws Exception {
User user = createUser();
DataAccessRequest dar = createDataAccessRequestV3();
DataSet dataset = createDataset();
Election openElection = createAccessElection(dar.getReferenceId(), dataset.getDataSetId());
Election canceledElection = createCancelledAccessElection(dar.getReferenceId(), dataset.getDataSetId());
Vote vote1 = createDacVote(user.getDacUserId(), openElection.getElectionId());
Vote vote2 = createDacVote(user.getDacUserId(), canceledElection.getElectionId());
String rationale = "rationale";
initService();
serviceDAO.updateVotesWithValue(List.of(vote1, vote2), true, rationale);
}
use of org.broadinstitute.consent.http.models.Dataset in project consent by DataBiosphere.
the class VoteServiceDAOTest method testUpdateVotesWithValue_DacVote.
@Test
public void testUpdateVotesWithValue_DacVote() throws Exception {
User user = createUser();
DataAccessRequest dar = createDataAccessRequestV3();
DataSet dataset = createDataset();
Election election = createAccessElection(dar.getReferenceId(), dataset.getDataSetId());
Vote vote = createDacVote(user.getDacUserId(), election.getElectionId());
String rationale = "rationale";
initService();
List<Vote> votes = serviceDAO.updateVotesWithValue(List.of(vote), true, rationale);
assertNotNull(votes);
assertFalse(votes.isEmpty());
assertTrue(votes.get(0).getVote());
assertEquals(rationale, votes.get(0).getRationale());
Election foundElection = electionDAO.findElectionById(vote.getElectionId());
assertNotEquals(ElectionStatus.CLOSED.getValue(), foundElection.getStatus());
assertEquals(vote.getVoteId(), votes.get(0).getVoteId());
}
Aggregations