use of org.broadinstitute.consent.http.models.grammar.UseRestriction in project consent by DataBiosphere.
the class UseRestrictionConverterTest method testFailedUseRestrictionConverterConnection.
/*
* Test that when the UseRestrictionConverter makes a failed call to the ontology service, a null is returned.
*/
@Test
public void testFailedUseRestrictionConverterConnection() {
mockDarTranslateFailure();
Client client = ClientBuilder.newClient();
UseRestrictionConverter converter = new UseRestrictionConverter(client, config());
DataUse dataUse = converter.parseDataUsePurpose("{ }");
UseRestriction restriction = converter.parseUseRestriction(dataUse);
assertNull(restriction);
}
use of org.broadinstitute.consent.http.models.grammar.UseRestriction in project consent by DataBiosphere.
the class JsonTest method testOr.
@Test
public void testOr() {
UseRestriction r = new Or(new Named("DOID:1"), new Named("DOID:2"));
String json = r.toString();
Assert.assertTrue(json.equals("{\"type\":\"or\",\"operands\":[{\"type\":\"named\",\"name\":\"DOID:1\"},{\"type\":\"named\",\"name\":\"DOID:2\"}]}"));
}
use of org.broadinstitute.consent.http.models.grammar.UseRestriction in project consent by DataBiosphere.
the class JsonTest method testAnd.
@Test
public void testAnd() {
UseRestriction r = new And(new Named("DOID:1"), new Named("DOID:2"));
String json = r.toString();
Assert.assertTrue(json.equals("{\"type\":\"and\",\"operands\":[{\"type\":\"named\",\"name\":\"DOID:1\"},{\"type\":\"named\",\"name\":\"DOID:2\"}]}"));
}
use of org.broadinstitute.consent.http.models.grammar.UseRestriction in project consent by DataBiosphere.
the class ElectionServiceTest method setUpClass.
@BeforeClass
public static void setUpClass() {
UseRestriction sampleUseRestriction1 = new And(new Not(new Named("http://purl.obolibrary.org/obo/DUO_0000015")), new Not(new Named("http://purl.obolibrary.org/obo/DUO_0000011")), new Not(new Named("http://www.broadinstitute.org/ontologies/DUOS/control")));
String referenceId = "CONS-1";
sampleLibraryCard = new LibraryCard();
sampleDataset1 = new DataSet();
sampleDataset1.setDataSetId(1);
sampleDataset1.setObjectId("ObjectID 1");
sampleDataset1.setActive(true);
sampleDataset1.setNeedsApproval(false);
sampleDataset1.setConsentName(referenceId);
sampleDataset1.setName("Dataset 1");
sampleDataset1.setAlias(1);
sampleElection1 = new Election(1, ElectionType.DATA_ACCESS.getValue(), ElectionStatus.OPEN.getValue(), new Date(), sampleDataset1.getConsentName(), new Date(), false, sampleDataset1.getDataSetId());
sampleElection2 = new Election(2, ElectionType.DATA_ACCESS.getValue(), ElectionStatus.CLOSED.getValue(), new Date(), sampleDataset1.getConsentName(), new Date(), false, sampleDataset1.getDataSetId());
sampleElectionRP = new Election(3, ElectionType.RP.getValue(), ElectionStatus.OPEN.getValue(), new Date(), sampleDataset1.getConsentName(), new Date(), false, sampleDataset1.getDataSetId());
sampleDatasetElection = new Election(4, ElectionType.DATA_SET.getValue(), ElectionStatus.OPEN.getValue(), new Date(), sampleDataset1.getConsentName(), new Date(), false, sampleDataset1.getDataSetId());
sampleDatasetElectionDenied = new Election(5, ElectionType.DATA_SET.getValue(), ElectionStatus.CLOSED.getValue(), new Date(), sampleDataset1.getConsentName(), new Date(), false, sampleDataset1.getDataSetId());
sampleDatasetElectionApproved = new Election(6, ElectionType.DATA_SET.getValue(), ElectionStatus.CLOSED.getValue(), new Date(), sampleDataset1.getConsentName(), new Date(), true, sampleDataset1.getDataSetId());
authUser = new AuthUser("test@test.com");
sampleUserChairperson = new User(1, "test@test.com", "Test User", new Date());
sampleUserChairperson.addRole(new UserRole(UserRoles.CHAIRPERSON.getRoleId(), UserRoles.CHAIRPERSON.getRoleName()));
sampleUserMember = new User(2, "test@test.com", "Test User", new Date());
sampleUserMember.addRole(new UserRole(UserRoles.MEMBER.getRoleId(), UserRoles.MEMBER.getRoleName()));
sampleConsent1 = new Consent(false, sampleUseRestriction1, "A data use letter", "sampleConsent1", null, null, null, "Group Name Test");
sampleConsent1.setConsentId(sampleDataset1.getConsentName());
sampleDataAccessRequest1 = new DataAccessRequest();
sampleDataAccessRequest1.setUserId(2);
DataAccessRequestData data = new DataAccessRequestData();
data.setReferenceId(sampleElection1.getReferenceId());
data.setDatasetIds(Arrays.asList(sampleDataset1.getDataSetId()));
DatasetEntry entry = new DatasetEntry();
entry.setKey(sampleDataset1.getConsentName());
entry.setValue(sampleDataset1.getName());
data.setDatasets(Arrays.asList(entry));
DatasetDetailEntry entryDetail = new DatasetDetailEntry();
entryDetail.setDatasetId(sampleDataset1.getDataSetId().toString());
entryDetail.setName(sampleDataset1.getName());
entryDetail.setObjectId(sampleDataset1.getObjectId());
data.setDatasetDetail(Arrays.asList(entryDetail));
sampleDataAccessRequest1.setData(data);
sampleDac1 = new Dac();
sampleDac1.setDacId(1);
sampleDac1.setName("DAC-1");
sampleDac1.setCreateDate(new Date());
sampleDac1.setUpdateDate(new Date());
sampleVoteChairpersonApproval = new Vote();
sampleVoteChairpersonApproval.setElectionId(sampleElection1.getElectionId());
sampleVoteChairpersonApproval.setDacUserId(sampleUserChairperson.getDacUserId());
sampleVoteChairpersonApproval.setVote(true);
sampleVoteChairpersonApproval.setVoteId(1);
sampleVoteChairpersonApproval.setRationale("Go for it");
sampleVoteChairpersonReject = new Vote();
sampleVoteChairpersonReject.setElectionId(sampleElection1.getElectionId());
sampleVoteChairpersonReject.setDacUserId(sampleUserChairperson.getDacUserId());
sampleVoteChairpersonReject.setVote(false);
sampleVoteChairpersonReject.setVoteId(1);
sampleVoteChairpersonReject.setRationale("Rejection vote");
sampleVoteMember = new Vote();
sampleVoteMember.setElectionId(sampleElection1.getElectionId());
sampleVoteMember.setDacUserId(sampleUserMember.getDacUserId());
sampleVoteMember.setVote(true);
sampleVoteMember.setVoteId(2);
sampleVoteMember.setRationale("Go for it");
sampleVoteRP = new Vote();
sampleVoteRP.setElectionId(sampleElectionRP.getElectionId());
sampleVoteRP.setDacUserId(sampleUserMember.getDacUserId());
sampleVoteRP.setVote(true);
sampleVoteRP.setVoteId(3);
sampleVoteRP.setRationale("Yep");
}
use of org.broadinstitute.consent.http.models.grammar.UseRestriction in project consent by DataBiosphere.
the class JsonTest method testNothing.
@Test
public void testNothing() {
UseRestriction r = new Nothing();
String json = r.toString();
Assert.assertTrue(json.equals("{\"type\":\"nothing\"}"));
}
Aggregations