Search in sources :

Example 6 with SourceClientId

use of org.orcid.jaxb.model.v3.dev1.common.SourceClientId 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(org.orcid.jaxb.model.notification_v2.NotificationType.AMENDED, notificationEntity.getNotificationType());
    // Source
    assertNull(notificationAmendedEntity.getSourceId());
    assertNull(notificationAmendedEntity.getClientSourceId());
    assertNull(notificationAmendedEntity.getElementSourceId());
}
Also used : NotificationAmendedEntity(org.orcid.persistence.jpa.entities.NotificationAmendedEntity) 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) Items(org.orcid.jaxb.model.v3.dev1.notification.permission.Items) NotificationEntity(org.orcid.persistence.jpa.entities.NotificationEntity) Source(org.orcid.jaxb.model.v3.dev1.common.Source) NotificationAmended(org.orcid.jaxb.model.v3.dev1.notification.amended.NotificationAmended) Test(org.junit.Test)

Example 7 with SourceClientId

use of org.orcid.jaxb.model.v3.dev1.common.SourceClientId in project ORCID-Source by ORCID.

the class ActivityValidatorTest method checkDupesNormalized.

// validate normalization is being used
@Test(expected = OrcidDuplicatedActivityException.class)
public void checkDupesNormalized() {
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("agr");
    id1.setValue("UPPER");
    ExternalIDs ids1 = new ExternalIDs();
    ids1.getExternalIdentifier().add(id1);
    ExternalID id2 = new ExternalID();
    id2.setRelationship(Relationship.SELF);
    id2.setType("agr");
    id2.setValue("upper");
    id2.setNormalized(new TransientNonEmptyString("upper"));
    ExternalIDs ids2 = new ExternalIDs();
    ids2.getExternalIdentifier().add(id2);
    SourceEntity source1 = mock(SourceEntity.class);
    when(source1.getSourceName()).thenReturn("source name");
    when(source1.getSourceId()).thenReturn("APP-00000000000000");
    SourceClientId sourceClientId = new SourceClientId();
    sourceClientId.setPath("APP-00000000000000");
    Source source2 = mock(Source.class);
    when(source2.getSourceName()).thenReturn(new SourceName("source name"));
    when(source2.getSourceClientId()).thenReturn(sourceClientId);
    activityValidator.checkExternalIdentifiersForDuplicates(ids1, ids2, source2, source1);
}
Also used : ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) SourceClientId(org.orcid.jaxb.model.v3.dev1.common.SourceClientId) SourceName(org.orcid.jaxb.model.v3.dev1.common.SourceName) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) Source(org.orcid.jaxb.model.v3.dev1.common.Source) Test(org.junit.Test)

Aggregations

SourceClientId (org.orcid.jaxb.model.v3.dev1.common.SourceClientId)7 Source (org.orcid.jaxb.model.v3.dev1.common.Source)6 Test (org.junit.Test)4 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)3 SourceName (org.orcid.jaxb.model.v3.dev1.common.SourceName)2 Item (org.orcid.jaxb.model.v3.dev1.notification.permission.Item)2 Items (org.orcid.jaxb.model.v3.dev1.notification.permission.Items)2 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)2 NotificationEntity (org.orcid.persistence.jpa.entities.NotificationEntity)2 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)2 CreatedDate (org.orcid.jaxb.model.v3.dev1.common.CreatedDate)1 SourceOrcid (org.orcid.jaxb.model.v3.dev1.common.SourceOrcid)1 TransientNonEmptyString (org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString)1 Url (org.orcid.jaxb.model.v3.dev1.common.Url)1 NotificationAmended (org.orcid.jaxb.model.v3.dev1.notification.amended.NotificationAmended)1 AuthorizationUrl (org.orcid.jaxb.model.v3.dev1.notification.permission.AuthorizationUrl)1 NotificationPermission (org.orcid.jaxb.model.v3.dev1.notification.permission.NotificationPermission)1 Work (org.orcid.jaxb.model.v3.dev1.record.Work)1 NotificationAddItemsEntity (org.orcid.persistence.jpa.entities.NotificationAddItemsEntity)1 NotificationAmendedEntity (org.orcid.persistence.jpa.entities.NotificationAmendedEntity)1