use of org.orcid.persistence.jpa.entities.IdentityProviderNameEntity in project ORCID-Source by ORCID.
the class IdentityProviderManagerTest method testCreateEntityFromXml.
@Test
public void testCreateEntityFromXml() throws SAXException, IOException, ParserConfigurationException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(getClass().getResourceAsStream("example_idp.xml"));
Element idpElement = doc.getDocumentElement();
IdentityProviderEntity result = identityProviderManager.createEntityFromXml(idpElement);
assertNotNull(result);
assertEquals("https://idp.example.ch/idp/shibboleth", result.getProviderid());
List<IdentityProviderNameEntity> names = result.getNames();
assertNotNull(names);
assertEquals(4, names.size());
Map<String, IdentityProviderNameEntity> mapByLang = names.stream().collect(Collectors.toMap(IdentityProviderNameEntity::getLang, Function.identity()));
assertEquals("Universität Example Display", mapByLang.get("de").getDisplayName());
assertEquals("University of Example Display", mapByLang.get("en").getDisplayName());
assertEquals("Université de Example Display", mapByLang.get("fr").getDisplayName());
assertEquals("Università di Example Display", mapByLang.get("it").getDisplayName());
assertEquals("Universität Example Display", result.getDisplayName());
assertEquals("support@example.ch", result.getSupportEmail());
assertNull(result.getAdminEmail());
assertEquals("technical@example.ch", result.getTechEmail());
}
Aggregations