Search in sources :

Example 6 with PeerReviewEntity

use of org.orcid.persistence.jpa.entities.PeerReviewEntity in project ORCID-Source by ORCID.

the class PeerReviewManagerTest method displayIndexIsSetTo_0_FromAPI.

@Test
public void displayIndexIsSetTo_0_FromAPI() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    PeerReview p1 = getPeerReview("fromAPI-1");
    p1 = peerReviewManager.createPeerReview(claimedOrcid, p1, true);
    PeerReviewEntity p = peerReviewDao.find(p1.getPutCode());
    assertNotNull(91);
    assertEquals(Long.valueOf(0), 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 7 with PeerReviewEntity

use of org.orcid.persistence.jpa.entities.PeerReviewEntity 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 8 with PeerReviewEntity

use of org.orcid.persistence.jpa.entities.PeerReviewEntity in project ORCID-Source by ORCID.

the class JpaJaxbPeerReviewAdapterTest method fromOrgAffiliationRelationEntityToEducation.

@Test
public void fromOrgAffiliationRelationEntityToEducation() {
    PeerReviewEntity entity = getPeerReviewEntity();
    assertNotNull(entity);
    PeerReview peerReview = jpaJaxbPeerReviewAdapter.toPeerReview(entity);
    assertNotNull(peerReview);
    assertEquals(Long.valueOf(12345), peerReview.getPutCode());
    assertEquals("private", peerReview.getVisibility().value());
    assertEquals("orcid-generated:12345", peerReview.getGroupId());
    //Subject
    assertNotNull(peerReview.getSubjectExternalIdentifier());
    assertEquals("peer-review:subject-external-identifier-id", peerReview.getSubjectExternalIdentifier().getValue());
    assertEquals("source-work-id", peerReview.getSubjectExternalIdentifier().getType());
    assertEquals("peer-review:subject-container-name", peerReview.getSubjectContainerName().getContent());
    assertEquals("peer-review:subject-name", peerReview.getSubjectName().getTitle().getContent());
    assertEquals("peer-review:subject-translated-name", peerReview.getSubjectName().getTranslatedTitle().getContent());
    assertEquals("en", peerReview.getSubjectName().getTranslatedTitle().getLanguageCode());
    assertEquals(WorkType.BOOK_REVIEW.value(), peerReview.getSubjectType().value());
    assertEquals("peer-review:subject-url", peerReview.getSubjectUrl().getValue());
    //Fields
    assertNotNull(peerReview.getExternalIdentifiers());
    assertNotNull(peerReview.getExternalIdentifiers().getExternalIdentifier());
    assertEquals(1, peerReview.getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("peer-review:external-identifier-id", peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("source-work-id", peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals(Role.MEMBER.value(), peerReview.getRole().value());
    assertEquals(PeerReviewType.EVALUATION.value(), peerReview.getType().value());
    assertEquals("peer-review:url", peerReview.getUrl().getValue());
    assertNotNull(peerReview.getCompletionDate());
    assertEquals("2015", peerReview.getCompletionDate().getYear().getValue());
    assertEquals("01", peerReview.getCompletionDate().getMonth().getValue());
    assertEquals("01", peerReview.getCompletionDate().getDay().getValue());
    assertNotNull(peerReview.getOrganization());
    assertEquals("org:name", peerReview.getOrganization().getName());
    assertNotNull(peerReview.getOrganization().getAddress());
    assertEquals("org:city", peerReview.getOrganization().getAddress().getCity());
    assertEquals("org:region", peerReview.getOrganization().getAddress().getRegion());
    assertNotNull(peerReview.getSource());
    assertEquals("APP-000000001", peerReview.getSource().retrieveSourcePath());
}
Also used : PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Example 9 with PeerReviewEntity

use of org.orcid.persistence.jpa.entities.PeerReviewEntity in project ORCID-Source by ORCID.

the class JpaJaxbPeerReviewAdapterTest method fromPeerReviewEntityToPeerReviewSummary.

@Test
public void fromPeerReviewEntityToPeerReviewSummary() {
    PeerReviewEntity entity = getPeerReviewEntity();
    assertNotNull(entity);
    PeerReviewSummary peerReviewSummary = jpaJaxbPeerReviewAdapter.toPeerReviewSummary(entity);
    assertNotNull(peerReviewSummary);
    assertEquals(Long.valueOf(12345), peerReviewSummary.getPutCode());
    assertEquals("private", peerReviewSummary.getVisibility().value());
    assertNotNull(peerReviewSummary.getCompletionDate());
    assertEquals("2015", peerReviewSummary.getCompletionDate().getYear().getValue());
    assertEquals("01", peerReviewSummary.getCompletionDate().getMonth().getValue());
    assertEquals("01", peerReviewSummary.getCompletionDate().getDay().getValue());
    assertNotNull(peerReviewSummary.getExternalIdentifiers());
    assertNotNull(peerReviewSummary.getExternalIdentifiers().getExternalIdentifier());
    assertEquals(1, peerReviewSummary.getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("peer-review:external-identifier-id", peerReviewSummary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("source-work-id", peerReviewSummary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
    assertNotNull(peerReviewSummary.getSource());
    assertEquals("APP-000000001", peerReviewSummary.getSource().retrieveSourcePath());
}
Also used : PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) Test(org.junit.Test)

Example 10 with PeerReviewEntity

use of org.orcid.persistence.jpa.entities.PeerReviewEntity in project ORCID-Source by ORCID.

the class JpaJaxbPeerReviewAdapterTest method getPeerReviewEntity.

private PeerReviewEntity getPeerReviewEntity() {
    OrgEntity orgEntity = new OrgEntity();
    orgEntity.setCity("org:city");
    orgEntity.setCountry(org.orcid.jaxb.model.message.Iso3166Country.US);
    orgEntity.setName("org:name");
    orgEntity.setRegion("org:region");
    orgEntity.setUrl("org:url");
    orgEntity.setSource(new SourceEntity("APP-000000001"));
    PeerReviewEntity result = new PeerReviewEntity();
    result.setOrg(orgEntity);
    result.setCompletionDate(new CompletionDateEntity(2015, 1, 1));
    result.setExternalIdentifiersJson("{\"workExternalIdentifier\":[{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"SOURCE_WORK_ID\",\"workExternalIdentifierId\":{\"content\":\"peer-review:external-identifier-id\"}}]}");
    result.setProfile(new ProfileEntity("0000-0001-0002-0003"));
    result.setRole(Role.MEMBER);
    result.setType(PeerReviewType.EVALUATION);
    result.setUrl("peer-review:url");
    result.setSubjectExternalIdentifiersJson("{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"SOURCE_WORK_ID\",\"workExternalIdentifierId\":{\"content\":\"peer-review:subject-external-identifier-id\"}}");
    result.setSubjectContainerName("peer-review:subject-container-name");
    result.setSubjectName("peer-review:subject-name");
    result.setSubjectTranslatedName("peer-review:subject-translated-name");
    result.setSubjectTranslatedNameLanguageCode("en");
    result.setSubjectUrl("peer-review:subject-url");
    result.setSubjectType(WorkType.BOOK_REVIEW);
    result.setVisibility(Visibility.PRIVATE);
    result.setClientSourceId("APP-000000001");
    result.setGroupId("orcid-generated:12345");
    result.setId(12345L);
    return result;
}
Also used : CompletionDateEntity(org.orcid.persistence.jpa.entities.CompletionDateEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity)

Aggregations

PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)13 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)8 Test (org.junit.Test)6 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)6 BaseTest (org.orcid.core.BaseTest)3 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)3 OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)3 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)3 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)2 Query (javax.persistence.Query)1 TypedQuery (javax.persistence.TypedQuery)1 MapperFactory (ma.glasnost.orika.MapperFactory)1 ConverterFactory (ma.glasnost.orika.converter.ConverterFactory)1 DefaultMapperFactory (ma.glasnost.orika.impl.DefaultMapperFactory)1 PeerReviewWorkExternalIDConverter (org.orcid.core.adapter.impl.jsonidentifiers.PeerReviewWorkExternalIDConverter)1 WorkExternalIDsConverter (org.orcid.core.adapter.impl.jsonidentifiers.WorkExternalIDsConverter)1 ApplicationException (org.orcid.core.exception.ApplicationException)1 CreditName (org.orcid.jaxb.model.common_v2.CreditName)1 Visibility (org.orcid.jaxb.model.common_v2.Visibility)1 Item (org.orcid.jaxb.model.notification.permission_v2.Item)1