Skip to content

Commit

Permalink
Email domain fixes + fix for failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Camelia-Orcid committed Sep 16, 2024
1 parent d50e10a commit 8598627
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.orcid.pojo.PeerReviewMinimizedSummary;
import org.orcid.pojo.ajaxForm.Date;
import org.orcid.pojo.summary.AffiliationSummary;
import org.orcid.pojo.summary.EmailDomainSummary;
import org.orcid.pojo.summary.ExternalIdentifiersSummary;
import org.orcid.pojo.summary.RecordSummaryPojo;
import org.orcid.utils.DateUtils;
Expand Down Expand Up @@ -278,6 +279,20 @@ public RecordSummaryPojo getRecordSummaryPojo(String orcid) {
pojo.setValidatedResearchResources(recordSummary.getResearchResources().getValidatedCount());
}

if (recordSummary.getEmailDomains() != null) {
List<EmailDomainSummary> emailDomains = new ArrayList<EmailDomainSummary>();
if (recordSummary.getEmailDomains() != null && recordSummary.getEmailDomains().getEmailDomains() != null) {
for (EmailDomain ed : recordSummary.getEmailDomains().getEmailDomains()) {
EmailDomainSummary eds = new EmailDomainSummary();
eds.setValue(ed.getValue());
eds.setCreatedDate(ed.getCreatedDate().toFuzzyDate().toString());
eds.setLastModified(ed.getLastModified().toFuzzyDate().toString());
}
}
pojo.setEmailDomains(emailDomains);
pojo.setEmailDomainsCount(recordSummary.getEmailDomains().getCount());
}

return pojo;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package org.orcid.pojo.summary;

import java.util.Date;

import org.orcid.persistence.jpa.entities.ProfileEmailDomainEntity;
import org.orcid.pojo.ajaxForm.PojoUtil;

public class EmailDomainSummary {
private String value;
private Date createdDate;
private Date lastModified;
private String createdDate;
private String lastModified;

public String getValue() {
return value;
Expand All @@ -18,19 +16,19 @@ public void setValue(String value) {
this.value = value;
}

public Date getCreatedDate() {
public String getCreatedDate() {
return createdDate;
}

public void setCreatedDate(Date createdDate) {
public void setCreatedDate(String createdDate) {
this.createdDate = createdDate;
}

public Date getLastModified() {
public String getLastModified() {
return lastModified;
}

public void setLastModified(Date lastModified) {
public void setLastModified(String lastModified) {
this.lastModified = lastModified;
}

Expand All @@ -44,11 +42,11 @@ public static EmailDomainSummary valueOf(ProfileEmailDomainEntity pem) {
}

if (pem.getDateCreated() != null) {
form.setCreatedDate(pem.getDateCreated());
form.setCreatedDate(org.orcid.pojo.ajaxForm.Date.valueOf(pem.getDateCreated()).toFuzzyDate().toString());
}

if (pem.getLastModified() !=null) {
form.setLastModified(pem.getLastModified());
form.setLastModified(org.orcid.pojo.ajaxForm.Date.valueOf(pem.getLastModified()).toFuzzyDate().toString());
}
}
return form;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
import org.orcid.core.manager.v3.read_only.AffiliationsManagerReadOnly;
import org.orcid.core.manager.v3.read_only.ExternalIdentifierManagerReadOnly;
import org.orcid.core.manager.v3.read_only.PeerReviewManagerReadOnly;
import org.orcid.core.manager.v3.read_only.ProfileEmailDomainManagerReadOnly;
import org.orcid.core.manager.v3.read_only.ProfileFundingManagerReadOnly;
import org.orcid.core.manager.v3.read_only.RecordManagerReadOnly;
import org.orcid.core.manager.v3.read_only.RecordNameManagerReadOnly;
import org.orcid.core.manager.v3.read_only.ResearchResourceManagerReadOnly;
import org.orcid.core.model.EmailDomains;
import org.orcid.core.model.ProfessionalActivity;
import org.orcid.core.model.RecordSummary;
import org.orcid.jaxb.model.v3.release.common.CreatedDate;
Expand Down Expand Up @@ -63,10 +65,13 @@
import org.orcid.jaxb.model.v3.release.record.summary.InvitedPositionSummary;
import org.orcid.jaxb.model.v3.release.record.summary.MembershipSummary;
import org.orcid.jaxb.model.v3.release.record.summary.QualificationSummary;
import org.orcid.jaxb.model.v3.release.record.summary.ResearchResourceSummary;
import org.orcid.jaxb.model.v3.release.record.summary.ServiceSummary;
import org.orcid.jaxb.model.v3.release.record.summary.WorkGroup;
import org.orcid.jaxb.model.v3.release.record.summary.WorkSummary;
import org.orcid.jaxb.model.v3.release.record.summary.Works;
import org.orcid.jaxb.model.v3.release.record.summary.ResearchResources;
import org.orcid.persistence.jpa.entities.ProfileEmailDomainEntity;
import org.orcid.persistence.jpa.entities.ProfileEntity;
import org.orcid.pojo.PeerReviewMinimizedSummary;
import org.orcid.pojo.summary.RecordSummaryPojo;
Expand Down Expand Up @@ -107,7 +112,10 @@ public class SummaryManagerTest {
private WorksCacheManager worksCacheManagerMock;

@Mock
private ResearchResourceManagerReadOnly researchResourceManagerReadOnly;
private ResearchResourceManagerReadOnly researchResourceManagerReadOnlyMock;

@Mock
private ProfileEmailDomainManagerReadOnly profileEmailDomainManagerReadOnlyMock;

@Before
public void setUp() {
Expand Down Expand Up @@ -148,7 +156,20 @@ public void setUp() {
// Set peer reviews
Mockito.when(peerReviewManagerReadOnlyMock.getPeerReviewMinimizedSummaryList(Mockito.eq(ORCID), Mockito.eq(true))).thenReturn(getPeerReviewSummaryList());
ReflectionTestUtils.setField(manager, "peerReviewManagerReadOnly", peerReviewManagerReadOnlyMock);


// Set ResearchResources
ResearchResources researchResources = getResearchResources();
Mockito.when(researchResourceManagerReadOnlyMock.getResearchResourceSummaryList(Mockito.eq(ORCID))).thenReturn(new ArrayList<ResearchResourceSummary>());
Mockito.when(researchResourceManagerReadOnlyMock.groupResearchResources(Mockito.anyList(), Mockito.eq(true))).thenReturn(researchResources);
ReflectionTestUtils.setField(manager, "researchResourceManagerReadOnly", researchResourceManagerReadOnlyMock);

// Set EmailDomains
EmailDomains emailDomains = getEmailDomains();
Mockito.when(profileEmailDomainManagerReadOnlyMock.getPublicEmailDomains(Mockito.eq(ORCID))).thenReturn(new ArrayList<ProfileEmailDomainEntity>());
ReflectionTestUtils.setField(manager, "profileEmailDomainManagerReadOnly", profileEmailDomainManagerReadOnlyMock);


// Set metadata
OrcidIdentifier oi = new OrcidIdentifier();
oi.setUri("https://test.orcid.org/0000-0000-0000-0000");
Expand Down Expand Up @@ -579,6 +600,20 @@ private PersonExternalIdentifiers getPersonExternalIdentifiers() {
peis.getExternalIdentifiers().add(pei);
return peis;
}

private ResearchResources getResearchResources() {
ResearchResources researchResources = new ResearchResources();

return researchResources;
}

private EmailDomains getEmailDomains() {
EmailDomains emailDomains = new EmailDomains();

return emailDomains;
}



private List<AffiliationGroup<AffiliationSummary>> getAffiliations(AffiliationType affiliationType) {
List<AffiliationGroup<AffiliationSummary>> affiliationGroups = new ArrayList<>();
Expand Down

0 comments on commit 8598627

Please sign in to comment.