use of org.apereo.portal.io.xml.user.ExternalUser in project uPortal by Jasig.
the class JaxbPortalDataHandlerServiceTest method testUpgradeThenImport.
@Test
public void testUpgradeThenImport() throws Exception {
final ClassPathResource importDataResource = new ClassPathResource("/org/apereo/portal/io/xml/user/test_3-2.user.xml");
when(resourceLoader.getResource("classpath:/org/apereo/portal/io/xml/user/test_3-2.user.xml")).thenReturn(importDataResource);
final ClassPathResource xslResource = new ClassPathResource("/org/apereo/portal/io/xml/user/upgrade-user_3-2.xsl");
final IDataUpgrader xsltDataUpgrader = createXsltDataUpgrader(xslResource, UserPortalDataType.IMPORT_32_DATA_KEY);
dataImportExportService.setDataUpgraders(Arrays.asList(xsltDataUpgrader));
final Jaxb2Marshaller userJaxb2Marshaller = new Jaxb2Marshaller();
userJaxb2Marshaller.setContextPath("org.apereo.portal.io.xml.user");
userJaxb2Marshaller.afterPropertiesSet();
final IDataImporter<ExternalUser> userDataImporter = mock(IDataImporter.class);
when(userDataImporter.getImportDataKeys()).thenReturn(Collections.singleton(UserPortalDataType.IMPORT_40_DATA_KEY));
when(userDataImporter.getUnmarshaller()).thenReturn(userJaxb2Marshaller);
Collection<IDataImporter<?>> dataImporters = new LinkedList<IDataImporter<?>>();
dataImporters.add(userDataImporter);
dataImportExportService.setDataImporters(dataImporters);
final Resource resource = resourceLoader.getResource("classpath:/org/apereo/portal/io/xml/user/test_3-2.user.xml");
dataImportExportService.importData(resource);
final ArgumentCaptor<ExternalUser> userArgumentCaptor = ArgumentCaptor.forClass(ExternalUser.class);
verify(userDataImporter).importData(userArgumentCaptor.capture());
final ExternalUser externalUser = userArgumentCaptor.getValue();
assertNotNull(externalUser);
assertEquals("student", externalUser.getUsername());
assertEquals("defaultTemplateUser", externalUser.getDefaultUser());
assertEquals("(MD5)mhmjKvf2F3gPizS9DrA+CsFmqj74oTSb", externalUser.getPassword());
assertNull(externalUser.getLastPasswordChange());
}
Aggregations