use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_PeerReviewsTest method testAddPeerReviewWithInvalidExtIdTypeFail.
@Test
public void testAddPeerReviewWithInvalidExtIdTypeFail() {
String orcid = "4444-4444-4444-4499";
SecurityContextTestUtils.setUpSecurityContext(orcid, ScopePathType.ACTIVITIES_READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
PeerReview peerReview = Utils.getPeerReview();
// Set both to a correct value
peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).setType("doi");
peerReview.getSubjectExternalIdentifier().setType("doi");
// Check it fail on external identifier type
try {
peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).setType("INVALID");
serviceDelegator.createPeerReview(orcid, peerReview);
fail();
} catch (ActivityIdentifierValidationException e) {
} catch (Exception e) {
fail();
}
/*
* This case is now ok (external-id-api branch 05/16) - adapters ensure
* correct value is stored in DB. try {
* peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).
* setType("DOI"); serviceDelegator.createPeerReview(orcid, peerReview);
* fail(); } catch(ActivityIdentifierValidationException e) {
*
* } catch(Exception e) { fail(); }
*/
// Set the ext id to a correct value to test the subject ext id
peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).setType("doi");
// Check it fail on subject external identifier type
try {
peerReview.getSubjectExternalIdentifier().setType("INVALID");
serviceDelegator.createPeerReview(orcid, peerReview);
fail();
} catch (ActivityIdentifierValidationException e) {
} catch (Exception e) {
fail();
}
/*
* try { peerReview.getSubjectExternalIdentifier().setType("DOI");
* serviceDelegator.createPeerReview(orcid, peerReview); fail(); }
* catch(ActivityIdentifierValidationException e) {
*
* } catch(Exception e) { fail(); }
*/
// Test it works with correct values
peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).setType("doi");
peerReview.getSubjectExternalIdentifier().setType("doi");
Response response = serviceDelegator.createPeerReview(orcid, peerReview);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
Map<?, ?> map = response.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List<?> resultWithPutCode = (List<?>) map.get("Location");
Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
// Delete it to roll back the test data
response = serviceDelegator.deletePeerReview(orcid, putCode);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_PeerReviewsTest method testUpdatePeerReview.
@Test
public void testUpdatePeerReview() {
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);
Utils.verifyLastModified(peerReview.getLastModifiedDate());
LastModifiedDate before = peerReview.getLastModifiedDate();
peerReview.setUrl(new Url("http://updated.com/url"));
peerReview.getSubjectName().getTitle().setContent("Updated Title");
response = serviceDelegator.updatePeerReview("4444-4444-4444-4447", 6L, peerReview);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 6L);
PeerReview updatedPeerReview = (PeerReview) response.getEntity();
assertNotNull(updatedPeerReview);
Utils.verifyLastModified(updatedPeerReview.getLastModifiedDate());
assertTrue(updatedPeerReview.getLastModifiedDate().after(before));
assertEquals("http://updated.com/url", updatedPeerReview.getUrl().getValue());
assertEquals("Updated Title", updatedPeerReview.getSubjectName().getTitle().getContent());
}
use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_PeerReviewsTest method testUpdatePeerReviewWhenYouAreNotTheSourceOf.
@Test
public void testUpdatePeerReviewWhenYouAreNotTheSourceOf() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 2L);
assertNotNull(response);
PeerReview peerReview = (PeerReview) response.getEntity();
assertNotNull(peerReview);
assertEquals("http://peer_review.com/2", peerReview.getUrl().getValue());
assertEquals("APP-6666666666666666", peerReview.getSource().retrieveSourcePath());
// Update the info
peerReview.setUrl(new Url("http://updated.com/url"));
peerReview.getSubjectName().getTitle().setContent("Updated Title");
peerReview.getExternalIdentifiers().getExternalIdentifier().iterator().next().setValue("different");
// disambiguated org is required in API v3
DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
disambiguatedOrg.setDisambiguatedOrganizationIdentifier("some-org");
disambiguatedOrg.setDisambiguationSource("FUNDREF");
peerReview.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
try {
response = serviceDelegator.updatePeerReview("4444-4444-4444-4447", 2L, peerReview);
fail();
} catch (WrongSourceException wse) {
}
response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", Long.valueOf(2));
peerReview = (PeerReview) response.getEntity();
assertNotNull(peerReview);
assertEquals("http://peer_review.com/2", peerReview.getUrl().getValue());
assertEquals("APP-6666666666666666", peerReview.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_PeerReviewsTest method testUpdatePeerReviewChangingVisibilityTest.
@Test(expected = VisibilityMismatchException.class)
public void testUpdatePeerReviewChangingVisibilityTest() {
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(Visibility.PRIVATE);
response = serviceDelegator.updatePeerReview("4444-4444-4444-4447", 6L, peerReview);
fail();
}
use of org.orcid.jaxb.model.v3.dev1.record.PeerReview in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_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());
}
Aggregations