Search in sources :

Example 91 with PeerReview

use of org.orcid.jaxb.model.record_rc4.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 92 with PeerReview

use of org.orcid.jaxb.model.record_rc4.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 93 with PeerReview

use of org.orcid.jaxb.model.record_rc4.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 94 with PeerReview

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

Example 95 with PeerReview

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

the class PublicV2Test method checkPeerReview.

public void checkPeerReview(String readPublicToken) throws JSONException, InterruptedException, URISyntaxException {
    PeerReview peerReviewToCreate = (PeerReview) unmarshallFromPath("/record_2.0_rc1/samples/peer-review-2.0_rc1.xml", PeerReview.class);
    peerReviewToCreate.setPutCode(null);
    peerReviewToCreate.setGroupId(groupRecords.get(0).getGroupId());
    peerReviewToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PUBLIC);
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV2ApiClient.createPeerReviewXml(getUser1OrcidId(), peerReviewToCreate, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    String path = postResponse.getLocation().getPath();
    String putCode = path.substring(path.lastIndexOf('/') + 1, path.length());
    ClientResponse getPeerReviewResponse = null;
    if (readPublicToken != null) {
        getPeerReviewResponse = publicV2ApiClient.viewPeerReviewXml(getUser1OrcidId(), putCode, readPublicToken);
    } else {
        getPeerReviewResponse = publicV2ApiClient.viewPeerReviewXml(getUser1OrcidId(), putCode);
    }
    assertNotNull(getPeerReviewResponse);
    checkResponse(getPeerReviewResponse);
    PeerReview peerReview = getPeerReviewResponse.getEntity(PeerReview.class);
    assertNotNull(peerReview);
    assertEquals("peer-review:url", peerReview.getUrl().getValue());
    ClientResponse getPeerReviewSummaryResponse = publicV2ApiClient.viewPeerReviewSummaryXml(getUser1OrcidId(), putCode);
    if (readPublicToken != null) {
        getPeerReviewSummaryResponse = publicV2ApiClient.viewPeerReviewSummaryXml(getUser1OrcidId(), putCode, readPublicToken);
    } else {
        getPeerReviewSummaryResponse = publicV2ApiClient.viewPeerReviewSummaryXml(getUser1OrcidId(), putCode);
    }
    assertNotNull(getPeerReviewSummaryResponse);
    checkResponse(getPeerReviewSummaryResponse);
    PeerReviewSummary summary = getPeerReviewSummaryResponse.getEntity(PeerReviewSummary.class);
    assertNotNull(summary);
    assertEquals("1848", summary.getCompletionDate().getYear().getValue());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) PeerReviewSummary(org.orcid.jaxb.model.record.summary_rc1.PeerReviewSummary) PeerReview(org.orcid.jaxb.model.record_rc1.PeerReview)

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