Search in sources :

Example 86 with FundingSummary

use of org.orcid.jaxb.model.record.summary_rc2.FundingSummary in project ORCID-Source by ORCID.

the class JpaJaxbFundingAdapterTest method fromFundingEntityToSummaryTest.

@Test
public void fromFundingEntityToSummaryTest() throws JAXBException {
    ProfileFundingEntity entity = getProfileFundingEntity();
    assertNotNull(entity);
    assertEquals("123456", entity.getNumericAmount().toString());
    FundingSummary summary = jpaJaxbFundingAdapter.toFundingSummary(entity);
    assertNotNull(summary);
    assertEquals(Long.valueOf(12345), summary.getPutCode());
    assertNotNull(summary.getStartDate());
    assertEquals("01", summary.getStartDate().getDay().getValue());
    assertEquals("01", summary.getStartDate().getMonth().getValue());
    assertEquals("2000", summary.getStartDate().getYear().getValue());
    assertNotNull(summary.getEndDate());
    assertEquals("01", summary.getEndDate().getDay().getValue());
    assertEquals("01", summary.getEndDate().getMonth().getValue());
    assertEquals("2020", summary.getEndDate().getYear().getValue());
    assertEquals("funding:title", summary.getTitle().getTitle().getContent());
    assertEquals(FundingType.SALARY_AWARD, summary.getType());
    assertEquals(Visibility.PRIVATE, summary.getVisibility());
}
Also used : FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Test(org.junit.Test)

Example 87 with FundingSummary

use of org.orcid.jaxb.model.record.summary_rc2.FundingSummary in project ORCID-Source by ORCID.

the class ProfileFundingManagerTest method testGroupFundings_groupOnlyPublicFundings1.

@Test
public void testGroupFundings_groupOnlyPublicFundings1() {
    FundingSummary s1 = getFundingSummary("Public 1", "ext-id-1", Visibility.PUBLIC);
    FundingSummary s2 = getFundingSummary("Limited 1", "ext-id-2", Visibility.LIMITED);
    FundingSummary s3 = getFundingSummary("Private 1", "ext-id-3", Visibility.PRIVATE);
    FundingSummary s4 = getFundingSummary("Public 2", "ext-id-4", Visibility.PUBLIC);
    FundingSummary s5 = getFundingSummary("Limited 2", "ext-id-5", Visibility.LIMITED);
    FundingSummary s6 = getFundingSummary("Private 2", "ext-id-6", Visibility.PRIVATE);
    FundingSummary s7 = getFundingSummary("Public 3", "ext-id-7", Visibility.PUBLIC);
    FundingSummary s8 = getFundingSummary("Limited 3", "ext-id-8", Visibility.LIMITED);
    FundingSummary s9 = getFundingSummary("Private 3", "ext-id-9", Visibility.PRIVATE);
    List<FundingSummary> fundingList = Arrays.asList(s1, s2, s3, s4, s5, s6, s7, s8, s9);
    /**
         * They should be grouped as
         * 
         * Group 1: Public 1
         * Group 2: Public 2
         * Group 3: Public 3
         * */
    Fundings fundings = profileFundingManager.groupFundings(fundingList, true);
    assertNotNull(fundings);
    assertEquals(3, fundings.getFundingGroup().size());
    assertEquals(1, fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals(1, fundings.getFundingGroup().get(0).getFundingSummary().size());
    assertEquals("ext-id-1", fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("Public 1", fundings.getFundingGroup().get(0).getFundingSummary().get(0).getTitle().getTitle().getContent());
    assertEquals(1, fundings.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().size());
    assertEquals(1, fundings.getFundingGroup().get(1).getFundingSummary().size());
    assertEquals("ext-id-4", fundings.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("Public 2", fundings.getFundingGroup().get(1).getFundingSummary().get(0).getTitle().getTitle().getContent());
    assertEquals(1, fundings.getFundingGroup().get(2).getIdentifiers().getExternalIdentifier().size());
    assertEquals(1, fundings.getFundingGroup().get(2).getFundingSummary().size());
    assertEquals("ext-id-7", fundings.getFundingGroup().get(2).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("Public 3", fundings.getFundingGroup().get(2).getFundingSummary().get(0).getTitle().getTitle().getContent());
}
Also used : Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 88 with FundingSummary

use of org.orcid.jaxb.model.record.summary_rc2.FundingSummary in project ORCID-Source by ORCID.

the class PublicV2Test method checkFunding.

private void checkFunding(String readPublicToken) throws JSONException, InterruptedException, URISyntaxException {
    Funding fundingToCreate = (Funding) unmarshallFromPath("/record_2.0_rc1/samples/funding-2.0_rc1.xml", Funding.class);
    fundingToCreate.setPutCode(null);
    fundingToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PUBLIC);
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV2ApiClient.createFundingXml(getUser1OrcidId(), fundingToCreate, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    String path = postResponse.getLocation().getPath();
    String putCode = path.substring(path.lastIndexOf('/') + 1, path.length());
    ClientResponse getFundingResponse = null;
    if (readPublicToken != null) {
        getFundingResponse = publicV2ApiClient.viewFundingXml(getUser1OrcidId(), putCode, readPublicToken);
    } else {
        getFundingResponse = publicV2ApiClient.viewFundingXml(getUser1OrcidId(), putCode);
    }
    assertNotNull(getFundingResponse);
    checkResponse(getFundingResponse);
    Funding funding = getFundingResponse.getEntity(Funding.class);
    assertNotNull(funding);
    assertEquals("common:title", funding.getTitle().getTitle().getContent());
    ClientResponse getFundingSummaryResponse = null;
    if (readPublicToken != null) {
        getFundingSummaryResponse = publicV2ApiClient.viewFundingSummaryXml(getUser1OrcidId(), putCode, readPublicToken);
    } else {
        getFundingSummaryResponse = publicV2ApiClient.viewFundingSummaryXml(getUser1OrcidId(), putCode);
    }
    assertNotNull(getFundingSummaryResponse);
    checkResponse(getFundingSummaryResponse);
    FundingSummary summary = getFundingSummaryResponse.getEntity(FundingSummary.class);
    assertNotNull(summary);
    assertEquals("common:title", summary.getTitle().getTitle().getContent());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Funding(org.orcid.jaxb.model.record_rc1.Funding) FundingSummary(org.orcid.jaxb.model.record.summary_rc1.FundingSummary)

Aggregations

FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)72 Test (org.junit.Test)69 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)45 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)45 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)45 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)43 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)39 ClientResponse (com.sun.jersey.api.client.ClientResponse)20 FundingGroup (org.orcid.jaxb.model.record.summary_v2.FundingGroup)18 Fundings (org.orcid.jaxb.model.record.summary_v2.Fundings)18 Address (org.orcid.jaxb.model.record_v2.Address)18 Email (org.orcid.jaxb.model.record_v2.Email)18 Keyword (org.orcid.jaxb.model.record_v2.Keyword)18 OtherName (org.orcid.jaxb.model.record_v2.OtherName)18 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)18 Record (org.orcid.jaxb.model.record_v2.Record)18 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)18 Name (org.orcid.jaxb.model.record_v2.Name)17 Addresses (org.orcid.jaxb.model.record_v2.Addresses)15 Biography (org.orcid.jaxb.model.record_v2.Biography)15