Search in sources :

Example 56 with PeerReview

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

the class PeerReviewManagerTest method testAddMultipleModifiesIndexingStatus.

@Test
public void testAddMultipleModifiesIndexingStatus() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    PeerReview p1 = getPeerReview("extId1");
    p1 = peerReviewManager.createPeerReview(claimedOrcid, p1, true);
    PeerReview p2 = getPeerReview("extId2");
    p2 = peerReviewManager.createPeerReview(claimedOrcid, p2, true);
    PeerReview p3 = getPeerReview("extId3");
    p3 = peerReviewManager.createPeerReview(claimedOrcid, p3, true);
    PeerReviewEntity entity1 = peerReviewDao.find(p1.getPutCode());
    PeerReviewEntity entity2 = peerReviewDao.find(p2.getPutCode());
    PeerReviewEntity entity3 = peerReviewDao.find(p3.getPutCode());
    assertNotNull(entity1.getDisplayIndex());
    assertNotNull(entity2.getDisplayIndex());
    assertNotNull(entity3.getDisplayIndex());
    assertEquals(Long.valueOf(0), entity3.getDisplayIndex());
    // Rollback all changes
    peerReviewDao.remove(entity1.getId());
    peerReviewDao.remove(entity2.getId());
    peerReviewDao.remove(entity3.getId());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 57 with PeerReview

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

the class PeerReviewManagerTest method displayIndexIsSetTo_1_FromUI.

@Test
public void displayIndexIsSetTo_1_FromUI() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    PeerReview p1 = getPeerReview("fromUI-1");
    p1 = peerReviewManager.createPeerReview(claimedOrcid, p1, false);
    PeerReviewEntity p = peerReviewDao.find(p1.getPutCode());
    assertNotNull(p);
    assertEquals(Long.valueOf(1), p.getDisplayIndex());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 58 with PeerReview

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

the class JpaJaxbPeerReviewAdapterTest method getPeerReview.

private PeerReview getPeerReview(boolean full) throws JAXBException {
    JAXBContext context = JAXBContext.newInstance(new Class[] { PeerReview.class });
    Unmarshaller unmarshaller = context.createUnmarshaller();
    String name = "/record_2.0/samples/read_samples/peer-review-2.0.xml";
    if (full) {
        name = "/record_2.0/samples/read_samples/peer-review-full-2.0.xml";
    }
    InputStream inputStream = getClass().getResourceAsStream(name);
    return (PeerReview) unmarshaller.unmarshal(inputStream);
}
Also used : InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview)

Example 59 with PeerReview

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

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

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