Skip to content

Commit

Permalink
Added the new summaries to the record marshalling test
Browse files Browse the repository at this point in the history
  • Loading branch information
Camelia-Orcid committed Sep 16, 2024
1 parent 6b71189 commit 07bc96c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public void setEmailDomains(EmailDomains emailDomains) {
@Override
public int hashCode() {
return Objects.hash(createdDate, creditName, employments, externalIdentifiers, fundings, lastModifiedDate, orcidIdentifier, orcidUrlManager, peerReviews,
professionalActivities, works, educationQualifications, researchResources, emailDomains);
professionalActivities, works, emailDomains, educationQualifications, researchResources );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.orcid.jaxb.model.v3.release.common.Month;
import org.orcid.jaxb.model.v3.release.common.OrcidIdentifier;
import org.orcid.jaxb.model.v3.release.common.Year;
import org.orcid.pojo.ajaxForm.Date;
import org.orcid.utils.DateUtils;

public class RecordSummaryMarshallingTest {
Expand All @@ -29,7 +30,6 @@ public void marshallingTest() throws JAXBException, IOException {
JAXBContext context = JAXBContext.newInstance(new Class[] { RecordSummary.class });
Marshaller marshaller = context.createMarshaller();
String expectedText = IOUtils.toString(getClass().getResourceAsStream("summary-3.0.xml"), StandardCharsets.UTF_8);

RecordSummary recordSummary = getRecordSummary();
StringWriter stringWriter = new StringWriter();
marshaller.marshal(recordSummary, stringWriter);
Expand Down Expand Up @@ -93,12 +93,25 @@ private RecordSummary getRecordSummary() {
peerReviews.setTotal(6);
record.setPeerReviews(peerReviews);

//Set education/qualifications

//Set research resources

//Set email domains
EmailDomains emailDomains = new EmailDomains();
emailDomains.setCount(4);
emailDomains.setEmailDomains(new ArrayList<EmailDomain>());
emailDomains.getEmailDomains().add(getEmailDomain("sometrusted.org", getEmailDomainCreatedDate(), getEmailDomainLastModified()));
record.setEmailDomains(emailDomains);

//Set education/qualifications
EducationQualifications educationQualifications = new EducationQualifications();
educationQualifications.setCount(6);
educationQualifications.setEducationQualifications(new ArrayList<EducationQualification>());
educationQualifications.getEducationQualifications().add(getEducationQualification(1, "Org # 1", "Fake role title", "https://test.orcid.org/", "education", false));
record.setEducationQualifications(educationQualifications);
//Set research resources
ResearchResources researchResources = new ResearchResources();
researchResources.setSelfAssertedCount(0);
researchResources.setValidatedCount(1);
record.setResearchResources(researchResources);

return record;
}

Expand Down Expand Up @@ -137,11 +150,41 @@ private ProfessionalActivity getProfessionalActivity(int putCode, String role, S
return pa;
}

private EducationQualification getEducationQualification(int putCode, String role, String org, String url, String type, boolean validated) {
EducationQualification eq = new EducationQualification();
eq.setPutCode(Long.valueOf(putCode));
eq.setEndDate(getEndDate());
eq.setStartDate(getStartDate());
eq.setOrganizationName(org);
eq.setRole(role);
eq.setUrl(url);
eq.setValidated(validated);
eq.setType(type);
return eq;
}

private EmailDomain getEmailDomain(String domainValue, Date created, Date modified) {
EmailDomain emailDomain = new EmailDomain();
emailDomain.setValue(domainValue);
//emailDomain.setCreatedDate(created);
//emailDomain.setLastModified(modified);
return emailDomain;
}

private FuzzyDate getEndDate() {
return new FuzzyDate(new Year(2024), new Month(12), new Day(31));
}

private FuzzyDate getStartDate() {
return new FuzzyDate(new Year(2020), new Month(1), new Day(1));
}


private Date getEmailDomainCreatedDate() {
return Date.valueOf(new FuzzyDate(new Year(2020), new Month(1), new Day(1)));
}

private Date getEmailDomainLastModified() {
return Date.valueOf(new FuzzyDate(new Year(2020), new Month(1), new Day(1)));
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><summary:record-summary xmlns:summary="http://www.orcid.org/ns/summary" xmlns:common="http://www.orcid.org/ns/common" xmlns:activities="http://www.orcid.org/ns/activities"><common:created-date>2024-01-01T12:00:00</common:created-date><common:last-modified-date>2024-01-01T12:00:00</common:last-modified-date><summary:credit-name>User credited name</summary:credit-name><common:orcid-identifier><common:uri>https://orcid.org/8888-8888-8888-8880</common:uri><common:path>8888-8888-8888-8880</common:path><common:host>orcid.org</common:host></common:orcid-identifier><summary:external-identifiers><summary:external-identifier><summary:put-code>1</summary:put-code><summary:external-id-type>Scopus</summary:external-id-type><summary:external-id-value>1</summary:external-id-value><summary:external-id-url>https://test.orcid.org/1</summary:external-id-url><summary:validated>true</summary:validated></summary:external-identifier><summary:external-identifier><summary:put-code>2</summary:put-code><summary:external-id-type>ResearcherID</summary:external-id-type><summary:external-id-value>2</summary:external-id-value><summary:external-id-url>https://test.orcid.org/2</summary:external-id-url><summary:validated>true</summary:validated></summary:external-identifier><summary:external-identifier><summary:put-code>3</summary:put-code><summary:external-id-type>Other</summary:external-id-type><summary:external-id-value>3</summary:external-id-value><summary:external-id-url>https://test.orcid.org/3</summary:external-id-url><summary:validated>true</summary:validated></summary:external-identifier></summary:external-identifiers><summary:employments><summary:count>5</summary:count><summary:employment><summary:put-code>1</summary:put-code><summary:type>employment</summary:type><summary:organization-name>Fake role title 1</summary:organization-name><summary:role>Org # 1</summary:role><summary:url>https://test.orcid.org/1</summary:url><common:start-date><common:year>2020</common:year><common:month>01</common:month><common:day>01</common:day></common:start-date><common:end-date><common:year>2024</common:year><common:month>12</common:month><common:day>31</common:day></common:end-date><summary:validated>false</summary:validated></summary:employment><summary:employment><summary:put-code>2</summary:put-code><summary:type>employment</summary:type><summary:organization-name>Fake role title 2</summary:organization-name><summary:role>Org # 2</summary:role><summary:url>https://test.orcid.org/2</summary:url><common:start-date><common:year>2020</common:year><common:month>01</common:month><common:day>01</common:day></common:start-date><common:end-date><common:year>2024</common:year><common:month>12</common:month><common:day>31</common:day></common:end-date><summary:validated>false</summary:validated></summary:employment><summary:employment><summary:put-code>3</summary:put-code><summary:type>employment</summary:type><summary:organization-name>Fake role title 3</summary:organization-name><summary:role>Org # 3</summary:role><summary:url>https://test.orcid.org/3</summary:url><common:start-date><common:year>2020</common:year><common:month>01</common:month><common:day>01</common:day></common:start-date><common:end-date><common:year>2024</common:year><common:month>12</common:month><common:day>31</common:day></common:end-date><summary:validated>true</summary:validated></summary:employment></summary:employments><summary:professional-activities><summary:count>5</summary:count><summary:professional-activity><summary:put-code>1</summary:put-code><summary:type>distinction</summary:type><summary:organization-name>Fake role title</summary:organization-name><summary:role>Org # 1</summary:role><summary:url>https://test.orcid.org/</summary:url><common:start-date><common:year>2020</common:year><common:month>01</common:month><common:day>01</common:day></common:start-date><common:end-date><common:year>2024</common:year><common:month>12</common:month><common:day>31</common:day></common:end-date><summary:validated>false</summary:validated></summary:professional-activity></summary:professional-activities><summary:fundings><summary:self-asserted-count>0</summary:self-asserted-count><summary:validated-count>1</summary:validated-count></summary:fundings><summary:works><summary:self-asserted-count>0</summary:self-asserted-count><summary:validated-count>1</summary:validated-count></summary:works><summary:peer-reviews><summary:peer-review-publication-grants>6</summary:peer-review-publication-grants><summary:self-asserted-count>0</summary:self-asserted-count><summary:total>6</summary:total></summary:peer-reviews></summary:record-summary>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><summary:record-summary xmlns:summary="http://www.orcid.org/ns/summary" xmlns:common="http://www.orcid.org/ns/common" xmlns:activities="http://www.orcid.org/ns/activities"><common:created-date>2024-01-01T12:00:00</common:created-date><common:last-modified-date>2024-01-01T12:00:00</common:last-modified-date><summary:credit-name>User credited name</summary:credit-name><common:orcid-identifier><common:uri>https://orcid.org/8888-8888-8888-8880</common:uri><common:path>8888-8888-8888-8880</common:path><common:host>orcid.org</common:host></common:orcid-identifier><summary:external-identifiers><summary:external-identifier><summary:put-code>1</summary:put-code><summary:external-id-type>Scopus</summary:external-id-type><summary:external-id-value>1</summary:external-id-value><summary:external-id-url>https://test.orcid.org/1</summary:external-id-url><summary:validated>true</summary:validated></summary:external-identifier><summary:external-identifier><summary:put-code>2</summary:put-code><summary:external-id-type>ResearcherID</summary:external-id-type><summary:external-id-value>2</summary:external-id-value><summary:external-id-url>https://test.orcid.org/2</summary:external-id-url><summary:validated>true</summary:validated></summary:external-identifier><summary:external-identifier><summary:put-code>3</summary:put-code><summary:external-id-type>Other</summary:external-id-type><summary:external-id-value>3</summary:external-id-value><summary:external-id-url>https://test.orcid.org/3</summary:external-id-url><summary:validated>true</summary:validated></summary:external-identifier></summary:external-identifiers><summary:employments><summary:count>5</summary:count><summary:employment><summary:put-code>1</summary:put-code><summary:type>employment</summary:type><summary:organization-name>Fake role title 1</summary:organization-name><summary:role>Org # 1</summary:role><summary:url>https://test.orcid.org/1</summary:url><common:start-date><common:year>2020</common:year><common:month>01</common:month><common:day>01</common:day></common:start-date><common:end-date><common:year>2024</common:year><common:month>12</common:month><common:day>31</common:day></common:end-date><summary:validated>false</summary:validated></summary:employment><summary:employment><summary:put-code>2</summary:put-code><summary:type>employment</summary:type><summary:organization-name>Fake role title 2</summary:organization-name><summary:role>Org # 2</summary:role><summary:url>https://test.orcid.org/2</summary:url><common:start-date><common:year>2020</common:year><common:month>01</common:month><common:day>01</common:day></common:start-date><common:end-date><common:year>2024</common:year><common:month>12</common:month><common:day>31</common:day></common:end-date><summary:validated>false</summary:validated></summary:employment><summary:employment><summary:put-code>3</summary:put-code><summary:type>employment</summary:type><summary:organization-name>Fake role title 3</summary:organization-name><summary:role>Org # 3</summary:role><summary:url>https://test.orcid.org/3</summary:url><common:start-date><common:year>2020</common:year><common:month>01</common:month><common:day>01</common:day></common:start-date><common:end-date><common:year>2024</common:year><common:month>12</common:month><common:day>31</common:day></common:end-date><summary:validated>true</summary:validated></summary:employment></summary:employments><summary:professional-activities><summary:count>5</summary:count><summary:professional-activity><summary:put-code>1</summary:put-code><summary:type>distinction</summary:type><summary:organization-name>Fake role title</summary:organization-name><summary:role>Org # 1</summary:role><summary:url>https://test.orcid.org/</summary:url><common:start-date><common:year>2020</common:year><common:month>01</common:month><common:day>01</common:day></common:start-date><common:end-date><common:year>2024</common:year><common:month>12</common:month><common:day>31</common:day></common:end-date><summary:validated>false</summary:validated></summary:professional-activity></summary:professional-activities><summary:fundings><summary:self-asserted-count>0</summary:self-asserted-count><summary:validated-count>1</summary:validated-count></summary:fundings><summary:works><summary:self-asserted-count>0</summary:self-asserted-count><summary:validated-count>1</summary:validated-count></summary:works><summary:peer-reviews><summary:peer-review-publication-grants>6</summary:peer-review-publication-grants><summary:self-asserted-count>0</summary:self-asserted-count><summary:total>6</summary:total></summary:peer-reviews><summary:email-domains><summary:count>4</summary:count><summary:email-domain><summary:value>sometrusted.org</summary:value></summary:email-domain></summary:email-domains><summary:education-qualifications><summary:count>6</summary:count><summary:education-qualification><summary:put-code>1</summary:put-code><summary:type>education</summary:type><summary:organization-name>Fake role title</summary:organization-name><summary:role>Org # 1</summary:role><summary:url>https://test.orcid.org/</summary:url><common:start-date><common:year>2020</common:year><common:month>01</common:month><common:day>01</common:day></common:start-date><common:end-date><common:year>2024</common:year><common:month>12</common:month><common:day>31</common:day></common:end-date><summary:validated>false</summary:validated></summary:education-qualification></summary:education-qualifications><summary:research-resources><summary:self-asserted-count>0</summary:self-asserted-count><summary:validated-count>1</summary:validated-count></summary:research-resources></summary:record-summary>

0 comments on commit 07bc96c

Please sign in to comment.