Search in sources :

Example 51 with ClientDetailsEntity

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

the class ResearcherUrlManagerTest method displayIndexIsSetTo_0_FromAPI.

@Test
public void displayIndexIsSetTo_0_FromAPI() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    ResearcherUrl rUrl = getResearcherUrl();
    rUrl.getUrl().setValue(rUrl.getUrl().getValue() + "/fromAPI");
    rUrl = researcherUrlManager.createResearcherUrl(claimedOrcid, rUrl, true);
    rUrl = researcherUrlManager.getResearcherUrl(claimedOrcid, rUrl.getPutCode());
    assertNotNull(rUrl);
    assertEquals(Long.valueOf(0), rUrl.getDisplayIndex());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 52 with ClientDetailsEntity

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

the class ResearcherUrlManagerTest method displayIndexIsSetTo_1_FromUI.

@Test
public void displayIndexIsSetTo_1_FromUI() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    ResearcherUrl rUrl = getResearcherUrl();
    rUrl.getUrl().setValue(rUrl.getUrl().getValue() + "/fromUI");
    rUrl = researcherUrlManager.createResearcherUrl(claimedOrcid, rUrl, false);
    rUrl = researcherUrlManager.getResearcherUrl(claimedOrcid, rUrl.getPutCode());
    assertNotNull(rUrl);
    assertEquals(Long.valueOf(1), rUrl.getDisplayIndex());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 53 with ClientDetailsEntity

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

the class ResearcherUrlManagerTest method testAddResearcherUrToClaimedRecordPreserveUserDefaultVisibility.

@Test
public void testAddResearcherUrToClaimedRecordPreserveUserDefaultVisibility() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    ResearcherUrl rUrl = getResearcherUrl();
    rUrl = researcherUrlManager.createResearcherUrl(claimedOrcid, rUrl, true);
    rUrl = researcherUrlManager.getResearcherUrl(claimedOrcid, rUrl.getPutCode());
    assertNotNull(rUrl);
    assertEquals(Visibility.LIMITED, rUrl.getVisibility());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 54 with ClientDetailsEntity

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

the class ResearcherUrlManagerTest method testAddResearcherUrlToUnclaimedRecordPreserveResearcherUrlVisibility.

@Test
public void testAddResearcherUrlToUnclaimedRecordPreserveResearcherUrlVisibility() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    ResearcherUrl rUrl = getResearcherUrl();
    rUrl = researcherUrlManager.createResearcherUrl(unclaimedOrcid, rUrl, true);
    rUrl = researcherUrlManager.getResearcherUrl(unclaimedOrcid, rUrl.getPutCode());
    assertNotNull(rUrl);
    assertEquals(Visibility.PUBLIC, rUrl.getVisibility());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 55 with ClientDetailsEntity

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

the class ProfileFundingManagerTest method testAddMultipleModifiesIndexingStatus.

@Test
public void testAddMultipleModifiesIndexingStatus() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    Funding f1 = getFunding("F1");
    f1 = profileFundingManager.createFunding(claimedOrcid, f1, true);
    Funding f2 = getFunding("F2");
    f2 = profileFundingManager.createFunding(claimedOrcid, f2, true);
    Funding f3 = getFunding("F3");
    f3 = profileFundingManager.createFunding(claimedOrcid, f3, true);
    ProfileFundingEntity entity1 = profileFundingDao.find(f1.getPutCode());
    ProfileFundingEntity entity2 = profileFundingDao.find(f2.getPutCode());
    ProfileFundingEntity entity3 = profileFundingDao.find(f3.getPutCode());
    assertNotNull(entity1.getDisplayIndex());
    assertNotNull(entity2.getDisplayIndex());
    assertNotNull(entity3.getDisplayIndex());
    assertEquals(Long.valueOf(0), entity3.getDisplayIndex());
    //Rollback all changes
    profileFundingDao.remove(entity1.getId());
    profileFundingDao.remove(entity2.getId());
    profileFundingDao.remove(entity3.getId());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Funding(org.orcid.jaxb.model.record_v2.Funding) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)149 Test (org.junit.Test)75 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)57 BaseTest (org.orcid.core.BaseTest)51 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)33 Date (java.util.Date)23 Transactional (org.springframework.transaction.annotation.Transactional)16 HashSet (java.util.HashSet)15 DBUnitTest (org.orcid.test.DBUnitTest)15 HashMap (java.util.HashMap)14 Authentication (org.springframework.security.core.Authentication)13 OAuth2Authentication (org.springframework.security.oauth2.provider.OAuth2Authentication)13 OAuth2Request (org.springframework.security.oauth2.provider.OAuth2Request)11 Work (org.orcid.jaxb.model.record_v2.Work)9 Before (org.junit.Before)8 ArrayList (java.util.ArrayList)7 OrcidClient (org.orcid.jaxb.model.clientgroup.OrcidClient)7 ClientSecretEntity (org.orcid.persistence.jpa.entities.ClientSecretEntity)7 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)6 Funding (org.orcid.jaxb.model.record_v2.Funding)6