Search in sources :

Example 56 with PeerReview

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

the class MemberV2Test method testPeerReviewMustHaveAtLeastOneExtId.

@Test
public void testPeerReviewMustHaveAtLeastOneExtId() throws JSONException, InterruptedException, URISyntaxException {
    PeerReview peerReview = (PeerReview) unmarshallFromPath("/record_2.0_rc1/samples/peer-review-2.0_rc1.xml", PeerReview.class);
    peerReview.setPutCode(null);
    peerReview.setGroupId(groupRecords.get(0).getGroupId());
    peerReview.getExternalIdentifiers().getExternalIdentifier().clear();
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV2ApiClient.createPeerReviewXml(this.getUser1OrcidId(), peerReview, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), postResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) PeerReview(org.orcid.jaxb.model.record_rc1.PeerReview) Test(org.junit.Test)

Example 57 with PeerReview

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

the class PublicV2Test method checkPeerReview.

public void checkPeerReview(String readPublicToken) throws JSONException, InterruptedException, URISyntaxException {
    PeerReview peerReviewToCreate = (PeerReview) unmarshallFromPath("/record_2.0_rc1/samples/peer-review-2.0_rc1.xml", PeerReview.class);
    peerReviewToCreate.setPutCode(null);
    peerReviewToCreate.setGroupId(groupRecords.get(0).getGroupId());
    peerReviewToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PUBLIC);
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV2ApiClient.createPeerReviewXml(getUser1OrcidId(), peerReviewToCreate, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    String path = postResponse.getLocation().getPath();
    String putCode = path.substring(path.lastIndexOf('/') + 1, path.length());
    ClientResponse getPeerReviewResponse = null;
    if (readPublicToken != null) {
        getPeerReviewResponse = publicV2ApiClient.viewPeerReviewXml(getUser1OrcidId(), putCode, readPublicToken);
    } else {
        getPeerReviewResponse = publicV2ApiClient.viewPeerReviewXml(getUser1OrcidId(), putCode);
    }
    assertNotNull(getPeerReviewResponse);
    checkResponse(getPeerReviewResponse);
    PeerReview peerReview = getPeerReviewResponse.getEntity(PeerReview.class);
    assertNotNull(peerReview);
    assertEquals("peer-review:url", peerReview.getUrl().getValue());
    ClientResponse getPeerReviewSummaryResponse = publicV2ApiClient.viewPeerReviewSummaryXml(getUser1OrcidId(), putCode);
    if (readPublicToken != null) {
        getPeerReviewSummaryResponse = publicV2ApiClient.viewPeerReviewSummaryXml(getUser1OrcidId(), putCode, readPublicToken);
    } else {
        getPeerReviewSummaryResponse = publicV2ApiClient.viewPeerReviewSummaryXml(getUser1OrcidId(), putCode);
    }
    assertNotNull(getPeerReviewSummaryResponse);
    checkResponse(getPeerReviewSummaryResponse);
    PeerReviewSummary summary = getPeerReviewSummaryResponse.getEntity(PeerReviewSummary.class);
    assertNotNull(summary);
    assertEquals("1848", summary.getCompletionDate().getYear().getValue());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) PeerReviewSummary(org.orcid.jaxb.model.record.summary_rc1.PeerReviewSummary) PeerReview(org.orcid.jaxb.model.record_rc1.PeerReview)

Example 58 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/samples/read_samples/peer-review-2.0.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/" + 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_v2.ExternalID) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Example 59 with PeerReview

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

the class MemberV2ApiServiceDelegator_PeerReviewsTest method testViewPrivatePeerReview.

@Test
public void testViewPrivatePeerReview() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4446", 4L);
    assertNotNull(response);
    PeerReview peerReview = (PeerReview) response.getEntity();
    assertNotNull(peerReview);
    assertEquals("/4444-4444-4444-4446/peer-review/4", peerReview.getPath());
    Utils.verifyLastModified(peerReview.getLastModifiedDate());
    assertEquals(Long.valueOf(4L), 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#3", peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("private", peerReview.getVisibility().value());
    assertEquals("issn:0000003", 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 60 with PeerReview

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

the class MemberV2ApiServiceDelegator_PeerReviewsTest method testAddPeerReview.

@Test
public void testAddPeerReview() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4444", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewActivities("4444-4444-4444-4444");
    assertNotNull(response);
    ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    assertNotNull(summary.getPeerReviews());
    assertNotNull(summary.getPeerReviews().getPeerReviewGroup());
    assertEquals(1, summary.getPeerReviews().getPeerReviewGroup().size());
    assertNotNull(summary.getPeerReviews().getPeerReviewGroup().get(0));
    assertNotNull(summary.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary());
    assertNotNull(summary.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0));
    assertEquals("issn:0000001", summary.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getGroupId());
    PeerReview peerReview = Utils.getPeerReview();
    response = serviceDelegator.createPeerReview("4444-4444-4444-4444", peerReview);
    assertNotNull(response);
    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)));
    response = serviceDelegator.viewActivities("4444-4444-4444-4444");
    assertNotNull(response);
    summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    Utils.verifyLastModified(summary.getLastModifiedDate());
    assertNotNull(summary.getPeerReviews());
    Utils.verifyLastModified(summary.getLastModifiedDate());
    assertNotNull(summary.getPeerReviews().getPeerReviewGroup());
    assertEquals(2, summary.getPeerReviews().getPeerReviewGroup().size());
    boolean haveOld = false;
    boolean haveNew = false;
    for (PeerReviewGroup group : summary.getPeerReviews().getPeerReviewGroup()) {
        Utils.verifyLastModified(group.getLastModifiedDate());
        Utils.verifyLastModified(group.getPeerReviewSummary().get(0).getLastModifiedDate());
        if ("issn:0000001".equals(group.getPeerReviewSummary().get(0).getGroupId())) {
            haveOld = true;
        } else {
            assertEquals("issn:0000003", group.getPeerReviewSummary().get(0).getGroupId());
            haveNew = true;
        }
    }
    assertTrue(haveOld);
    assertTrue(haveNew);
    // Delete the new so it doesn't affect other tests
    serviceDelegator.deletePeerReview("4444-4444-4444-4444", putCode);
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) List(java.util.List) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) 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