Search in sources :

Example 16 with WorkTitle

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

the class MemberV3ApiServiceDelegator_WorksTest method testCreateWorksWithBulkAllOK.

@Test
public void testCreateWorksWithBulkAllOK() {
    RequestAttributes previousAttrs = RequestContextHolder.getRequestAttributes();
    RequestAttributes attrs = new ServletRequestAttributes(new MockHttpServletRequest());
    attrs.setAttribute(ApiVersionFilter.API_VERSION_REQUEST_ATTRIBUTE_NAME, "3.0_dev1", RequestAttributes.SCOPE_REQUEST);
    RequestContextHolder.setRequestAttributes(attrs);
    Long time = System.currentTimeMillis();
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    WorkBulk bulk = new WorkBulk();
    for (int i = 0; i < 5; i++) {
        Work work = new Work();
        WorkTitle title = new WorkTitle();
        title.setTitle(new Title("Bulk work " + i + " " + time));
        work.setWorkTitle(title);
        ExternalIDs extIds = new ExternalIDs();
        ExternalID extId = new ExternalID();
        extId.setRelationship(Relationship.SELF);
        extId.setType("doi");
        extId.setUrl(new Url("http://doi/" + i + "/" + time));
        extId.setValue("doi-" + i + "-" + time);
        extIds.getExternalIdentifier().add(extId);
        work.setWorkExternalIdentifiers(extIds);
        work.setWorkType(WorkType.BOOK);
        bulk.getBulk().add(work);
    }
    Response response = serviceDelegator.createWorks(ORCID, bulk);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    bulk = (WorkBulk) response.getEntity();
    assertNotNull(bulk);
    assertEquals(5, bulk.getBulk().size());
    for (int i = 0; i < 5; i++) {
        assertTrue(Work.class.isAssignableFrom(bulk.getBulk().get(i).getClass()));
        Work w = (Work) bulk.getBulk().get(i);
        Utils.verifyLastModified(w.getLastModifiedDate());
        assertNotNull(w.getPutCode());
        assertTrue(0L < w.getPutCode());
        assertEquals("Bulk work " + i + " " + time, w.getWorkTitle().getTitle().getContent());
        assertNotNull(w.getExternalIdentifiers().getExternalIdentifier());
        assertEquals("doi-" + i + "-" + time, w.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
        Response r = serviceDelegator.viewWork(ORCID, w.getPutCode());
        assertNotNull(r);
        assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
        assertEquals("Bulk work " + i + " " + time, ((Work) r.getEntity()).getWorkTitle().getTitle().getContent());
        // Delete the work
        r = serviceDelegator.deleteWork(ORCID, w.getPutCode());
        assertNotNull(r);
        assertEquals(Response.Status.NO_CONTENT.getStatusCode(), r.getStatus());
    }
    RequestContextHolder.setRequestAttributes(previousAttrs);
}
Also used : ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) WorkBulk(org.orcid.jaxb.model.v3.dev1.record.WorkBulk) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Title(org.orcid.jaxb.model.v3.dev1.common.Title) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) RequestAttributes(org.springframework.web.context.request.RequestAttributes) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url) Response(javax.ws.rs.core.Response) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Work(org.orcid.jaxb.model.v3.dev1.record.Work) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 17 with WorkTitle

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

the class MemberV3ApiServiceDelegator_WorksTest method testCleanEmptyFieldsOnWorks.

@Test
public void testCleanEmptyFieldsOnWorks() {
    LastModifiedDate lmd = new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis()));
    Work work = new Work();
    work.setLastModifiedDate(lmd);
    work.setWorkCitation(new Citation("", CitationType.FORMATTED_UNSPECIFIED));
    WorkTitle title = new WorkTitle();
    title.setTitle(new Title("My Work"));
    title.setSubtitle(new Subtitle("My subtitle"));
    title.setTranslatedTitle(new TranslatedTitle("", ""));
    work.setWorkTitle(title);
    ActivityUtils.cleanEmptyFields(work);
    assertNotNull(work);
    Utils.verifyLastModified(work.getLastModifiedDate());
    assertNotNull(work.getWorkTitle());
    assertNotNull(work.getWorkTitle().getTitle());
    assertNotNull(work.getWorkTitle().getSubtitle());
    assertEquals("My Work", work.getWorkTitle().getTitle().getContent());
    assertEquals("My subtitle", work.getWorkTitle().getSubtitle().getContent());
    assertNull(work.getWorkCitation());
    assertNull(work.getWorkTitle().getTranslatedTitle());
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) Subtitle(org.orcid.jaxb.model.v3.dev1.common.Subtitle) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Title(org.orcid.jaxb.model.v3.dev1.common.Title) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Citation(org.orcid.jaxb.model.v3.dev1.record.Citation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 18 with WorkTitle

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

the class WorksPaginatorTest method getTitle.

private WorkTitle getTitle(int i) {
    WorkTitle title = new WorkTitle();
    title.setTitle(new Title(UUID.randomUUID().toString()));
    title.setSubtitle(new Subtitle(UUID.randomUUID().toString()));
    return title;
}
Also used : Subtitle(org.orcid.jaxb.model.v3.dev1.common.Subtitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle)

Example 19 with WorkTitle

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

the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testCleanEmptyFieldsOnActivities.

@Test
public void testCleanEmptyFieldsOnActivities() {
    LastModifiedDate lmd = new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis()));
    Works works = new Works();
    works.setLastModifiedDate(lmd);
    WorkGroup group = new WorkGroup();
    group.setLastModifiedDate(lmd);
    for (int i = 0; i < 5; i++) {
        WorkSummary summary = new WorkSummary();
        summary.setLastModifiedDate(lmd);
        WorkTitle title = new WorkTitle();
        title.setTitle(new Title("Work " + i));
        title.setTranslatedTitle(new TranslatedTitle("", ""));
        summary.setTitle(title);
        group.getWorkSummary().add(summary);
    }
    works.getWorkGroup().add(group);
    ActivitiesSummary as = new ActivitiesSummary();
    as.setWorks(works);
    ActivityUtils.cleanEmptyFields(as);
    assertNotNull(as);
    assertNotNull(as.getWorks());
    Utils.verifyLastModified(as.getWorks().getLastModifiedDate());
    assertNotNull(as.getWorks().getWorkGroup());
    assertEquals(1, as.getWorks().getWorkGroup().size());
    assertNotNull(as.getWorks().getWorkGroup().get(0).getWorkSummary());
    Utils.verifyLastModified(as.getWorks().getWorkGroup().get(0).getLastModifiedDate());
    assertEquals(5, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
    for (WorkSummary summary : as.getWorks().getWorkGroup().get(0).getWorkSummary()) {
        Utils.verifyLastModified(summary.getLastModifiedDate());
        assertNotNull(summary.getTitle());
        assertNotNull(summary.getTitle().getTitle());
        assertTrue(summary.getTitle().getTitle().getContent().startsWith("Work "));
        assertNull(summary.getTitle().getTranslatedTitle());
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Title(org.orcid.jaxb.model.v3.dev1.common.Title) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 20 with WorkTitle

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

the class MemberV3ApiServiceDelegator_PeerReviewsTest method testAddPeerReviewWithSameExtIdValueButDifferentExtIdType.

@Test
public void testAddPeerReviewWithSameExtIdValueButDifferentExtIdType() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4444", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    PeerReview peerReview1 = new PeerReview();
    ExternalIDs weis1 = new ExternalIDs();
    ExternalID wei1 = new ExternalID();
    wei1.setRelationship(null);
    wei1.setValue("same_but_different_type");
    wei1.setType(WorkExternalIdentifierType.DOI.value());
    weis1.getExternalIdentifier().add(wei1);
    peerReview1.setExternalIdentifiers(weis1);
    peerReview1.setGroupId("issn:0000003");
    peerReview1.setOrganization(Utils.getOrganization());
    peerReview1.setRole(Role.CHAIR);
    peerReview1.setSubjectContainerName(new Title("subject-container-name"));
    peerReview1.setSubjectExternalIdentifier(wei1);
    WorkTitle workTitle1 = new WorkTitle();
    workTitle1.setTitle(new Title("work-title"));
    peerReview1.setSubjectName(workTitle1);
    peerReview1.setSubjectType(WorkType.DATA_SET);
    peerReview1.setType(PeerReviewType.EVALUATION);
    Response response1 = serviceDelegator.createPeerReview("4444-4444-4444-4444", peerReview1);
    assertNotNull(response1);
    assertEquals(Response.Status.CREATED.getStatusCode(), response1.getStatus());
    Map<?, ?> map = response1.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode1 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    PeerReview peerReview2 = new PeerReview();
    ExternalIDs weis2 = new ExternalIDs();
    ExternalID wei2 = new ExternalID();
    wei2.setRelationship(null);
    // Same value
    wei2.setValue("same_but_different_type");
    // But different
    wei2.setType(WorkExternalIdentifierType.ARXIV.value());
    // type
    weis2.getExternalIdentifier().add(wei2);
    peerReview2.setExternalIdentifiers(weis2);
    peerReview2.setGroupId("issn:0000003");
    peerReview2.setOrganization(Utils.getOrganization());
    peerReview2.setRole(Role.CHAIR);
    peerReview2.setSubjectContainerName(new Title("subject-container-name"));
    peerReview2.setSubjectExternalIdentifier(wei2);
    WorkTitle workTitle2 = new WorkTitle();
    workTitle2.setTitle(new Title("work-title"));
    peerReview2.setSubjectName(workTitle2);
    peerReview2.setSubjectType(WorkType.DATA_SET);
    peerReview2.setType(PeerReviewType.EVALUATION);
    Response response2 = serviceDelegator.createPeerReview("4444-4444-4444-4444", peerReview2);
    assertNotNull(response2);
    assertEquals(Response.Status.CREATED.getStatusCode(), response2.getStatus());
    map = response2.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    resultWithPutCode = (List<?>) map.get("Location");
    Long putCode2 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    // Delete new peer reviews so they don't affect other tests
    serviceDelegator.deletePeerReview("4444-4444-4444-4444", putCode1);
    serviceDelegator.deletePeerReview("4444-4444-4444-4444", putCode2);
}
Also used : Response(javax.ws.rs.core.Response) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) List(java.util.List) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)30 Title (org.orcid.jaxb.model.v3.dev1.common.Title)29 Work (org.orcid.jaxb.model.v3.dev1.record.Work)21 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)19 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)18 Url (org.orcid.jaxb.model.v3.dev1.common.Url)14 Test (org.junit.Test)12 TranslatedTitle (org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle)9 Subtitle (org.orcid.jaxb.model.v3.dev1.common.Subtitle)7 FundingTitle (org.orcid.jaxb.model.v3.dev1.record.FundingTitle)7 WorkBulk (org.orcid.jaxb.model.v3.dev1.record.WorkBulk)7 BaseTest (org.orcid.core.BaseTest)6 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)6 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)5 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)5 DBUnitTest (org.orcid.test.DBUnitTest)5 Day (org.orcid.jaxb.model.v3.dev1.common.Day)4 Month (org.orcid.jaxb.model.v3.dev1.common.Month)4 Year (org.orcid.jaxb.model.v3.dev1.common.Year)4 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)4