use of org.orcid.jaxb.model.record_rc1.PeerReview in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_PeerReviewsTest method testViewLimitedPeerReview.
@Test
public void testViewLimitedPeerReview() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4446", 3L);
assertNotNull(response);
PeerReview peerReview = (PeerReview) response.getEntity();
assertNotNull(peerReview);
assertEquals("/4444-4444-4444-4446/peer-review/3", peerReview.getPath());
Utils.verifyLastModified(peerReview.getLastModifiedDate());
assertEquals(Long.valueOf(3L), 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#2", peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("limited", peerReview.getVisibility().value());
assertEquals("issn:0000002", peerReview.getGroupId());
}
use of org.orcid.jaxb.model.record_rc1.PeerReview in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_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.record_rc1.PeerReview in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validatePeerReview_noExternalIdentifiersTest.
@Test(expected = ActivityIdentifierValidationException.class)
public void validatePeerReview_noExternalIdentifiersTest() {
PeerReview pr = getPeerReview();
pr.getExternalIdentifiers().getExternalIdentifier().clear();
activityValidator.validatePeerReview(pr, null, true, true, Visibility.PUBLIC);
}
use of org.orcid.jaxb.model.record_rc1.PeerReview in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validatePeerReview_validPeerReviewTest.
/**
* VALIDATE PEER REVIEW
* */
@Test
public void validatePeerReview_validPeerReviewTest() {
PeerReview pr = getPeerReview();
activityValidator.validatePeerReview(pr, null, true, true, Visibility.PUBLIC);
}
use of org.orcid.jaxb.model.record_rc1.PeerReview in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validatePeerReview_invalidSubjectExternalIdentifiersTest.
@Test(expected = ActivityIdentifierValidationException.class)
public void validatePeerReview_invalidSubjectExternalIdentifiersTest() {
PeerReview pr = getPeerReview();
pr.getSubjectExternalIdentifier().setType(null);
activityValidator.validatePeerReview(pr, null, true, true, Visibility.PUBLIC);
}
Aggregations