use of org.orcid.persistence.jpa.entities.ProfileEntity in project ORCID-Source by ORCID.
the class SourceInActivitiesTest method sourceDoesntChange_Funding_Test.
@Test
@Transactional
public void sourceDoesntChange_Funding_Test() {
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ProfileEntity(userOrcid)));
Funding funding1 = getFunding(userOrcid);
assertNotNull(funding1);
assertNotNull(funding1.getTitle());
assertNotNull(funding1.getTitle().getTitle());
assertFalse(PojoUtil.isEmpty(funding1.getTitle().getTitle().getContent()));
assertEquals(userOrcid, funding1.getSource().retrieveSourcePath());
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
Funding funding2 = getFunding(userOrcid);
assertNotNull(funding2.getTitle());
assertNotNull(funding2.getTitle().getTitle());
assertFalse(PojoUtil.isEmpty(funding2.getTitle().getTitle().getContent()));
assertEquals(CLIENT_1_ID, funding2.getSource().retrieveSourcePath());
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_2_ID)));
Funding funding3 = getFunding(userOrcid);
assertNotNull(funding3.getTitle());
assertNotNull(funding3.getTitle().getTitle());
assertFalse(PojoUtil.isEmpty(funding3.getTitle().getTitle().getContent()));
assertEquals(CLIENT_2_ID, funding3.getSource().retrieveSourcePath());
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ProfileEntity(userOrcid)));
Funding funding4 = getFunding(userOrcid);
assertNotNull(funding4.getTitle());
assertNotNull(funding4.getTitle().getTitle());
assertFalse(PojoUtil.isEmpty(funding4.getTitle().getTitle().getContent()));
assertEquals(userOrcid, funding4.getSource().retrieveSourcePath());
Funding fromDb1 = profileFundingManager.getFunding(userOrcid, funding1.getPutCode());
assertNotNull(fromDb1);
assertEquals(userOrcid, fromDb1.getSource().retrieveSourcePath());
Funding fromDb2 = profileFundingManager.getFunding(userOrcid, funding2.getPutCode());
assertNotNull(fromDb2);
assertEquals(CLIENT_1_ID, fromDb2.getSource().retrieveSourcePath());
Funding fromDb3 = profileFundingManager.getFunding(userOrcid, funding3.getPutCode());
assertNotNull(fromDb3);
assertEquals(CLIENT_2_ID, fromDb3.getSource().retrieveSourcePath());
Funding fromDb4 = profileFundingManager.getFunding(userOrcid, funding4.getPutCode());
assertNotNull(fromDb4);
assertEquals(userOrcid, fromDb4.getSource().retrieveSourcePath());
}
use of org.orcid.persistence.jpa.entities.ProfileEntity 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.ProfileEntity 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.ProfileEntity 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.ProfileEntity in project ORCID-Source by ORCID.
the class OrcidClientCredentialEndPointDelegatorTest method createAuthorizationCode.
private OrcidOauth2AuthoriziationCodeDetail createAuthorizationCode(String value, String clientId, String redirectUri, boolean persistent, String... scopes) {
OrcidOauth2AuthoriziationCodeDetail authorizationCode = new OrcidOauth2AuthoriziationCodeDetail();
authorizationCode.setId(value);
authorizationCode.setApproved(true);
authorizationCode.setScopes(new HashSet<String>(Arrays.asList(scopes)));
authorizationCode.setClientDetailsEntity(new ClientDetailsEntity(clientId));
authorizationCode.setPersistent(persistent);
authorizationCode.setProfileEntity(new ProfileEntity(USER_ORCID));
authorizationCode.setRedirectUri(redirectUri);
authorizationCode.setResourceIds(new HashSet<String>(Arrays.asList("orcid")));
authorizationCode.setAuthenticated(true);
orcidOauth2AuthoriziationCodeDetailDao.persist(authorizationCode);
return authorizationCode;
}
Aggregations