Search in sources :

Example 41 with PeerReview

use of org.orcid.jaxb.model.record_rc4.PeerReview in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorTest method testGetPublicPeerReviewUsingToken.

// Peer review
@Test
public void testGetPublicPeerReviewUsingToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewPeerReview(ORCID, 9L);
    assertNotNull(r);
    PeerReview p = (PeerReview) r.getEntity();
    assertNotNull(p);
    assertNotNull(p.getLastModifiedDate());
    assertNotNull(p.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(9), p.getPutCode());
}
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 42 with PeerReview

use of org.orcid.jaxb.model.record_rc4.PeerReview in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_PeerReviewsTest method testDeletePeerReview.

@Test
public void testDeletePeerReview() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4443", 8L);
    assertNotNull(response);
    PeerReview review = (PeerReview) response.getEntity();
    assertNotNull(review);
    assertNotNull(review.getSubjectName());
    assertNotNull(review.getSubjectName().getTitle());
    assertEquals("Peer Review # 3", review.getSubjectName().getTitle().getContent());
    response = serviceDelegator.deletePeerReview("4444-4444-4444-4443", 8L);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
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 43 with PeerReview

use of org.orcid.jaxb.model.record_rc4.PeerReview in project ORCID-Source by ORCID.

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

Example 44 with PeerReview

use of org.orcid.jaxb.model.record_rc4.PeerReview in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_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();
}
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 45 with PeerReview

use of org.orcid.jaxb.model.record_rc4.PeerReview in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_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");
    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());
}
Also used : Response(javax.ws.rs.core.Response) WrongSourceException(org.orcid.core.exception.WrongSourceException) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) 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