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