Search in sources :

Example 46 with Work

use of org.orcid.jaxb.model.record_rc4.Work in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_WorksTest method testViewPrivateWork.

@Test
public void testViewPrivateWork() {
    // Use the smallest scope in the pyramid to verify that you can read
    // your own limited and protected data
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewWork("4444-4444-4444-4446", 7L);
    assertNotNull(response);
    Work work = (Work) response.getEntity();
    Utils.verifyLastModified(work.getLastModifiedDate());
    assertNotNull(work.getWorkTitle());
    assertNotNull(work.getWorkTitle().getTitle());
    assertEquals("Journal article C", work.getWorkTitle().getTitle().getContent());
    assertEquals(Long.valueOf(7), work.getPutCode());
    assertEquals("/4444-4444-4444-4446/work/7", work.getPath());
    assertEquals(WorkType.JOURNAL_ARTICLE, work.getWorkType());
    assertEquals(Visibility.PRIVATE.value(), work.getVisibility().value());
}
Also used : Response(javax.ws.rs.core.Response) Work(org.orcid.jaxb.model.record_v2.Work) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 47 with Work

use of org.orcid.jaxb.model.record_rc4.Work in project ORCID-Source by ORCID.

the class JpaJaxbWorkAdapterTest method testToWorkEntity.

@Test
public void testToWorkEntity() throws JAXBException {
    Work work = getWork(true);
    assertNotNull(work);
    WorkEntity workEntity = jpaJaxbWorkAdapter.toWorkEntity(work);
    assertNotNull(workEntity);
    assertEquals(Visibility.PRIVATE, workEntity.getVisibility());
    assertNotNull(workEntity);
    assertEquals(123, workEntity.getId().longValue());
    assertEquals("common:title", workEntity.getTitle());
    assertTrue(PojoUtil.isEmpty(workEntity.getSubtitle()));
    assertEquals("common:translated-title", workEntity.getTranslatedTitle());
    assertEquals("en", workEntity.getTranslatedTitleLanguageCode());
    assertEquals("work:short-description", workEntity.getDescription());
    assertEquals(CitationType.FORMATTED_UNSPECIFIED, workEntity.getCitationType());
    assertEquals(WorkType.ARTISTIC_PERFORMANCE, workEntity.getWorkType());
    PublicationDateEntity publicationDateEntity = workEntity.getPublicationDate();
    assertNotNull(publicationDateEntity);
    assertEquals(1848, publicationDateEntity.getYear().intValue());
    assertEquals(02, publicationDateEntity.getMonth().intValue());
    assertEquals(02, publicationDateEntity.getDay().intValue());
    assertEquals("{\"workExternalIdentifier\":[{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"AGR\",\"workExternalIdentifierId\":{\"content\":\"work:external-identifier-id\"}}]}", workEntity.getExternalIdentifiersJson());
    assertEquals("http://tempuri.org", workEntity.getWorkUrl());
    assertEquals("{\"contributor\":[{\"contributorOrcid\":{\"uri\":\"http://orcid.org/8888-8888-8888-8880\",\"path\":\"8888-8888-8888-8880\",\"host\":\"orcid.org\"},\"creditName\":{\"content\":\"work:credit-name\"},\"contributorEmail\":{\"value\":\"work@contributor.email\"},\"contributorAttributes\":{\"contributorSequence\":\"FIRST\",\"contributorRole\":\"AUTHOR\"}}]}", workEntity.getContributorsJson());
    assertEquals("en", workEntity.getLanguageCode());
    assertEquals(Iso3166Country.AF, workEntity.getIso2Country());
    // Source
    assertNull(workEntity.getSourceId());
    assertNull(workEntity.getClientSourceId());
    assertNull(workEntity.getElementSourceId());
}
Also used : WorkEntity(org.orcid.persistence.jpa.entities.WorkEntity) PublicationDateEntity(org.orcid.persistence.jpa.entities.PublicationDateEntity) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test)

Example 48 with Work

use of org.orcid.jaxb.model.record_rc4.Work in project ORCID-Source by ORCID.

the class OrcidSecurityManagerTestBase method createWork.

protected Work createWork(Visibility v, String sourceId) {
    Work work = new Work();
    work.setVisibility(v);
    setSource(work, sourceId);
    return work;
}
Also used : Work(org.orcid.jaxb.model.record_v2.Work)

Example 49 with Work

use of org.orcid.jaxb.model.record_rc4.Work in project ORCID-Source by ORCID.

the class ActivityValidatorTest method validateWork_emptyContributorEmailTest.

@Test(expected = OrcidValidationException.class)
public void validateWork_emptyContributorEmailTest() {
    Work work = getWork();
    work.getWorkContributors().getContributor().get(0).getContributorEmail().setValue("");
    activityValidator.validateWork(work, null, true, true, Visibility.PUBLIC);
}
Also used : Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test)

Example 50 with Work

use of org.orcid.jaxb.model.record_rc4.Work in project ORCID-Source by ORCID.

the class ActivityValidatorTest method validateWork_invalidLanguageCodeTest.

@Test(expected = ActivityTypeValidationException.class)
public void validateWork_invalidLanguageCodeTest() {
    Work work = getWork();
    work.setLanguageCode("xx");
    activityValidator.validateWork(work, null, true, true, Visibility.PUBLIC);
}
Also used : Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)153 Work (org.orcid.jaxb.model.record_v2.Work)151 ClientResponse (com.sun.jersey.api.client.ClientResponse)53 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)35 WorkBulk (org.orcid.jaxb.model.record_v2.WorkBulk)26 DBUnitTest (org.orcid.test.DBUnitTest)25 Response (javax.ws.rs.core.Response)24 Title (org.orcid.jaxb.model.common_v2.Title)24 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)23 Url (org.orcid.jaxb.model.common_v2.Url)22 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)22 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)17 ArrayList (java.util.ArrayList)16 BaseTest (org.orcid.core.BaseTest)16 BulkElement (org.orcid.jaxb.model.record.bulk.BulkElement)16 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)15 Work (org.orcid.jaxb.model.record_rc1.Work)12 Work (org.orcid.jaxb.model.record_rc3.Work)11 ExternalID (org.orcid.jaxb.model.record_rc4.ExternalID)11 Work (org.orcid.jaxb.model.record_rc4.Work)11