Search in sources :

Example 16 with Url

use of org.orcid.jaxb.model.common_rc4.Url in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testUpdateExternalIdentifier.

@Test
public void testUpdateExternalIdentifier() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 2L);
    assertNotNull(response);
    PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(extId);
    Utils.verifyLastModified(extId.getLastModifiedDate());
    LastModifiedDate before = extId.getLastModifiedDate();
    assertEquals("Facebook", extId.getType());
    assertEquals("abc123", extId.getValue());
    assertNotNull(extId.getUrl());
    assertEquals("http://www.facebook.com/abc123", extId.getUrl().getValue());
    extId.setType("updated-common-name");
    extId.setValue("updated-reference");
    extId.setUrl(new Url("http://updatedUrl.com"));
    response = serviceDelegator.updateExternalIdentifier("4444-4444-4444-4442", 2L, extId);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 2L);
    assertNotNull(response);
    PersonExternalIdentifier updatedExtId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(updatedExtId);
    Utils.verifyLastModified(updatedExtId.getLastModifiedDate());
    assertTrue(updatedExtId.getLastModifiedDate().after(before));
    assertEquals("updated-common-name", updatedExtId.getType());
    assertEquals("updated-reference", updatedExtId.getValue());
    assertNotNull(updatedExtId.getUrl());
    assertEquals("http://updatedUrl.com", updatedExtId.getUrl().getValue());
    // Revert changes so other tests still works
    extId.setType("Facebook");
    extId.setValue("abc123");
    extId.setUrl(new Url("http://www.facebook.com/abc123"));
    response = serviceDelegator.updateExternalIdentifier("4444-4444-4444-4442", 2L, extId);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 17 with Url

use of org.orcid.jaxb.model.common_rc4.Url in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_WorksTest method testUpdateWorkYouAreNotTheSourceOf.

@Test(expected = WrongSourceException.class)
public void testUpdateWorkYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewWork("4444-4444-4444-4443", 2L);
    assertNotNull(response);
    Work work = (Work) response.getEntity();
    assertNotNull(work);
    Utils.verifyLastModified(work.getLastModifiedDate());
    assertEquals(Long.valueOf(2), work.getPutCode());
    assertNotNull(work.getWorkTitle());
    assertNotNull(work.getWorkTitle().getTitle());
    assertEquals("Another day in the life", work.getWorkTitle().getTitle().getContent());
    assertEquals(WorkType.BOOK, work.getWorkType());
    work.setWorkType(WorkType.EDITED_BOOK);
    work.getWorkTitle().getTitle().setContent("Updated work title");
    ExternalIDs extIds = new ExternalIDs();
    ExternalID extId = new ExternalID();
    extId.setRelationship(Relationship.PART_OF);
    extId.setType(WorkExternalIdentifierType.AGR.value());
    extId.setValue("ext-id-" + System.currentTimeMillis());
    extId.setUrl(new Url("http://thisIsANewUrl.com"));
    extIds.getExternalIdentifier().add(extId);
    work.setWorkExternalIdentifiers(extIds);
    serviceDelegator.updateWork("4444-4444-4444-4443", 2L, work);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Work(org.orcid.jaxb.model.record_v2.Work) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 18 with Url

use of org.orcid.jaxb.model.common_rc4.Url in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_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.common_v2.LastModifiedDate) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 19 with Url

use of org.orcid.jaxb.model.common_rc4.Url in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ResearcherUrlsTest method testUpdateResearcherUrl.

@Test
public void testUpdateResearcherUrl() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewResearcherUrl("4444-4444-4444-4443", 5L);
    assertNotNull(response);
    ResearcherUrl researcherUrl = (ResearcherUrl) response.getEntity();
    assertNotNull(researcherUrl);
    Utils.verifyLastModified(researcherUrl.getLastModifiedDate());
    LastModifiedDate before = researcherUrl.getLastModifiedDate();
    assertNotNull(researcherUrl.getUrl());
    assertEquals("http://www.researcherurl2.com?id=5", researcherUrl.getUrl().getValue());
    assertEquals("443_3", researcherUrl.getUrlName());
    researcherUrl.setUrl(new Url("http://theNewResearcherUrl.com"));
    researcherUrl.setUrlName("My Updated Researcher Url");
    response = serviceDelegator.updateResearcherUrl("4444-4444-4444-4443", 5L, researcherUrl);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewResearcherUrl("4444-4444-4444-4443", 5L);
    assertNotNull(response);
    researcherUrl = (ResearcherUrl) response.getEntity();
    assertNotNull(researcherUrl);
    Utils.verifyLastModified(researcherUrl.getLastModifiedDate());
    assertTrue(researcherUrl.getLastModifiedDate().after(before));
    assertNotNull(researcherUrl.getUrl());
    assertEquals("http://theNewResearcherUrl.com", researcherUrl.getUrl().getValue());
    assertEquals("My Updated Researcher Url", researcherUrl.getUrlName());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 20 with Url

use of org.orcid.jaxb.model.common_rc4.Url in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_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");
    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) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Url (org.orcid.jaxb.model.common_v2.Url)86 Test (org.junit.Test)84 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)55 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)37 ClientResponse (com.sun.jersey.api.client.ClientResponse)30 MarshallingTest (org.orcid.jaxb.model.notification.custom.MarshallingTest)24 Title (org.orcid.jaxb.model.common_v2.Title)23 Work (org.orcid.jaxb.model.record_v2.Work)21 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)20 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)18 Validator (javax.xml.validation.Validator)16 Funding (org.orcid.jaxb.model.record_v2.Funding)15 ArrayList (java.util.ArrayList)14 Url (org.orcid.jaxb.model.common_rc3.Url)11 Url (org.orcid.jaxb.model.common_rc4.Url)11 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)11 Response (javax.ws.rs.core.Response)10 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)10 DBUnitTest (org.orcid.test.DBUnitTest)10 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)9