Search in sources :

Example 6 with Funding

use of org.orcid.jaxb.model.v3.dev1.record.Funding in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_FundingTest method testUpdateFundingChangingVisibilityTest.

@Test(expected = VisibilityMismatchException.class)
public void testUpdateFundingChangingVisibilityTest() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewFunding("4444-4444-4444-4447", 6L);
    assertNotNull(response);
    Funding funding = (Funding) response.getEntity();
    assertNotNull(funding);
    assertEquals(Visibility.PUBLIC, funding.getVisibility());
    funding.setVisibility(Visibility.PRIVATE);
    response = serviceDelegator.updateFunding("4444-4444-4444-4447", 6L, funding);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 7 with Funding

use of org.orcid.jaxb.model.v3.dev1.record.Funding in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_FundingTest method testViewPrivateFunding.

@Test
public void testViewPrivateFunding() {
    // Use the smallest scope in the pyramid to verify that you can read
    // your own limited and protected data
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewFunding("4444-4444-4444-4446", 4L);
    assertNotNull(response);
    Funding funding = (Funding) response.getEntity();
    assertNotNull(funding);
    Utils.verifyLastModified(funding.getLastModifiedDate());
    assertNotNull(funding.getTitle());
    assertNotNull(funding.getTitle().getTitle());
    assertEquals(Long.valueOf(4), funding.getPutCode());
    assertEquals("/4444-4444-4444-4446/funding/4", funding.getPath());
    assertEquals("Private Funding", funding.getTitle().getTitle().getContent());
    assertEquals(Visibility.PRIVATE.value(), funding.getVisibility().value());
}
Also used : Response(javax.ws.rs.core.Response) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 8 with Funding

use of org.orcid.jaxb.model.v3.dev1.record.Funding in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_FundingTest method testDeleteFunding.

@Test(expected = NoResultException.class)
public void testDeleteFunding() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewFunding("4444-4444-4444-4442", 7L);
    assertNotNull(response);
    Funding funding = (Funding) response.getEntity();
    assertNotNull(funding);
    response = serviceDelegator.deleteFunding("4444-4444-4444-4442", 7L);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    serviceDelegator.viewFunding("4444-4444-4444-4442", 7L);
}
Also used : Response(javax.ws.rs.core.Response) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 9 with Funding

use of org.orcid.jaxb.model.v3.dev1.record.Funding in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_FundingTest method testAddFunding.

@Test
public void testAddFunding() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewActivities("4444-4444-4444-4447");
    assertNotNull(response);
    ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    Utils.verifyLastModified(summary.getLastModifiedDate());
    assertNotNull(summary.getFundings());
    Utils.verifyLastModified(summary.getFundings().getLastModifiedDate());
    assertNotNull(summary.getFundings().getFundingGroup());
    assertNotNull(summary.getFundings().getFundingGroup().get(0));
    Utils.verifyLastModified(summary.getLastModifiedDate());
    assertNotNull(summary.getFundings().getFundingGroup().get(0).getFundingSummary());
    assertEquals(1, summary.getFundings().getFundingGroup().get(0).getFundingSummary().size());
    assertNotNull(summary.getFundings().getFundingGroup().get(0).getFundingSummary().get(0));
    Utils.verifyLastModified(summary.getLastModifiedDate());
    assertNotNull(summary.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getTitle());
    assertNotNull(summary.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getTitle().getTitle());
    assertEquals("Public Funding # 1", summary.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getTitle().getTitle().getContent());
    Funding newFunding = Utils.getFunding();
    response = serviceDelegator.createFunding("4444-4444-4444-4447", newFunding);
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewActivities("4444-4444-4444-4447");
    assertNotNull(response);
    summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    Utils.verifyLastModified(summary.getLastModifiedDate());
    assertNotNull(summary.getFundings());
    assertNotNull(summary.getFundings().getFundingGroup());
    assertEquals(2, summary.getFundings().getFundingGroup().size());
    boolean haveOld = false;
    boolean haveNew = false;
    for (FundingGroup group : summary.getFundings().getFundingGroup()) {
        assertNotNull(group.getFundingSummary().get(0));
        assertNotNull(group.getFundingSummary().get(0).getTitle());
        assertNotNull(group.getFundingSummary().get(0).getTitle().getTitle());
        assertNotNull(group.getFundingSummary().get(0).getTitle().getTitle().getContent());
        if ("Public Funding # 1".equals(group.getFundingSummary().get(0).getTitle().getTitle().getContent())) {
            haveOld = true;
        } else if ("Public Funding # 2".equals(group.getFundingSummary().get(0).getTitle().getTitle().getContent())) {
            haveNew = true;
        }
    }
    assertTrue(haveOld);
    assertTrue(haveNew);
}
Also used : Response(javax.ws.rs.core.Response) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) FundingGroup(org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 10 with Funding

use of org.orcid.jaxb.model.v3.dev1.record.Funding in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_FundingTest method testUpdateFunding.

@Test
public void testUpdateFunding() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewFunding("4444-4444-4444-4447", 6L);
    assertNotNull(response);
    Funding funding = (Funding) response.getEntity();
    assertNotNull(funding);
    assertEquals("Public Funding # 1", funding.getTitle().getTitle().getContent());
    assertEquals("This is the description for funding with id 6", funding.getDescription());
    LastModifiedDate before = funding.getLastModifiedDate();
    funding.getTitle().getTitle().setContent("Updated funding title");
    funding.setDescription("This is an updated description");
    ExternalID fExtId = new ExternalID();
    fExtId.setRelationship(Relationship.PART_OF);
    fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
    fExtId.setUrl(new Url("http://fundingExtId.com"));
    fExtId.setValue("new-funding-ext-id");
    ExternalIDs fExtIds = new ExternalIDs();
    fExtIds.getExternalIdentifier().add(fExtId);
    funding.setExternalIdentifiers(fExtIds);
    response = serviceDelegator.updateFunding("4444-4444-4444-4447", 6L, funding);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewFunding("4444-4444-4444-4447", 6L);
    assertNotNull(response);
    funding = (Funding) response.getEntity();
    assertNotNull(funding);
    Utils.verifyLastModified(funding.getLastModifiedDate());
    assertTrue(funding.getLastModifiedDate().after(before));
    assertEquals("Updated funding title", funding.getTitle().getTitle().getContent());
    assertEquals("This is an updated description", funding.getDescription());
    // Rollback changes
    funding.getTitle().getTitle().setContent("Public Funding # 1");
    funding.setDescription("This is the description for funding with id 6");
    response = serviceDelegator.updateFunding("4444-4444-4444-4447", 6L, funding);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)76 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)72 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)24 Response (javax.ws.rs.core.Response)23 DBUnitTest (org.orcid.test.DBUnitTest)23 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)20 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)15 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)12 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)12 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)12 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)12 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)10 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)10 MembershipSummary (org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)10 QualificationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary)10 ServiceSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)10 Url (org.orcid.jaxb.model.v3.dev1.common.Url)9 FundingContributor (org.orcid.jaxb.model.v3.dev1.record.FundingContributor)9 ArrayList (java.util.ArrayList)8 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)8