Search in sources :

Example 11 with Email

use of org.orcid.jaxb.model.message.Email in project ORCID-Source by ORCID.

the class OrcidProfileManagerImplTest method setBio.

private void setBio(OrcidProfile profile, Visibility defaultVisibility) {
    OrcidBio bio = new OrcidBio();
    Biography biography = new Biography("This is my biography");
    if (defaultVisibility != null) {
        biography.setVisibility(defaultVisibility);
    }
    bio.setBiography(biography);
    ContactDetails contactDetails = new ContactDetails();
    Address address = new Address();
    address.setCountry(new Country(Iso3166Country.US));
    if (defaultVisibility != null) {
        address.getCountry().setVisibility(defaultVisibility);
    }
    contactDetails.setAddress(address);
    List<Email> emails = new ArrayList<Email>();
    Email email = new Email();
    email.setPrimary(true);
    email.setValue(System.currentTimeMillis() + "@test.orcid.org");
    emails.add(email);
    contactDetails.setEmail(emails);
    bio.setContactDetails(contactDetails);
    ExternalIdentifiers extIds = new ExternalIdentifiers();
    ExternalIdentifier extId = new ExternalIdentifier();
    extId.setExternalIdCommonName(new ExternalIdCommonName("common-name"));
    extId.setExternalIdReference(new ExternalIdReference("ext-id-reference"));
    extId.setExternalIdUrl(new ExternalIdUrl("http://orcid.org/ext-id"));
    extIds.getExternalIdentifier().add(extId);
    if (defaultVisibility != null) {
        extIds.setVisibility(defaultVisibility);
    }
    bio.setExternalIdentifiers(extIds);
    Keywords keywords = new Keywords();
    Keyword keyword = new Keyword();
    keyword.setContent("k1");
    keywords.getKeyword().add(keyword);
    if (defaultVisibility != null) {
        keywords.setVisibility(defaultVisibility);
    }
    bio.setKeywords(keywords);
    PersonalDetails personalDetails = new PersonalDetails();
    personalDetails.setCreditName(new CreditName("credit-name"));
    personalDetails.setGivenNames(new GivenNames("given-names"));
    personalDetails.setFamilyName(new FamilyName("family-name"));
    OtherNames otherNames = new OtherNames();
    OtherName otherName = new OtherName();
    otherName.setContent("o1");
    otherNames.getOtherName().add(otherName);
    if (defaultVisibility != null) {
        otherNames.setVisibility(defaultVisibility);
    }
    personalDetails.setOtherNames(otherNames);
    bio.setPersonalDetails(personalDetails);
    ResearcherUrls researcherUrls = new ResearcherUrls();
    ResearcherUrl researcherUrl = new ResearcherUrl();
    researcherUrl.setUrl(new Url("http://orcid.org/researcher-url-1"));
    researcherUrl.setUrlName(new UrlName("url-name-1"));
    researcherUrls.getResearcherUrl().add(researcherUrl);
    if (defaultVisibility != null) {
        researcherUrls.setVisibility(defaultVisibility);
    }
    bio.setResearcherUrls(researcherUrls);
    profile.setOrcidBio(bio);
}
Also used : Email(org.orcid.jaxb.model.message.Email) Keywords(org.orcid.jaxb.model.message.Keywords) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Address(org.orcid.jaxb.model.message.Address) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) FamilyName(org.orcid.jaxb.model.message.FamilyName) OtherNames(org.orcid.jaxb.model.message.OtherNames) ArrayList(java.util.ArrayList) Url(org.orcid.jaxb.model.message.Url) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) ExternalIdUrl(org.orcid.jaxb.model.message.ExternalIdUrl) ExternalIdUrl(org.orcid.jaxb.model.message.ExternalIdUrl) ExternalIdCommonName(org.orcid.jaxb.model.message.ExternalIdCommonName) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) GivenNames(org.orcid.jaxb.model.message.GivenNames) Biography(org.orcid.jaxb.model.message.Biography) ResearcherUrls(org.orcid.jaxb.model.message.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) FundingExternalIdentifiers(org.orcid.jaxb.model.message.FundingExternalIdentifiers) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) ExternalIdReference(org.orcid.jaxb.model.message.ExternalIdReference) Keyword(org.orcid.jaxb.model.message.Keyword) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) CreditName(org.orcid.jaxb.model.message.CreditName) OtherName(org.orcid.jaxb.model.message.OtherName) UrlName(org.orcid.jaxb.model.message.UrlName) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Country(org.orcid.jaxb.model.message.Country) Iso3166Country(org.orcid.jaxb.model.message.Iso3166Country)

Example 12 with Email

use of org.orcid.jaxb.model.message.Email in project ORCID-Source by ORCID.

the class RegistrationManagerImplTest method createBasicProfile.

private OrcidProfile createBasicProfile(String email, boolean claimed, String sourceId) {
    OrcidProfile profile = new OrcidProfile();
    profile.setPassword("password");
    profile.setVerificationCode("1234");
    OrcidBio bio = new OrcidBio();
    ContactDetails contactDetails = new ContactDetails();
    contactDetails.addOrReplacePrimaryEmail(new Email(email));
    bio.setContactDetails(contactDetails);
    profile.setOrcidBio(bio);
    PersonalDetails personalDetails = new PersonalDetails();
    bio.setPersonalDetails(personalDetails);
    personalDetails.setGivenNames(new GivenNames("New"));
    personalDetails.setFamilyName(new FamilyName("User"));
    OrcidHistory orcidHistory = new OrcidHistory();
    orcidHistory.setClaimed(new Claimed(claimed));
    orcidHistory.setCreationMethod(CreationMethod.DIRECT);
    orcidHistory.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    profile.setOrcidHistory(orcidHistory);
    //Set the source
    profile.getOrcidHistory().setSource(new Source(sourceId));
    return profile;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) FamilyName(org.orcid.jaxb.model.message.FamilyName) GivenNames(org.orcid.jaxb.model.message.GivenNames) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Claimed(org.orcid.jaxb.model.message.Claimed) Date(java.util.Date) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Source(org.orcid.jaxb.model.message.Source)

Example 13 with Email

use of org.orcid.jaxb.model.message.Email in project ORCID-Source by ORCID.

the class Api12MembersTest method testViewFullDetails.

@Test
public void testViewFullDetails() throws Exception {
    JAXBContext context = JAXBContext.newInstance(OrcidMessage.class);
    Unmarshaller unmarshaller = context.createUnmarshaller();
    OrcidMessage record = (OrcidMessage) unmarshaller.unmarshal(Api12MembersTest.class.getResourceAsStream("/samples/orcid_profile.xml"));
    record.getOrcidProfile().setOrcidHistory(null);
    String emailAddress = System.currentTimeMillis() + "_test@test.orcid.org";
    Email email = new Email(emailAddress);
    email.setPrimary(true);
    List<Email> emails = Arrays.asList(email);
    record.getOrcidProfile().getOrcidBio().getContactDetails().setEmail(emails);
    String accessToken = getClientCredentialsAccessToken(ScopePathType.ORCID_PROFILE_CREATE, this.getClient1ClientId(), this.getClient1ClientSecret(), APIRequestType.MEMBER);
    String orcid = Api12Helper.createRecord(accessToken, record, t2OAuthClient_1_2);
    assertClientResponse401Details(t2OAuthClient_1_2.viewFullDetailsXml(orcid, null));
    ClientResponse clientResponse = t2OAuthClient_1_2.viewFullDetailsXml(orcid, accessToken);
    assertNotNull(clientResponse);
    assertEquals(200, clientResponse.getStatus());
    assertEquals("application/vnd.orcid+xml; charset=UTF-8; qs=5", clientResponse.getType().toString());
    OrcidMessage orcidMessage = clientResponse.getEntity(OrcidMessage.class);
    assertNotNull(orcidMessage);
    assertEquals(orcid, orcidMessage.getOrcidProfile().getOrcidIdentifier().getPath());
    //Bio
    assertNotNull(orcidMessage.getOrcidProfile().getOrcidBio());
    assertEquals(1, orcidMessage.getOrcidProfile().getOrcidBio().getContactDetails().getEmail().size());
    assertEquals(emailAddress, orcidMessage.getOrcidProfile().getOrcidBio().getContactDetails().getEmail().get(0).getValue());
    assertEquals(Iso3166Country.US, orcidMessage.getOrcidProfile().getOrcidBio().getContactDetails().getAddress().getCountry().getValue());
    assertEquals("credit name", orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getCreditName().getContent());
    assertEquals("family name", orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getFamilyName().getContent());
    assertEquals("given names", orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getGivenNames().getContent());
    assertEquals(2, orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().size());
    assertThat(orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().get(0).getContent(), anyOf(is("Other 1"), is("Other 2")));
    assertThat(orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().get(1).getContent(), anyOf(is("Other 1"), is("Other 2")));
    assertEquals("Lets test some crazy stuff! How about a 1000 chars in japanese 難フドょ三点93隊は比埼回へ美宝投トしレ手採シ領馬公ノネ氏細ケロウヌ係入ヲハヌヱ厚院ひゃお川的ばぴイぎ言提オサ所熱サ自通をぶちス後筆本在親も。仕退ニレト由界フぱし庫越トメキホ来転を半別どば鈴内ト全41秀かゅや果物心マオル討赤モナマフ参月スどこや座念コソ言社ぐ食理ラセ対演ぎの変理かラ広暮クスネテ上進傑ゆくス。16要べ南聖ウチサ認府ネ長悪たやふ能住とぜべ王是にど新断切年セテ不紀つドょ歳県オスニ質38碁れ容57雑スネモ老泉シヘヒ関裕よはラク更記兆ムタワラ投困ゅんぜ治木ぞほ細通ウヤ年覧ト運現ざイたね冊7績よゆ暮誉ソサト投46軽ロ終時イ必迫の触勇囲速ぐイす。特なイりド通結ま鳥寄育ぼべく拶奈拳ナコ回書マク道月スどばせ社的ケ探尽タエホ枝力トル害地べっ治電は際材ヨ別断ツカウ文国ラヒ応治ぴぶ戦75収否禁辞4帝おだあへ平悪由ごと禁者ヒワコタ長強ふて見際まをづ質相抽綱もえ。卓側68点宇どのゆ式長実52染な憶オ調浄もゆ高京セハヘミ世曄タニ合東らね約環リ理聞話学ほ心褒ぼどばこ補禁球かを運人ねの判言ネツユタ級投とそらぜ辺罪サ放唱セ請月試セツヲリ票監笑怠殊ぼスお。断きだて野重探がそょ会上ミヘ社69点ルラコ憶オ調浄もゆ高京セハヘミ世曄タニ合東らね約環リ理聞話学ほ心褒ぼどばこ補禁球かを運人ねの判言ネツユタ級投とそらぜ辺罪サ放唱セ請月試セツヲリ票監笑怠殊ぼスお。断きだて野重探がそょ会上ミヘ社69点ルラコ憶オ調浄もゆ高京セハヘミ世曄タニ合東らね約環リ理聞話学ほ心褒ぼどばこ補禁球かを運人ねの判言ネツユタ級投とそらぜ辺罪サ放唱セ請月試セツヲリ票監笑怠殊ぼスお。断きだて野重探がそょ会上ミヘ社69点ルラコv憶オ調浄もゆ高京セハヘミ世曄タニ合東らね約環リ理聞話学ほ心褒ぼどばこ補禁球かを運人ねの判言ネツユタ級投とそらぜ辺罪サ放唱セ請月試セツヲリ票監笑怠殊ぼスお。断きだて野重探がそょ会上ミヘ社69点ルラコ憶オ調浄もゆ高京セハヘミ世曄タニ合東らね約環リ理聞話学ほ心褒ぼどばこ補禁球かを運人ねの判言ネツユタ級投とそらぜ辺罪サ放唱セ請月試セツヲリ票監笑怠殊ぼスお。断きだて野重探がそょ会上ミヘ社69点ルラコ人ねの判言ネツユタ級投とそらぜ辺罪サ放唱セ請月試セツヲリ票監笑怠殊ぼスお。断きだ", orcidMessage.getOrcidProfile().getOrcidBio().getBiography().getContent());
    assertEquals(2, orcidMessage.getOrcidProfile().getOrcidBio().getResearcherUrls().getResearcherUrl().size());
    assertThat(orcidMessage.getOrcidProfile().getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrl().getValue(), anyOf(is("http://www.wjrs.co.uk"), is("http://www.vvs.com")));
    assertThat(orcidMessage.getOrcidProfile().getOrcidBio().getResearcherUrls().getResearcherUrl().get(1).getUrl().getValue(), anyOf(is("http://www.wjrs.co.uk"), is("http://www.vvs.com")));
    assertEquals(2, orcidMessage.getOrcidProfile().getOrcidBio().getKeywords().getKeyword().size());
    assertThat(orcidMessage.getOrcidProfile().getOrcidBio().getKeywords().getKeyword().get(0).getContent(), anyOf(is("Pavement Studies"), is("Advanced Tea Making")));
    assertThat(orcidMessage.getOrcidProfile().getOrcidBio().getKeywords().getKeyword().get(1).getContent(), anyOf(is("Pavement Studies"), is("Advanced Tea Making")));
    assertEquals(2, orcidMessage.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
    assertThat(orcidMessage.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent(), anyOf(is("extId#1"), is("extId#2")));
    assertThat(orcidMessage.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(1).getExternalIdCommonName().getContent(), anyOf(is("extId#1"), is("extId#2")));
    assertThat(orcidMessage.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdReference().getContent(), anyOf(is("extId#1"), is("extId#2")));
    assertThat(orcidMessage.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(1).getExternalIdReference().getContent(), anyOf(is("extId#1"), is("extId#2")));
    assertThat(orcidMessage.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdUrl().getValue(), anyOf(is("http://orcid.org/extId#1"), is("http://orcid.org/extId#2")));
    assertThat(orcidMessage.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(1).getExternalIdUrl().getValue(), anyOf(is("http://orcid.org/extId#1"), is("http://orcid.org/extId#2")));
    //Affiliations
    assertEquals(2, orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliation().size());
    assertEquals(1, orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EDUCATION).size());
    assertEquals(AffiliationType.EDUCATION, orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EDUCATION).get(0).getType());
    assertEquals("department-name", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EDUCATION).get(0).getDepartmentName());
    assertEquals("01", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EDUCATION).get(0).getEndDate().getDay().getValue());
    assertEquals("01", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EDUCATION).get(0).getEndDate().getMonth().getValue());
    assertEquals("2018", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EDUCATION).get(0).getEndDate().getYear().getValue());
    assertEquals("city", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EDUCATION).get(0).getOrganization().getAddress().getCity());
    assertEquals(Iso3166Country.US, orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EDUCATION).get(0).getOrganization().getAddress().getCountry());
    assertEquals("region", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EDUCATION).get(0).getOrganization().getAddress().getRegion());
    assertEquals("role-title", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EDUCATION).get(0).getRoleTitle());
    assertEquals("01", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EDUCATION).get(0).getStartDate().getDay().getValue());
    assertEquals("01", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EDUCATION).get(0).getStartDate().getMonth().getValue());
    assertEquals("2017", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EDUCATION).get(0).getStartDate().getYear().getValue());
    assertEquals(AffiliationType.EMPLOYMENT, orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EMPLOYMENT).get(0).getType());
    assertEquals("department-name", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EMPLOYMENT).get(0).getDepartmentName());
    assertEquals("01", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EMPLOYMENT).get(0).getEndDate().getDay().getValue());
    assertEquals("01", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EMPLOYMENT).get(0).getEndDate().getMonth().getValue());
    assertEquals("2018", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EMPLOYMENT).get(0).getEndDate().getYear().getValue());
    assertEquals("city", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EMPLOYMENT).get(0).getOrganization().getAddress().getCity());
    assertEquals(Iso3166Country.US, orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EMPLOYMENT).get(0).getOrganization().getAddress().getCountry());
    assertEquals("region", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EMPLOYMENT).get(0).getOrganization().getAddress().getRegion());
    assertEquals("role-title", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EMPLOYMENT).get(0).getRoleTitle());
    assertEquals("01", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EMPLOYMENT).get(0).getStartDate().getDay().getValue());
    assertEquals("01", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EMPLOYMENT).get(0).getStartDate().getMonth().getValue());
    assertEquals("2017", orcidMessage.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliationsByType(AffiliationType.EMPLOYMENT).get(0).getStartDate().getYear().getValue());
    //Funding
    assertEquals(1, orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().size());
    assertEquals("1000", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getAmount().getContent());
    assertEquals("USD", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getAmount().getCurrencyCode());
    assertEquals("short-description", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getDescription());
    assertEquals("01", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getEndDate().getDay().getValue());
    assertEquals("01", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getEndDate().getMonth().getValue());
    assertEquals("2018", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getEndDate().getYear().getValue());
    assertEquals(FundingContributorRole.LEAD, orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getFundingContributors().getContributor().get(0).getContributorAttributes().getContributorRole());
    //Contributors email should be removed
    assertNull("test@test.orcid.org", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getFundingContributors().getContributor().get(0).getContributorEmail());
    assertEquals("credit-name", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getFundingContributors().getContributor().get(0).getCreditName().getContent());
    assertEquals(FundingExternalIdentifierType.GRANT_NUMBER, orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getFundingExternalIdentifiers().getFundingExternalIdentifier().get(0).getType());
    assertEquals("http://orcid.org", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getFundingExternalIdentifiers().getFundingExternalIdentifier().get(0).getUrl().getValue());
    assertEquals("funding-external-identifier-value", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getFundingExternalIdentifiers().getFundingExternalIdentifier().get(0).getValue());
    assertEquals("city", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getOrganization().getAddress().getCity());
    assertEquals(Iso3166Country.US, orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getOrganization().getAddress().getCountry());
    assertEquals("region", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getOrganization().getAddress().getRegion());
    assertEquals("name", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getOrganization().getName());
    assertEquals("organization-defined-type", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getOrganizationDefinedFundingType().getContent());
    assertEquals("01", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getStartDate().getDay().getValue());
    assertEquals("01", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getStartDate().getMonth().getValue());
    assertEquals("2017", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getStartDate().getYear().getValue());
    assertEquals("title", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getTitle().getTitle().getContent());
    assertEquals(FundingType.GRANT, orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getType());
    assertEquals("http://orcid.org", orcidMessage.getOrcidProfile().getOrcidActivities().getFundings().getFundings().get(0).getUrl().getValue());
    //Works
    assertEquals(1, orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().size());
    assertEquals(Iso3166Country.US, orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getCountry().getValue());
    assertEquals("journal title", orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getJournalTitle().getContent());
    assertEquals("en", orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getLanguageCode());
    assertEquals("01", orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getPublicationDate().getDay().getValue());
    assertEquals("01", orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getPublicationDate().getMonth().getValue());
    assertEquals("2017", orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getPublicationDate().getYear().getValue());
    assertEquals("description", orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getShortDescription());
    assertEquals("http://orcid.org", orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getUrl().getValue());
    assertEquals("citation", orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkCitation().getCitation());
    assertEquals(CitationType.FORMATTED_UNSPECIFIED, orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkCitation().getWorkCitationType());
    assertEquals(ContributorRole.AUTHOR, orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkContributors().getContributor().get(0).getContributorAttributes().getContributorRole());
    assertEquals(SequenceType.FIRST, orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkContributors().getContributor().get(0).getContributorAttributes().getContributorSequence());
    assertNull(orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkContributors().getContributor().get(0).getContributorEmail());
    assertEquals("credit-name", orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkContributors().getContributor().get(0).getCreditName().getContent());
    assertEquals("10.5555/12345ABCDE", orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).getWorkExternalIdentifierId().getContent());
    assertEquals(WorkExternalIdentifierType.DOI, orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).getWorkExternalIdentifierType());
    assertEquals("title", orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkTitle().getTitle().getContent());
    assertEquals("subtitle", orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkTitle().getSubtitle().getContent());
    assertEquals(WorkType.BOOK, orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkType());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Email(org.orcid.jaxb.model.message.Email) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Example 14 with Email

use of org.orcid.jaxb.model.message.Email in project ORCID-Source by ORCID.

the class Api12MembersTest method testViewBioDetails.

@Test
public void testViewBioDetails() throws Exception {
    JAXBContext context = JAXBContext.newInstance(OrcidMessage.class);
    Unmarshaller unmarshaller = context.createUnmarshaller();
    OrcidMessage record = (OrcidMessage) unmarshaller.unmarshal(Api12MembersTest.class.getResourceAsStream("/samples/small_orcid_profile.xml"));
    record.getOrcidProfile().setOrcidHistory(null);
    String emailAddress = System.currentTimeMillis() + "_test@test.orcid.org";
    Email email = new Email(emailAddress);
    email.setPrimary(true);
    List<Email> emails = Arrays.asList(email);
    record.getOrcidProfile().getOrcidBio().getContactDetails().setEmail(emails);
    String accessToken = getClientCredentialsAccessToken(ScopePathType.ORCID_PROFILE_CREATE, this.getClient1ClientId(), this.getClient1ClientSecret(), APIRequestType.MEMBER);
    String orcid = Api12Helper.createRecord(accessToken, record, t2OAuthClient_1_2);
    assertClientResponse401Details(t2OAuthClient_1_2.viewBioDetailsXml(orcid, null));
    ClientResponse clientResponse = t2OAuthClient_1_2.viewBioDetailsXml(orcid, accessToken);
    assertNotNull(clientResponse);
    assertEquals(200, clientResponse.getStatus());
    assertEquals("application/vnd.orcid+xml; charset=UTF-8; qs=5", clientResponse.getType().toString());
    OrcidMessage orcidMessage = clientResponse.getEntity(OrcidMessage.class);
    assertNotNull(orcidMessage);
    assertEquals(orcid, orcidMessage.getOrcidProfile().getOrcidIdentifier().getPath());
    assertNotNull(orcidMessage.getOrcidProfile().getOrcidBio());
    assertEquals(1, orcidMessage.getOrcidProfile().getOrcidBio().getContactDetails().getEmail().size());
    assertEquals(emailAddress, orcidMessage.getOrcidProfile().getOrcidBio().getContactDetails().getEmail().get(0).getValue());
    assertEquals(Iso3166Country.CR, orcidMessage.getOrcidProfile().getOrcidBio().getContactDetails().getAddress().getCountry().getValue());
    assertEquals("credit", orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getCreditName().getContent());
    assertEquals("family", orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getFamilyName().getContent());
    assertEquals("given", orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getGivenNames().getContent());
    assertEquals(1, orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().size());
    assertEquals("other", orcidMessage.getOrcidProfile().getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().get(0).getContent());
    assertEquals("biography", orcidMessage.getOrcidProfile().getOrcidBio().getBiography().getContent());
    assertEquals(1, orcidMessage.getOrcidProfile().getOrcidBio().getResearcherUrls().getResearcherUrl().size());
    assertEquals("http://www.site.com", orcidMessage.getOrcidProfile().getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrl().getValue());
    assertEquals("The site", orcidMessage.getOrcidProfile().getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrlName().getContent());
    assertEquals(1, orcidMessage.getOrcidProfile().getOrcidBio().getKeywords().getKeyword().size());
    assertEquals("K1", orcidMessage.getOrcidProfile().getOrcidBio().getKeywords().getKeyword().get(0).getContent());
    assertEquals(1, orcidMessage.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("extId#1", orcidMessage.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
    assertEquals("extId#1", orcidMessage.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdReference().getContent());
    assertEquals("http://orcid.org/extId#1", orcidMessage.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdUrl().getValue());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Email(org.orcid.jaxb.model.message.Email) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test)

Example 15 with Email

use of org.orcid.jaxb.model.message.Email in project ORCID-Source by ORCID.

the class EmailsTest method cantUpdateEmailsTest.

/**
     * Test update email for a specific user
     * */
@Test
public void cantUpdateEmailsTest() throws JSONException, InterruptedException {
    String clientId = getClient1ClientId();
    String clientRedirectUri = getClient1RedirectUri();
    String clientSecret = getClient1ClientSecret();
    String userId = getUser1OrcidId();
    String originalEmail = getUser1UserName();
    String password = getUser1Password();
    String accessToken = getAccessToken(userId, password, Arrays.asList("/orcid-bio/update"), clientId, clientSecret, clientRedirectUri, true);
    long time = System.currentTimeMillis();
    String updatedEmail = time + "@update.com";
    ContactDetails contactDetails = new ContactDetails();
    contactDetails.getEmail().add(new Email(updatedEmail));
    OrcidBio orcidBio = new OrcidBio();
    orcidBio.setContactDetails(contactDetails);
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidProfile.setType(OrcidType.USER);
    orcidProfile.setOrcidBio(orcidBio);
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2");
    orcidMessage.setOrcidProfile(orcidProfile);
    ClientResponse clientResponse = t2OAuthClient_1_2.updateBioDetailsXml(userId, orcidMessage, accessToken);
    assertEquals(200, clientResponse.getStatus());
    clientResponse = t2OAuthClient_1_2.viewBioDetailsXml(userId, accessToken);
    assertEquals(200, clientResponse.getStatus());
    OrcidMessage result = clientResponse.getEntity(OrcidMessage.class);
    // Check returning message
    assertNotNull(result);
    assertNotNull(result.getOrcidProfile());
    assertNotNull(result.getOrcidProfile().getOrcidBio());
    assertNotNull(result.getOrcidProfile().getOrcidBio().getContactDetails());
    assertNotNull(result.getOrcidProfile().getOrcidBio().getContactDetails().getEmail());
    boolean haveOriginalEmail = false;
    for (Email email : result.getOrcidProfile().getOrcidBio().getContactDetails().getEmail()) {
        assertFalse(email.getValue().equals(updatedEmail));
        if (email.getValue().equals(originalEmail)) {
            haveOriginalEmail = true;
        }
    }
    assertTrue(haveOriginalEmail);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ClientResponse(com.sun.jersey.api.client.ClientResponse) Email(org.orcid.jaxb.model.message.Email) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) Test(org.junit.Test)

Aggregations

Email (org.orcid.jaxb.model.message.Email)45 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)22 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)20 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)20 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)18 Test (org.junit.Test)17 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)14 GivenNames (org.orcid.jaxb.model.message.GivenNames)12 FamilyName (org.orcid.jaxb.model.message.FamilyName)11 DBUnitTest (org.orcid.test.DBUnitTest)10 ArrayList (java.util.ArrayList)8 Address (org.orcid.jaxb.model.message.Address)7 Biography (org.orcid.jaxb.model.message.Biography)7 CreditName (org.orcid.jaxb.model.message.CreditName)7 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)7 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)7 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)6 Keyword (org.orcid.jaxb.model.message.Keyword)6 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)6 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)6