Search in sources :

Example 21 with OrgEntity

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

the class LoadLEIDataTest method testUpdateWithNewTranslatedName.

@Test
public void testUpdateWithNewTranslatedName() throws URISyntaxException, FileNotFoundException, XMLStreamException {
    Path path = Paths.get(getClass().getClassLoader().getResource("lei/complex.xml").toURI());
    File testFile = path.toFile();
    // fake finding existing
    OrgDisambiguatedEntity found = new OrgDisambiguatedEntity();
    found.setSourceId("213800ZH4VUOQOUVYX93");
    found.setSourceType("LEI");
    Mockito.when(orgDisambiguatedDao.findBySourceIdAndSourceType(Mockito.anyString(), Mockito.anyString())).thenReturn(found);
    // capture merge
    ArgumentCaptor<OrgDisambiguatedEntity> argument = ArgumentCaptor.forClass(OrgDisambiguatedEntity.class);
    Mockito.when(orgDisambiguatedDao.merge(argument.capture())).then(AdditionalAnswers.returnsFirstArg());
    // fake not finding existing org
    ArgumentCaptor<OrgEntity> orgArgument = ArgumentCaptor.forClass(OrgEntity.class);
    doNothing().when(orgDao).persist(orgArgument.capture());
    ;
    // make sure we're not calling the wrong things
    doThrow(new RuntimeException()).when(orgDao).merge(Mockito.anyObject());
    doThrow(new RuntimeException()).when(orgDisambiguatedDao).persist(Mockito.anyObject());
    loadLeiData.setFileToLoad(testFile);
    loadLeiData.execute();
    assertEquals("213800ZH4VUOQOUVYX93", argument.getValue().getSourceId());
    assertEquals("МОНБАТ АД", argument.getValue().getName());
    assertEquals("SOFIA", argument.getValue().getCity());
    assertEquals("BG", argument.getValue().getCountry().value());
    assertEquals("AKTSIONERNO DRUZHESTVO", argument.getValue().getOrgType());
    assertEquals("BG-22", argument.getValue().getRegion());
    assertEquals("PENDING", argument.getValue().getIndexingStatus().toString());
    assertEquals(null, argument.getValue().getStatus());
    assertEquals("LEI", argument.getValue().getSourceType());
    assertEquals("MONBAT PLC", orgArgument.getAllValues().get(0).getName());
    assertEquals("SOFIA", orgArgument.getAllValues().get(0).getCity());
    assertEquals("BG", orgArgument.getAllValues().get(0).getCountry().value());
    assertEquals("BG-22", orgArgument.getAllValues().get(0).getRegion());
    assertEquals("213800ZH4VUOQOUVYX93", orgArgument.getAllValues().get(0).getOrgDisambiguated().getSourceId());
}
Also used : Path(java.nio.file.Path) OrgDisambiguatedEntity(org.orcid.persistence.jpa.entities.OrgDisambiguatedEntity) File(java.io.File) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity) Test(org.junit.Test)

Example 22 with OrgEntity

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

the class LoadRinggoldDataTest method test_AddOrg.

@Test
public void test_AddOrg() throws URISyntaxException {
    setupInitialMocks();
    Path path = Paths.get(getClass().getClassLoader().getResource("ringgold/test_addOrg/").toURI());
    File testDirectory = path.toFile();
    assertTrue(testDirectory.exists());
    loader.setDirectory(testDirectory);
    loader.execute();
    verify(mockOrgDisambiguatedDao, times(0)).persist(any());
    verify(mockOrgDisambiguatedDao, times(0)).merge(any());
    verify(mockOrgDisambiguatedExternalIdentifierDao, times(0)).persist(any());
    verify(mockOrgDisambiguatedExternalIdentifierDao, times(0)).merge(any());
    verify(mockOrgDisambiguatedExternalIdentifierDao, times(0)).remove(anyLong());
    ArgumentCaptor<OrgEntity> orgEntityCaptor = ArgumentCaptor.forClass(OrgEntity.class);
    verify(mockOrgDao, times(1)).persist(orgEntityCaptor.capture());
    verify(mockOrgDao, times(0)).merge(any());
    List<OrgEntity> list = orgEntityCaptor.getAllValues();
    assertEquals(1, list.size());
    OrgEntity entity = list.get(0);
    assertEquals("AltCity#3", entity.getCity());
    assertEquals(Iso3166Country.CA, entity.getCountry());
    assertEquals("3. Alt Name", entity.getName());
    assertEquals(Long.valueOf(3000), entity.getOrgDisambiguated().getId());
    assertNull(entity.getRegion());
}
Also used : Path(java.nio.file.Path) File(java.io.File) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity) Test(org.junit.Test)

Example 23 with OrgEntity

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

the class JpaJaxbInvitedPositionAdapterTest method getEntity.

private OrgAffiliationRelationEntity getEntity() {
    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.INVITED_POSITION);
    result.setDepartment("invited-position: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("invited-position:title");
    result.setVisibility(org.orcid.jaxb.model.common_v2.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 24 with OrgEntity

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

the class JpaJaxbDistinctionAdapterTest method getEntity.

private OrgAffiliationRelationEntity getEntity() {
    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.DISTINCTION);
    result.setDepartment("distinction: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("distinction:title");
    result.setVisibility(org.orcid.jaxb.model.common_v2.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 25 with OrgEntity

use of org.orcid.persistence.jpa.entities.OrgEntity 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(org.orcid.jaxb.model.common_v2.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)

Aggregations

OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)53 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)30 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)26 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)17 EndDateEntity (org.orcid.persistence.jpa.entities.EndDateEntity)11 StartDateEntity (org.orcid.persistence.jpa.entities.StartDateEntity)11 Test (org.junit.Test)10 OrgDisambiguatedEntity (org.orcid.persistence.jpa.entities.OrgDisambiguatedEntity)8 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)8 AmbiguousOrgEntity (org.orcid.persistence.jpa.entities.AmbiguousOrgEntity)7 File (java.io.File)6 Path (java.nio.file.Path)6 ProfileFundingEntity (org.orcid.persistence.jpa.entities.ProfileFundingEntity)6 Transactional (org.springframework.transaction.annotation.Transactional)5 Date (java.util.Date)4 Visibility (org.orcid.jaxb.model.common_v2.Visibility)4 Organization (org.orcid.jaxb.model.message.Organization)4 CompletionDateEntity (org.orcid.persistence.jpa.entities.CompletionDateEntity)4 HashSet (java.util.HashSet)3 Iso3166Country (org.orcid.jaxb.model.message.Iso3166Country)3