@Test public final void testExecuteWithUrl() throws Exception { final String themeName = "Las Vegas"; final String themeDesc = "Las Vegas sky line"; final String personName = "Phil Plait"; final String personEmail = "phil.plait@awesome.com"; final String themeBannerId = "http: DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); final Document xmlDoc = db.parse("src/test/resources/themes/vegas.xml"); Theme theme = new Theme(); context.checking(new Expectations() { { oneOf(documentCreator).execute("src/test/resources/themes/vegas.xml"); will(returnValue(xmlDoc)); } }); sut.populate(theme, "src/test/resources/themes/vegas.xml"); context.assertIsSatisfied(); assertEquals("property should be gotten", themeName, theme.getName()); assertEquals("property should be gotten", themeDesc, theme.getDescription()); assertEquals("property should be gotten", personName, theme.getAuthorName()); assertEquals("property should be gotten", personEmail, theme.getAuthorEmail()); assertEquals("property should be gotten", themeBannerId, theme.getBannerId()); }
public void populate(final Theme inTheme, final String inThemeUrl) { Document xmlDoc = null; try { xmlDoc = documentCreator.execute(inThemeUrl); } catch (Exception e) { log.error(e); } xmlDoc.getDocumentElement().normalize(); NodeList nodeList = xmlDoc.getElementsByTagName("Title"); Element element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String themeName = (nodeList.item(0)).getNodeValue(); inTheme.setName(themeName); nodeList = xmlDoc.getElementsByTagName("Description"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String descrption = (nodeList.item(0)).getNodeValue(); inTheme.setDescription(descrption); nodeList = xmlDoc.getElementsByTagName("AuthorName"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String authorName = (nodeList.item(0)).getNodeValue(); inTheme.setAuthorName(authorName); nodeList = xmlDoc.getElementsByTagName("AuthorEmail"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String authorEmail = (nodeList.item(0)).getNodeValue(); inTheme.setAuthorEmail(authorEmail); nodeList = xmlDoc.getElementsByTagName("HeaderBackground"); Node headerBackgroundNode = nodeList.item(0); Element headerBackgroundItemImageElement = (Element) headerBackgroundNode; nodeList = headerBackgroundItemImageElement.getElementsByTagName("HeaderBackgroundImage"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String bannerId = (nodeList.item(0)).getNodeValue(); inTheme.setBannerId(bannerId); String themeUuid = inTheme.getUUID(); if (!StringUtils.isEmpty(themeUuid)) { Set<String> keySet = new HashSet<String>(); for (String key : keyList) { keySet.add(key + themeUuid); } deleteCacheKeysMapper.execute(keySet); } }
ThemePopulator implements GalleryItemPopulator<Theme> { public void populate(final Theme inTheme, final String inThemeUrl) { Document xmlDoc = null; try { xmlDoc = documentCreator.execute(inThemeUrl); } catch (Exception e) { log.error(e); } xmlDoc.getDocumentElement().normalize(); NodeList nodeList = xmlDoc.getElementsByTagName("Title"); Element element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String themeName = (nodeList.item(0)).getNodeValue(); inTheme.setName(themeName); nodeList = xmlDoc.getElementsByTagName("Description"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String descrption = (nodeList.item(0)).getNodeValue(); inTheme.setDescription(descrption); nodeList = xmlDoc.getElementsByTagName("AuthorName"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String authorName = (nodeList.item(0)).getNodeValue(); inTheme.setAuthorName(authorName); nodeList = xmlDoc.getElementsByTagName("AuthorEmail"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String authorEmail = (nodeList.item(0)).getNodeValue(); inTheme.setAuthorEmail(authorEmail); nodeList = xmlDoc.getElementsByTagName("HeaderBackground"); Node headerBackgroundNode = nodeList.item(0); Element headerBackgroundItemImageElement = (Element) headerBackgroundNode; nodeList = headerBackgroundItemImageElement.getElementsByTagName("HeaderBackgroundImage"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String bannerId = (nodeList.item(0)).getNodeValue(); inTheme.setBannerId(bannerId); String themeUuid = inTheme.getUUID(); if (!StringUtils.isEmpty(themeUuid)) { Set<String> keySet = new HashSet<String>(); for (String key : keyList) { keySet.add(key + themeUuid); } deleteCacheKeysMapper.execute(keySet); } } }
ThemePopulator implements GalleryItemPopulator<Theme> { public void populate(final Theme inTheme, final String inThemeUrl) { Document xmlDoc = null; try { xmlDoc = documentCreator.execute(inThemeUrl); } catch (Exception e) { log.error(e); } xmlDoc.getDocumentElement().normalize(); NodeList nodeList = xmlDoc.getElementsByTagName("Title"); Element element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String themeName = (nodeList.item(0)).getNodeValue(); inTheme.setName(themeName); nodeList = xmlDoc.getElementsByTagName("Description"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String descrption = (nodeList.item(0)).getNodeValue(); inTheme.setDescription(descrption); nodeList = xmlDoc.getElementsByTagName("AuthorName"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String authorName = (nodeList.item(0)).getNodeValue(); inTheme.setAuthorName(authorName); nodeList = xmlDoc.getElementsByTagName("AuthorEmail"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String authorEmail = (nodeList.item(0)).getNodeValue(); inTheme.setAuthorEmail(authorEmail); nodeList = xmlDoc.getElementsByTagName("HeaderBackground"); Node headerBackgroundNode = nodeList.item(0); Element headerBackgroundItemImageElement = (Element) headerBackgroundNode; nodeList = headerBackgroundItemImageElement.getElementsByTagName("HeaderBackgroundImage"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String bannerId = (nodeList.item(0)).getNodeValue(); inTheme.setBannerId(bannerId); String themeUuid = inTheme.getUUID(); if (!StringUtils.isEmpty(themeUuid)) { Set<String> keySet = new HashSet<String>(); for (String key : keyList) { keySet.add(key + themeUuid); } deleteCacheKeysMapper.execute(keySet); } } ThemePopulator(final DocumentCreator inDocumentCreator,
            final DomainMapper<Set<String>, Boolean> inDeleteCacheKeysMapper, final List<String> deleteCacheKeys); }
ThemePopulator implements GalleryItemPopulator<Theme> { public void populate(final Theme inTheme, final String inThemeUrl) { Document xmlDoc = null; try { xmlDoc = documentCreator.execute(inThemeUrl); } catch (Exception e) { log.error(e); } xmlDoc.getDocumentElement().normalize(); NodeList nodeList = xmlDoc.getElementsByTagName("Title"); Element element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String themeName = (nodeList.item(0)).getNodeValue(); inTheme.setName(themeName); nodeList = xmlDoc.getElementsByTagName("Description"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String descrption = (nodeList.item(0)).getNodeValue(); inTheme.setDescription(descrption); nodeList = xmlDoc.getElementsByTagName("AuthorName"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String authorName = (nodeList.item(0)).getNodeValue(); inTheme.setAuthorName(authorName); nodeList = xmlDoc.getElementsByTagName("AuthorEmail"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String authorEmail = (nodeList.item(0)).getNodeValue(); inTheme.setAuthorEmail(authorEmail); nodeList = xmlDoc.getElementsByTagName("HeaderBackground"); Node headerBackgroundNode = nodeList.item(0); Element headerBackgroundItemImageElement = (Element) headerBackgroundNode; nodeList = headerBackgroundItemImageElement.getElementsByTagName("HeaderBackgroundImage"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String bannerId = (nodeList.item(0)).getNodeValue(); inTheme.setBannerId(bannerId); String themeUuid = inTheme.getUUID(); if (!StringUtils.isEmpty(themeUuid)) { Set<String> keySet = new HashSet<String>(); for (String key : keyList) { keySet.add(key + themeUuid); } deleteCacheKeysMapper.execute(keySet); } } ThemePopulator(final DocumentCreator inDocumentCreator,
            final DomainMapper<Set<String>, Boolean> inDeleteCacheKeysMapper, final List<String> deleteCacheKeys); void populate(final Theme inTheme, final String inThemeUrl); }
ThemePopulator implements GalleryItemPopulator<Theme> { public void populate(final Theme inTheme, final String inThemeUrl) { Document xmlDoc = null; try { xmlDoc = documentCreator.execute(inThemeUrl); } catch (Exception e) { log.error(e); } xmlDoc.getDocumentElement().normalize(); NodeList nodeList = xmlDoc.getElementsByTagName("Title"); Element element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String themeName = (nodeList.item(0)).getNodeValue(); inTheme.setName(themeName); nodeList = xmlDoc.getElementsByTagName("Description"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String descrption = (nodeList.item(0)).getNodeValue(); inTheme.setDescription(descrption); nodeList = xmlDoc.getElementsByTagName("AuthorName"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String authorName = (nodeList.item(0)).getNodeValue(); inTheme.setAuthorName(authorName); nodeList = xmlDoc.getElementsByTagName("AuthorEmail"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String authorEmail = (nodeList.item(0)).getNodeValue(); inTheme.setAuthorEmail(authorEmail); nodeList = xmlDoc.getElementsByTagName("HeaderBackground"); Node headerBackgroundNode = nodeList.item(0); Element headerBackgroundItemImageElement = (Element) headerBackgroundNode; nodeList = headerBackgroundItemImageElement.getElementsByTagName("HeaderBackgroundImage"); element = (Element) nodeList.item(0); nodeList = element.getChildNodes(); String bannerId = (nodeList.item(0)).getNodeValue(); inTheme.setBannerId(bannerId); String themeUuid = inTheme.getUUID(); if (!StringUtils.isEmpty(themeUuid)) { Set<String> keySet = new HashSet<String>(); for (String key : keyList) { keySet.add(key + themeUuid); } deleteCacheKeysMapper.execute(keySet); } } ThemePopulator(final DocumentCreator inDocumentCreator,
            final DomainMapper<Set<String>, Boolean> inDeleteCacheKeysMapper, final List<String> deleteCacheKeys); void populate(final Theme inTheme, final String inThemeUrl);  }