Search in sources :

Example 66 with Email

use of org.orcid.jaxb.model.v3.dev1.record.Email in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getEmailMapperFacade.

public MapperFacade getEmailMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ClassMapBuilder<Email, EmailEntity> emailClassMap = mapperFactory.classMap(Email.class, EmailEntity.class);
    emailClassMap.byDefault();
    emailClassMap.field("email", "id");
    emailClassMap.field("primary", "primary");
    emailClassMap.field("verified", "verified");
    addV3DateFields(emailClassMap);
    registerSourceConverters(mapperFactory, emailClassMap);
    emailClassMap.register();
    return mapperFactory.getMapperFacade();
}
Also used : Email(org.orcid.jaxb.model.v3.dev1.record.Email) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) EmailEntity(org.orcid.persistence.jpa.entities.EmailEntity)

Example 67 with Email

use of org.orcid.jaxb.model.v3.dev1.record.Email in project ORCID-Source by ORCID.

the class NotificationManagerTest method testAddedDelegatesSentCorrectEmail.

@Test
public void testAddedDelegatesSentCorrectEmail() throws JAXBException, IOException, URISyntaxException {
    TargetProxyHelper.injectIntoProxy(notificationManager, "profileEntityCacheManager", mockProfileEntityCacheManager);
    TargetProxyHelper.injectIntoProxy(notificationManager, "emailManager", mockEmailManager);
    TargetProxyHelper.injectIntoProxy(notificationManager, "profileDao", mockProfileDao);
    TargetProxyHelper.injectIntoProxy(notificationManager, "notificationDao", mockNotificationDao);
    TargetProxyHelper.injectIntoProxy(notificationManager, "notificationAdapter", mockNotificationAdapter);
    final String orcid = "0000-0000-0000-0003";
    String delegateOrcid = "1234-5678-1234-5678";
    ProfileEntity profile = new ProfileEntity();
    RecordNameEntity recordName = new RecordNameEntity();
    recordName.setCreditName("My credit name");
    recordName.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
    profile.setRecordNameEntity(recordName);
    profile.setSendAdministrativeChangeNotifications(true);
    profile.setSendChangeNotifications(true);
    profile.setSendMemberUpdateRequests(true);
    profile.setSendOrcidNews(true);
    EmailEntity emailEntity = new EmailEntity();
    emailEntity.setId("test@email.com");
    emailEntity.setPrimary(true);
    emailEntity.setCurrent(true);
    Set<EmailEntity> emails = new HashSet<EmailEntity>();
    emails.add(emailEntity);
    profile.setEmails(emails);
    SourceEntity sourceEntity = new SourceEntity(new ClientDetailsEntity("APP-5555555555555555"));
    when(sourceManager.retrieveSourceEntity()).thenReturn(sourceEntity);
    when(sourceManager.retrieveSourceOrcid()).thenReturn("APP-5555555555555555");
    when(mockNotificationAdapter.toNotificationEntity(Mockito.any(Notification.class))).thenReturn(new NotificationCustomEntity());
    Email email = new Email();
    email.setEmail("test@email.com");
    Email delegateEmail = new Email();
    delegateEmail.setEmail("delegate@email.com");
    when(mockProfileEntityCacheManager.retrieve(Mockito.anyString())).thenAnswer(new Answer<ProfileEntity>() {

        @Override
        public ProfileEntity answer(InvocationOnMock invocation) throws Throwable {
            profile.setId(invocation.getArgument(0));
            return profile;
        }
    });
    when(mockProfileDao.find(Mockito.anyString())).thenAnswer(new Answer<ProfileEntity>() {

        @Override
        public ProfileEntity answer(InvocationOnMock invocation) throws Throwable {
            profile.setId(invocation.getArgument(0));
            return profile;
        }
    });
    when(mockEmailManager.findPrimaryEmail(orcid)).thenReturn(email);
    when(mockEmailManager.findPrimaryEmail(delegateOrcid)).thenReturn(delegateEmail);
    for (org.orcid.jaxb.model.common_v2.Locale locale : org.orcid.jaxb.model.common_v2.Locale.values()) {
        profile.setLocale(locale);
        notificationManager.sendNotificationToAddedDelegate("0000-0000-0000-0003", delegateOrcid);
    }
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Email(org.orcid.jaxb.model.v3.dev1.record.Email) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) EmailEntity(org.orcid.persistence.jpa.entities.EmailEntity) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NotificationCustomEntity(org.orcid.persistence.jpa.entities.NotificationCustomEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Notification(org.orcid.jaxb.model.v3.dev1.notification.Notification) InvocationOnMock(org.mockito.invocation.InvocationOnMock) HashSet(java.util.HashSet) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 68 with Email

use of org.orcid.jaxb.model.v3.dev1.record.Email in project ORCID-Source by ORCID.

the class NotificationManagerTest method testChangeEmailAddress.

@Test
public void testChangeEmailAddress() throws Exception {
    TargetProxyHelper.injectIntoProxy(notificationManager, "profileEntityCacheManager", mockProfileEntityCacheManager);
    TargetProxyHelper.injectIntoProxy(notificationManager, "emailManager", mockEmailManager);
    final String orcid = "0000-0000-0000-0003";
    ProfileEntity profile = new ProfileEntity(orcid);
    RecordNameEntity recordName = new RecordNameEntity();
    recordName.setCreditName("My credit name");
    recordName.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
    profile.setRecordNameEntity(recordName);
    Email email = new Email();
    email.setEmail("test@email.com");
    when(mockProfileEntityCacheManager.retrieve(orcid)).thenReturn(profile);
    when(mockEmailManager.findPrimaryEmail(orcid)).thenReturn(email);
    for (org.orcid.jaxb.model.common_v2.Locale locale : org.orcid.jaxb.model.common_v2.Locale.values()) {
        profile.setLocale(locale);
        notificationManager.sendEmailAddressChangedNotification(orcid, "new@email.com", "original@email.com");
    }
}
Also used : Email(org.orcid.jaxb.model.v3.dev1.record.Email) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 69 with Email

use of org.orcid.jaxb.model.v3.dev1.record.Email in project ORCID-Source by ORCID.

the class NotificationManagerTest method testSendReactivationEmail.

@Test
public void testSendReactivationEmail() throws Exception {
    String userOrcid = "0000-0000-0000-0003";
    String primaryEmail = "public_0000-0000-0000-0003@test.orcid.org";
    String email = "original@email.com";
    for (Locale locale : Locale.values()) {
        profileEntityManager.updateLocale(userOrcid, locale);
        notificationManager.sendReactivationEmail(email, userOrcid);
    }
}
Also used : Locale(org.orcid.jaxb.model.v3.dev1.common.Locale) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 70 with Email

use of org.orcid.jaxb.model.v3.dev1.record.Email in project ORCID-Source by ORCID.

the class NotificationManagerTest method testSendDeactivateEmail.

@Test
public void testSendDeactivateEmail() throws JAXBException, IOException, URISyntaxException {
    TargetProxyHelper.injectIntoProxy(notificationManager, "profileEntityCacheManager", mockProfileEntityCacheManager);
    TargetProxyHelper.injectIntoProxy(notificationManager, "emailManager", mockEmailManager);
    final String orcid = "0000-0000-0000-0003";
    ProfileEntity profile = new ProfileEntity(orcid);
    RecordNameEntity recordName = new RecordNameEntity();
    recordName.setCreditName("My credit name");
    recordName.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
    profile.setRecordNameEntity(recordName);
    Email email = new Email();
    email.setEmail("test@email.com");
    when(mockProfileEntityCacheManager.retrieve(orcid)).thenReturn(profile);
    when(mockEmailManager.findPrimaryEmail(orcid)).thenReturn(email);
    for (org.orcid.jaxb.model.common_v2.Locale locale : org.orcid.jaxb.model.common_v2.Locale.values()) {
        profile.setLocale(locale);
        notificationManager.sendOrcidDeactivateEmail(orcid);
    }
}
Also used : Email(org.orcid.jaxb.model.v3.dev1.record.Email) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Email (org.orcid.jaxb.model.v3.dev1.record.Email)75 Test (org.junit.Test)62 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)50 Address (org.orcid.jaxb.model.v3.dev1.record.Address)37 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)36 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)36 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)36 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)36 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)33 Person (org.orcid.jaxb.model.v3.dev1.record.Person)33 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)31 Addresses (org.orcid.jaxb.model.v3.dev1.record.Addresses)30 Keywords (org.orcid.jaxb.model.v3.dev1.record.Keywords)30 PersonExternalIdentifiers (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers)30 ResearcherUrls (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)30 Name (org.orcid.jaxb.model.v3.dev1.record.Name)29 ArrayList (java.util.ArrayList)16 Record (org.orcid.jaxb.model.v3.dev1.record.Record)16 DBUnitTest (org.orcid.test.DBUnitTest)16 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)15