Search in sources :

Example 66 with PeerReview

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());
}
Also used : Response(javax.ws.rs.core.Response) List(java.util.List) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) OrcidDuplicatedActivityException(org.orcid.core.exception.OrcidDuplicatedActivityException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 67 with PeerReview

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);
}
Also used : PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Example 68 with PeerReview

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);
}
Also used : PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Example 69 with PeerReview

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);
}
Also used : SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Example 70 with PeerReview

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);
}
Also used : PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)74 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)66 ClientResponse (com.sun.jersey.api.client.ClientResponse)35 Response (javax.ws.rs.core.Response)18 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)18 DBUnitTest (org.orcid.test.DBUnitTest)18 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)11 Url (org.orcid.jaxb.model.common_v2.Url)10 Funding (org.orcid.jaxb.model.record_v2.Funding)10 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)10 PeerReview (org.orcid.jaxb.model.record_rc1.PeerReview)9 Education (org.orcid.jaxb.model.record_v2.Education)9 Work (org.orcid.jaxb.model.record_v2.Work)9 OtherName (org.orcid.jaxb.model.record_v2.OtherName)8 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)8 ArrayList (java.util.ArrayList)7 BaseTest (org.orcid.core.BaseTest)6 WorkExternalIdentifier (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifier)6 WorkExternalIdentifierId (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifierId)6 PeerReview (org.orcid.jaxb.model.record_rc3.PeerReview)6