Search in sources :

Example 6 with Title

use of org.orcid.jaxb.model.v3.dev1.common.Title 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)

Example 7 with Title

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

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testUpdateInvitedPositionYouAreNotTheSourceOf.

@Test(expected = WrongSourceException.class)
public void testUpdateInvitedPositionYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewInvitedPosition(ORCID, 35L);
    assertNotNull(response);
    InvitedPosition invitedPosition = (InvitedPosition) response.getEntity();
    assertNotNull(invitedPosition);
    invitedPosition.setDepartmentName("Updated department name");
    invitedPosition.setRoleTitle("The updated role title");
    serviceDelegator.updateInvitedPosition(ORCID, 35L, invitedPosition);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 8 with Title

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

the class MemberV3ApiServiceDelegator_MembershipsTest method testUpdateMembershipYouAreNotTheSourceOf.

@Test(expected = WrongSourceException.class)
public void testUpdateMembershipYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewMembership(ORCID, 40L);
    assertNotNull(response);
    Membership membership = (Membership) response.getEntity();
    assertNotNull(membership);
    membership.setDepartmentName("Updated department name");
    membership.setRoleTitle("The updated role title");
    serviceDelegator.updateMembership(ORCID, 40L, membership);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 9 with Title

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

the class MemberV3ApiServiceDelegator_QualificationsTest method testUpdateQualification.

@Test
public void testUpdateQualification() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewQualification(ORCID, 43L);
    assertNotNull(response);
    Qualification qualification = (Qualification) response.getEntity();
    assertNotNull(qualification);
    assertEquals("LIMITED Department", qualification.getDepartmentName());
    assertEquals("LIMITED", qualification.getRoleTitle());
    Utils.verifyLastModified(qualification.getLastModifiedDate());
    LastModifiedDate before = qualification.getLastModifiedDate();
    qualification.setDepartmentName("Updated department name");
    qualification.setRoleTitle("The updated role title");
    // disambiguated org is required in API v3
    DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
    disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
    disambiguatedOrg.setDisambiguationSource("WDB");
    qualification.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
    response = serviceDelegator.updateQualification(ORCID, 43L, qualification);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewQualification(ORCID, 43L);
    assertNotNull(response);
    qualification = (Qualification) response.getEntity();
    assertNotNull(qualification);
    Utils.verifyLastModified(qualification.getLastModifiedDate());
    assertTrue(qualification.getLastModifiedDate().after(before));
    assertEquals("Updated department name", qualification.getDepartmentName());
    assertEquals("The updated role title", qualification.getRoleTitle());
    // Rollback changes
    qualification.setDepartmentName("LIMITED Department");
    qualification.setRoleTitle("QUALIFICATION");
    response = serviceDelegator.updateQualification(ORCID, 43L, qualification);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 10 with Title

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

the class MemberV3ApiServiceDelegator_ServicesTest method testUpdateServiceYouAreNotTheSourceOf.

@Test(expected = WrongSourceException.class)
public void testUpdateServiceYouAreNotTheSourceOf() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewService(ORCID, 50L);
    assertNotNull(response);
    Service service = (Service) response.getEntity();
    assertNotNull(service);
    service.setDepartmentName("Updated department name");
    service.setRoleTitle("The updated role title");
    serviceDelegator.updateService(ORCID, 50L, service);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) Service(org.orcid.jaxb.model.v3.dev1.record.Service) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)81 Title (org.orcid.jaxb.model.v3.dev1.common.Title)44 Work (org.orcid.jaxb.model.v3.dev1.record.Work)43 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)40 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)38 Url (org.orcid.jaxb.model.v3.dev1.common.Url)33 DBUnitTest (org.orcid.test.DBUnitTest)29 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)27 ClientResponse (com.sun.jersey.api.client.ClientResponse)26 Response (javax.ws.rs.core.Response)25 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)23 FundingTitle (org.orcid.jaxb.model.v3.dev1.record.FundingTitle)19 OrcidError (org.orcid.jaxb.model.v3.dev1.error.OrcidError)17 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)17 TranslatedTitle (org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle)14 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)14 ArrayList (java.util.ArrayList)13 DisambiguatedOrganization (org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization)13 LastModifiedDate (org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate)13 Visibility (org.orcid.jaxb.model.v3.dev1.common.Visibility)13