Search in sources :

Example 71 with Work

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

the class WorkFormTest method getWork.

public static Work getWork() {
    Work work = new Work();
    work.setCountry(new Country(Iso3166Country.US));
    Date date = new Date();
    work.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(date)));
    work.setJournalTitle(new Title("Journal Title"));
    work.setLanguageCode("EN");
    work.setPublicationDate(new PublicationDate(new Year(2015), new Month(1), new Day(1)));
    work.setPutCode(Long.valueOf("12345"));
    work.setShortDescription("Short description");
    work.setUrl(new Url("http://test.com"));
    work.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.LIMITED);
    work.setWorkCitation(new org.orcid.jaxb.model.record_v2.Citation("Citation", CitationType.BIBTEX));
    WorkContributors contributors = new WorkContributors();
    org.orcid.jaxb.model.common_v2.Contributor contributor = new org.orcid.jaxb.model.common_v2.Contributor();
    contributor.setCreditName(new CreditName("Credit name"));
    contributor.setContributorOrcid(new ContributorOrcid("0000-0000-0000-0000"));
    ContributorAttributes att = new ContributorAttributes();
    att.setContributorRole(ContributorRole.ASSIGNEE);
    att.setContributorSequence(SequenceType.FIRST);
    contributor.setContributorAttributes(att);
    contributors.getContributor().add(contributor);
    work.setWorkContributors(contributors);
    ExternalIDs weis = new ExternalIDs();
    ExternalID wei = new ExternalID();
    wei.setRelationship(Relationship.SELF);
    wei.setUrl(new Url("http://test.com"));
    wei.setValue("ID");
    wei.setType(WorkExternalIdentifierType.AGR.value());
    weis.getExternalIdentifier().add(wei);
    work.setWorkExternalIdentifiers(weis);
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(new Title("Work Title"));
    workTitle.setSubtitle(new Subtitle("Subtitle"));
    TranslatedTitle translated = new TranslatedTitle("Translated", "US");
    workTitle.setTranslatedTitle(translated);
    work.setWorkTitle(workTitle);
    work.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
    return work;
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) WorkContributors(org.orcid.jaxb.model.record_v2.WorkContributors) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Url(org.orcid.jaxb.model.common_v2.Url) Month(org.orcid.jaxb.model.common_v2.Month) Work(org.orcid.jaxb.model.record_v2.Work) PublicationDate(org.orcid.jaxb.model.common_v2.PublicationDate) ContributorAttributes(org.orcid.jaxb.model.common_v2.ContributorAttributes) CreditName(org.orcid.jaxb.model.common_v2.CreditName) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Title(org.orcid.jaxb.model.common_v2.Title) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) Date(java.util.Date) CreatedDate(org.orcid.jaxb.model.common_v2.CreatedDate) PublicationDate(org.orcid.jaxb.model.common_v2.PublicationDate) Subtitle(org.orcid.jaxb.model.common_v2.Subtitle) Year(org.orcid.jaxb.model.common_v2.Year) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) CreatedDate(org.orcid.jaxb.model.common_v2.CreatedDate) Country(org.orcid.jaxb.model.common_v2.Country) Iso3166Country(org.orcid.jaxb.model.common_v2.Iso3166Country) ContributorOrcid(org.orcid.jaxb.model.common_v2.ContributorOrcid) Day(org.orcid.jaxb.model.common_v2.Day)

Example 72 with Work

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

the class WorkFormTest method testValueOfAndBack.

@Test
public void testValueOfAndBack() throws Exception {
    Work work = getWork();
    WorkForm workForm = WorkForm.valueOf(work);
    Work backToWork = workForm.toWork();
    assertEquals(work, backToWork);
}
Also used : WorkForm(org.orcid.pojo.ajaxForm.WorkForm) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test)

Example 73 with Work

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

the class MemberV2ApiServiceDelegator_WorksTest method testUpdateWorkLeavingVisibilityNullTest.

@Test
public void testUpdateWorkLeavingVisibilityNullTest() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewWork("4444-4444-4444-4447", 10L);
    assertNotNull(response);
    Work work = (Work) response.getEntity();
    assertNotNull(work);
    assertEquals(Visibility.PUBLIC, work.getVisibility());
    work.setVisibility(null);
    response = serviceDelegator.updateWork("4444-4444-4444-4447", 10L, work);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    work = (Work) response.getEntity();
    assertNotNull(work);
    Utils.verifyLastModified(work.getLastModifiedDate());
    assertEquals(Visibility.PUBLIC, work.getVisibility());
}
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 74 with Work

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

the class MemberV2ApiServiceDelegator_WorksTest method testDeleteWork.

@Test(expected = NoResultException.class)
public void testDeleteWork() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewWork("4444-4444-4444-4447", 9L);
    assertNotNull(response);
    Work work = (Work) response.getEntity();
    assertNotNull(work);
    response = serviceDelegator.deleteWork("4444-4444-4444-4447", 9L);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    serviceDelegator.viewWork("4444-4444-4444-4447", 9L);
}
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 75 with Work

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

the class MemberV2ApiServiceDelegator_WorksTest method testUpdateWork.

@Test
public void testUpdateWork() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewWork("4444-4444-4444-4443", 1L);
    assertNotNull(response);
    Work work = (Work) response.getEntity();
    assertNotNull(work);
    Utils.verifyLastModified(work.getLastModifiedDate());
    assertEquals(Long.valueOf(1), work.getPutCode());
    assertNotNull(work.getWorkTitle());
    assertNotNull(work.getWorkTitle().getTitle());
    assertEquals("A day in the life", work.getWorkTitle().getTitle().getContent());
    assertEquals(WorkType.BOOK, work.getWorkType());
    assertEquals(Visibility.PUBLIC, work.getVisibility());
    work.setWorkType(WorkType.EDITED_BOOK);
    work.getWorkTitle().getTitle().setContent("Updated work title");
    response = serviceDelegator.updateWork("4444-4444-4444-4443", 1L, work);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewWork("4444-4444-4444-4443", 1L);
    assertNotNull(response);
    work = (Work) response.getEntity();
    assertNotNull(work);
    Utils.verifyLastModified(work.getLastModifiedDate());
    assertEquals(Long.valueOf(1), work.getPutCode());
    assertNotNull(work.getWorkTitle());
    assertNotNull(work.getWorkTitle().getTitle());
    assertEquals("Updated work title", work.getWorkTitle().getTitle().getContent());
    assertEquals(WorkType.EDITED_BOOK, work.getWorkType());
    // Rollback changes so we dont break other tests
    work.setWorkType(WorkType.BOOK);
    work.getWorkTitle().getTitle().setContent("A day in the life");
    response = serviceDelegator.updateWork("4444-4444-4444-4443", 1L, work);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
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)

Aggregations

Work (org.orcid.jaxb.model.record_v2.Work)150 Test (org.junit.Test)147 ClientResponse (com.sun.jersey.api.client.ClientResponse)52 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)33 DBUnitTest (org.orcid.test.DBUnitTest)24 Response (javax.ws.rs.core.Response)23 Title (org.orcid.jaxb.model.common_v2.Title)22 WorkBulk (org.orcid.jaxb.model.record_v2.WorkBulk)22 Url (org.orcid.jaxb.model.common_v2.Url)21 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)21 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)19 ArrayList (java.util.ArrayList)16 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)16 BaseTest (org.orcid.core.BaseTest)14 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)13 Work (org.orcid.jaxb.model.record_rc1.Work)12 Work (org.orcid.jaxb.model.record_rc3.Work)11 Work (org.orcid.jaxb.model.record_rc4.Work)11 Funding (org.orcid.jaxb.model.record_v2.Funding)11 BulkElement (org.orcid.jaxb.model.record_v2.BulkElement)9