use of org.orcid.jaxb.model.record_rc4.ExternalID in project ORCID-Source by ORCID.
the class ValidateV2_1SamplesTest method testUnmarshallWorks.
@Test
public void testUnmarshallWorks() throws JAXBException, SAXException, URISyntaxException {
Works works = (Works) unmarshallFromPath("/record_2.1/samples/read_samples/works-2.1.xml", Works.class, "/record_2.1/activities-2.1.xsd");
assertNotNull(works);
assertNotNull(works.getLastModifiedDate());
assertNotNull(works.getLastModifiedDate().getValue());
assertEquals(3, works.getWorkGroup().size());
boolean foundWorkWithNoExtIds = false;
for (WorkGroup group : works.getWorkGroup()) {
assertNotNull(group.getLastModifiedDate().getValue());
assertNotNull(group.getIdentifiers().getExternalIdentifier());
if (group.getIdentifiers().getExternalIdentifier().isEmpty()) {
WorkSummary summary = group.getWorkSummary().get(0);
validateSourceInHttps(summary.getSource());
assertEquals("1", summary.getDisplayIndex());
assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("doi", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
assertEquals("https://doi.org/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("/8888-8888-8888-8880/work/3356", summary.getPath());
assertEquals("03", summary.getPublicationDate().getDay().getValue());
assertEquals("03", summary.getPublicationDate().getMonth().getValue());
assertEquals("2017", summary.getPublicationDate().getYear().getValue());
assertEquals("Work # 0", summary.getTitle().getTitle().getContent());
assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
assertEquals(Visibility.PUBLIC, summary.getVisibility());
foundWorkWithNoExtIds = true;
} else {
assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
ExternalID extId = group.getIdentifiers().getExternalIdentifier().get(0);
if (extId.getType().equals("arxiv")) {
assertEquals(Relationship.SELF, extId.getRelationship());
assertEquals("http://arxiv.org/abs/123456", extId.getUrl().getValue());
assertEquals("123456", extId.getValue());
} else if (extId.getType().equals("bibcode")) {
assertEquals(Relationship.SELF, extId.getRelationship());
assertEquals("http://adsabs.harvard.edu/abs/4567", extId.getUrl().getValue());
assertEquals("4567", extId.getValue());
} else {
fail("Invalid ext id type " + extId.getType());
}
assertEquals(1, group.getWorkSummary().size());
WorkSummary summary = group.getWorkSummary().get(0);
validateSourceInHttps(summary.getSource());
if (summary.getPutCode().equals(Long.valueOf(3357))) {
assertEquals("1", summary.getDisplayIndex());
assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("arxiv", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
assertEquals("http://arxiv.org/abs/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("/8888-8888-8888-8880/work/3357", summary.getPath());
assertEquals("02", summary.getPublicationDate().getDay().getValue());
assertEquals("02", summary.getPublicationDate().getMonth().getValue());
assertEquals("2017", summary.getPublicationDate().getYear().getValue());
assertEquals("Work # 1", summary.getTitle().getTitle().getContent());
assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
assertEquals(Visibility.PUBLIC, summary.getVisibility());
} else if (summary.getPutCode().equals(Long.valueOf(3358))) {
assertEquals("1", summary.getDisplayIndex());
assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("bibcode", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
assertEquals("http://adsabs.harvard.edu/abs/4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
assertEquals("4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("/8888-8888-8888-8880/work/3358", summary.getPath());
assertEquals("03", summary.getPublicationDate().getDay().getValue());
assertEquals("03", summary.getPublicationDate().getMonth().getValue());
assertEquals("2017", summary.getPublicationDate().getYear().getValue());
assertEquals("Work # 2", summary.getTitle().getTitle().getContent());
assertEquals(WorkType.JOURNAL_ARTICLE, summary.getType());
assertEquals(Visibility.PUBLIC, summary.getVisibility());
} else {
fail("Invalid put code " + summary.getPutCode());
}
}
}
assertTrue(foundWorkWithNoExtIds);
}
use of org.orcid.jaxb.model.record_rc4.ExternalID in project ORCID-Source by ORCID.
the class ValidateV2_1IdentifiersTest method testPeerReview.
/** Test both types of identifier here
*
* @throws SAXException
* @throws IOException
* @throws JAXBException
* @throws ParserConfigurationException
*/
@Test
public void testPeerReview() throws SAXException, IOException, JAXBException, ParserConfigurationException {
PeerReview peerReview = unmarshallFromPath("/record_2.1/samples/read_samples/peer-review-2.1.xml", PeerReview.class);
ExternalID id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
assertEquals("source-work-id", id.getType());
assertEquals("work:external-identifier-id", id.getValue());
assertEquals(new Url("http://orcid.org"), id.getUrl());
assertEquals(Relationship.SELF, id.getRelationship());
ExternalID subjectid = peerReview.getSubjectExternalIdentifier();
assertEquals("doi", subjectid.getType());
assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
assertEquals(Relationship.SELF, subjectid.getRelationship());
Validator validator = getValidator("peer-review");
validator.validate(marshall(PeerReview.class, peerReview));
validator.validate(marshallToDOM(PeerReview.class, peerReview));
//do the full record too
peerReview = unmarshallFromPath("/record_2.1/samples/read_samples/peer-review-full-2.1.xml", PeerReview.class);
id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
assertEquals("source-work-id", id.getType());
assertEquals("work:external-identifier-id", id.getValue());
assertEquals(new Url("http://orcid.org"), id.getUrl());
assertEquals(Relationship.SELF, id.getRelationship());
subjectid = peerReview.getSubjectExternalIdentifier();
assertEquals("doi", subjectid.getType());
assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
assertEquals(Relationship.SELF, subjectid.getRelationship());
}
use of org.orcid.jaxb.model.record_rc4.ExternalID in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_WorksTest method testUpdateWorkYouAreNotTheSourceOf.
@Test(expected = WrongSourceException.class)
public void testUpdateWorkYouAreNotTheSourceOf() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewWork("4444-4444-4444-4443", 2L);
assertNotNull(response);
Work work = (Work) response.getEntity();
assertNotNull(work);
Utils.verifyLastModified(work.getLastModifiedDate());
assertEquals(Long.valueOf(2), work.getPutCode());
assertNotNull(work.getWorkTitle());
assertNotNull(work.getWorkTitle().getTitle());
assertEquals("Another day in the life", work.getWorkTitle().getTitle().getContent());
assertEquals(WorkType.BOOK, work.getWorkType());
work.setWorkType(WorkType.EDITED_BOOK);
work.getWorkTitle().getTitle().setContent("Updated work title");
ExternalIDs extIds = new ExternalIDs();
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.PART_OF);
extId.setType(WorkExternalIdentifierType.AGR.value());
extId.setValue("ext-id-" + System.currentTimeMillis());
extId.setUrl(new Url("http://thisIsANewUrl.com"));
extIds.getExternalIdentifier().add(extId);
work.setWorkExternalIdentifiers(extIds);
serviceDelegator.updateWork("4444-4444-4444-4443", 2L, work);
fail();
}
use of org.orcid.jaxb.model.record_rc4.ExternalID in project ORCID-Source by ORCID.
the class JpaJaxbNotificationAdapterTest method testToNotificationAmendedEntity.
@Test
public void testToNotificationAmendedEntity() {
NotificationAmended notification = new NotificationAmended();
notification.setNotificationType(NotificationType.AMENDED);
Source source = new Source();
notification.setSource(source);
SourceClientId clientId = new SourceClientId();
source.setSourceClientId(clientId);
clientId.setPath("APP-5555-5555-5555-5555");
Items activities = new Items();
notification.setItems(activities);
Item activity = new Item();
activities.getItems().add(activity);
activity.setItemType(ItemType.WORK);
activity.setItemName("Latest Research Article");
ExternalID extId = new ExternalID();
activity.setExternalIdentifier(extId);
extId.setType("doi");
extId.setValue("1234/abc123");
NotificationEntity notificationEntity = jpaJaxbNotificationAdapter.toNotificationEntity(notification);
assertTrue(notificationEntity instanceof NotificationAmendedEntity);
NotificationAmendedEntity notificationAmendedEntity = (NotificationAmendedEntity) notificationEntity;
assertNotNull(notificationEntity);
assertEquals(NotificationType.AMENDED, notificationEntity.getNotificationType());
// Source
assertNull(notificationAmendedEntity.getSourceId());
assertNull(notificationAmendedEntity.getClientSourceId());
assertNull(notificationAmendedEntity.getElementSourceId());
}
use of org.orcid.jaxb.model.record_rc4.ExternalID in project ORCID-Source by ORCID.
the class JpaJaxbNotificationAdapterTest method testToNotificationPermissionEntity.
@Test
public void testToNotificationPermissionEntity() {
NotificationPermission notification = new NotificationPermission();
notification.setNotificationType(NotificationType.PERMISSION);
String authorizationUrlString = "https://orcid.org/oauth/authorize?client_id=APP-U4UKCNSSIM1OCVQY&response_type=code&scope=/orcid-works/create&redirect_uri=http://somethirdparty.com";
AuthorizationUrl url = new AuthorizationUrl();
notification.setAuthorizationUrl(url);
notification.setNotificationIntro("This is the intro");
notification.setNotificationSubject("This is the subject");
Source source = new Source();
notification.setSource(source);
SourceClientId clientId = new SourceClientId();
source.setSourceClientId(clientId);
clientId.setPath("APP-5555-5555-5555-5555");
url.setUri(authorizationUrlString);
Items activities = new Items();
notification.setItems(activities);
Item activity = new Item();
activities.getItems().add(activity);
activity.setItemType(ItemType.WORK);
activity.setItemName("Latest Research Article");
ExternalID extId = new ExternalID();
activity.setExternalIdentifier(extId);
extId.setType("doi");
extId.setValue("1234/abc123");
NotificationEntity notificationEntity = jpaJaxbNotificationAdapter.toNotificationEntity(notification);
assertTrue(notificationEntity instanceof NotificationAddItemsEntity);
NotificationAddItemsEntity addActivitiesEntity = (NotificationAddItemsEntity) notificationEntity;
assertNotNull(notificationEntity);
assertEquals(NotificationType.PERMISSION, notificationEntity.getNotificationType());
assertEquals(authorizationUrlString, addActivitiesEntity.getAuthorizationUrl());
assertEquals(notification.getNotificationIntro(), notificationEntity.getNotificationIntro());
assertEquals(notification.getNotificationSubject(), notificationEntity.getNotificationSubject());
// Source
assertNull(notificationEntity.getSourceId());
assertNull(notificationEntity.getClientSourceId());
assertNull(notificationEntity.getElementSourceId());
Set<NotificationItemEntity> activityEntities = addActivitiesEntity.getNotificationItems();
assertNotNull(activityEntities);
assertEquals(1, activityEntities.size());
NotificationItemEntity activityEntity = activityEntities.iterator().next();
assertEquals(ItemType.WORK, activityEntity.getItemType());
assertEquals("Latest Research Article", activityEntity.getItemName());
assertEquals("DOI", activityEntity.getExternalIdType());
assertEquals("1234/abc123", activityEntity.getExternalIdValue());
}
Aggregations