use of org.orcid.jaxb.model.common_rc3.LastModifiedDate 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());
}
use of org.orcid.jaxb.model.common_rc3.LastModifiedDate in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_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.common_rc3.LastModifiedDate in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_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.common_rc3.LastModifiedDate in project ORCID-Source by ORCID.
the class Api2_0_rc2_LastModifiedDatesHelper method calculateLatest.
public static Date calculateLatest(Keywords keywords) {
Date latestAct = null;
if (keywords != null && keywords.getKeywords() != null && !keywords.getKeywords().isEmpty()) {
XMLGregorianCalendar latest = keywords.getKeywords().get(0).getLastModifiedDate().getValue();
for (Keyword keyword : keywords.getKeywords()) {
if (latest.compare(keyword.getLastModifiedDate().getValue()) == -1) {
latest = keyword.getLastModifiedDate().getValue();
}
}
latestAct = latest.toGregorianCalendar().getTime();
keywords.setLastModifiedDate(new LastModifiedDate(latest));
}
return latestAct;
}
use of org.orcid.jaxb.model.common_rc3.LastModifiedDate in project ORCID-Source by ORCID.
the class Api2_0_rc2_LastModifiedDatesHelper method calculateLatest.
public static Date calculateLatest(PersonExternalIdentifiers extIds) {
Date latestAct = null;
if (extIds != null && extIds.getExternalIdentifiers() != null && !extIds.getExternalIdentifiers().isEmpty()) {
XMLGregorianCalendar latest = extIds.getExternalIdentifiers().get(0).getLastModifiedDate().getValue();
for (PersonExternalIdentifier extId : extIds.getExternalIdentifiers()) {
if (latest.compare(extId.getLastModifiedDate().getValue()) == -1) {
latest = extId.getLastModifiedDate().getValue();
}
}
latestAct = latest.toGregorianCalendar().getTime();
extIds.setLastModifiedDate(new LastModifiedDate(latest));
}
return latestAct;
}
Aggregations