use of org.orcid.jaxb.model.v3.dev1.record.Keyword in project ORCID-Source by ORCID.
the class PersonTest method testViewPersonFromMemberAPI.
@Test
public void testViewPersonFromMemberAPI() throws InterruptedException, JSONException {
String accessToken = getAccessToken();
assertNotNull(accessToken);
ClientResponse response = memberV3Dev1ApiClient.viewPerson(getUser1OrcidId(), accessToken);
assertNotNull(response);
assertEquals("invalid " + response, 200, response.getStatus());
Thread.sleep(100);
org.orcid.jaxb.model.v3.dev1.record.Person person = response.getEntity(org.orcid.jaxb.model.v3.dev1.record.Person.class);
assertNotNull(person);
assertNotNull(person.getAddresses());
assertNotNull(person.getAddresses().getAddress());
assertEquals(1, person.getAddresses().getAddress().size());
assertNotNull(person.getAddresses().getAddress().get(0).getCountry());
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Iso3166Country.US, person.getAddresses().getAddress().get(0).getCountry().getValue());
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC, person.getAddresses().getAddress().get(0).getVisibility());
assertNotNull(person.getBiography());
assertEquals(getUser1Bio(), person.getBiography().getContent());
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC, person.getBiography().getVisibility());
assertNotNull(person.getEmails());
EmailTest.assertListContainsEmail(getUser1UserName(), org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC, person.getEmails());
EmailTest.assertListContainsEmail(limitedEmail, org.orcid.jaxb.model.v3.dev1.common.Visibility.LIMITED, person.getEmails());
assertNotNull(person.getExternalIdentifiers());
assertNotNull(person.getExternalIdentifiers().getExternalIdentifiers());
assertEquals(2, person.getExternalIdentifiers().getExternalIdentifiers().size());
boolean foundPublic = false;
boolean foundLimited = false;
for (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier e : person.getExternalIdentifiers().getExternalIdentifiers()) {
if ("A-0001".equals(e.getValue())) {
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC, e.getVisibility());
foundPublic = true;
} else if ("A-0002".equals(e.getValue())) {
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.LIMITED, e.getVisibility());
foundLimited = true;
}
}
assertTrue(foundPublic);
assertTrue(foundLimited);
assertNotNull(person.getKeywords());
assertNotNull(person.getKeywords().getKeywords());
assertEquals(2, person.getKeywords().getKeywords().size());
assertThat(person.getKeywords().getKeywords().get(0).getContent(), anyOf(is("keyword-1"), is("keyword-2")));
assertThat(person.getKeywords().getKeywords().get(1).getContent(), anyOf(is("keyword-1"), is("keyword-2")));
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC, person.getKeywords().getKeywords().get(0).getVisibility());
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC, person.getKeywords().getKeywords().get(1).getVisibility());
assertNotNull(person.getOtherNames());
assertNotNull(person.getOtherNames().getOtherNames());
assertEquals(2, person.getOtherNames().getOtherNames().size());
assertThat(person.getOtherNames().getOtherNames().get(0).getContent(), anyOf(is("other-name-1"), is("other-name-2")));
assertThat(person.getOtherNames().getOtherNames().get(1).getContent(), anyOf(is("other-name-1"), is("other-name-2")));
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC, person.getOtherNames().getOtherNames().get(0).getVisibility());
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC, person.getOtherNames().getOtherNames().get(1).getVisibility());
assertNotNull(person.getResearcherUrls());
assertNotNull(person.getResearcherUrls().getResearcherUrls());
assertEquals(2, person.getResearcherUrls().getResearcherUrls().size());
assertThat(person.getResearcherUrls().getResearcherUrls().get(0).getUrl().getValue(), anyOf(is(researcherUrl1), is(researcherUrl2)));
assertThat(person.getResearcherUrls().getResearcherUrls().get(1).getUrl().getValue(), anyOf(is(researcherUrl1), is(researcherUrl2)));
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC, person.getResearcherUrls().getResearcherUrls().get(0).getVisibility());
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC, person.getResearcherUrls().getResearcherUrls().get(1).getVisibility());
assertNotNull(person.getName());
assertEquals(getUser1GivenName(), person.getName().getGivenNames().getContent());
assertNotNull(person.getName().getFamilyName());
assertEquals(getUser1FamilyNames(), person.getName().getFamilyName().getContent());
assertNotNull(person.getName().getCreditName());
assertEquals(getUser1CreditName(), person.getName().getCreditName().getContent());
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC, person.getName().getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.Keyword in project ORCID-Source by ORCID.
the class Api3_0_Dev1LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(Keywords keywords) {
if (keywords != null && keywords.getKeywords() != null && !keywords.getKeywords().isEmpty()) {
LastModifiedDate latest = null;
for (Keyword keyword : keywords.getKeywords()) {
if (keyword.getLastModifiedDate() != null && keyword.getLastModifiedDate().after(latest)) {
latest = keyword.getLastModifiedDate();
}
}
keywords.setLastModifiedDate(latest);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Keyword in project ORCID-Source by ORCID.
the class JpaJaxbKeywordAdapterTest method getKeyword.
private Keyword getKeyword() throws JAXBException {
JAXBContext context = JAXBContext.newInstance(new Class[] { Keyword.class });
Unmarshaller unmarshaller = context.createUnmarshaller();
String name = "/record_3.0_dev1/samples/read_samples/keyword-3.0_dev1.xml";
InputStream inputStream = getClass().getResourceAsStream(name);
return (Keyword) unmarshaller.unmarshal(inputStream);
}
use of org.orcid.jaxb.model.v3.dev1.record.Keyword in project ORCID-Source by ORCID.
the class JpaJaxbKeywordAdapterTest method fromProfileKeywordEntityToKeywordTest.
@Test
public void fromProfileKeywordEntityToKeywordTest() {
ProfileKeywordEntity entity = getProfileKeywordEntity();
Keyword keyword = adapter.toKeyword(entity);
assertNotNull(keyword);
assertEquals("keyword-1", keyword.getContent());
assertNotNull(keyword.getCreatedDate());
assertNotNull(keyword.getCreatedDate().getValue());
assertNotNull(keyword.getLastModifiedDate());
assertNotNull(keyword.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(1), keyword.getPutCode());
assertNotNull(keyword.getSource());
assertEquals("APP-000000000000", keyword.getSource().retrieveSourcePath());
assertEquals(Visibility.LIMITED, keyword.getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.Keyword in project ORCID-Source by ORCID.
the class JpaJaxbKeywordAdapterTest method fromKeywordToProfileKeywordEntityTest.
@Test
public void fromKeywordToProfileKeywordEntityTest() throws JAXBException {
Keyword keyword = getKeyword();
ProfileKeywordEntity entity = adapter.toProfileKeywordEntity(keyword);
assertNotNull(entity);
assertNotNull(entity.getDateCreated());
assertNotNull(entity.getLastModified());
assertEquals(Long.valueOf(1), entity.getId());
assertEquals("keyword1", entity.getKeywordName());
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC, entity.getVisibility());
// Source
assertNull(entity.getSourceId());
assertNull(entity.getClientSourceId());
assertNull(entity.getElementSourceId());
}
Aggregations