Search in sources :

Example 71 with Work

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

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

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

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

Example 75 with Work

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

the class MemberV2ApiServiceVersionedDelegatorTest method testViewBulkWorksWithBadPutCode.

@Test
public void testViewBulkWorksWithBadPutCode() {
    SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0003", ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewBulkWorks("0000-0000-0000-0003", "11,12,13,bad");
    WorkBulk workBulk = (WorkBulk) response.getEntity();
    assertNotNull(workBulk);
    assertNotNull(workBulk.getBulk());
    assertEquals(4, workBulk.getBulk().size());
    assertTrue(workBulk.getBulk().get(0) instanceof Work);
    assertTrue(workBulk.getBulk().get(1) instanceof Work);
    // private work
    assertTrue(workBulk.getBulk().get(2) instanceof Work);
    // bad put code
    assertTrue(workBulk.getBulk().get(3) instanceof OrcidError);
}
Also used : Response(javax.ws.rs.core.Response) OrcidError(org.orcid.jaxb.model.error_v2.OrcidError) WorkBulk(org.orcid.jaxb.model.record_v2.WorkBulk) 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)148 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 ExternalID (org.orcid.jaxb.model.record_rc3.ExternalID)11 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