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