Search in sources :

Example 1 with UseRestriction

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);
}
Also used : DataUse(org.broadinstitute.consent.http.models.DataUse) UseRestriction(org.broadinstitute.consent.http.models.grammar.UseRestriction) Client(javax.ws.rs.client.Client) MockServerClient(org.mockserver.client.MockServerClient) Test(org.junit.Test)

Example 2 with UseRestriction

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\"}]}"));
}
Also used : Named(org.broadinstitute.consent.http.models.grammar.Named) Or(org.broadinstitute.consent.http.models.grammar.Or) UseRestriction(org.broadinstitute.consent.http.models.grammar.UseRestriction) Test(org.junit.Test)

Example 3 with UseRestriction

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\"}]}"));
}
Also used : Named(org.broadinstitute.consent.http.models.grammar.Named) UseRestriction(org.broadinstitute.consent.http.models.grammar.UseRestriction) And(org.broadinstitute.consent.http.models.grammar.And) Test(org.junit.Test)

Example 4 with UseRestriction

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");
}
Also used : DataAccessRequestData(org.broadinstitute.consent.http.models.DataAccessRequestData) Named(org.broadinstitute.consent.http.models.grammar.Named) LibraryCard(org.broadinstitute.consent.http.models.LibraryCard) DatasetEntry(org.broadinstitute.consent.http.models.DatasetEntry) Vote(org.broadinstitute.consent.http.models.Vote) User(org.broadinstitute.consent.http.models.User) AuthUser(org.broadinstitute.consent.http.models.AuthUser) DataSet(org.broadinstitute.consent.http.models.DataSet) Dac(org.broadinstitute.consent.http.models.Dac) DataAccessRequest(org.broadinstitute.consent.http.models.DataAccessRequest) AuthUser(org.broadinstitute.consent.http.models.AuthUser) Election(org.broadinstitute.consent.http.models.Election) Date(java.util.Date) Not(org.broadinstitute.consent.http.models.grammar.Not) Consent(org.broadinstitute.consent.http.models.Consent) UseRestriction(org.broadinstitute.consent.http.models.grammar.UseRestriction) And(org.broadinstitute.consent.http.models.grammar.And) UserRole(org.broadinstitute.consent.http.models.UserRole) DatasetDetailEntry(org.broadinstitute.consent.http.models.DatasetDetailEntry) BeforeClass(org.junit.BeforeClass)

Example 5 with UseRestriction

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\"}"));
}
Also used : UseRestriction(org.broadinstitute.consent.http.models.grammar.UseRestriction) Nothing(org.broadinstitute.consent.http.models.grammar.Nothing) Test(org.junit.Test)

Aggregations

UseRestriction (org.broadinstitute.consent.http.models.grammar.UseRestriction)15 Test (org.junit.Test)11 Named (org.broadinstitute.consent.http.models.grammar.Named)8 DataUse (org.broadinstitute.consent.http.models.DataUse)5 Consent (org.broadinstitute.consent.http.models.Consent)4 Date (java.util.Date)3 Not (org.broadinstitute.consent.http.models.grammar.Not)3 Client (javax.ws.rs.client.Client)2 DataAccessRequestData (org.broadinstitute.consent.http.models.DataAccessRequestData)2 DataSet (org.broadinstitute.consent.http.models.DataSet)2 DatasetDTO (org.broadinstitute.consent.http.models.dto.DatasetDTO)2 And (org.broadinstitute.consent.http.models.grammar.And)2 Everything (org.broadinstitute.consent.http.models.grammar.Everything)2 RequestMatchingObject (org.broadinstitute.consent.http.models.matching.RequestMatchingObject)2 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1