Search in sources :

Example 41 with Keyword

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());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) Test(org.junit.Test)

Example 42 with Keyword

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);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword)

Example 43 with Keyword

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);
}
Also used : Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 44 with Keyword

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());
}
Also used : ProfileKeywordEntity(org.orcid.persistence.jpa.entities.ProfileKeywordEntity) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) Test(org.junit.Test)

Example 45 with Keyword

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());
}
Also used : ProfileKeywordEntity(org.orcid.persistence.jpa.entities.ProfileKeywordEntity) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) Test(org.junit.Test)

Aggregations

Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)75 Test (org.junit.Test)59 Keywords (org.orcid.jaxb.model.v3.dev1.record.Keywords)40 Address (org.orcid.jaxb.model.v3.dev1.record.Address)39 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)39 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)39 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)39 Email (org.orcid.jaxb.model.v3.dev1.record.Email)36 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)31 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)31 Addresses (org.orcid.jaxb.model.v3.dev1.record.Addresses)30 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)30 PersonExternalIdentifiers (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers)30 ResearcherUrls (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)30 Person (org.orcid.jaxb.model.v3.dev1.record.Person)28 Name (org.orcid.jaxb.model.v3.dev1.record.Name)27 DBUnitTest (org.orcid.test.DBUnitTest)20 Response (javax.ws.rs.core.Response)18 Record (org.orcid.jaxb.model.v3.dev1.record.Record)15 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)15