Search in sources :

Example 71 with Funding

use of org.orcid.jaxb.model.record_v2.Funding in project ORCID-Source by ORCID.

the class ActivityValidatorTest method validateFunding_dontChangeVisibilityTest.

@Test(expected = VisibilityMismatchException.class)
public void validateFunding_dontChangeVisibilityTest() {
    Funding funding = getFunding();
    funding.setVisibility(Visibility.LIMITED);
    activityValidator.validateFunding(funding, null, false, true, Visibility.PUBLIC);
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) Test(org.junit.Test)

Example 72 with Funding

use of org.orcid.jaxb.model.record_v2.Funding in project ORCID-Source by ORCID.

the class ActivityValidatorTest method validateFunding_emptyTitleTest.

@Test(expected = ActivityTitleValidationException.class)
public void validateFunding_emptyTitleTest() {
    Funding funding = getFunding();
    funding.getTitle().getTitle().setContent(null);
    activityValidator.validateFunding(funding, null, true, true, Visibility.PUBLIC);
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) Test(org.junit.Test)

Example 73 with Funding

use of org.orcid.jaxb.model.record_v2.Funding in project ORCID-Source by ORCID.

the class ActivityValidatorTest method getFunding.

public Funding getFunding() {
    Funding funding = new Funding();
    Amount amount = new Amount();
    amount.setContent("1000");
    amount.setCurrencyCode("$");
    funding.setAmount(amount);
    FundingContributor contributor = new FundingContributor();
    FundingContributorAttributes attributes = new FundingContributorAttributes();
    attributes.setContributorRole(FundingContributorRole.LEAD);
    ContributorOrcid contributorOrcid = new ContributorOrcid();
    contributorOrcid.setHost("http://test.orcid.org");
    contributorOrcid.setPath("0000-0000-0000-0000");
    contributorOrcid.setUri("http://test.orcid.org/0000-0000-0000-0000");
    contributor.setContributorAttributes(attributes);
    contributor.setContributorOrcid(contributorOrcid);
    FundingContributors contributors = new FundingContributors();
    contributors.getContributor().add(contributor);
    funding.setContributors(contributors);
    funding.setDescription("description");
    funding.setEndDate(getFuzzyDate());
    funding.setExternalIdentifiers(getExternalIDs());
    funding.setOrganization(getOrganization());
    funding.setOrganizationDefinedType(new OrganizationDefinedFundingSubType("subtype"));
    funding.setStartDate(getFuzzyDate());
    FundingTitle title = new FundingTitle();
    title.setTitle(new Title("title"));
    title.setTranslatedTitle(new TranslatedTitle("translated title", "en"));
    funding.setTitle(title);
    funding.setType(FundingType.AWARD);
    funding.setUrl(new Url("http://test.orcid.org"));
    funding.setVisibility(Visibility.PUBLIC);
    return funding;
}
Also used : TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) Funding(org.orcid.jaxb.model.record_v2.Funding) Amount(org.orcid.jaxb.model.common_v2.Amount) FundingContributor(org.orcid.jaxb.model.record_v2.FundingContributor) FundingContributors(org.orcid.jaxb.model.record_v2.FundingContributors) FundingContributorAttributes(org.orcid.jaxb.model.record_v2.FundingContributorAttributes) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Title(org.orcid.jaxb.model.common_v2.Title) ContributorOrcid(org.orcid.jaxb.model.common_v2.ContributorOrcid) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Url(org.orcid.jaxb.model.common_v2.Url) OrganizationDefinedFundingSubType(org.orcid.jaxb.model.common_v2.OrganizationDefinedFundingSubType)

Example 74 with Funding

use of org.orcid.jaxb.model.record_v2.Funding in project ORCID-Source by ORCID.

the class ActivityValidatorTest method validateFunding_emptyExternalIdentifiersTest.

@Test(expected = ActivityIdentifierValidationException.class)
public void validateFunding_emptyExternalIdentifiersTest() {
    Funding funding = getFunding();
    funding.getExternalIdentifiers().getExternalIdentifier().clear();
    activityValidator.validateFunding(funding, null, true, true, Visibility.PUBLIC);
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) Test(org.junit.Test)

Example 75 with Funding

use of org.orcid.jaxb.model.record_v2.Funding in project ORCID-Source by ORCID.

the class MemberV2_1Test method testTokenWorksOnlyForTheScopeItWasIssued.

@SuppressWarnings({ "deprecation", "rawtypes" })
@Test
public void testTokenWorksOnlyForTheScopeItWasIssued() throws JSONException, InterruptedException, URISyntaxException {
    long time = System.currentTimeMillis();
    List<String> scopes = getScopes(ScopePathType.FUNDING_CREATE, ScopePathType.FUNDING_UPDATE);
    String accessToken = getAccessToken(scopes);
    Work work1 = (Work) unmarshallFromPath("/record_2.1/samples/read_samples/work-2.1.xml", Work.class);
    work1.setPutCode(null);
    work1.getExternalIdentifiers().getExternalIdentifier().clear();
    org.orcid.jaxb.model.record_v2.WorkTitle title1 = new org.orcid.jaxb.model.record_v2.WorkTitle();
    title1.setTitle(new Title("Work # 1"));
    work1.setWorkTitle(title1);
    ExternalID wExtId1 = new ExternalID();
    wExtId1.setValue("Work Id " + time);
    wExtId1.setType(WorkExternalIdentifierType.AGR.value());
    wExtId1.setRelationship(Relationship.SELF);
    wExtId1.setUrl(new Url("http://orcid.org/work#1"));
    work1.getExternalIdentifiers().getExternalIdentifier().clear();
    work1.getExternalIdentifiers().getExternalIdentifier().add(wExtId1);
    //Add the work
    ClientResponse postResponse = memberV2_1ApiClient.createWorkXml(this.getUser1OrcidId(), work1, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.FORBIDDEN.getStatusCode(), postResponse.getStatus());
    Funding funding = (Funding) unmarshallFromPath("/record_2.1/samples/read_samples/funding-2.1.xml", Funding.class);
    funding.setPutCode(null);
    funding.setVisibility(Visibility.PUBLIC);
    funding.getExternalIdentifiers().getExternalIdentifier().clear();
    ExternalID fExtId = new ExternalID();
    fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
    fExtId.setValue("Funding Id " + time);
    fExtId.setRelationship(Relationship.SELF);
    funding.getExternalIdentifiers().getExternalIdentifier().add(fExtId);
    //Add the funding
    postResponse = memberV2_1ApiClient.createFundingXml(this.getUser1OrcidId(), funding, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    // Delete funding        
    Map map = postResponse.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List resultWithPutCode = (List) map.get("Location");
    String location = resultWithPutCode.get(0).toString();
    Long putCode = Long.valueOf(location.substring(location.lastIndexOf('/') + 1));
    ClientResponse deleteResponse = memberV2_1ApiClient.deleteFundingXml(this.getUser1OrcidId(), putCode, accessToken);
    assertNotNull(deleteResponse);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Funding(org.orcid.jaxb.model.record_v2.Funding) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Title(org.orcid.jaxb.model.common_v2.Title) Url(org.orcid.jaxb.model.common_v2.Url) Work(org.orcid.jaxb.model.record_v2.Work) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Funding (org.orcid.jaxb.model.record_v2.Funding)82 Test (org.junit.Test)75 ClientResponse (com.sun.jersey.api.client.ClientResponse)28 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)21 ArrayList (java.util.ArrayList)19 Response (javax.ws.rs.core.Response)16 Url (org.orcid.jaxb.model.common_v2.Url)16 DBUnitTest (org.orcid.test.DBUnitTest)16 Title (org.orcid.jaxb.model.common_v2.Title)12 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)12 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)11 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)10 OtherName (org.orcid.jaxb.model.record_v2.OtherName)10 Work (org.orcid.jaxb.model.record_v2.Work)10 ProfileFundingEntity (org.orcid.persistence.jpa.entities.ProfileFundingEntity)10 List (java.util.List)9 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)9 FundingContributor (org.orcid.jaxb.model.record_v2.FundingContributor)8 IOException (java.io.IOException)7 BaseTest (org.orcid.core.BaseTest)7