use of org.orcid.jaxb.model.v3.dev1.record.WorkTitle in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_WorksTest method testCreateWorksWithBulkAllOK.
@Test
public void testCreateWorksWithBulkAllOK() {
RequestAttributes previousAttrs = RequestContextHolder.getRequestAttributes();
RequestAttributes attrs = new ServletRequestAttributes(new MockHttpServletRequest());
attrs.setAttribute(ApiVersionFilter.API_VERSION_REQUEST_ATTRIBUTE_NAME, "3.0_dev1", RequestAttributes.SCOPE_REQUEST);
RequestContextHolder.setRequestAttributes(attrs);
Long time = System.currentTimeMillis();
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
WorkBulk bulk = new WorkBulk();
for (int i = 0; i < 5; i++) {
Work work = new Work();
WorkTitle title = new WorkTitle();
title.setTitle(new Title("Bulk work " + i + " " + time));
work.setWorkTitle(title);
ExternalIDs extIds = new ExternalIDs();
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.SELF);
extId.setType("doi");
extId.setUrl(new Url("http://doi/" + i + "/" + time));
extId.setValue("doi-" + i + "-" + time);
extIds.getExternalIdentifier().add(extId);
work.setWorkExternalIdentifiers(extIds);
work.setWorkType(WorkType.BOOK);
bulk.getBulk().add(work);
}
Response response = serviceDelegator.createWorks(ORCID, bulk);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
bulk = (WorkBulk) response.getEntity();
assertNotNull(bulk);
assertEquals(5, bulk.getBulk().size());
for (int i = 0; i < 5; i++) {
assertTrue(Work.class.isAssignableFrom(bulk.getBulk().get(i).getClass()));
Work w = (Work) bulk.getBulk().get(i);
Utils.verifyLastModified(w.getLastModifiedDate());
assertNotNull(w.getPutCode());
assertTrue(0L < w.getPutCode());
assertEquals("Bulk work " + i + " " + time, w.getWorkTitle().getTitle().getContent());
assertNotNull(w.getExternalIdentifiers().getExternalIdentifier());
assertEquals("doi-" + i + "-" + time, w.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
Response r = serviceDelegator.viewWork(ORCID, w.getPutCode());
assertNotNull(r);
assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
assertEquals("Bulk work " + i + " " + time, ((Work) r.getEntity()).getWorkTitle().getTitle().getContent());
// Delete the work
r = serviceDelegator.deleteWork(ORCID, w.getPutCode());
assertNotNull(r);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), r.getStatus());
}
RequestContextHolder.setRequestAttributes(previousAttrs);
}
use of org.orcid.jaxb.model.v3.dev1.record.WorkTitle in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_WorksTest method testCleanEmptyFieldsOnWorks.
@Test
public void testCleanEmptyFieldsOnWorks() {
LastModifiedDate lmd = new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis()));
Work work = new Work();
work.setLastModifiedDate(lmd);
work.setWorkCitation(new Citation("", CitationType.FORMATTED_UNSPECIFIED));
WorkTitle title = new WorkTitle();
title.setTitle(new Title("My Work"));
title.setSubtitle(new Subtitle("My subtitle"));
title.setTranslatedTitle(new TranslatedTitle("", ""));
work.setWorkTitle(title);
ActivityUtils.cleanEmptyFields(work);
assertNotNull(work);
Utils.verifyLastModified(work.getLastModifiedDate());
assertNotNull(work.getWorkTitle());
assertNotNull(work.getWorkTitle().getTitle());
assertNotNull(work.getWorkTitle().getSubtitle());
assertEquals("My Work", work.getWorkTitle().getTitle().getContent());
assertEquals("My subtitle", work.getWorkTitle().getSubtitle().getContent());
assertNull(work.getWorkCitation());
assertNull(work.getWorkTitle().getTranslatedTitle());
}
use of org.orcid.jaxb.model.v3.dev1.record.WorkTitle in project ORCID-Source by ORCID.
the class WorksPaginatorTest method getTitle.
private WorkTitle getTitle(int i) {
WorkTitle title = new WorkTitle();
title.setTitle(new Title(UUID.randomUUID().toString()));
title.setSubtitle(new Subtitle(UUID.randomUUID().toString()));
return title;
}
use of org.orcid.jaxb.model.v3.dev1.record.WorkTitle 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.record.WorkTitle in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_PeerReviewsTest method testAddPeerReviewWithSameExtIdValueButDifferentExtIdType.
@Test
public void testAddPeerReviewWithSameExtIdValueButDifferentExtIdType() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4444", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
PeerReview peerReview1 = new PeerReview();
ExternalIDs weis1 = new ExternalIDs();
ExternalID wei1 = new ExternalID();
wei1.setRelationship(null);
wei1.setValue("same_but_different_type");
wei1.setType(WorkExternalIdentifierType.DOI.value());
weis1.getExternalIdentifier().add(wei1);
peerReview1.setExternalIdentifiers(weis1);
peerReview1.setGroupId("issn:0000003");
peerReview1.setOrganization(Utils.getOrganization());
peerReview1.setRole(Role.CHAIR);
peerReview1.setSubjectContainerName(new Title("subject-container-name"));
peerReview1.setSubjectExternalIdentifier(wei1);
WorkTitle workTitle1 = new WorkTitle();
workTitle1.setTitle(new Title("work-title"));
peerReview1.setSubjectName(workTitle1);
peerReview1.setSubjectType(WorkType.DATA_SET);
peerReview1.setType(PeerReviewType.EVALUATION);
Response response1 = serviceDelegator.createPeerReview("4444-4444-4444-4444", peerReview1);
assertNotNull(response1);
assertEquals(Response.Status.CREATED.getStatusCode(), response1.getStatus());
Map<?, ?> map = response1.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List<?> resultWithPutCode = (List<?>) map.get("Location");
Long putCode1 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
PeerReview peerReview2 = new PeerReview();
ExternalIDs weis2 = new ExternalIDs();
ExternalID wei2 = new ExternalID();
wei2.setRelationship(null);
// Same value
wei2.setValue("same_but_different_type");
// But different
wei2.setType(WorkExternalIdentifierType.ARXIV.value());
// type
weis2.getExternalIdentifier().add(wei2);
peerReview2.setExternalIdentifiers(weis2);
peerReview2.setGroupId("issn:0000003");
peerReview2.setOrganization(Utils.getOrganization());
peerReview2.setRole(Role.CHAIR);
peerReview2.setSubjectContainerName(new Title("subject-container-name"));
peerReview2.setSubjectExternalIdentifier(wei2);
WorkTitle workTitle2 = new WorkTitle();
workTitle2.setTitle(new Title("work-title"));
peerReview2.setSubjectName(workTitle2);
peerReview2.setSubjectType(WorkType.DATA_SET);
peerReview2.setType(PeerReviewType.EVALUATION);
Response response2 = serviceDelegator.createPeerReview("4444-4444-4444-4444", peerReview2);
assertNotNull(response2);
assertEquals(Response.Status.CREATED.getStatusCode(), response2.getStatus());
map = response2.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
resultWithPutCode = (List<?>) map.get("Location");
Long putCode2 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
// Delete new peer reviews so they don't affect other tests
serviceDelegator.deletePeerReview("4444-4444-4444-4444", putCode1);
serviceDelegator.deletePeerReview("4444-4444-4444-4444", putCode2);
}
Aggregations