Search in sources :

Example 86 with PeerReview

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());
}
Also used : Response(javax.ws.rs.core.Response) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 87 with PeerReview

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());
}
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 88 with PeerReview

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

Example 89 with PeerReview

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

Example 90 with PeerReview

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

Aggregations

Test (org.junit.Test)71 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)68 ClientResponse (com.sun.jersey.api.client.ClientResponse)35 Response (javax.ws.rs.core.Response)17 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)17 DBUnitTest (org.orcid.test.DBUnitTest)17 Url (org.orcid.jaxb.model.common_v2.Url)11 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)10 ArrayList (java.util.ArrayList)9 PeerReview (org.orcid.jaxb.model.record_rc1.PeerReview)9 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)8 BaseTest (org.orcid.core.BaseTest)6 Title (org.orcid.jaxb.model.common_v2.Title)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 PeerReview (org.orcid.jaxb.model.record_rc4.PeerReview)6 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)6 Funding (org.orcid.jaxb.model.record_v2.Funding)6 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)6