use of org.orcid.jaxb.model.record_rc2.PeerReview in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_PeerReviewsTest method testViewPeerReviewReadPublic.
@Test
public void testViewPeerReviewReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 2L);
PeerReview element = (PeerReview) r.getEntity();
assertNotNull(element);
assertEquals("/4444-4444-4444-4447/peer-review/2", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.record_rc2.PeerReview in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_PeerReviewsTest method testUpdatePeerReviewLeavingVisibilityNullTest.
@Test
public void testUpdatePeerReviewLeavingVisibilityNullTest() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 6L);
assertNotNull(response);
PeerReview peerReview = (PeerReview) response.getEntity();
assertNotNull(peerReview);
assertEquals(Visibility.PUBLIC, peerReview.getVisibility());
peerReview.setVisibility(null);
response = serviceDelegator.updatePeerReview("4444-4444-4444-4447", 6L, peerReview);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
peerReview = (PeerReview) response.getEntity();
assertNotNull(peerReview);
assertEquals(Visibility.PUBLIC, peerReview.getVisibility());
}
use of org.orcid.jaxb.model.record_rc2.PeerReview in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_PeerReviewsTest method testViewPublicPeerReview.
@Test
public void testViewPublicPeerReview() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4446", 1L);
assertNotNull(response);
PeerReview peerReview = (PeerReview) response.getEntity();
assertNotNull(peerReview);
assertEquals("/4444-4444-4444-4446/peer-review/1", peerReview.getPath());
Utils.verifyLastModified(peerReview.getLastModifiedDate());
assertEquals(Long.valueOf(1L), peerReview.getPutCode());
assertNotNull(peerReview.getCompletionDate());
assertEquals("01", peerReview.getCompletionDate().getDay().getValue());
assertEquals("01", peerReview.getCompletionDate().getMonth().getValue());
assertEquals("2015", peerReview.getCompletionDate().getYear().getValue());
assertEquals("work:external-identifier-id#1", peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("reviewer", peerReview.getRole().value());
assertEquals("APP-5555555555555555", peerReview.getSource().retrieveSourcePath());
assertEquals("public", peerReview.getVisibility().value());
assertEquals("review", peerReview.getType().value());
assertEquals("http://peer_review.com", peerReview.getUrl().getValue());
assertEquals("Peer Review # 1", peerReview.getSubjectName().getTitle().getContent());
assertEquals("es", peerReview.getSubjectName().getTranslatedTitle().getLanguageCode());
assertEquals("artistic-performance", peerReview.getSubjectType().value());
assertEquals("http://work.com", peerReview.getSubjectUrl().getValue());
assertEquals("Peer Review # 1 container name", peerReview.getSubjectContainerName().getContent());
assertEquals("peer-review:subject-external-identifier-id#1", peerReview.getSubjectExternalIdentifier().getValue());
assertEquals("agr", peerReview.getSubjectExternalIdentifier().getType());
assertEquals("issn:0000001", peerReview.getGroupId());
}
use of org.orcid.jaxb.model.record_rc2.PeerReview in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_PeerReviewsTest method testAddPeerReviewDuplicateFails.
@Test(expected = OrcidDuplicatedActivityException.class)
public void testAddPeerReviewDuplicateFails() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 6L);
assertNotNull(response);
PeerReview peerReview = (PeerReview) response.getEntity();
assertNotNull(peerReview);
peerReview.setUrl(new Url("http://updated.com/url"));
peerReview.getSubjectName().getTitle().setContent("Updated Title");
peerReview.setPutCode(null);
response = serviceDelegator.createPeerReview("4444-4444-4444-4447", peerReview);
}
use of org.orcid.jaxb.model.record_rc2.PeerReview in project ORCID-Source by ORCID.
the class MemberV2Test method testUpdatePeerReviewWithProfileCreationTokenWhenClaimedAndNotSource.
@Test
public void testUpdatePeerReviewWithProfileCreationTokenWhenClaimedAndNotSource() throws JSONException, InterruptedException, URISyntaxException {
long time = System.currentTimeMillis();
PeerReview peerReviewToCreate = (PeerReview) unmarshallFromPath("/record_2.0_rc4/samples/peer-review-2.0_rc4.xml", PeerReview.class);
peerReviewToCreate.setPutCode(null);
peerReviewToCreate.setGroupId(groupRecords.get(0).getGroupId());
peerReviewToCreate.setVisibility(Visibility.PUBLIC);
peerReviewToCreate.getExternalIdentifiers().getExternalIdentifier().clear();
ExternalID wExtId = new ExternalID();
wExtId.setValue("Work Id " + time);
wExtId.setType(WorkExternalIdentifierType.AGR.value());
wExtId.setRelationship(Relationship.SELF);
peerReviewToCreate.getExternalIdentifiers().getExternalIdentifier().add(wExtId);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV2ApiClient.createPeerReviewXml(this.getUser1OrcidId(), peerReviewToCreate, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
String locationPath = postResponse.getLocation().getPath();
assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v2.0_rc4/" + this.getUser1OrcidId() + "/peer-review/\\d+"));
ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
PeerReview gotPeerReview = getResponse.getEntity(PeerReview.class);
assertEquals("peer-review:subject-name", gotPeerReview.getSubjectName().getTitle().getContent());
gotPeerReview.getSubjectName().getTitle().setContent("updated title");
String profileCreateToken = oauthHelper.getClientCredentialsAccessToken(this.getClient2ClientId(), this.getClient2ClientSecret(), ScopePathType.ORCID_PROFILE_CREATE);
ClientResponse putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), profileCreateToken, gotPeerReview);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
ClientResponse getAfterUpdateResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
PeerReview gotAfterUpdatePeerReview = getAfterUpdateResponse.getEntity(PeerReview.class);
assertEquals("peer-review:subject-name", gotAfterUpdatePeerReview.getSubjectName().getTitle().getContent());
ClientResponse deleteResponse = memberV2ApiClient.deletePeerReviewXml(this.getUser1OrcidId(), gotAfterUpdatePeerReview.getPutCode(), accessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Aggregations