Search in sources :

Example 41 with LastModifiedDate

use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate 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 42 with LastModifiedDate

use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testUpdateInvitedPosition.

@Test
public void testUpdateInvitedPosition() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewInvitedPosition(ORCID, 32L);
    assertNotNull(response);
    InvitedPosition invitedPosition = (InvitedPosition) response.getEntity();
    assertNotNull(invitedPosition);
    assertEquals("PUBLIC Department", invitedPosition.getDepartmentName());
    assertEquals("PUBLIC", invitedPosition.getRoleTitle());
    Utils.verifyLastModified(invitedPosition.getLastModifiedDate());
    LastModifiedDate before = invitedPosition.getLastModifiedDate();
    invitedPosition.setDepartmentName("Updated department name");
    invitedPosition.setRoleTitle("The updated role title");
    // disambiguated org is required in API v3
    DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
    disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
    disambiguatedOrg.setDisambiguationSource("WDB");
    invitedPosition.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
    response = serviceDelegator.updateInvitedPosition(ORCID, 32L, invitedPosition);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewInvitedPosition(ORCID, 32L);
    assertNotNull(response);
    invitedPosition = (InvitedPosition) response.getEntity();
    assertNotNull(invitedPosition);
    Utils.verifyLastModified(invitedPosition.getLastModifiedDate());
    assertTrue(invitedPosition.getLastModifiedDate().after(before));
    assertEquals("Updated department name", invitedPosition.getDepartmentName());
    assertEquals("The updated role title", invitedPosition.getRoleTitle());
    // Rollback changes
    invitedPosition.setDepartmentName("PUBLIC Department");
    invitedPosition.setRoleTitle("PUBLIC");
    response = serviceDelegator.updateInvitedPosition(ORCID, 32L, invitedPosition);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 43 with LastModifiedDate

use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_KeywordsTest method testUpdateKeyword.

@Test
public void testUpdateKeyword() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4441", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewKeyword("4444-4444-4444-4441", 6L);
    assertNotNull(response);
    Keyword keyword = (Keyword) response.getEntity();
    assertNotNull(keyword);
    Utils.verifyLastModified(keyword.getLastModifiedDate());
    LastModifiedDate before = keyword.getLastModifiedDate();
    assertEquals("keyword-2", keyword.getContent());
    assertEquals(Visibility.PUBLIC, keyword.getVisibility());
    keyword.setContent("Updated keyword");
    response = serviceDelegator.updateKeyword("4444-4444-4444-4441", 6L, keyword);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewKeyword("4444-4444-4444-4441", 6L);
    assertNotNull(response);
    keyword = (Keyword) response.getEntity();
    assertNotNull(keyword);
    Utils.verifyLastModified(keyword.getLastModifiedDate());
    assertTrue(keyword.getLastModifiedDate().after(before));
    assertEquals("Updated keyword", keyword.getContent());
    assertEquals(Visibility.PUBLIC, keyword.getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 44 with LastModifiedDate

use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_MembershipsTest method testUpdateMembership.

@Test
public void testUpdateMembership() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewMembership(ORCID, 39L);
    assertNotNull(response);
    Membership membership = (Membership) response.getEntity();
    assertNotNull(membership);
    assertEquals("PRIVATE Department", membership.getDepartmentName());
    assertEquals("PRIVATE", membership.getRoleTitle());
    Utils.verifyLastModified(membership.getLastModifiedDate());
    LastModifiedDate before = membership.getLastModifiedDate();
    membership.setDepartmentName("Updated department name");
    membership.setRoleTitle("The updated role title");
    // disambiguated org is required in API v3
    DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
    disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
    disambiguatedOrg.setDisambiguationSource("WDB");
    membership.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
    response = serviceDelegator.updateMembership(ORCID, 39L, membership);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewMembership(ORCID, 39L);
    assertNotNull(response);
    membership = (Membership) response.getEntity();
    assertNotNull(membership);
    Utils.verifyLastModified(membership.getLastModifiedDate());
    assertTrue(membership.getLastModifiedDate().after(before));
    assertEquals("Updated department name", membership.getDepartmentName());
    assertEquals("The updated role title", membership.getRoleTitle());
    // Rollback changes
    membership.setDepartmentName("PRIVATE Department");
    membership.setRoleTitle("PRIVATE");
    response = serviceDelegator.updateMembership(ORCID, 39L, membership);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 45 with LastModifiedDate

use of org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_PeerReviewsTest method testUpdatePeerReview.

@Test
public void testUpdatePeerReview() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 6L);
    assertNotNull(response);
    PeerReview peerReview = (PeerReview) response.getEntity();
    assertNotNull(peerReview);
    Utils.verifyLastModified(peerReview.getLastModifiedDate());
    LastModifiedDate before = peerReview.getLastModifiedDate();
    peerReview.setUrl(new Url("http://updated.com/url"));
    peerReview.getSubjectName().getTitle().setContent("Updated Title");
    response = serviceDelegator.updatePeerReview("4444-4444-4444-4447", 6L, peerReview);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 6L);
    PeerReview updatedPeerReview = (PeerReview) response.getEntity();
    assertNotNull(updatedPeerReview);
    Utils.verifyLastModified(updatedPeerReview.getLastModifiedDate());
    assertTrue(updatedPeerReview.getLastModifiedDate().after(before));
    assertEquals("http://updated.com/url", updatedPeerReview.getUrl().getValue());
    assertEquals("Updated Title", updatedPeerReview.getSubjectName().getTitle().getContent());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

LastModifiedDate (org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate)45 Test (org.junit.Test)18 DBUnitTest (org.orcid.test.DBUnitTest)17 Response (javax.ws.rs.core.Response)15 CreatedDate (org.orcid.jaxb.model.v3.dev1.common.CreatedDate)8 DisambiguatedOrganization (org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization)7 Url (org.orcid.jaxb.model.v3.dev1.common.Url)5 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)5 ArrayList (java.util.ArrayList)4 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)4 FuzzyDate (org.orcid.jaxb.model.v3.dev1.common.FuzzyDate)3 PublicationDate (org.orcid.jaxb.model.v3.dev1.common.PublicationDate)3 Title (org.orcid.jaxb.model.v3.dev1.common.Title)3 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)3 Name (org.orcid.jaxb.model.v3.dev1.record.Name)3 WorkGroup (org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup)3 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)3 Works (org.orcid.jaxb.model.v3.dev1.record.summary.Works)3 Date (java.util.Date)2 CreditName (org.orcid.jaxb.model.v3.dev1.common.CreditName)2