use of org.broadinstitute.consent.http.models.DataUseBuilder in project consent by DataBiosphere.
the class UseRestrictionConverterTest method testTranslateDataUsePurpose.
/*
* Test that the UseRestrictionConverter makes a call to the ontology service and gets back a valid translation
*/
@Test
public void testTranslateDataUsePurpose() {
mockDataUseTranslateSuccess();
Client client = ClientBuilder.newClient();
UseRestrictionConverter converter = new UseRestrictionConverter(client, config());
DataUse dataUse = new DataUseBuilder().setHmbResearch(true).build();
String translation = converter.translateDataUse(dataUse, DataUseTranslationType.PURPOSE);
assertNotNull(translation);
}
use of org.broadinstitute.consent.http.models.DataUseBuilder 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.DataUseBuilder in project consent by DataBiosphere.
the class ConsentResourceTest method testCreateConsent.
@Test
public void testCreateConsent() throws Exception {
User dacUser = new User();
dacUser.setEmail("test@email.com");
AuthUser user = new AuthUser(dacUser.getEmail());
Consent consent = new Consent();
consent.setConsentId(UUID.randomUUID().toString());
consent.setDataUse(new DataUseBuilder().setGeneralUse(true).build());
when(userService.findUserByEmail(any())).thenReturn(dacUser);
doNothing().when(useRestrictionValidator).validateUseRestriction(any());
when(consentService.create(any())).thenReturn(consent);
doNothing().when(auditService).saveConsentAudit(any(), any(), any(), any());
doNothing().when(matchService).reprocessMatchesForConsent(any());
initResource();
Response response = resource.createConsent(info, consent, user);
assertEquals(201, response.getStatus());
}
use of org.broadinstitute.consent.http.models.DataUseBuilder in project consent by DataBiosphere.
the class ConsentResourceTest method testUpdateConsent.
@Test
public void testUpdateConsent() throws Exception {
User dacUser = new User();
dacUser.setEmail("test@email.com");
AuthUser user = new AuthUser(dacUser.getEmail());
Consent consent = new Consent();
// Unarchived consents cannot be updated.
consent.setLastElectionArchived(true);
consent.setConsentId(UUID.randomUUID().toString());
consent.setDataUse(new DataUseBuilder().setGeneralUse(true).build());
when(userService.findUserByEmail(any())).thenReturn(dacUser);
doNothing().when(useRestrictionValidator).validateUseRestriction(any());
when(consentService.retrieve(any())).thenReturn(consent);
when(consentService.update(any(), any())).thenReturn(consent);
doNothing().when(auditService).saveConsentAudit(any(), any(), any(), any());
doNothing().when(matchService).reprocessMatchesForConsent(any());
initResource();
Response response = resource.update(consent.getConsentId(), consent, user);
assertEquals(200, response.getStatus());
}
use of org.broadinstitute.consent.http.models.DataUseBuilder in project consent by DataBiosphere.
the class ConsentResourceTest method testInvalidDULCreate.
@Test
public void testInvalidDULCreate() throws Exception {
User dacUser = new User();
dacUser.setEmail("test@email.com");
AuthUser user = new AuthUser(dacUser.getEmail());
Consent consent = new Consent();
consent.setDataUse(new DataUseBuilder().setGeneralUse(true).build());
consent.setConsentId(UUID.randomUUID().toString());
consent.setDataUseLetter(UUID.randomUUID().toString());
when(consentService.retrieve(any())).thenReturn(consent);
when(userService.findUserByEmail(any())).thenReturn(dacUser);
doNothing().when(useRestrictionValidator).validateUseRestriction(any());
initResource();
Response response = resource.createConsent(info, consent, user);
assertEquals(400, response.getStatus());
}
Aggregations