Search in sources :

Example 56 with PeerReview

use of org.orcid.jaxb.model.record_rc1.PeerReview in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorTest method testGetPublicPeerReviewUsingToken.

// Peer review
@Test
public void testGetPublicPeerReviewUsingToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewPeerReview(ORCID, 9L);
    assertNotNull(r);
    PeerReview p = (PeerReview) r.getEntity();
    assertNotNull(p);
    assertNotNull(p.getLastModifiedDate());
    assertNotNull(p.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(9), p.getPutCode());
}
Also used : Response(javax.ws.rs.core.Response) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 57 with PeerReview

use of org.orcid.jaxb.model.record_rc1.PeerReview in project ORCID-Source by ORCID.

the class JpaJaxbPeerReviewAdapterTest method fromOrgAffiliationRelationEntityToEducation.

@Test
public void fromOrgAffiliationRelationEntityToEducation() {
    PeerReviewEntity entity = getPeerReviewEntity();
    assertNotNull(entity);
    PeerReview peerReview = jpaJaxbPeerReviewAdapter.toPeerReview(entity);
    assertNotNull(peerReview);
    assertEquals(Long.valueOf(12345), peerReview.getPutCode());
    assertEquals("private", peerReview.getVisibility().value());
    assertEquals("orcid-generated:12345", peerReview.getGroupId());
    //Subject
    assertNotNull(peerReview.getSubjectExternalIdentifier());
    assertEquals("peer-review:subject-external-identifier-id", peerReview.getSubjectExternalIdentifier().getValue());
    assertEquals("source-work-id", peerReview.getSubjectExternalIdentifier().getType());
    assertEquals("peer-review:subject-container-name", peerReview.getSubjectContainerName().getContent());
    assertEquals("peer-review:subject-name", peerReview.getSubjectName().getTitle().getContent());
    assertEquals("peer-review:subject-translated-name", peerReview.getSubjectName().getTranslatedTitle().getContent());
    assertEquals("en", peerReview.getSubjectName().getTranslatedTitle().getLanguageCode());
    assertEquals(WorkType.BOOK_REVIEW.value(), peerReview.getSubjectType().value());
    assertEquals("peer-review:subject-url", peerReview.getSubjectUrl().getValue());
    //Fields
    assertNotNull(peerReview.getExternalIdentifiers());
    assertNotNull(peerReview.getExternalIdentifiers().getExternalIdentifier());
    assertEquals(1, peerReview.getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("peer-review:external-identifier-id", peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("source-work-id", peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals(Role.MEMBER.value(), peerReview.getRole().value());
    assertEquals(PeerReviewType.EVALUATION.value(), peerReview.getType().value());
    assertEquals("peer-review:url", peerReview.getUrl().getValue());
    assertNotNull(peerReview.getCompletionDate());
    assertEquals("2015", peerReview.getCompletionDate().getYear().getValue());
    assertEquals("01", peerReview.getCompletionDate().getMonth().getValue());
    assertEquals("01", peerReview.getCompletionDate().getDay().getValue());
    assertNotNull(peerReview.getOrganization());
    assertEquals("org:name", peerReview.getOrganization().getName());
    assertNotNull(peerReview.getOrganization().getAddress());
    assertEquals("org:city", peerReview.getOrganization().getAddress().getCity());
    assertEquals("org:region", peerReview.getOrganization().getAddress().getRegion());
    assertNotNull(peerReview.getSource());
    assertEquals("APP-000000001", peerReview.getSource().retrieveSourcePath());
}
Also used : PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Example 58 with PeerReview

use of org.orcid.jaxb.model.record_rc1.PeerReview in project ORCID-Source by ORCID.

the class JpaJaxbPeerReviewAdapterTest method getPeerReview.

private PeerReview getPeerReview(boolean full) throws JAXBException {
    JAXBContext context = JAXBContext.newInstance(new Class[] { PeerReview.class });
    Unmarshaller unmarshaller = context.createUnmarshaller();
    String name = "/record_2.0/samples/read_samples/peer-review-2.0.xml";
    if (full) {
        name = "/record_2.0/samples/read_samples/peer-review-full-2.0.xml";
    }
    InputStream inputStream = getClass().getResourceAsStream(name);
    return (PeerReview) unmarshaller.unmarshal(inputStream);
}
Also used : InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview)

Example 59 with PeerReview

use of org.orcid.jaxb.model.record_rc1.PeerReview in project ORCID-Source by ORCID.

the class MemberV2Test method testPeerReviewMustHaveAtLeastOneExtId.

@Test
public void testPeerReviewMustHaveAtLeastOneExtId() throws JSONException, InterruptedException, URISyntaxException {
    PeerReview peerReview = (PeerReview) unmarshallFromPath("/record_2.0_rc1/samples/peer-review-2.0_rc1.xml", PeerReview.class);
    peerReview.setPutCode(null);
    peerReview.setGroupId(groupRecords.get(0).getGroupId());
    peerReview.getExternalIdentifiers().getExternalIdentifier().clear();
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV2ApiClient.createPeerReviewXml(this.getUser1OrcidId(), peerReview, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), postResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) PeerReview(org.orcid.jaxb.model.record_rc1.PeerReview) Test(org.junit.Test)

Example 60 with PeerReview

use of org.orcid.jaxb.model.record_rc1.PeerReview in project ORCID-Source by ORCID.

the class MemberV2Test method testAddPeerReviewWithInvalidGroupingId.

@Test
public void testAddPeerReviewWithInvalidGroupingId() throws JSONException, InterruptedException, URISyntaxException {
    PeerReview peerReview = (PeerReview) unmarshallFromPath("/record_2.0_rc1/samples/peer-review-2.0_rc1.xml", PeerReview.class);
    peerReview.setPutCode(null);
    peerReview.setGroupId("Invalid group id " + System.currentTimeMillis());
    peerReview.getExternalIdentifiers().getExternalIdentifier().clear();
    WorkExternalIdentifier pExtId = new WorkExternalIdentifier();
    pExtId.setWorkExternalIdentifierId(new WorkExternalIdentifierId("Work Id " + System.currentTimeMillis()));
    pExtId.setWorkExternalIdentifierType(WorkExternalIdentifierType.AGR);
    pExtId.setRelationship(Relationship.SELF);
    peerReview.getExternalIdentifiers().getExternalIdentifier().add(pExtId);
    String accessToken = getAccessToken();
    //Pattern not valid
    ClientResponse postResponse = memberV2ApiClient.createPeerReviewXml(this.getUser1OrcidId(), peerReview, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), postResponse.getStatus());
    //Null group id 
    peerReview.setGroupId(null);
    postResponse = memberV2ApiClient.createPeerReviewXml(this.getUser1OrcidId(), peerReview, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), postResponse.getStatus());
    //Empty group id
    peerReview.setGroupId("");
    postResponse = memberV2ApiClient.createPeerReviewXml(this.getUser1OrcidId(), peerReview, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), postResponse.getStatus());
    //Invalid group id
    peerReview.setGroupId("orcid-generated:" + peerReview.getGroupId());
    postResponse = memberV2ApiClient.createPeerReviewXml(this.getUser1OrcidId(), peerReview, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), postResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) WorkExternalIdentifierId(org.orcid.jaxb.model.record_rc1.WorkExternalIdentifierId) WorkExternalIdentifier(org.orcid.jaxb.model.record_rc1.WorkExternalIdentifier) PeerReview(org.orcid.jaxb.model.record_rc1.PeerReview) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)71 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)68 ClientResponse (com.sun.jersey.api.client.ClientResponse)35 Response (javax.ws.rs.core.Response)17 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)17 DBUnitTest (org.orcid.test.DBUnitTest)17 Url (org.orcid.jaxb.model.common_v2.Url)11 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)10 ArrayList (java.util.ArrayList)9 PeerReview (org.orcid.jaxb.model.record_rc1.PeerReview)9 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)8 BaseTest (org.orcid.core.BaseTest)6 Title (org.orcid.jaxb.model.common_v2.Title)6 WorkExternalIdentifier (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifier)6 WorkExternalIdentifierId (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifierId)6 PeerReview (org.orcid.jaxb.model.record_rc3.PeerReview)6 PeerReview (org.orcid.jaxb.model.record_rc4.PeerReview)6 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)6 Funding (org.orcid.jaxb.model.record_v2.Funding)6 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)6