use of javax.xml.bind.Unmarshaller 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());
}
use of javax.xml.bind.Unmarshaller 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());
}
use of javax.xml.bind.Unmarshaller in project ORCID-Source by ORCID.
the class NotificationsTest method unmarshall.
public NotificationPermission unmarshall(Reader reader) {
try {
JAXBContext context = JAXBContext.newInstance(NotificationPermission.class.getPackage().getName());
Unmarshaller unmarshaller = context.createUnmarshaller();
return (NotificationPermission) unmarshaller.unmarshal(reader);
} catch (JAXBException e) {
throw new RuntimeException("Unable to unmarshall orcid message" + e);
}
}
use of javax.xml.bind.Unmarshaller in project ORCID-Source by ORCID.
the class ValidateV2IdentifiersTest method unmarshall.
private Object unmarshall(Reader reader, Class<?> type) {
try {
JAXBContext context = JAXBContext.newInstance(type);
Unmarshaller unmarshaller = context.createUnmarshaller();
return unmarshaller.unmarshal(reader);
} catch (JAXBException e) {
throw new RuntimeException("Unable to unmarshall orcid message" + e);
}
}
use of javax.xml.bind.Unmarshaller in project ORCID-Source by ORCID.
the class MarshallingTest method testMarshallingV2_0_RC4.
@Test
public void testMarshallingV2_0_RC4() throws JAXBException, IOException, SAXException {
JAXBContext context = JAXBContext.newInstance("org.orcid.jaxb.model.notification.permission_rc4");
Unmarshaller unmarshaller = context.createUnmarshaller();
InputStream inputStream = MarshallingTest.class.getResourceAsStream(SAMPLE_PATH_RC4);
org.orcid.jaxb.model.notification.permission_rc4.NotificationPermission notification = (org.orcid.jaxb.model.notification.permission_rc4.NotificationPermission) unmarshaller.unmarshal(inputStream);
assertNotNull(notification);
assertEquals(org.orcid.jaxb.model.notification_rc4.NotificationType.PERMISSION, notification.getNotificationType());
assertEquals(2, notification.getItems().getItems().size());
assertEquals("2014-01-01T14:45:32", notification.getSentDate().toXMLFormat());
// Back the other way
String expected = IOUtils.toString(getClass().getResourceAsStream(SAMPLE_PATH_RC4), "UTF-8");
Pattern pattern = Pattern.compile("<!--.*?-->\\s*", Pattern.DOTALL);
expected = pattern.matcher(expected).replaceAll("");
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "http://www.orcid.org/ns/notification ../notification-permission-2.0_rc4.xsd");
StringWriter writer = new StringWriter();
marshaller.marshal(notification, writer);
XMLUnit.setIgnoreWhitespace(true);
Diff diff = new Diff(expected, writer.toString());
assertTrue(diff.identical());
}
Aggregations