Search in sources :

Example 56 with Keyword

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

the class ValidateV2_1SamplesTest method testUnmarshallKeyword.

@Test
public void testUnmarshallKeyword() throws SAXException, URISyntaxException {
    Keywords keywords = (Keywords) unmarshallFromPath("/record_2.1/samples/read_samples/keywords-2.1.xml", Keywords.class, "/record_2.1/keyword-2.1.xsd");
    assertNotNull(keywords);
    assertNotNull(keywords.getKeywords());
    assertEquals(2, keywords.getKeywords().size());
    for (Keyword keyword : keywords.getKeywords()) {
        assertThat(keyword.getContent(), anyOf(is("keyword1"), is("keyword2")));
        assertThat(keyword.getPutCode(), anyOf(is(Long.valueOf(1)), is(Long.valueOf(2))));
        assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
        assertNotNull(keyword.getCreatedDate());
        assertNotNull(keyword.getLastModifiedDate());
        assertNotNull(keyword.getSource());
        validateSourceInHttps(keyword.getSource());
        assertEquals("8888-8888-8888-8880", keyword.getSource().retrieveSourcePath());
    }
    Keyword keyword = (Keyword) unmarshallFromPath("/record_2.1/samples/read_samples/keyword-2.1.xml", Keyword.class);
    assertNotNull(keyword);
    assertEquals("keyword1", keyword.getContent());
    assertEquals(Long.valueOf(1), keyword.getPutCode());
    assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
    assertNotNull(keyword.getCreatedDate());
    assertNotNull(keyword.getLastModifiedDate());
    assertNotNull(keyword.getSource());
    validateSourceInHttps(keyword.getSource());
    assertEquals("8888-8888-8888-8880", keyword.getSource().retrieveSourcePath());
}
Also used : Keywords(org.orcid.jaxb.model.record_v2.Keywords) Keyword(org.orcid.jaxb.model.record_v2.Keyword) Test(org.junit.Test)

Example 57 with Keyword

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

the class ValidateV2_1SamplesTest method unmarshallFromPath.

private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
    try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
        Object obj = unmarshall(reader, type, schemaPath);
        Object result = null;
        if (ResearcherUrls.class.equals(type)) {
            result = (ResearcherUrls) obj;
        } else if (ResearcherUrl.class.equals(type)) {
            result = (ResearcherUrl) obj;
        } else if (PersonalDetails.class.equals(type)) {
            result = (PersonalDetails) obj;
        } else if (PersonExternalIdentifier.class.equals(type)) {
            result = (PersonExternalIdentifier) obj;
        } else if (PersonExternalIdentifiers.class.equals(type)) {
            result = (PersonExternalIdentifiers) obj;
        } else if (Biography.class.equals(type)) {
            result = (Biography) obj;
        } else if (Name.class.equals(type)) {
            result = (Name) obj;
        } else if (CreditName.class.equals(type)) {
            result = (CreditName) obj;
        } else if (OtherName.class.equals(type)) {
            result = (OtherName) obj;
        } else if (OtherNames.class.equals(type)) {
            result = (OtherNames) obj;
        } else if (Keywords.class.equals(type)) {
            result = (Keywords) obj;
        } else if (Keyword.class.equals(type)) {
            result = (Keyword) obj;
        } else if (Addresses.class.equals(type)) {
            result = (Addresses) obj;
        } else if (Address.class.equals(type)) {
            result = (Address) obj;
        } else if (Emails.class.equals(type)) {
            result = (Emails) obj;
        } else if (Email.class.equals(type)) {
            result = (Email) obj;
        } else if (Person.class.equals(type)) {
            result = (Person) obj;
        } else if (Deprecated.class.equals(type)) {
            result = (Deprecated) obj;
        } else if (Preferences.class.equals(type)) {
            result = (Preferences) obj;
        } else if (History.class.equals(type)) {
            result = (History) obj;
        } else if (Record.class.equals(type)) {
            result = (Record) obj;
        } else if (ActivitiesSummary.class.equals(type)) {
            result = (ActivitiesSummary) obj;
        } else if (Works.class.equals(type)) {
            result = (Works) obj;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) InputStreamReader(java.io.InputStreamReader) Keyword(org.orcid.jaxb.model.record_v2.Keyword) Address(org.orcid.jaxb.model.record_v2.Address) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) CreditName(org.orcid.jaxb.model.record_v2.CreditName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) History(org.orcid.jaxb.model.record_v2.History) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Deprecated(org.orcid.jaxb.model.record_v2.Deprecated) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl)

Example 58 with Keyword

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

the class PublicV2ApiServiceDelegatorTest method testViewKeyword.

@Test
public void testViewKeyword() {
    Response response = serviceDelegator.viewKeyword(ORCID, 9L);
    assertNotNull(response);
    Keyword keyword = (Keyword) response.getEntity();
    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) Keyword(org.orcid.jaxb.model.record_v2.Keyword) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 59 with Keyword

use of org.orcid.jaxb.model.record_rc3.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 60 with Keyword

use of org.orcid.jaxb.model.record_rc3.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)

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