use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testCleanEmptyFieldsOnActivities.
@Test
public void testCleanEmptyFieldsOnActivities() {
LastModifiedDate lmd = new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis()));
Works works = new Works();
works.setLastModifiedDate(lmd);
WorkGroup group = new WorkGroup();
group.setLastModifiedDate(lmd);
for (int i = 0; i < 5; i++) {
WorkSummary summary = new WorkSummary();
summary.setLastModifiedDate(lmd);
WorkTitle title = new WorkTitle();
title.setTitle(new Title("Work " + i));
title.setTranslatedTitle(new TranslatedTitle("", ""));
summary.setTitle(title);
group.getWorkSummary().add(summary);
}
works.getWorkGroup().add(group);
ActivitiesSummary as = new ActivitiesSummary();
as.setWorks(works);
ActivityUtils.cleanEmptyFields(as);
assertNotNull(as);
assertNotNull(as.getWorks());
Utils.verifyLastModified(as.getWorks().getLastModifiedDate());
assertNotNull(as.getWorks().getWorkGroup());
assertEquals(1, as.getWorks().getWorkGroup().size());
assertNotNull(as.getWorks().getWorkGroup().get(0).getWorkSummary());
Utils.verifyLastModified(as.getWorks().getWorkGroup().get(0).getLastModifiedDate());
assertEquals(5, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
for (WorkSummary summary : as.getWorks().getWorkGroup().get(0).getWorkSummary()) {
Utils.verifyLastModified(summary.getLastModifiedDate());
assertNotNull(summary.getTitle());
assertNotNull(summary.getTitle().getTitle());
assertTrue(summary.getTitle().getTitle().getContent().startsWith("Work "));
assertNull(summary.getTitle().getTranslatedTitle());
}
}
use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testUpdateInvitedPosition.
@Test
public void testUpdateInvitedPosition() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewInvitedPosition(ORCID, 32L);
assertNotNull(response);
InvitedPosition invitedPosition = (InvitedPosition) response.getEntity();
assertNotNull(invitedPosition);
assertEquals("PUBLIC Department", invitedPosition.getDepartmentName());
assertEquals("PUBLIC", invitedPosition.getRoleTitle());
Utils.verifyLastModified(invitedPosition.getLastModifiedDate());
LastModifiedDate before = invitedPosition.getLastModifiedDate();
invitedPosition.setDepartmentName("Updated department name");
invitedPosition.setRoleTitle("The updated role title");
// disambiguated org is required in API v3
DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
disambiguatedOrg.setDisambiguationSource("WDB");
invitedPosition.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
response = serviceDelegator.updateInvitedPosition(ORCID, 32L, invitedPosition);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewInvitedPosition(ORCID, 32L);
assertNotNull(response);
invitedPosition = (InvitedPosition) response.getEntity();
assertNotNull(invitedPosition);
Utils.verifyLastModified(invitedPosition.getLastModifiedDate());
assertTrue(invitedPosition.getLastModifiedDate().after(before));
assertEquals("Updated department name", invitedPosition.getDepartmentName());
assertEquals("The updated role title", invitedPosition.getRoleTitle());
// Rollback changes
invitedPosition.setDepartmentName("PUBLIC Department");
invitedPosition.setRoleTitle("PUBLIC");
response = serviceDelegator.updateInvitedPosition(ORCID, 32L, invitedPosition);
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_KeywordsTest method testUpdateKeyword.
@Test
public void testUpdateKeyword() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4441", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewKeyword("4444-4444-4444-4441", 6L);
assertNotNull(response);
Keyword keyword = (Keyword) response.getEntity();
assertNotNull(keyword);
Utils.verifyLastModified(keyword.getLastModifiedDate());
LastModifiedDate before = keyword.getLastModifiedDate();
assertEquals("keyword-2", keyword.getContent());
assertEquals(Visibility.PUBLIC, keyword.getVisibility());
keyword.setContent("Updated keyword");
response = serviceDelegator.updateKeyword("4444-4444-4444-4441", 6L, keyword);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewKeyword("4444-4444-4444-4441", 6L);
assertNotNull(response);
keyword = (Keyword) response.getEntity();
assertNotNull(keyword);
Utils.verifyLastModified(keyword.getLastModifiedDate());
assertTrue(keyword.getLastModifiedDate().after(before));
assertEquals("Updated keyword", keyword.getContent());
assertEquals(Visibility.PUBLIC, keyword.getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_MembershipsTest method testUpdateMembership.
@Test
public void testUpdateMembership() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewMembership(ORCID, 39L);
assertNotNull(response);
Membership membership = (Membership) response.getEntity();
assertNotNull(membership);
assertEquals("PRIVATE Department", membership.getDepartmentName());
assertEquals("PRIVATE", membership.getRoleTitle());
Utils.verifyLastModified(membership.getLastModifiedDate());
LastModifiedDate before = membership.getLastModifiedDate();
membership.setDepartmentName("Updated department name");
membership.setRoleTitle("The updated role title");
// disambiguated org is required in API v3
DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
disambiguatedOrg.setDisambiguationSource("WDB");
membership.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
response = serviceDelegator.updateMembership(ORCID, 39L, membership);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewMembership(ORCID, 39L);
assertNotNull(response);
membership = (Membership) response.getEntity();
assertNotNull(membership);
Utils.verifyLastModified(membership.getLastModifiedDate());
assertTrue(membership.getLastModifiedDate().after(before));
assertEquals("Updated department name", membership.getDepartmentName());
assertEquals("The updated role title", membership.getRoleTitle());
// Rollback changes
membership.setDepartmentName("PRIVATE Department");
membership.setRoleTitle("PRIVATE");
response = serviceDelegator.updateMembership(ORCID, 39L, membership);
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_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());
}
Aggregations