use of org.orcid.jaxb.model.record_v2.PeerReview in project ORCID-Source by ORCID.
the class PeerReviewManagerTest method testAddMultipleModifiesIndexingStatus.
@Test
public void testAddMultipleModifiesIndexingStatus() {
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
PeerReview p1 = getPeerReview("extId1");
p1 = peerReviewManager.createPeerReview(claimedOrcid, p1, true);
PeerReview p2 = getPeerReview("extId2");
p2 = peerReviewManager.createPeerReview(claimedOrcid, p2, true);
PeerReview p3 = getPeerReview("extId3");
p3 = peerReviewManager.createPeerReview(claimedOrcid, p3, true);
PeerReviewEntity entity1 = peerReviewDao.find(p1.getPutCode());
PeerReviewEntity entity2 = peerReviewDao.find(p2.getPutCode());
PeerReviewEntity entity3 = peerReviewDao.find(p3.getPutCode());
assertNotNull(entity1.getDisplayIndex());
assertNotNull(entity2.getDisplayIndex());
assertNotNull(entity3.getDisplayIndex());
assertEquals(Long.valueOf(0), entity3.getDisplayIndex());
// Rollback all changes
peerReviewDao.remove(entity1.getId());
peerReviewDao.remove(entity2.getId());
peerReviewDao.remove(entity3.getId());
}
use of org.orcid.jaxb.model.record_v2.PeerReview in project ORCID-Source by ORCID.
the class PeerReviewManagerTest method displayIndexIsSetTo_1_FromUI.
@Test
public void displayIndexIsSetTo_1_FromUI() {
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
PeerReview p1 = getPeerReview("fromUI-1");
p1 = peerReviewManager.createPeerReview(claimedOrcid, p1, false);
PeerReviewEntity p = peerReviewDao.find(p1.getPutCode());
assertNotNull(p);
assertEquals(Long.valueOf(1), p.getDisplayIndex());
}
use of org.orcid.jaxb.model.record_v2.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_v2.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_v2.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