Skip to content

Commit

Permalink
ImproveValidatedActivitiesCount
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Apr 4, 2024
1 parent 791d080 commit 585d8b7
Showing 1 changed file with 114 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ public void setUp() {
ReflectionTestUtils.setField(manager, "profileFundingManagerReadOnly", profileFundingManagerReadOnlyMock);

// Set peer reviews
List<PeerReviewMinimizedSummary> peerReviews = getPeerReviewSummaryList();
Mockito.when(peerReviewManagerReadOnlyMock.getPeerReviewMinimizedSummaryList(Mockito.eq(ORCID), Mockito.eq(true))).thenReturn(peerReviews);
Mockito.when(peerReviewManagerReadOnlyMock.getPeerReviewMinimizedSummaryList(Mockito.eq(ORCID), Mockito.eq(true))).thenReturn(getPeerReviewSummaryList());
ReflectionTestUtils.setField(manager, "peerReviewManagerReadOnly", peerReviewManagerReadOnlyMock);

// Set metadata
Expand Down Expand Up @@ -377,6 +376,62 @@ public void generateFundingSummaryTest() {
assertEquals(3, rs.getValidatedFunds());
}

@Test
public void generateFundingSummary_OboValidatedTest() {
RecordSummary rs = new RecordSummary();
Source s = new Source();
s.setSourceClientId(new SourceClientId(CLIENT1));
s.setAssertionOriginClientId(new SourceClientId(CLIENT1));
Fundings fundings = getFundings();
for(FundingGroup fg : fundings.getFundingGroup()) {
for(FundingSummary fs : fg.getFundingSummary()) {
fs.setSource(s);
}
}
Mockito.when(profileFundingManagerReadOnlyMock.groupFundings(Mockito.anyList(), Mockito.eq(true))).thenReturn(fundings);

manager.generateFundingSummary(rs, ORCID);
assertEquals(0, rs.getSelfAssertedFunds());
assertEquals(3, rs.getValidatedFunds());
}

@Test
public void generateFundingSummary_SelfAssertedTest() {
RecordSummary rs = new RecordSummary();
Source s = new Source();
s.setSourceOrcid(new SourceOrcid(ORCID));
Fundings fundings = getFundings();
for(FundingGroup fg : fundings.getFundingGroup()) {
for(FundingSummary fs : fg.getFundingSummary()) {
fs.setSource(s);
}
}
Mockito.when(profileFundingManagerReadOnlyMock.groupFundings(Mockito.anyList(), Mockito.eq(true))).thenReturn(fundings);

manager.generateFundingSummary(rs, ORCID);
assertEquals(3, rs.getSelfAssertedFunds());
assertEquals(0, rs.getValidatedFunds());
}

@Test
public void generateFundingSummary_OboSelfAssertedTest() {
RecordSummary rs = new RecordSummary();
Source s = new Source();
s.setSourceClientId(new SourceClientId(CLIENT1));
s.setAssertionOriginOrcid(new SourceOrcid(ORCID));
Fundings fundings = getFundings();
for(FundingGroup fg : fundings.getFundingGroup()) {
for(FundingSummary fs : fg.getFundingSummary()) {
fs.setSource(s);
}
}
Mockito.when(profileFundingManagerReadOnlyMock.groupFundings(Mockito.anyList(), Mockito.eq(true))).thenReturn(fundings);

manager.generateFundingSummary(rs, ORCID);
assertEquals(3, rs.getSelfAssertedFunds());
assertEquals(0, rs.getValidatedFunds());
}

@Test
public void generatePeerReviewSummaryTest() {
RecordSummary rs = new RecordSummary();
Expand All @@ -388,6 +443,63 @@ public void generatePeerReviewSummaryTest() {
assertEquals(16, rs.getPeerReviewsTotal());
}

@Test
public void generatePeerReviewSummary_OboValidatedTest() {
RecordSummary rs = new RecordSummary();
List<PeerReviewMinimizedSummary> peerReviews = getPeerReviewSummaryList();
for(PeerReviewMinimizedSummary pr : peerReviews) {
pr.setClientSourceId(CLIENT1);
pr.setAssertionOriginSourceId(CLIENT1);
pr.setSourceId(null);
}
Mockito.when(peerReviewManagerReadOnlyMock.getPeerReviewMinimizedSummaryList(Mockito.eq(ORCID), Mockito.eq(true))).thenReturn(peerReviews);

manager.generatePeerReviewSummary(rs, ORCID);
// Each peer review group have 1 self asserted peer review and 1 user obo asserted peer review
// So, we have 3 groups = 6 self asserted peer reviews in total
assertEquals(0, rs.getSelfAssertedPeerReviews());
assertEquals(4, rs.getPeerReviewPublicationGrants());
assertEquals(16, rs.getPeerReviewsTotal());
}

@Test
public void generatePeerReviewSummary_SelfAssertedTest() {
RecordSummary rs = new RecordSummary();
List<PeerReviewMinimizedSummary> peerReviews = getPeerReviewSummaryList();
for(PeerReviewMinimizedSummary pr : peerReviews) {
pr.setClientSourceId(null);
pr.setAssertionOriginSourceId(null);
pr.setSourceId(ORCID);
}
Mockito.when(peerReviewManagerReadOnlyMock.getPeerReviewMinimizedSummaryList(Mockito.eq(ORCID), Mockito.eq(true))).thenReturn(peerReviews);

manager.generatePeerReviewSummary(rs, ORCID);
// Each peer review group have 1 self asserted peer review and 1 user obo asserted peer review
// So, we have 3 groups = 6 self asserted peer reviews in total
assertEquals(4, rs.getSelfAssertedPeerReviews());
assertEquals(4, rs.getPeerReviewPublicationGrants());
assertEquals(16, rs.getPeerReviewsTotal());
}

@Test
public void generatePeerReviewSummary_Test() {
RecordSummary rs = new RecordSummary();
List<PeerReviewMinimizedSummary> peerReviews = getPeerReviewSummaryList();
for(PeerReviewMinimizedSummary pr : peerReviews) {
pr.setClientSourceId(CLIENT1);
pr.setAssertionOriginSourceId(ORCID);
pr.setSourceId(null);
}
Mockito.when(peerReviewManagerReadOnlyMock.getPeerReviewMinimizedSummaryList(Mockito.eq(ORCID), Mockito.eq(true))).thenReturn(peerReviews);

manager.generatePeerReviewSummary(rs, ORCID);
// Each peer review group have 1 self asserted peer review and 1 user obo asserted peer review
// So, we have 3 groups = 6 self asserted peer reviews in total
assertEquals(4, rs.getSelfAssertedPeerReviews());
assertEquals(4, rs.getPeerReviewPublicationGrants());
assertEquals(16, rs.getPeerReviewsTotal());
}

private PersonExternalIdentifiers getPersonExternalIdentifiers() {
PersonExternalIdentifiers peis = new PersonExternalIdentifiers();
PersonExternalIdentifier pei = new PersonExternalIdentifier();
Expand Down

0 comments on commit 585d8b7

Please sign in to comment.