use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate 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.LastModifiedDate in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_GroupIdTest method testUpdateGroupIdRecord.
@Test
public void testUpdateGroupIdRecord() {
SecurityContextTestUtils.setUpSecurityContextForGroupIdClientOnly();
Response response = serviceDelegator.viewGroupIdRecord(Long.valueOf("3"));
assertNotNull(response);
GroupIdRecord groupIdRecord = (GroupIdRecord) response.getEntity();
assertNotNull(groupIdRecord);
Utils.verifyLastModified(groupIdRecord.getLastModifiedDate());
LastModifiedDate before = groupIdRecord.getLastModifiedDate();
// Verify the name
assertEquals(groupIdRecord.getName(), "TestGroup3");
// Set a new name for update
groupIdRecord.setName("TestGroup33");
serviceDelegator.updateGroupIdRecord(groupIdRecord, Long.valueOf("3"));
// Get the entity again and verify the name
response = serviceDelegator.viewGroupIdRecord(Long.valueOf("3"));
assertNotNull(response);
GroupIdRecord groupIdRecordNew = (GroupIdRecord) response.getEntity();
assertNotNull(groupIdRecordNew);
Utils.verifyLastModified(groupIdRecordNew.getLastModifiedDate());
assertTrue(groupIdRecordNew.getLastModifiedDate().after(before));
// Verify the name
assertEquals(groupIdRecordNew.getName(), "TestGroup33");
}
use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_OtherNamesTest method testUpdateOtherName.
@Test
public void testUpdateOtherName() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewOtherName("4444-4444-4444-4443", 1L);
assertNotNull(response);
OtherName otherName = (OtherName) response.getEntity();
assertNotNull(otherName);
Utils.verifyLastModified(otherName.getLastModifiedDate());
LastModifiedDate before = otherName.getLastModifiedDate();
assertEquals("Slibberdy Slabinah", otherName.getContent());
assertEquals(Visibility.PUBLIC, otherName.getVisibility());
otherName.setContent("Updated Other Name");
response = serviceDelegator.updateOtherName("4444-4444-4444-4443", 1L, otherName);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewOtherName("4444-4444-4444-4443", 1L);
assertNotNull(response);
OtherName updatedOtherName = (OtherName) response.getEntity();
assertNotNull(updatedOtherName);
Utils.verifyLastModified(updatedOtherName.getLastModifiedDate());
assertTrue(updatedOtherName.getLastModifiedDate().after(before));
assertEquals("Updated Other Name", updatedOtherName.getContent());
assertEquals(Visibility.PUBLIC, updatedOtherName.getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate 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.LastModifiedDate in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_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());
}
Aggregations