@Test public final void testExecuteEmpty() throws Exception { final List<GadgetMetaDataDTO> metaData = new ArrayList<GadgetMetaDataDTO>(); context.checking(new Expectations() { { oneOf(fetcher).getGadgetsMetaData(with(any(Map.class))); will(returnValue(metaData)); } }); sut.populate(gadgetDefinitionMock, "src/main/webapp/gadget/gadget.xml"); context.assertIsSatisfied(); }
public void populate(final GadgetDefinition inGadgetDefinition, final String inGadgetDefinitionUrl) { final Map<String, GeneralGadgetDefinition> gadgetDefs = new HashMap<String, GeneralGadgetDefinition>(); gadgetDefs.put(inGadgetDefinitionUrl, inGadgetDefinition); log.info("Fetching gadget data"); try { List<GadgetMetaDataDTO> meta = metaDataFetcher.getGadgetsMetaData(gadgetDefs); if (meta.size() > 0) { GadgetMetaDataDTO metadata = meta.get(0); inGadgetDefinition.setGadgetAuthor(metadata.getAuthor()); log.info("Got gadget author: " + inGadgetDefinition.getGadgetAuthor()); inGadgetDefinition.setGadgetTitle(metadata.getTitle()); log.info("Got gadget title: " + inGadgetDefinition.getGadgetTitle()); inGadgetDefinition.setGadgetDescription(metadata.getDescription()); log.info("Got gadget description: " + inGadgetDefinition.getGadgetDescription()); } } catch (Exception e) { log.debug("Failed to fetch data", e); } }
GadgetDefinitionPopulator implements GalleryItemPopulator<GadgetDefinition> { public void populate(final GadgetDefinition inGadgetDefinition, final String inGadgetDefinitionUrl) { final Map<String, GeneralGadgetDefinition> gadgetDefs = new HashMap<String, GeneralGadgetDefinition>(); gadgetDefs.put(inGadgetDefinitionUrl, inGadgetDefinition); log.info("Fetching gadget data"); try { List<GadgetMetaDataDTO> meta = metaDataFetcher.getGadgetsMetaData(gadgetDefs); if (meta.size() > 0) { GadgetMetaDataDTO metadata = meta.get(0); inGadgetDefinition.setGadgetAuthor(metadata.getAuthor()); log.info("Got gadget author: " + inGadgetDefinition.getGadgetAuthor()); inGadgetDefinition.setGadgetTitle(metadata.getTitle()); log.info("Got gadget title: " + inGadgetDefinition.getGadgetTitle()); inGadgetDefinition.setGadgetDescription(metadata.getDescription()); log.info("Got gadget description: " + inGadgetDefinition.getGadgetDescription()); } } catch (Exception e) { log.debug("Failed to fetch data", e); } } }
GadgetDefinitionPopulator implements GalleryItemPopulator<GadgetDefinition> { public void populate(final GadgetDefinition inGadgetDefinition, final String inGadgetDefinitionUrl) { final Map<String, GeneralGadgetDefinition> gadgetDefs = new HashMap<String, GeneralGadgetDefinition>(); gadgetDefs.put(inGadgetDefinitionUrl, inGadgetDefinition); log.info("Fetching gadget data"); try { List<GadgetMetaDataDTO> meta = metaDataFetcher.getGadgetsMetaData(gadgetDefs); if (meta.size() > 0) { GadgetMetaDataDTO metadata = meta.get(0); inGadgetDefinition.setGadgetAuthor(metadata.getAuthor()); log.info("Got gadget author: " + inGadgetDefinition.getGadgetAuthor()); inGadgetDefinition.setGadgetTitle(metadata.getTitle()); log.info("Got gadget title: " + inGadgetDefinition.getGadgetTitle()); inGadgetDefinition.setGadgetDescription(metadata.getDescription()); log.info("Got gadget description: " + inGadgetDefinition.getGadgetDescription()); } } catch (Exception e) { log.debug("Failed to fetch data", e); } } GadgetDefinitionPopulator(final GadgetMetaDataFetcher inMetaDataFetcher); }
GadgetDefinitionPopulator implements GalleryItemPopulator<GadgetDefinition> { public void populate(final GadgetDefinition inGadgetDefinition, final String inGadgetDefinitionUrl) { final Map<String, GeneralGadgetDefinition> gadgetDefs = new HashMap<String, GeneralGadgetDefinition>(); gadgetDefs.put(inGadgetDefinitionUrl, inGadgetDefinition); log.info("Fetching gadget data"); try { List<GadgetMetaDataDTO> meta = metaDataFetcher.getGadgetsMetaData(gadgetDefs); if (meta.size() > 0) { GadgetMetaDataDTO metadata = meta.get(0); inGadgetDefinition.setGadgetAuthor(metadata.getAuthor()); log.info("Got gadget author: " + inGadgetDefinition.getGadgetAuthor()); inGadgetDefinition.setGadgetTitle(metadata.getTitle()); log.info("Got gadget title: " + inGadgetDefinition.getGadgetTitle()); inGadgetDefinition.setGadgetDescription(metadata.getDescription()); log.info("Got gadget description: " + inGadgetDefinition.getGadgetDescription()); } } catch (Exception e) { log.debug("Failed to fetch data", e); } } GadgetDefinitionPopulator(final GadgetMetaDataFetcher inMetaDataFetcher); void populate(final GadgetDefinition inGadgetDefinition, final String inGadgetDefinitionUrl); }
GadgetDefinitionPopulator implements GalleryItemPopulator<GadgetDefinition> { public void populate(final GadgetDefinition inGadgetDefinition, final String inGadgetDefinitionUrl) { final Map<String, GeneralGadgetDefinition> gadgetDefs = new HashMap<String, GeneralGadgetDefinition>(); gadgetDefs.put(inGadgetDefinitionUrl, inGadgetDefinition); log.info("Fetching gadget data"); try { List<GadgetMetaDataDTO> meta = metaDataFetcher.getGadgetsMetaData(gadgetDefs); if (meta.size() > 0) { GadgetMetaDataDTO metadata = meta.get(0); inGadgetDefinition.setGadgetAuthor(metadata.getAuthor()); log.info("Got gadget author: " + inGadgetDefinition.getGadgetAuthor()); inGadgetDefinition.setGadgetTitle(metadata.getTitle()); log.info("Got gadget title: " + inGadgetDefinition.getGadgetTitle()); inGadgetDefinition.setGadgetDescription(metadata.getDescription()); log.info("Got gadget description: " + inGadgetDefinition.getGadgetDescription()); } } catch (Exception e) { log.debug("Failed to fetch data", e); } } GadgetDefinitionPopulator(final GadgetMetaDataFetcher inMetaDataFetcher); void populate(final GadgetDefinition inGadgetDefinition, final String inGadgetDefinitionUrl);  }