Search in sources :

Example 71 with PeerReview

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

the class MemberV2ApiServiceDelegator_PeerReviewsTest method testViewPeerReviewReadPublic.

@Test
public void testViewPeerReviewReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 2L);
    PeerReview element = (PeerReview) r.getEntity();
    assertNotNull(element);
    assertEquals("/4444-4444-4444-4447/peer-review/2", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
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 72 with PeerReview

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

the class MemberV2ApiServiceDelegator_PeerReviewsTest method testUpdatePeerReviewLeavingVisibilityNullTest.

@Test
public void testUpdatePeerReviewLeavingVisibilityNullTest() {
    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(null);
    response = serviceDelegator.updatePeerReview("4444-4444-4444-4447", 6L, peerReview);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    peerReview = (PeerReview) response.getEntity();
    assertNotNull(peerReview);
    assertEquals(Visibility.PUBLIC, peerReview.getVisibility());
}
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 73 with PeerReview

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

the class MemberV2ApiServiceDelegator_PeerReviewsTest method testViewPublicPeerReview.

@Test
public void testViewPublicPeerReview() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4446", 1L);
    assertNotNull(response);
    PeerReview peerReview = (PeerReview) response.getEntity();
    assertNotNull(peerReview);
    assertEquals("/4444-4444-4444-4446/peer-review/1", peerReview.getPath());
    Utils.verifyLastModified(peerReview.getLastModifiedDate());
    assertEquals(Long.valueOf(1L), 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#1", peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("reviewer", peerReview.getRole().value());
    assertEquals("APP-5555555555555555", peerReview.getSource().retrieveSourcePath());
    assertEquals("public", peerReview.getVisibility().value());
    assertEquals("review", peerReview.getType().value());
    assertEquals("http://peer_review.com", peerReview.getUrl().getValue());
    assertEquals("Peer Review # 1", peerReview.getSubjectName().getTitle().getContent());
    assertEquals("es", peerReview.getSubjectName().getTranslatedTitle().getLanguageCode());
    assertEquals("artistic-performance", peerReview.getSubjectType().value());
    assertEquals("http://work.com", peerReview.getSubjectUrl().getValue());
    assertEquals("Peer Review # 1 container name", peerReview.getSubjectContainerName().getContent());
    assertEquals("peer-review:subject-external-identifier-id#1", peerReview.getSubjectExternalIdentifier().getValue());
    assertEquals("agr", peerReview.getSubjectExternalIdentifier().getType());
    assertEquals("issn:0000001", 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 74 with PeerReview

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

the class MemberV2ApiServiceDelegator_PeerReviewsTest method testAddPeerReviewDuplicateFails.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testAddPeerReviewDuplicateFails() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 6L);
    assertNotNull(response);
    PeerReview peerReview = (PeerReview) response.getEntity();
    assertNotNull(peerReview);
    peerReview.setUrl(new Url("http://updated.com/url"));
    peerReview.getSubjectName().getTitle().setContent("Updated Title");
    peerReview.setPutCode(null);
    response = serviceDelegator.createPeerReview("4444-4444-4444-4447", peerReview);
}
Also used : Response(javax.ws.rs.core.Response) 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 75 with PeerReview

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

the class MemberV2Test method testUpdatePeerReviewWithProfileCreationTokenWhenClaimedAndNotSource.

@Test
public void testUpdatePeerReviewWithProfileCreationTokenWhenClaimedAndNotSource() throws JSONException, InterruptedException, URISyntaxException {
    long time = System.currentTimeMillis();
    PeerReview peerReviewToCreate = (PeerReview) unmarshallFromPath("/record_2.0_rc4/samples/peer-review-2.0_rc4.xml", PeerReview.class);
    peerReviewToCreate.setPutCode(null);
    peerReviewToCreate.setGroupId(groupRecords.get(0).getGroupId());
    peerReviewToCreate.setVisibility(Visibility.PUBLIC);
    peerReviewToCreate.getExternalIdentifiers().getExternalIdentifier().clear();
    ExternalID wExtId = new ExternalID();
    wExtId.setValue("Work Id " + time);
    wExtId.setType(WorkExternalIdentifierType.AGR.value());
    wExtId.setRelationship(Relationship.SELF);
    peerReviewToCreate.getExternalIdentifiers().getExternalIdentifier().add(wExtId);
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV2ApiClient.createPeerReviewXml(this.getUser1OrcidId(), peerReviewToCreate, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    String locationPath = postResponse.getLocation().getPath();
    assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v2.0_rc4/" + this.getUser1OrcidId() + "/peer-review/\\d+"));
    ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
    PeerReview gotPeerReview = getResponse.getEntity(PeerReview.class);
    assertEquals("peer-review:subject-name", gotPeerReview.getSubjectName().getTitle().getContent());
    gotPeerReview.getSubjectName().getTitle().setContent("updated title");
    String profileCreateToken = oauthHelper.getClientCredentialsAccessToken(this.getClient2ClientId(), this.getClient2ClientSecret(), ScopePathType.ORCID_PROFILE_CREATE);
    ClientResponse putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), profileCreateToken, gotPeerReview);
    assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
    ClientResponse getAfterUpdateResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
    PeerReview gotAfterUpdatePeerReview = getAfterUpdateResponse.getEntity(PeerReview.class);
    assertEquals("peer-review:subject-name", gotAfterUpdatePeerReview.getSubjectName().getTitle().getContent());
    ClientResponse deleteResponse = memberV2ApiClient.deletePeerReviewXml(this.getUser1OrcidId(), gotAfterUpdatePeerReview.getPutCode(), accessToken);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ExternalID(org.orcid.jaxb.model.record_rc4.ExternalID) PeerReview(org.orcid.jaxb.model.record_rc4.PeerReview) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)72 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)66 ClientResponse (com.sun.jersey.api.client.ClientResponse)35 Response (javax.ws.rs.core.Response)17 DBUnitTest (org.orcid.test.DBUnitTest)17 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)16 Url (org.orcid.jaxb.model.common_v2.Url)10 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)10 PeerReview (org.orcid.jaxb.model.record_rc1.PeerReview)9 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)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 PeerReview (org.orcid.jaxb.model.record_rc4.PeerReview)6 Funding (org.orcid.jaxb.model.record_v2.Funding)6 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)6 Title (org.orcid.jaxb.model.common_v2.Title)5 Education (org.orcid.jaxb.model.record_v2.Education)5