use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class NotificationManagerTest method deriveEmailFriendlyNameTest.
@Test
public void deriveEmailFriendlyNameTest() {
ProfileEntity testProfile = new ProfileEntity("0000-0000-0000-0003");
assertEquals("ORCID Registry User", notificationManager.deriveEmailFriendlyName(testProfile));
testProfile.setRecordNameEntity(new RecordNameEntity());
assertEquals("ORCID Registry User", notificationManager.deriveEmailFriendlyName(testProfile));
testProfile.getRecordNameEntity().setGivenNames("Given Name");
assertEquals("Given Name", notificationManager.deriveEmailFriendlyName(testProfile));
testProfile.getRecordNameEntity().setFamilyName("Family Name");
assertEquals("Given Name Family Name", notificationManager.deriveEmailFriendlyName(testProfile));
testProfile.getRecordNameEntity().setCreditName("Credit Name");
assertEquals("Credit Name", notificationManager.deriveEmailFriendlyName(testProfile));
}
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(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);
}
}
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(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");
}
}
use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class RecordNameDaoImpl method getRecordName.
@Override
public RecordNameEntity getRecordName(String orcid) {
Query query = entityManager.createQuery("FROM RecordNameEntity WHERE profile.id = :orcid");
query.setParameter("orcid", orcid);
return (RecordNameEntity) query.getSingleResult();
}
use of org.orcid.persistence.jpa.entities.RecordNameEntity in project ORCID-Source by ORCID.
the class RecordNameDaoImpl method findByCreditName.
@Override
public RecordNameEntity findByCreditName(String creditName) {
Query query = entityManager.createQuery("FROM RecordNameEntity WHERE creditName = :creditName");
query.setParameter("creditName", creditName);
@SuppressWarnings("unchecked") List<RecordNameEntity> names = (List<RecordNameEntity>) query.getResultList();
if (names == null || names.isEmpty()) {
return null;
}
//Return the first result
return names.get(0);
}
Aggregations