Search in sources :

Example 21 with Work

use of org.orcid.jaxb.model.v3.dev1.record.Work in project ORCID-Source by ORCID.

the class JSONInputValidatorTest method testValidateJSONInputForValidV3Work.

@Test
public void testValidateJSONInputForValidV3Work() throws JAXBException, SAXException, IOException {
    Work work = org.orcid.test.helper.v3.Utils.getWork("title");
    validator.validateJSONInput(work);
}
Also used : Work(org.orcid.jaxb.model.v3.dev1.record.Work) Test(org.junit.Test)

Example 22 with Work

use of org.orcid.jaxb.model.v3.dev1.record.Work in project ORCID-Source by ORCID.

the class JSONInputValidatorTest method testValidateJSONValidInputForInvalidV3Work.

@Test(expected = InvalidJSONException.class)
public void testValidateJSONValidInputForInvalidV3Work() throws JAXBException, SAXException, IOException {
    Work work = org.orcid.test.helper.v3.Utils.getWork(null);
    validator.validateJSONInput(work);
}
Also used : Work(org.orcid.jaxb.model.v3.dev1.record.Work) Test(org.junit.Test)

Example 23 with Work

use of org.orcid.jaxb.model.v3.dev1.record.Work in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorTest method testViewWork.

@Test
public void testViewWork() {
    Response response = serviceDelegator.viewWork(ORCID, 11L);
    assertNotNull(response);
    Work work = (Work) response.getEntity();
    assertNotNull(work);
    assertNotNull(work.getLastModifiedDate());
    assertNotNull(work.getLastModifiedDate().getValue());
    assertNotNull(work.getWorkTitle());
    assertNotNull(work.getWorkTitle().getTitle());
    assertEquals("PUBLIC", work.getWorkTitle().getTitle().getContent());
    assertEquals(Long.valueOf(11), work.getPutCode());
    assertEquals("/0000-0000-0000-0003/work/11", work.getPath());
    assertEquals(WorkType.JOURNAL_ARTICLE, work.getWorkType());
    assertEquals("APP-5555555555555555", work.getSource().retrieveSourcePath());
    assertNotNull(work.getWorkContributors());
    assertNotNull(work.getWorkContributors().getContributor());
    assertEquals(1, work.getWorkContributors().getContributor().size());
    assertNotNull(work.getWorkContributors().getContributor().get(0).getContributorOrcid());
    assertEquals("0000-0000-0000-0000", work.getWorkContributors().getContributor().get(0).getContributorOrcid().getPath());
    assertNull(work.getWorkContributors().getContributor().get(0).getCreditName());
}
Also used : Response(javax.ws.rs.core.Response) Work(org.orcid.jaxb.model.v3.dev1.record.Work) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 24 with Work

use of org.orcid.jaxb.model.v3.dev1.record.Work in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorTest method testViewBulkWorks.

@Test
public void testViewBulkWorks() {
    Response response = serviceDelegator.viewBulkWorks(ORCID, "11,12,13");
    assertNotNull(response);
    WorkBulk workBulk = (WorkBulk) response.getEntity();
    assertNotNull(workBulk);
    assertNotNull(workBulk.getBulk());
    assertEquals(3, workBulk.getBulk().size());
    assertTrue(workBulk.getBulk().get(0) instanceof Work);
    assertTrue(workBulk.getBulk().get(1) instanceof OrcidError);
    assertTrue(workBulk.getBulk().get(2) instanceof OrcidError);
    Work work = (Work) workBulk.getBulk().get(0);
    assertNotNull(work);
    assertNotNull(work.getLastModifiedDate());
    assertNotNull(work.getLastModifiedDate().getValue());
    assertNotNull(work.getWorkTitle());
    assertNotNull(work.getWorkTitle().getTitle());
    assertEquals("PUBLIC", work.getWorkTitle().getTitle().getContent());
    assertEquals(Long.valueOf(11), work.getPutCode());
    assertEquals("/0000-0000-0000-0003/work/11", work.getPath());
    assertEquals(WorkType.JOURNAL_ARTICLE, work.getWorkType());
    assertEquals("APP-5555555555555555", work.getSource().retrieveSourcePath());
    assertNotNull(work.getWorkContributors());
    assertNotNull(work.getWorkContributors().getContributor());
    assertEquals(1, work.getWorkContributors().getContributor().size());
    assertNotNull(work.getWorkContributors().getContributor().get(0).getContributorOrcid());
    assertEquals("0000-0000-0000-0000", work.getWorkContributors().getContributor().get(0).getContributorOrcid().getPath());
    assertNull(work.getWorkContributors().getContributor().get(0).getCreditName());
}
Also used : Response(javax.ws.rs.core.Response) OrcidError(org.orcid.jaxb.model.v3.dev1.error.OrcidError) WorkBulk(org.orcid.jaxb.model.v3.dev1.record.WorkBulk) Work(org.orcid.jaxb.model.v3.dev1.record.Work) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 25 with Work

use of org.orcid.jaxb.model.v3.dev1.record.Work in project ORCID-Source by ORCID.

the class BlackBoxBaseV3_0_dev1 method unmarshallFromPath.

public Object unmarshallFromPath(String path, Class<?> type) {
    try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
        Object obj = unmarshall(reader, type);
        Object result = null;
        if (Address.class.equals(type)) {
            result = (Address) obj;
        } else if (Education.class.equals(type)) {
            result = (Education) obj;
        } else if (Employment.class.equals(type)) {
            result = (Employment) obj;
        } else if (Funding.class.equals(type)) {
            result = (Funding) obj;
        } else if (Keyword.class.equals(type)) {
            result = (Keyword) obj;
        } else if (Work.class.equals(type)) {
            result = (Work) obj;
        } else if (PeerReview.class.equals(type)) {
            result = (PeerReview) obj;
        } else if (ResearcherUrl.class.equals(type)) {
            result = (ResearcherUrl) obj;
        } else if (PersonalDetails.class.equals(type)) {
            result = (PersonalDetails) obj;
        } else if (OtherName.class.equals(type)) {
            result = (OtherName) obj;
        } else if (PersonExternalIdentifier.class.equals(type)) {
            result = (PersonExternalIdentifier) obj;
        } else if (Distinction.class.equals(type)) {
            result = (Distinction) obj;
        } else if (InvitedPosition.class.equals(type)) {
            result = (InvitedPosition) obj;
        } else if (Membership.class.equals(type)) {
            result = (Membership) obj;
        } else if (Qualification.class.equals(type)) {
            result = (Qualification) obj;
        } else if (Service.class.equals(type)) {
            result = (Service) obj;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) Service(org.orcid.jaxb.model.v3.dev1.record.Service) T2OAuthAPIService(org.orcid.integration.blackbox.api.v12.T2OAuthAPIService) IOException(java.io.IOException) Education(org.orcid.jaxb.model.v3.dev1.record.Education) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction)

Aggregations

Test (org.junit.Test)154 Work (org.orcid.jaxb.model.v3.dev1.record.Work)141 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)46 DBUnitTest (org.orcid.test.DBUnitTest)41 Response (javax.ws.rs.core.Response)39 Title (org.orcid.jaxb.model.v3.dev1.common.Title)29 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)29 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)29 Url (org.orcid.jaxb.model.v3.dev1.common.Url)28 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)24 WorkBulk (org.orcid.jaxb.model.v3.dev1.record.WorkBulk)22 OrcidError (org.orcid.jaxb.model.v3.dev1.error.OrcidError)21 BaseTest (org.orcid.core.BaseTest)20 NoResultException (javax.persistence.NoResultException)17 OrcidAccessControlException (org.orcid.core.exception.OrcidAccessControlException)17 OrcidUnauthorizedException (org.orcid.core.exception.OrcidUnauthorizedException)17 OrcidVisibilityException (org.orcid.core.exception.OrcidVisibilityException)17 VisibilityMismatchException (org.orcid.core.exception.VisibilityMismatchException)17 WrongSourceException (org.orcid.core.exception.WrongSourceException)17 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)15