use of org.orcid.jaxb.model.record_v2.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_v2.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_v2.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);
}
use of org.orcid.jaxb.model.record_v2.PeerReview in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validatePeerReview_invalidPutCodeTest.
@Test(expected = InvalidPutCodeException.class)
public void validatePeerReview_invalidPutCodeTest() {
SourceEntity source = mock(SourceEntity.class);
when(source.getSourceName()).thenReturn("source name");
PeerReview pr = getPeerReview();
pr.setPutCode(1L);
activityValidator.validatePeerReview(pr, source, true, true, Visibility.PUBLIC);
}
use of org.orcid.jaxb.model.record_v2.PeerReview in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validatePeerReview_dontChangeVisibilityTest.
@Test(expected = VisibilityMismatchException.class)
public void validatePeerReview_dontChangeVisibilityTest() {
PeerReview pr = getPeerReview();
pr.setVisibility(Visibility.LIMITED);
activityValidator.validatePeerReview(pr, null, false, true, Visibility.PUBLIC);
}
Aggregations