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());
}
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());
}
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;
}
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;
}
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;
}
Aggregations