Search in sources :

Example 61 with RecordNameEntity

use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getNameMapperFacade.

public MapperFacade getNameMapperFacade() {
    MapperFactory mapperFactory = getNewMapperFactory();
    ClassMapBuilder<Name, RecordNameEntity> nameClassMap = mapperFactory.classMap(Name.class, RecordNameEntity.class);
    addV2DateFields(nameClassMap);
    nameClassMap.field("creditName.content", "creditName");
    nameClassMap.field("givenNames.content", "givenNames");
    nameClassMap.field("familyName.content", "familyName");
    nameClassMap.field("path", "profile.id");
    nameClassMap.byDefault();
    nameClassMap.register();
    return mapperFactory.getMapperFacade();
}
Also used : DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) SourceName(org.orcid.jaxb.model.common_v2.SourceName) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name)

Example 62 with RecordNameEntity

use of org.orcid.persistence.jpa.entities.RecordNameEntity 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 63 with RecordNameEntity

use of org.orcid.persistence.jpa.entities.RecordNameEntity 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 64 with RecordNameEntity

use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.

the class NotificationManagerTest method testSendVerificationReminderEmail.

@Test
public void testSendVerificationReminderEmail() throws JAXBException, IOException, URISyntaxException {
    String userOrcid = "0000-0000-0000-0003";
    TargetProxyHelper.injectIntoProxy(notificationManager, "profileEntityCacheManager", mockProfileEntityCacheManager);
    ProfileEntity profile = new ProfileEntity(userOrcid);
    RecordNameEntity recordName = new RecordNameEntity();
    recordName.setCreditName("My credit name");
    recordName.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
    profile.setRecordNameEntity(recordName);
    when(mockProfileEntityCacheManager.retrieve(userOrcid)).thenReturn(profile);
    String primaryEmail = "limited_0000-0000-0000-0003@test.orcid.org";
    for (Locale locale : Locale.values()) {
        profile.setLocale(org.orcid.jaxb.model.common_v2.Locale.fromValue(locale.value()));
        notificationManager.sendVerificationReminderEmail(userOrcid, primaryEmail);
    }
}
Also used : Locale(org.orcid.jaxb.model.v3.dev1.common.Locale) 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 65 with RecordNameEntity

use of org.orcid.persistence.jpa.entities.RecordNameEntity 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

RecordNameEntity (org.orcid.persistence.jpa.entities.RecordNameEntity)66 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)35 Test (org.junit.Test)26 DBUnitTest (org.orcid.test.DBUnitTest)13 Date (java.util.Date)11 EmailEntity (org.orcid.persistence.jpa.entities.EmailEntity)10 HashSet (java.util.HashSet)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 InvocationOnMock (org.mockito.invocation.InvocationOnMock)5 Before (org.junit.Before)4 Name (org.orcid.jaxb.model.v3.dev1.record.Name)4 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 Query (javax.persistence.Query)3 TypedQuery (javax.persistence.TypedQuery)3 Locale (org.orcid.jaxb.model.common_v2.Locale)3 Visibility (org.orcid.jaxb.model.common_v2.Visibility)3 Email (org.orcid.jaxb.model.record_v2.Email)3 Name (org.orcid.jaxb.model.record_v2.Name)3 Email (org.orcid.jaxb.model.v3.dev1.record.Email)3