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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations