Search in sources :

Example 76 with PeerReview

use of org.orcid.jaxb.model.record_v2.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 77 with PeerReview

use of org.orcid.jaxb.model.record_v2.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 78 with PeerReview

use of org.orcid.jaxb.model.record_v2.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 79 with PeerReview

use of org.orcid.jaxb.model.record_v2.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)

Example 80 with PeerReview

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

the class BlackBoxBaseV2Release method unmarshallFromPath.

public Object unmarshallFromPath(String path, Class<?> type) {
    try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
        Object obj = unmarshall(reader, type);
        Object result = null;
        if (Address.class.equals(type)) {
            result = (Address) obj;
        } else if (Education.class.equals(type)) {
            result = (Education) obj;
        } else if (Employment.class.equals(type)) {
            result = (Employment) obj;
        } else if (Funding.class.equals(type)) {
            result = (Funding) obj;
        } else if (Keyword.class.equals(type)) {
            result = (Keyword) obj;
        } else if (Work.class.equals(type)) {
            result = (Work) obj;
        } else if (PeerReview.class.equals(type)) {
            result = (PeerReview) obj;
        } else if (ResearcherUrl.class.equals(type)) {
            result = (ResearcherUrl) obj;
        } else if (PersonalDetails.class.equals(type)) {
            result = (PersonalDetails) obj;
        } else if (OtherName.class.equals(type)) {
            result = (OtherName) obj;
        } else if (PersonExternalIdentifier.class.equals(type)) {
            result = (PersonExternalIdentifier) obj;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) Education(org.orcid.jaxb.model.record_v2.Education) Funding(org.orcid.jaxb.model.record_v2.Funding) Work(org.orcid.jaxb.model.record_v2.Work) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) IOException(java.io.IOException)

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