Search in sources :

Example 1 with PeerReview

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

the class MemberV3ApiServiceDelegator_GeneralTest method testOrcidProfileCreate_CAN_CRUDOnUnclaimedAccounts.

@Test
public void testOrcidProfileCreate_CAN_CRUDOnUnclaimedAccounts() {
    String orcid = "0000-0000-0000-0001";
    SecurityContextTestUtils.setUpSecurityContextForClientOnly();
    // Test address
    Response response = serviceDelegator.createAddress(orcid, Utils.getAddress());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Long putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewAddress(orcid, putCode);
    assertNotNull(response);
    Address address = (Address) response.getEntity();
    assertNotNull(address);
    address.getCountry().setValue(Iso3166Country.ZW);
    response = serviceDelegator.updateAddress(orcid, putCode, address);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteAddress(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test education
    Education education = (Education) Utils.getAffiliation(AffiliationType.EDUCATION);
    response = serviceDelegator.createEducation(orcid, education);
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewEducation(orcid, putCode);
    assertNotNull(response);
    education = (Education) response.getEntity();
    assertNotNull(education);
    education.setDepartmentName("Updated department name");
    response = serviceDelegator.updateEducation(orcid, putCode, education);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteAffiliation(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test employment
    response = serviceDelegator.createEmployment(orcid, (Employment) Utils.getAffiliation(AffiliationType.EMPLOYMENT));
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewEmployment(orcid, putCode);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    employment.setDepartmentName("Updated department name");
    response = serviceDelegator.updateEmployment(orcid, putCode, employment);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteAffiliation(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test external identifiers
    response = serviceDelegator.createExternalIdentifier(orcid, Utils.getPersonExternalIdentifier());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewExternalIdentifier(orcid, putCode);
    assertNotNull(response);
    PersonExternalIdentifier externalIdentifier = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(externalIdentifier);
    response = serviceDelegator.updateExternalIdentifier(orcid, putCode, externalIdentifier);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteExternalIdentifier(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test funding
    response = serviceDelegator.createFunding(orcid, Utils.getFunding());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewFunding(orcid, putCode);
    assertNotNull(response);
    Funding funding = (Funding) response.getEntity();
    assertNotNull(funding);
    response = serviceDelegator.updateFunding(orcid, putCode, funding);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteFunding(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test keyword
    response = serviceDelegator.createKeyword(orcid, Utils.getKeyword());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewKeyword(orcid, putCode);
    assertNotNull(response);
    Keyword keyword = (Keyword) response.getEntity();
    assertNotNull(keyword);
    response = serviceDelegator.updateKeyword(orcid, putCode, keyword);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteKeyword(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test other names
    response = serviceDelegator.createOtherName(orcid, Utils.getOtherName());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewOtherName(orcid, putCode);
    assertNotNull(response);
    OtherName otherName = (OtherName) response.getEntity();
    assertNotNull(otherName);
    response = serviceDelegator.updateOtherName(orcid, putCode, otherName);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteOtherName(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test peer review
    response = serviceDelegator.createPeerReview(orcid, Utils.getPeerReview());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewPeerReview(orcid, putCode);
    assertNotNull(response);
    PeerReview peerReview = (PeerReview) response.getEntity();
    assertNotNull(peerReview);
    response = serviceDelegator.updatePeerReview(orcid, putCode, peerReview);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deletePeerReview(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test researcher url
    response = serviceDelegator.createResearcherUrl(orcid, Utils.getResearcherUrl());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewResearcherUrl(orcid, putCode);
    assertNotNull(response);
    ResearcherUrl rUrl = (ResearcherUrl) response.getEntity();
    assertNotNull(rUrl);
    response = serviceDelegator.updateResearcherUrl(orcid, putCode, rUrl);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteResearcherUrl(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test work
    response = serviceDelegator.createWork(orcid, Utils.getWork("work # 1 " + System.currentTimeMillis()));
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewWork(orcid, putCode);
    assertNotNull(response);
    Work work = (Work) response.getEntity();
    assertNotNull(work);
    response = serviceDelegator.updateWork(orcid, putCode, work);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteWork(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
Also used : Address(org.orcid.jaxb.model.v3.dev1.record.Address) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) Response(javax.ws.rs.core.Response) Education(org.orcid.jaxb.model.v3.dev1.record.Education) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) Work(org.orcid.jaxb.model.v3.dev1.record.Work) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 2 with PeerReview

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

the class MemberV3ApiServiceDelegator_PeerReviewsTest method testViewPeerReviewSummary.

@Test
public void testViewPeerReviewSummary() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewPeerReviewSummary("4444-4444-4444-4446", Long.valueOf(1));
    assertNotNull(response);
    PeerReviewSummary peerReview = (PeerReviewSummary) response.getEntity();
    assertNotNull(peerReview);
    assertEquals("/4444-4444-4444-4446/peer-review/1", peerReview.getPath());
    Utils.verifyLastModified(peerReview.getLastModifiedDate());
    assertEquals(Long.valueOf("1"), peerReview.getPutCode());
    assertNotNull(peerReview.getCompletionDate());
    assertEquals("01", peerReview.getCompletionDate().getDay().getValue());
    assertEquals("01", peerReview.getCompletionDate().getMonth().getValue());
    assertEquals("2015", peerReview.getCompletionDate().getYear().getValue());
    assertEquals("work:external-identifier-id#1", peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("APP-5555555555555555", peerReview.getSource().retrieveSourcePath());
    assertEquals("public", peerReview.getVisibility().value());
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with PeerReview

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

the class MemberV3ApiServiceDelegator_PeerReviewsTest method testDeletePeerReview.

@Test
public void testDeletePeerReview() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4443", 8L);
    assertNotNull(response);
    PeerReview review = (PeerReview) response.getEntity();
    assertNotNull(review);
    assertNotNull(review.getSubjectName());
    assertNotNull(review.getSubjectName().getTitle());
    assertEquals("Peer Review # 3", review.getSubjectName().getTitle().getContent());
    response = serviceDelegator.deletePeerReview("4444-4444-4444-4443", 8L);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 4 with PeerReview

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

the class MemberV3ApiServiceDelegator_PeerReviewsTest method testViewPrivatePeerReview.

@Test
public void testViewPrivatePeerReview() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4446", 4L);
    assertNotNull(response);
    PeerReview peerReview = (PeerReview) response.getEntity();
    assertNotNull(peerReview);
    assertEquals("/4444-4444-4444-4446/peer-review/4", peerReview.getPath());
    Utils.verifyLastModified(peerReview.getLastModifiedDate());
    assertEquals(Long.valueOf(4L), peerReview.getPutCode());
    assertNotNull(peerReview.getCompletionDate());
    assertEquals("01", peerReview.getCompletionDate().getDay().getValue());
    assertEquals("01", peerReview.getCompletionDate().getMonth().getValue());
    assertEquals("2015", peerReview.getCompletionDate().getYear().getValue());
    assertEquals("work:external-identifier-id#3", peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("private", peerReview.getVisibility().value());
    assertEquals("issn:0000003", peerReview.getGroupId());
}
Also used : Response(javax.ws.rs.core.Response) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 5 with PeerReview

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

the class JSONInputValidatorTest method testValidateJSONValidInputForInvalidV3PeerReview.

@Test(expected = InvalidJSONException.class)
public void testValidateJSONValidInputForInvalidV3PeerReview() throws JAXBException, SAXException, IOException {
    PeerReview peerReview = org.orcid.test.helper.v3.Utils.getPeerReview();
    peerReview.setCompletionDate(new FuzzyDate(new Year(2017), new Month(1), new Day(1)));
    peerReview.setRole(null);
    validator.validateJSONInput(peerReview);
}
Also used : Month(org.orcid.jaxb.model.v3.dev1.common.Month) Year(org.orcid.jaxb.model.v3.dev1.common.Year) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) Day(org.orcid.jaxb.model.v3.dev1.common.Day) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) Test(org.junit.Test)

Aggregations

PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)66 Test (org.junit.Test)49 Response (javax.ws.rs.core.Response)20 DBUnitTest (org.orcid.test.DBUnitTest)20 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)12 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)9 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)9 Url (org.orcid.jaxb.model.v3.dev1.common.Url)8 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)8 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)8 Work (org.orcid.jaxb.model.v3.dev1.record.Work)7 BaseTest (org.orcid.core.BaseTest)6 Title (org.orcid.jaxb.model.v3.dev1.common.Title)6 Education (org.orcid.jaxb.model.v3.dev1.record.Education)6 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)6 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)6 ArrayList (java.util.ArrayList)5 Day (org.orcid.jaxb.model.v3.dev1.common.Day)5 Month (org.orcid.jaxb.model.v3.dev1.common.Month)5 Year (org.orcid.jaxb.model.v3.dev1.common.Year)5