Search in sources :

Example 86 with Url

use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_MembershipsTest method testAddMembershipsDuplicateExternalIDs.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testAddMembershipsDuplicateExternalIDs() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    ExternalID e1 = new ExternalID();
    e1.setRelationship(Relationship.SELF);
    e1.setType("erm");
    e1.setUrl(new Url("https://orcid.org"));
    e1.setValue("err");
    ExternalID e2 = new ExternalID();
    e2.setRelationship(Relationship.SELF);
    e2.setType("err");
    e2.setUrl(new Url("http://bbc.co.uk"));
    e2.setValue("erm");
    ExternalIDs externalIDs = new ExternalIDs();
    externalIDs.getExternalIdentifier().add(e1);
    externalIDs.getExternalIdentifier().add(e2);
    Membership membership = (Membership) Utils.getAffiliation(AffiliationType.MEMBERSHIP);
    membership.setExternalIDs(externalIDs);
    Response response = serviceDelegator.createMembership(ORCID, membership);
    assertNotNull(response);
    assertEquals(HttpStatus.SC_CREATED, response.getStatus());
    Map<?, ?> map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    try {
        Membership duplicate = (Membership) Utils.getAffiliation(AffiliationType.MEMBERSHIP);
        duplicate.setExternalIDs(externalIDs);
        serviceDelegator.createMembership(ORCID, duplicate);
    } finally {
        serviceDelegator.deleteAffiliation(ORCID, putCode);
    }
}
Also used : Response(javax.ws.rs.core.Response) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) List(java.util.List) 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)

Example 87 with Url

use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_PeerReviewsTest method testAddPeerReviewDuplicateFails.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testAddPeerReviewDuplicateFails() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 6L);
    assertNotNull(response);
    PeerReview peerReview = (PeerReview) response.getEntity();
    assertNotNull(peerReview);
    peerReview.setUrl(new Url("http://updated.com/url"));
    peerReview.getSubjectName().getTitle().setContent("Updated Title");
    // disambiguated org is required in API v3
    DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
    disambiguatedOrg.setDisambiguatedOrganizationIdentifier("some-org");
    disambiguatedOrg.setDisambiguationSource("FUNDREF");
    peerReview.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
    peerReview.setPutCode(null);
    response = serviceDelegator.createPeerReview("4444-4444-4444-4447", peerReview);
}
Also used : Response(javax.ws.rs.core.Response) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) 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)

Example 88 with Url

use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_PeerReviewsTest method testUpdatePeerReview.

@Test
public void testUpdatePeerReview() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 6L);
    assertNotNull(response);
    PeerReview peerReview = (PeerReview) response.getEntity();
    assertNotNull(peerReview);
    Utils.verifyLastModified(peerReview.getLastModifiedDate());
    LastModifiedDate before = peerReview.getLastModifiedDate();
    peerReview.setUrl(new Url("http://updated.com/url"));
    peerReview.getSubjectName().getTitle().setContent("Updated Title");
    response = serviceDelegator.updatePeerReview("4444-4444-4444-4447", 6L, peerReview);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 6L);
    PeerReview updatedPeerReview = (PeerReview) response.getEntity();
    assertNotNull(updatedPeerReview);
    Utils.verifyLastModified(updatedPeerReview.getLastModifiedDate());
    assertTrue(updatedPeerReview.getLastModifiedDate().after(before));
    assertEquals("http://updated.com/url", updatedPeerReview.getUrl().getValue());
    assertEquals("Updated Title", updatedPeerReview.getSubjectName().getTitle().getContent());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) 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)

Example 89 with Url

use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_PeerReviewsTest method testUpdatePeerReviewWhenYouAreNotTheSourceOf.

@Test
public void testUpdatePeerReviewWhenYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 2L);
    assertNotNull(response);
    PeerReview peerReview = (PeerReview) response.getEntity();
    assertNotNull(peerReview);
    assertEquals("http://peer_review.com/2", peerReview.getUrl().getValue());
    assertEquals("APP-6666666666666666", peerReview.getSource().retrieveSourcePath());
    // Update the info
    peerReview.setUrl(new Url("http://updated.com/url"));
    peerReview.getSubjectName().getTitle().setContent("Updated Title");
    peerReview.getExternalIdentifiers().getExternalIdentifier().iterator().next().setValue("different");
    // disambiguated org is required in API v3
    DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
    disambiguatedOrg.setDisambiguatedOrganizationIdentifier("some-org");
    disambiguatedOrg.setDisambiguationSource("FUNDREF");
    peerReview.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
    try {
        response = serviceDelegator.updatePeerReview("4444-4444-4444-4447", 2L, peerReview);
        fail();
    } catch (WrongSourceException wse) {
    }
    response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", Long.valueOf(2));
    peerReview = (PeerReview) response.getEntity();
    assertNotNull(peerReview);
    assertEquals("http://peer_review.com/2", peerReview.getUrl().getValue());
    assertEquals("APP-6666666666666666", peerReview.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) WrongSourceException(org.orcid.core.exception.WrongSourceException) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) 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)

Example 90 with Url

use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.

the class Utils method getPeerReview.

public static PeerReview getPeerReview() {
    PeerReview peerReview = new PeerReview();
    ExternalIDs weis = new ExternalIDs();
    ExternalID wei1 = new ExternalID();
    wei1.setRelationship(Relationship.PART_OF);
    wei1.setUrl(new Url("http://myUrl.com"));
    wei1.setValue("work-external-identifier-id");
    wei1.setType(WorkExternalIdentifierType.DOI.value());
    weis.getExternalIdentifier().add(wei1);
    peerReview.setExternalIdentifiers(weis);
    peerReview.setGroupId("issn:0000003");
    peerReview.setOrganization(getOrganization());
    peerReview.setRole(Role.CHAIR);
    peerReview.setSubjectContainerName(new Title("subject-container-name"));
    peerReview.setSubjectExternalIdentifier(wei1);
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(new Title("work-title"));
    peerReview.setSubjectName(workTitle);
    peerReview.setSubjectType(WorkType.DATA_SET);
    peerReview.setType(PeerReviewType.EVALUATION);
    return peerReview;
}
Also used : ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Title(org.orcid.jaxb.model.v3.dev1.common.Title) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url)

Aggregations

Url (org.orcid.jaxb.model.v3.dev1.common.Url)85 Test (org.junit.Test)76 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)68 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)50 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)42 Response (javax.ws.rs.core.Response)28 DBUnitTest (org.orcid.test.DBUnitTest)28 Title (org.orcid.jaxb.model.v3.dev1.common.Title)23 Work (org.orcid.jaxb.model.v3.dev1.record.Work)23 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)19 List (java.util.List)16 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)13 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)13 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)12 ClientResponse (com.sun.jersey.api.client.ClientResponse)10 DisambiguatedOrganization (org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization)8 TranslatedTitle (org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle)8 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)8 BaseTest (org.orcid.core.BaseTest)7 Organization (org.orcid.jaxb.model.v3.dev1.common.Organization)6