Search in sources :

Example 66 with ExternalID

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);
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) Test(org.junit.Test)

Example 67 with ExternalID

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);
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) Test(org.junit.Test)

Example 68 with ExternalID

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());
}
Also used : WorkEntity(org.orcid.persistence.jpa.entities.WorkEntity) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Test(org.junit.Test)

Example 69 with ExternalID

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());
}
Also used : AuthorizationUrl(org.orcid.jaxb.model.v3.dev1.notification.permission.AuthorizationUrl) NotificationAddItemsEntity(org.orcid.persistence.jpa.entities.NotificationAddItemsEntity) Item(org.orcid.jaxb.model.v3.dev1.notification.permission.Item) SourceClientId(org.orcid.jaxb.model.v3.dev1.common.SourceClientId) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) NotificationPermission(org.orcid.jaxb.model.v3.dev1.notification.permission.NotificationPermission) Items(org.orcid.jaxb.model.v3.dev1.notification.permission.Items) NotificationItemEntity(org.orcid.persistence.jpa.entities.NotificationItemEntity) NotificationEntity(org.orcid.persistence.jpa.entities.NotificationEntity) Source(org.orcid.jaxb.model.v3.dev1.common.Source) Test(org.junit.Test)

Example 70 with ExternalID

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);
    }
}
Also used : Response(javax.ws.rs.core.Response) Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) List(java.util.List) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)120 Test (org.junit.Test)73 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)66 Url (org.orcid.jaxb.model.v3.dev1.common.Url)64 Title (org.orcid.jaxb.model.v3.dev1.common.Title)25 Work (org.orcid.jaxb.model.v3.dev1.record.Work)23 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)22 Response (javax.ws.rs.core.Response)20 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)20 DBUnitTest (org.orcid.test.DBUnitTest)20 List (java.util.List)16 TransientNonEmptyString (org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString)14 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)13 ClientResponse (com.sun.jersey.api.client.ClientResponse)12 BaseTest (org.orcid.core.BaseTest)9 OrcidError (org.orcid.jaxb.model.v3.dev1.error.OrcidError)9 ArrayList (java.util.ArrayList)8 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)8 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)8 JSONUrl (org.orcid.core.adapter.jsonidentifier.JSONUrl)7