use of org.broadinstitute.consent.http.models.grammar.Everything in project consent by DataBiosphere.
the class DataUseLetterResourceTest method setupConsent.
private Consent setupConsent(String dul) {
DataUse dataUse = new DataUseBuilder().setGeneralUse(true).build();
Consent consent = new Consent();
consent.setDulName(dul);
consent.setUseRestriction(new Everything());
consent.setConsentId(UUID.randomUUID().toString());
consent.setDataUse(dataUse);
return consent;
}
use of org.broadinstitute.consent.http.models.grammar.Everything in project consent by DataBiosphere.
the class DataAccessRequestServiceTest method testCreateReviewedDARDocument.
@Test
public void testCreateReviewedDARDocument() {
Election election = generateElection(1);
election.setFinalVote(true);
election.setFinalVoteDate(new Date());
when(electionDAO.findDataAccessClosedElectionsByFinalResult(true)).thenReturn(Collections.singletonList(election));
when(electionDAO.findDataAccessClosedElectionsByFinalResult(false)).thenReturn(Collections.emptyList());
DataAccessRequest dar = generateDataAccessRequest();
dar.setUserId(1);
when(dataAccessRequestDAO.findByReferenceId(any())).thenReturn(dar);
when(dataSetDAO.getAssociatedConsentIdByDataSetId(any())).thenReturn("CONS-1");
Consent consent = new Consent();
consent.setConsentId("CONS-1");
consent.setName("Consent 1");
consent.setUseRestriction(new Everything());
consent.setTranslatedUseRestriction(new Everything().toString());
when(consentDAO.findConsentById("CONS-1")).thenReturn(consent);
initService();
try {
File file = service.createReviewedDARDocument();
assertNotNull(file);
} catch (Exception e) {
assert false;
}
}
use of org.broadinstitute.consent.http.models.grammar.Everything in project consent by DataBiosphere.
the class ConsentServiceTest method getTestConsent.
private Consent getTestConsent() {
Consent consent = new Consent(false, new Everything(), "data use", "test consent", new Timestamp(new Date().getTime()), new Timestamp(new Date().getTime()), new Timestamp(new Date().getTime()), "test consent group");
consent.setDataUse(new DataUse());
return consent;
}
use of org.broadinstitute.consent.http.models.grammar.Everything in project consent by DataBiosphere.
the class DacServiceTest method testAddDacMember.
@Test
public void testAddDacMember() {
Gson gson = new Gson();
User user = getDacUsers().get(0);
Dac dac = getDacs().get(0);
when(userDAO.findUserById(any())).thenReturn(user);
when(userDAO.findUserById(any())).thenReturn(user);
when(dacDAO.findUserRolesForUser(any())).thenReturn(getDacUsers().get(0).getRoles());
List<Election> elections = getElections().stream().map(e -> {
Election newE = gson.fromJson(gson.toJson(e), Election.class);
newE.setElectionType(ElectionType.DATA_ACCESS.getValue());
newE.setReferenceId(UUID.randomUUID().toString());
return newE;
}).collect(Collectors.toList());
DataAccessRequest dar = new DataAccessRequest();
dar.setData(new DataAccessRequestData());
dar.getData().setRestriction(new Everything());
when(dataAccessRequestDAO.findByReferenceId(any())).thenReturn(dar);
when(electionDAO.findOpenElectionsByDacId(any())).thenReturn(elections);
when(voteService.createVotes(any(), any(), anyBoolean())).thenReturn(Collections.emptyList());
doNothing().when(dacDAO).addDacMember(anyInt(), anyInt(), anyInt());
initService();
Role role = new Role(UserRoles.CHAIRPERSON.getRoleId(), UserRoles.CHAIRPERSON.getRoleName());
User user1 = service.addDacMember(role, user, dac);
Assert.assertNotNull(user1);
Assert.assertFalse(user1.getRoles().isEmpty());
verify(voteService, times(elections.size())).createVotesForUser(any(), any(), any(), anyBoolean());
}
use of org.broadinstitute.consent.http.models.grammar.Everything in project consent by DataBiosphere.
the class JsonTest method testEverything.
@Test
public void testEverything() {
UseRestriction r = new Everything();
String json = r.toString();
Assert.assertTrue(json.equals("{\"type\":\"everything\"}"));
}
Aggregations