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());
}
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();
}
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();
}
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());
}
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();
}
Aggregations