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;
}
use of org.orcid.persistence.jpa.entities.ProfileEntity in project ORCID-Source by ORCID.
the class OrcidRefreshTokenTokenGranterTest method createToken.
private OrcidOauth2TokenDetail createToken(String clientId, String userOrcid, String tokenValue, String refreshTokenValue, Date expirationDate, String scopes) {
OrcidOauth2TokenDetail token = new OrcidOauth2TokenDetail();
token.setApproved(true);
token.setClientDetailsId(clientId);
token.setDateCreated(new Date());
token.setLastModified(new Date());
token.setProfile(new ProfileEntity(userOrcid));
token.setScope(scopes);
token.setTokenDisabled(false);
token.setTokenExpiration(expirationDate);
token.setTokenType("bearer");
token.setTokenValue(tokenValue);
token.setRefreshTokenValue(refreshTokenValue);
orcidOauth2TokenDetailService.saveOrUpdate(token);
return token;
}
Aggregations