Skip to content

Commit

Permalink
Fixing unit tests on members API
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Jan 23, 2023
1 parent 6db49f6 commit c329af6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.orcid.test.DBUnitTest;
import org.orcid.test.helper.Utils;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.persistence.NoResultException;
Expand Down Expand Up @@ -45,7 +43,9 @@
import org.orcid.jaxb.model.record_v2.ResearcherUrl;
import org.orcid.jaxb.model.record_v2.Work;
import org.orcid.jaxb.model.record_v2.WorkBulk;
import org.orcid.test.DBUnitTest;
import org.orcid.test.OrcidJUnit4ClassRunner;
import org.orcid.test.helper.Utils;
import org.springframework.test.context.ContextConfiguration;

@RunWith(OrcidJUnit4ClassRunner.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.orcid.jaxb.model.record_v2.PeerReview;
import org.orcid.jaxb.model.record_v2.PeerReviewType;
import org.orcid.jaxb.model.record_v2.PersonExternalIdentifier;
import org.orcid.jaxb.model.record_v2.Relationship;
import org.orcid.jaxb.model.record_v2.ResearcherUrl;
import org.orcid.jaxb.model.record_v2.Role;
import org.orcid.jaxb.model.record_v2.Work;
Expand Down Expand Up @@ -568,6 +569,7 @@ public void testAddPeerReviewWithSameExtIdValueButDifferentExtIdType() {
wei1.setRelationship(null);
wei1.setValue("same_but_different_type");
wei1.setType(WorkExternalIdentifierType.DOI.value());
wei1.setRelationship(Relationship.SELF);
weis1.getExternalIdentifier().add(wei1);
peerReview1.setExternalIdentifiers(weis1);
peerReview1.setGroupId("issn:0000-0003");
Expand All @@ -593,6 +595,7 @@ public void testAddPeerReviewWithSameExtIdValueButDifferentExtIdType() {
wei2.setValue("same_but_different_type"); // Same value
wei2.setType(WorkExternalIdentifierType.ARXIV.value()); // But different
// type
wei2.setRelationship(Relationship.SELF);
weis2.getExternalIdentifier().add(wei2);
peerReview2.setExternalIdentifiers(weis2);
peerReview2.setGroupId("issn:0000-0003");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ public static PersonExternalIdentifier getPersonExternalIdentifier() {
newExtId.setType("new-common-name");
newExtId.setValue("new-reference");
newExtId.setUrl(new Url("http://newUrl.com"));
newExtId.setRelationship(Relationship.SELF);
newExtId.setVisibility(Visibility.LIMITED);
return newExtId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public PeerReview updatePeerReview(String orcid, PeerReview peerReview, boolean
String existingSourceId = existingEntity.getSourceId();
String existingClientSourceId = existingEntity.getClientSourceId();

orcidSecurityManager.checkSource(existingEntity);

// If request comes from the API perform validations
if (isApiRequest) {
activityValidator.validatePeerReview(peerReview, sourceEntity, false, isApiRequest, Visibility.valueOf(originalVisibility));
Expand All @@ -156,9 +158,7 @@ public PeerReview updatePeerReview(String orcid, PeerReview peerReview, boolean
// check vocab of external identifiers
externalIDValidator.validateWorkOrPeerReview(peerReview.getExternalIdentifiers());
externalIDValidator.validateWorkOrPeerReview(peerReview.getSubjectExternalIdentifier());
}

orcidSecurityManager.checkSource(existingEntity);
}

jpaJaxbPeerReviewAdapter.toPeerReviewEntity(peerReview, existingEntity);
existingEntity.setVisibility(originalVisibility);
Expand Down
4 changes: 2 additions & 2 deletions orcid-test/src/main/resources/data/PeerReviewEntityData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<peer_review
id="6"
orcid="4444-4444-4444-4447"
external_identifiers_json="{&quot;workExternalIdentifier&quot;:[{&quot;workExternalIdentifierType&quot;:&quot;AGR&quot;,&quot;workExternalIdentifierId&quot;:{&quot;content&quot;:&quot;work:external-identifier-id#2&quot;}}]}"
external_identifiers_json="{&quot;workExternalIdentifier&quot;:[{&quot;workExternalIdentifierType&quot;:&quot;AGR&quot;,&quot;relationship&quot;:&quot;self&quot;,&quot;workExternalIdentifierId&quot;:{&quot;content&quot;:&quot;work:external-identifier-id#2&quot;}}]}"
org_id="4"
peer_review_role="REVIEWER"
peer_review_type="REVIEW"
Expand All @@ -138,7 +138,7 @@
url="http://peer_review.com/3"
visibility="PUBLIC"
group_id="issn:0000-0003"
subject_external_identifiers_json="{&quot;workExternalIdentifierType&quot;:&quot;AGR&quot;,&quot;workExternalIdentifierId&quot;:{&quot;content&quot;:&quot;peer-review:subject-external-identifier-id#3&quot;}}"
subject_external_identifiers_json="{&quot;workExternalIdentifierType&quot;:&quot;AGR&quot;,&quot;relationship&quot;:&quot;self&quot;,&quot;workExternalIdentifierId&quot;:{&quot;content&quot;:&quot;peer-review:subject-external-identifier-id#3&quot;}}"
subject_name="Peer Review # 3"
subject_type="ARTISTIC_PERFORMANCE"
subject_translated_name="Peer Review # 3 translated name"
Expand Down

0 comments on commit c329af6

Please sign in to comment.