Search in sources :

Example 61 with Keyword

use of org.orcid.jaxb.model.record_rc2.Keyword in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorTest method testViewKeywords.

@Test
public void testViewKeywords() {
    Response response = serviceDelegator.viewKeywords(ORCID);
    assertNotNull(response);
    Keywords keywords = (Keywords) response.getEntity();
    assertNotNull(keywords);
    assertNotNull(keywords.getLastModifiedDate());
    assertNotNull(keywords.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/keywords", keywords.getPath());
    assertEquals(1, keywords.getKeywords().size());
    Keyword keyword = keywords.getKeywords().get(0);
    assertNotNull(keyword);
    assertNotNull(keyword.getLastModifiedDate());
    assertNotNull(keyword.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(9), keyword.getPutCode());
    assertEquals("PUBLIC", keyword.getContent());
    assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
    assertEquals("/0000-0000-0000-0003/keywords/9", keyword.getPath());
    assertEquals("APP-5555555555555555", keyword.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) Keywords(org.orcid.jaxb.model.record_v2.Keywords) Keyword(org.orcid.jaxb.model.record_v2.Keyword) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 62 with Keyword

use of org.orcid.jaxb.model.record_rc2.Keyword in project ORCID-Source by ORCID.

the class Utils method getKeyword.

public static Keyword getKeyword() {
    Keyword keyword = new Keyword();
    keyword.setContent("New keyword");
    keyword.setVisibility(Visibility.LIMITED);
    return keyword;
}
Also used : Keyword(org.orcid.jaxb.model.record_v2.Keyword)

Example 63 with Keyword

use of org.orcid.jaxb.model.record_rc2.Keyword in project ORCID-Source by ORCID.

the class Api2_0_LastModifiedDatesHelper 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.common_v2.LastModifiedDate) Keyword(org.orcid.jaxb.model.record_v2.Keyword)

Example 64 with Keyword

use of org.orcid.jaxb.model.record_rc2.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_2.0/samples/read_samples/keyword-2.0.xml";
    InputStream inputStream = getClass().getResourceAsStream(name);
    return (Keyword) unmarshaller.unmarshal(inputStream);
}
Also used : Keyword(org.orcid.jaxb.model.record_v2.Keyword) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 65 with Keyword

use of org.orcid.jaxb.model.record_rc2.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.record_v2.Keyword) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)88 Keyword (org.orcid.jaxb.model.record_v2.Keyword)82 Address (org.orcid.jaxb.model.record_v2.Address)44 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)44 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)44 OtherName (org.orcid.jaxb.model.record_v2.OtherName)42 Email (org.orcid.jaxb.model.record_v2.Email)41 Keywords (org.orcid.jaxb.model.record_v2.Keywords)41 Biography (org.orcid.jaxb.model.record_v2.Biography)33 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)33 Addresses (org.orcid.jaxb.model.record_v2.Addresses)31 Emails (org.orcid.jaxb.model.record_v2.Emails)31 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)31 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)31 Person (org.orcid.jaxb.model.record_v2.Person)30 Name (org.orcid.jaxb.model.record_v2.Name)29 ClientResponse (com.sun.jersey.api.client.ClientResponse)22 DBUnitTest (org.orcid.test.DBUnitTest)20 Keyword (org.orcid.jaxb.model.record_rc3.Keyword)19 Response (javax.ws.rs.core.Response)18