use of org.orcid.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.
the class NormalizationServiceTest method checkISBNAndCaseNormalized.
@Test
public void checkISBNAndCaseNormalized() {
ExternalID normed = new ExternalID();
normed.setRelationship(Relationship.SELF);
normed.setType("isbn");
normed.setValue("ISBN: 123-456-7-89x junk");
// everything should normalize to this.
normed.setNormalized(new TransientNonEmptyString("123456789X"));
ExternalID id1 = new ExternalID();
id1.setRelationship(Relationship.SELF);
id1.setType("isbn");
id1.setValue("ISBN: 123-456-7-89x junk");
id1.setNormalized(new TransientNonEmptyString(norm.normalise(id1.getType(), id1.getValue())));
assertEquals(normed, id1);
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.
the class NormalizationServiceTest method checkCaseNormalized.
@Test
public void checkCaseNormalized() {
ExternalID id1 = new ExternalID();
id1.setRelationship(Relationship.SELF);
id1.setType("agr");
id1.setValue("UPPER");
id1.setNormalized(new TransientNonEmptyString(norm.normalise(id1.getType(), id1.getValue())));
ExternalID id2 = new ExternalID();
id2.setRelationship(Relationship.SELF);
id2.setType("agr");
id2.setValue("upper");
id2.setNormalized(new TransientNonEmptyString("upper"));
assertEquals(id1, id2);
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.
the class JpaJaxbWorkAdapterTest method fromProfileWorkEntityToWorkTest.
@Test
public void fromProfileWorkEntityToWorkTest() {
// Set base url to https to ensure source URI is converted to http
orcidUrlManager.setBaseUrl("https://testserver.orcid.org");
WorkEntity work = getWorkEntity();
assertNotNull(work);
Work w = jpaJaxbWorkAdapter.toWork(work);
assertNotNull(w);
assertNotNull(w.getCreatedDate());
assertEquals(DateUtils.convertToDate("2015-06-05T10:15:20"), DateUtils.convertToDate(w.getCreatedDate().getValue()));
assertNotNull(w.getLastModifiedDate());
assertEquals(DateUtils.convertToDate("2015-06-05T10:15:20"), DateUtils.convertToDate(w.getLastModifiedDate().getValue()));
assertEquals(Iso3166Country.CR.value(), w.getCountry().getValue().value());
assertEquals("work:citation", w.getWorkCitation().getCitation());
assertEquals("work:description", w.getShortDescription());
assertEquals("work:journalTitle", w.getJournalTitle().getContent());
assertEquals(CitationType.BIBTEX.value(), w.getWorkCitation().getWorkCitationType().value());
assertEquals(Long.valueOf(12345), w.getPutCode());
assertEquals(Visibility.LIMITED.value(), w.getVisibility().value());
assertEquals("work:title", w.getWorkTitle().getTitle().getContent());
assertEquals("work:subtitle", w.getWorkTitle().getSubtitle().getContent());
assertEquals("work:translatedTitle", w.getWorkTitle().getTranslatedTitle().getContent());
assertEquals("ES", w.getWorkTitle().getTranslatedTitle().getLanguageCode());
assertEquals(WorkType.ARTISTIC_PERFORMANCE.value(), w.getWorkType().value());
assertNotNull(w.getWorkExternalIdentifiers());
assertNotNull(w.getWorkExternalIdentifiers().getExternalIdentifier());
assertEquals(1, w.getWorkExternalIdentifiers().getExternalIdentifier().size());
ExternalID workExtId = w.getWorkExternalIdentifiers().getExternalIdentifier().get(0);
assertNotNull(workExtId.getValue());
assertEquals("123", workExtId.getValue());
assertNotNull(workExtId.getType());
assertEquals(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value(), workExtId.getType());
String sourcePath = w.getSource().retrieveSourcePath();
assertNotNull(sourcePath);
assertEquals("APP-5555555555555555", sourcePath);
// Identifier URIs should always be http, event if base url is https
assertEquals("https://testserver.orcid.org/client/APP-5555555555555555", w.getSource().retriveSourceUri());
}
use of org.orcid.jaxb.model.v3.dev1.record.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(org.orcid.jaxb.model.notification_v2.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(org.orcid.jaxb.model.notification.permission_v2.ItemType.WORK, activityEntity.getItemType());
assertEquals("Latest Research Article", activityEntity.getItemName());
assertEquals("DOI", activityEntity.getExternalIdType());
assertEquals("1234/abc123", activityEntity.getExternalIdValue());
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_QualificationsTest method testAddQualificationsDuplicateExternalIDs.
@Test(expected = OrcidDuplicatedActivityException.class)
public void testAddQualificationsDuplicateExternalIDs() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
ExternalID e1 = new ExternalID();
e1.setRelationship(Relationship.SELF);
e1.setType("erm");
e1.setUrl(new Url("https://orcid.org"));
e1.setValue("err");
ExternalID e2 = new ExternalID();
e2.setRelationship(Relationship.SELF);
e2.setType("err");
e2.setUrl(new Url("http://bbc.co.uk"));
e2.setValue("erm");
ExternalIDs externalIDs = new ExternalIDs();
externalIDs.getExternalIdentifier().add(e1);
externalIDs.getExternalIdentifier().add(e2);
Qualification qualification = (Qualification) Utils.getAffiliation(AffiliationType.QUALIFICATION);
qualification.setExternalIDs(externalIDs);
Response response = serviceDelegator.createQualification(ORCID, qualification);
assertNotNull(response);
assertEquals(HttpStatus.SC_CREATED, response.getStatus());
Map<?, ?> map = response.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List<?> resultWithPutCode = (List<?>) map.get("Location");
Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
try {
Qualification duplicate = (Qualification) Utils.getAffiliation(AffiliationType.QUALIFICATION);
duplicate.setExternalIDs(externalIDs);
serviceDelegator.createQualification(ORCID, duplicate);
} finally {
serviceDelegator.deleteAffiliation(ORCID, putCode);
}
}
Aggregations