Search in sources :

Example 11 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_rc4/samples/peer-review-2.0_rc4.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_rc4.PeerReview) Test(org.junit.Test)

Example 12 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_rc3/samples/peer-review-2.0_rc3.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_rc3.PeerReview) Test(org.junit.Test)

Example 13 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_rc3/samples/peer-review-2.0_rc3.xml", PeerReview.class);
    peerReview.setPutCode(null);
    peerReview.setGroupId("Invalid group id " + System.currentTimeMillis());
    peerReview.getExternalIdentifiers().getExternalIdentifier().clear();
    ExternalID pExtId = new ExternalID();
    pExtId.setValue("Work Id " + System.currentTimeMillis());
    pExtId.setType(WorkExternalIdentifierType.AGR.value());
    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) ExternalID(org.orcid.jaxb.model.record_rc3.ExternalID) PeerReview(org.orcid.jaxb.model.record_rc3.PeerReview) Test(org.junit.Test)

Example 14 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_rc4/samples/peer-review-2.0_rc4.xml", PeerReview.class);
    peerReview.setPutCode(null);
    peerReview.setGroupId("Invalid group id " + System.currentTimeMillis());
    peerReview.getExternalIdentifiers().getExternalIdentifier().clear();
    ExternalID pExtId = new ExternalID();
    pExtId.setValue("Work Id " + System.currentTimeMillis());
    pExtId.setType(WorkExternalIdentifierType.AGR.value());
    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) ExternalID(org.orcid.jaxb.model.record_rc4.ExternalID) PeerReview(org.orcid.jaxb.model.record_rc4.PeerReview) Test(org.junit.Test)

Example 15 with PeerReview

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

the class ValidateV2_1IdentifiersTest method testPeerReview.

/** Test both types of identifier here
     * 
     * @throws SAXException
     * @throws IOException
     * @throws JAXBException
     * @throws ParserConfigurationException
     */
@Test
public void testPeerReview() throws SAXException, IOException, JAXBException, ParserConfigurationException {
    PeerReview peerReview = unmarshallFromPath("/record_2.1/samples/read_samples/peer-review-2.1.xml", PeerReview.class);
    ExternalID id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("source-work-id", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    ExternalID subjectid = peerReview.getSubjectExternalIdentifier();
    assertEquals("doi", subjectid.getType());
    assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
    assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
    assertEquals(Relationship.SELF, subjectid.getRelationship());
    Validator validator = getValidator("peer-review");
    validator.validate(marshall(PeerReview.class, peerReview));
    validator.validate(marshallToDOM(PeerReview.class, peerReview));
    //do the full record too
    peerReview = unmarshallFromPath("/record_2.1/samples/read_samples/peer-review-full-2.1.xml", PeerReview.class);
    id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("source-work-id", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    subjectid = peerReview.getSubjectExternalIdentifier();
    assertEquals("doi", subjectid.getType());
    assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
    assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
    assertEquals(Relationship.SELF, subjectid.getRelationship());
}
Also used : ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Url(org.orcid.jaxb.model.common_v2.Url) Validator(javax.xml.validation.Validator) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) 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