use of org.orcid.jaxb.model.record_rc3.PeerReview in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_PeerReviewsTest method testUpdatePeerReview.
@Test
public void testUpdatePeerReview() {
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);
Utils.verifyLastModified(peerReview.getLastModifiedDate());
LastModifiedDate before = peerReview.getLastModifiedDate();
peerReview.setUrl(new Url("http://updated.com/url"));
peerReview.getSubjectName().getTitle().setContent("Updated Title");
response = serviceDelegator.updatePeerReview("4444-4444-4444-4447", 6L, peerReview);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 6L);
PeerReview updatedPeerReview = (PeerReview) response.getEntity();
assertNotNull(updatedPeerReview);
Utils.verifyLastModified(updatedPeerReview.getLastModifiedDate());
assertTrue(updatedPeerReview.getLastModifiedDate().after(before));
assertEquals("http://updated.com/url", updatedPeerReview.getUrl().getValue());
assertEquals("Updated Title", updatedPeerReview.getSubjectName().getTitle().getContent());
}
use of org.orcid.jaxb.model.record_rc3.PeerReview in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_PeerReviewsTest method testUpdatePeerReviewChangingVisibilityTest.
@Test(expected = VisibilityMismatchException.class)
public void testUpdatePeerReviewChangingVisibilityTest() {
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(Visibility.PRIVATE);
response = serviceDelegator.updatePeerReview("4444-4444-4444-4447", 6L, peerReview);
fail();
}
use of org.orcid.jaxb.model.record_rc3.PeerReview in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_PeerReviewsTest method testUpdatePeerReviewWhenYouAreNotTheSourceOf.
@Test
public void testUpdatePeerReviewWhenYouAreNotTheSourceOf() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 2L);
assertNotNull(response);
PeerReview peerReview = (PeerReview) response.getEntity();
assertNotNull(peerReview);
assertEquals("http://peer_review.com/2", peerReview.getUrl().getValue());
assertEquals("APP-6666666666666666", peerReview.getSource().retrieveSourcePath());
// Update the info
peerReview.setUrl(new Url("http://updated.com/url"));
peerReview.getSubjectName().getTitle().setContent("Updated Title");
peerReview.getExternalIdentifiers().getExternalIdentifier().iterator().next().setValue("different");
try {
response = serviceDelegator.updatePeerReview("4444-4444-4444-4447", 2L, peerReview);
fail();
} catch (WrongSourceException wse) {
}
response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", Long.valueOf(2));
peerReview = (PeerReview) response.getEntity();
assertNotNull(peerReview);
assertEquals("http://peer_review.com/2", peerReview.getUrl().getValue());
assertEquals("APP-6666666666666666", peerReview.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record_rc3.PeerReview in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getPeerReviewMapperFacade.
public MapperFacade getPeerReviewMapperFacade() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
ConverterFactory converterFactory = mapperFactory.getConverterFactory();
converterFactory.registerConverter("workExternalIdentifiersConverterId", new WorkExternalIDsConverter());
converterFactory.registerConverter("workExternalIdentifierConverterId", new PeerReviewWorkExternalIDConverter());
//do same as work
ClassMapBuilder<PeerReview, PeerReviewEntity> classMap = mapperFactory.classMap(PeerReview.class, PeerReviewEntity.class);
addV2CommonFields(classMap);
registerSourceConverters(mapperFactory, classMap);
classMap.field("url.value", "url");
classMap.field("organization.name", "org.name");
classMap.field("organization.address.city", "org.city");
classMap.field("organization.address.region", "org.region");
classMap.field("organization.address.country", "org.country");
classMap.field("organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier", "org.orgDisambiguated.sourceId");
classMap.field("organization.disambiguatedOrganization.disambiguationSource", "org.orgDisambiguated.sourceType");
classMap.field("groupId", "groupId");
classMap.field("subjectType", "subjectType");
classMap.field("subjectUrl.value", "subjectUrl");
classMap.field("subjectName.title.content", "subjectName");
classMap.field("subjectName.translatedTitle.content", "subjectTranslatedName");
classMap.field("subjectName.translatedTitle.languageCode", "subjectTranslatedNameLanguageCode");
classMap.field("subjectContainerName.content", "subjectContainerName");
classMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
classMap.fieldMap("subjectExternalIdentifier", "subjectExternalIdentifiersJson").converter("workExternalIdentifierConverterId").add();
classMap.register();
ClassMapBuilder<PeerReviewSummary, PeerReviewEntity> peerReviewSummaryClassMap = mapperFactory.classMap(PeerReviewSummary.class, PeerReviewEntity.class);
addV2CommonFields(peerReviewSummaryClassMap);
registerSourceConverters(mapperFactory, peerReviewSummaryClassMap);
peerReviewSummaryClassMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
peerReviewSummaryClassMap.field("organization.name", "org.name");
peerReviewSummaryClassMap.field("organization.address.city", "org.city");
peerReviewSummaryClassMap.field("organization.address.region", "org.region");
peerReviewSummaryClassMap.field("organization.address.country", "org.country");
peerReviewSummaryClassMap.field("organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier", "org.orgDisambiguated.sourceId");
peerReviewSummaryClassMap.field("organization.disambiguatedOrganization.disambiguationSource", "org.orgDisambiguated.sourceType");
peerReviewSummaryClassMap.register();
mapperFactory.classMap(FuzzyDate.class, CompletionDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
return mapperFactory.getMapperFacade();
}
use of org.orcid.jaxb.model.record_rc3.PeerReview in project ORCID-Source by ORCID.
the class JpaJaxbPeerReviewAdapterTest method testToOrgAffiliationRelationEntity.
@Test
public void testToOrgAffiliationRelationEntity() throws JAXBException {
PeerReview e = getPeerReview(true);
assertNotNull(e);
PeerReviewEntity pe = jpaJaxbPeerReviewAdapter.toPeerReviewEntity(e);
assertNotNull(pe);
//General info
assertEquals(Long.valueOf(12345), pe.getId());
assertEquals(Visibility.PRIVATE.value(), pe.getVisibility().value());
assertEquals("{\"workExternalIdentifier\":[{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"SOURCE_WORK_ID\",\"workExternalIdentifierId\":{\"content\":\"work:external-identifier-id\"}}]}", pe.getExternalIdentifiersJson());
assertEquals("reviewer", pe.getRole().value());
assertEquals("review", pe.getType().value());
assertEquals("peer-review:url", pe.getUrl());
//Dates
assertEquals(Integer.valueOf(2), pe.getCompletionDate().getDay());
assertEquals(Integer.valueOf(2), pe.getCompletionDate().getMonth());
assertEquals(Integer.valueOf(1848), pe.getCompletionDate().getYear());
// Source
assertNull(pe.getSourceId());
assertNull(pe.getClientSourceId());
assertNull(pe.getElementSourceId());
//Check org values
assertEquals("common:name", pe.getOrg().getName());
assertEquals("common:city", pe.getOrg().getCity());
assertEquals("common:region", pe.getOrg().getRegion());
assertEquals(Iso3166Country.AF.value(), pe.getOrg().getCountry().value());
assertEquals("common:disambiguated-organization-identifier", pe.getOrg().getOrgDisambiguated().getSourceId());
assertEquals("common:disambiguation-source", pe.getOrg().getOrgDisambiguated().getSourceType());
//Check subject
assertEquals("{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"DOI\",\"workExternalIdentifierId\":{\"content\":\"peer-review:subject-external-identifier-id\"}}", pe.getSubjectExternalIdentifiersJson());
assertEquals("peer-review:subject-container-name", pe.getSubjectContainerName());
assertEquals("peer-review:subject-name", pe.getSubjectName());
assertEquals("peer-review:subject-translated-name", pe.getSubjectTranslatedName());
assertEquals("en", pe.getSubjectTranslatedNameLanguageCode());
assertEquals("peer-review:subject-url", pe.getSubjectUrl());
assertEquals(WorkType.JOURNAL_ARTICLE, pe.getSubjectType());
//Check group id
assertEquals("orcid-generated:12345", pe.getGroupId());
}
Aggregations