use of org.orcid.core.manager.impl.OrcidProfileManagerImpl in project ORCID-Source by ORCID.
the class OrcidProfileManagerBaseTest method initMocks.
/**
* The classes loaded from the app context are in fact proxies to the
* OrcidProfileManagerImpl class, required for transactionality. However we
* can only return the proxied interface from the app context
* <p/>
* We need to mock the call to the OrcidIndexManager whenever a persist
* method is called, but this dependency is only accessible on the impl (as
* it should be).
* <p/>
* To preserve the transactionality AND allow us to mock a dependency that
* exists on the Impl we use the getTargetObject() method in the superclass
*
* @throws Exception
*/
@Before
public void initMocks() throws Exception {
OrcidProfileManagerImpl orcidProfileManagerImpl = getTargetObject(orcidProfileManager, OrcidProfileManagerImpl.class);
orcidProfileManagerImpl.setOrcidIndexManager(orcidIndexManager);
}
use of org.orcid.core.manager.impl.OrcidProfileManagerImpl in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method before.
@Before
@Transactional
@Rollback
public void before() throws Exception {
OrcidProfileManagerImpl orcidProfileManagerImpl = getTargetObject(orcidProfileManager, OrcidProfileManagerImpl.class);
orcidProfileManagerImpl.setNotificationManager(notificationManager);
if (profileDao.find(TEST_ORCID) != null) {
profileDao.remove(TEST_ORCID);
}
subjectDao.merge(new SubjectEntity("Computer Science"));
subjectDao.merge(new SubjectEntity("Dance"));
OrcidProfile delegateProfile = new OrcidProfile();
delegateProfile.setOrcidIdentifier(DELEGATE_ORCID);
OrcidBio delegateBio = new OrcidBio();
delegateProfile.setOrcidBio(delegateBio);
PersonalDetails delegatePersonalDetails = new PersonalDetails();
delegateBio.setPersonalDetails(delegatePersonalDetails);
CreditName delegateCreditName = new CreditName("H. Shearer");
delegateCreditName.setVisibility(Visibility.PUBLIC);
delegatePersonalDetails.setCreditName(delegateCreditName);
orcidProfileManager.createOrcidProfile(delegateProfile, false, false);
OrcidProfile applicationProfile = new OrcidProfile();
applicationProfile.setOrcidIdentifier(APPLICATION_ORCID);
OrcidBio applicationBio = new OrcidBio();
applicationProfile.setOrcidBio(applicationBio);
PersonalDetails applicationPersonalDetails = new PersonalDetails();
applicationBio.setPersonalDetails(applicationPersonalDetails);
applicationPersonalDetails.setCreditName(new CreditName("Brown University"));
orcidProfileManager.createOrcidProfile(applicationProfile, false, false);
ClientDetailsEntity clientDetails = new ClientDetailsEntity();
clientDetails.setId(applicationProfile.getOrcidIdentifier().getPath());
ProfileEntity applicationProfileEntity = profileDao.find(applicationProfile.getOrcidIdentifier().getPath());
profileDao.refresh(applicationProfileEntity);
clientDetails.setGroupProfileId(applicationProfileEntity.getId());
clientDetailsManager.merge(clientDetails);
ClientDetailsEntity clientDetails2 = new ClientDetailsEntity();
clientDetails2.setId(APPLICATION_ORCID_2);
clientDetails.setGroupProfileId(applicationProfileEntity.getId());
clientDetailsManager.merge(clientDetails2);
OrcidOauth2TokenDetail token = new OrcidOauth2TokenDetail();
token.setTokenValue("1234");
token.setClientDetailsId(clientDetails.getId());
token.setProfile(profileDao.find(delegateProfile.getOrcidIdentifier().getPath()));
token.setScope(StringUtils.join(new String[] { ScopePathType.ORCID_BIO_READ_LIMITED.value(), ScopePathType.ORCID_BIO_UPDATE.value() }, " "));
SortedSet<OrcidOauth2TokenDetail> tokens = new TreeSet<>();
tokens.add(token);
ProfileEntity delegateProfileEntity = profileDao.find(delegateProfile.getOrcidIdentifier().getPath());
delegateProfileEntity.setTokenDetails(tokens);
profileDao.merge(delegateProfileEntity);
SecurityQuestionEntity existingSecurityQuestionEntity = securityQuestionDao.find(3);
if (existingSecurityQuestionEntity == null) {
SecurityQuestionEntity securityQuestionEntity = new SecurityQuestionEntity();
securityQuestionEntity.setId(3);
securityQuestionEntity.setQuestion("What?");
securityQuestionDao.persist(securityQuestionEntity);
}
orcidProfileManager.setCompareWorksUsingScopusWay(true);
MockitoAnnotations.initMocks(this);
TargetProxyHelper.injectIntoProxy(jaxb2JpaAdapter, "sourceManager", mockSourceManager);
TargetProxyHelper.injectIntoProxy(orcidProfileManager, "sourceManager", mockSourceManager);
SourceEntity sourceEntity = new SourceEntity();
sourceEntity.setSourceClient(clientDetails);
when(mockSourceManager.retrieveSourceEntity()).thenReturn(sourceEntity);
SourceEntity sourceEntity2 = new SourceEntity();
sourceEntity2.setSourceClient(clientDetails2);
when(anotherMockSourceManager.retrieveSourceEntity()).thenReturn(sourceEntity2);
}
Aggregations