Search in sources :

Example 56 with ProfileEntity

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

the class JpaJaxbEducationAdapterTest method getEducationEntity.

private OrgAffiliationRelationEntity getEducationEntity() {
    OrgEntity orgEntity = new OrgEntity();
    orgEntity.setCity("org:city");
    orgEntity.setCountry(org.orcid.jaxb.model.message.Iso3166Country.US);
    orgEntity.setName("org:name");
    orgEntity.setRegion("org:region");
    orgEntity.setUrl("org:url");
    orgEntity.setSource(new SourceEntity("APP-000000001"));
    OrgAffiliationRelationEntity result = new OrgAffiliationRelationEntity();
    result.setAffiliationType(AffiliationType.EDUCATION);
    result.setDepartment("education:department");
    result.setEndDate(new EndDateEntity(2020, 2, 2));
    result.setId(123456L);
    result.setOrg(orgEntity);
    result.setProfile(new ProfileEntity("0000-0001-0002-0003"));
    result.setStartDate(new StartDateEntity(2000, 1, 1));
    result.setTitle("education:title");
    result.setVisibility(Visibility.PRIVATE);
    result.setClientSourceId("APP-000000001");
    return result;
}
Also used : EndDateEntity(org.orcid.persistence.jpa.entities.EndDateEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) StartDateEntity(org.orcid.persistence.jpa.entities.StartDateEntity) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

Example 57 with ProfileEntity

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

the class JpaJaxbEmailAdapterTest method getEmailEntity.

private EmailEntity getEmailEntity() {
    EmailEntity result = new EmailEntity();
    result.setId("email@test.orcid.org");
    result.setCurrent(true);
    result.setPrimary(true);
    result.setProfile(new ProfileEntity("0000-0000-0000-0000"));
    result.setVerified(true);
    result.setDateCreated(new Date());
    result.setLastModified(new Date());
    result.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
    result.setClientSourceId("APP-000000001");
    return result;
}
Also used : EmailEntity(org.orcid.persistence.jpa.entities.EmailEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Date(java.util.Date)

Example 58 with ProfileEntity

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

the class JpaJaxbEmploymentAdapterTest method getEmploymentEntity.

private OrgAffiliationRelationEntity getEmploymentEntity() {
    OrgEntity orgEntity = new OrgEntity();
    orgEntity.setCity("org:city");
    orgEntity.setCountry(org.orcid.jaxb.model.message.Iso3166Country.US);
    orgEntity.setName("org:name");
    orgEntity.setRegion("org:region");
    orgEntity.setUrl("org:url");
    orgEntity.setSource(new SourceEntity("APP-000000001"));
    OrgAffiliationRelationEntity result = new OrgAffiliationRelationEntity();
    result.setAffiliationType(AffiliationType.EMPLOYMENT);
    result.setDepartment("employment:department");
    result.setEndDate(new EndDateEntity(2020, 2, 2));
    result.setId(123456L);
    result.setOrg(orgEntity);
    result.setProfile(new ProfileEntity("0000-0001-0002-0003"));
    result.setStartDate(new StartDateEntity(2000, 1, 1));
    result.setTitle("employment:title");
    result.setVisibility(Visibility.PRIVATE);
    result.setClientSourceId("APP-000000001");
    return result;
}
Also used : EndDateEntity(org.orcid.persistence.jpa.entities.EndDateEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) StartDateEntity(org.orcid.persistence.jpa.entities.StartDateEntity) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

Example 59 with ProfileEntity

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

the class SourceInActivitiesTest method sourceDoesntChange_PeerReview_Test.

@Test
public void sourceDoesntChange_PeerReview_Test() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ProfileEntity(userOrcid)));
    PeerReview peerReview1 = getPeerReview(userOrcid);
    assertNotNull(peerReview1);
    assertNotNull(peerReview1.getSubjectName());
    assertNotNull(peerReview1.getSubjectName().getTitle());
    assertFalse(PojoUtil.isEmpty(peerReview1.getSubjectName().getTitle().getContent()));
    assertEquals(userOrcid, peerReview1.retrieveSourcePath());
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    PeerReview peerReview2 = getPeerReview(userOrcid);
    assertNotNull(peerReview2);
    assertNotNull(peerReview2.getSubjectName());
    assertNotNull(peerReview2.getSubjectName().getTitle());
    assertFalse(PojoUtil.isEmpty(peerReview2.getSubjectName().getTitle().getContent()));
    assertEquals(CLIENT_1_ID, peerReview2.retrieveSourcePath());
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_2_ID)));
    PeerReview peerReview3 = getPeerReview(userOrcid);
    assertNotNull(peerReview3);
    assertNotNull(peerReview3.getSubjectName());
    assertNotNull(peerReview3.getSubjectName().getTitle());
    assertFalse(PojoUtil.isEmpty(peerReview3.getSubjectName().getTitle().getContent()));
    assertEquals(CLIENT_2_ID, peerReview3.retrieveSourcePath());
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ProfileEntity(userOrcid)));
    PeerReview peerReview4 = getPeerReview(userOrcid);
    assertNotNull(peerReview4);
    assertNotNull(peerReview4.getSubjectName());
    assertNotNull(peerReview4.getSubjectName().getTitle());
    assertFalse(PojoUtil.isEmpty(peerReview4.getSubjectName().getTitle().getContent()));
    assertEquals(userOrcid, peerReview4.retrieveSourcePath());
    PeerReview fromDb1 = peerReviewManager.getPeerReview(userOrcid, peerReview1.getPutCode());
    assertNotNull(fromDb1);
    assertEquals(userOrcid, fromDb1.retrieveSourcePath());
    PeerReview fromDb2 = peerReviewManager.getPeerReview(userOrcid, peerReview2.getPutCode());
    assertNotNull(fromDb2);
    assertEquals(CLIENT_1_ID, fromDb2.retrieveSourcePath());
    PeerReview fromDb3 = peerReviewManager.getPeerReview(userOrcid, peerReview3.getPutCode());
    assertNotNull(fromDb3);
    assertEquals(CLIENT_2_ID, fromDb3.retrieveSourcePath());
    PeerReview fromDb4 = peerReviewManager.getPeerReview(userOrcid, peerReview4.getPutCode());
    assertNotNull(fromDb4);
    assertEquals(userOrcid, fromDb4.retrieveSourcePath());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Example 60 with ProfileEntity

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());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Funding(org.orcid.jaxb.model.record_v2.Funding) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)231 Test (org.junit.Test)65 Date (java.util.Date)64 Transactional (org.springframework.transaction.annotation.Transactional)58 DBUnitTest (org.orcid.test.DBUnitTest)44 HashMap (java.util.HashMap)41 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)37 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)36 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)33 HashSet (java.util.HashSet)30 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)28 Rollback (org.springframework.test.annotation.Rollback)25 RecordNameEntity (org.orcid.persistence.jpa.entities.RecordNameEntity)20 Set (java.util.Set)16 ArrayList (java.util.ArrayList)15 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)14 EmailEntity (org.orcid.persistence.jpa.entities.EmailEntity)14 OAuth2Authentication (org.springframework.security.oauth2.provider.OAuth2Authentication)13 OAuth2Request (org.springframework.security.oauth2.provider.OAuth2Request)13 Authentication (org.springframework.security.core.Authentication)12