@Test public final void testExecuteWithPlugin() throws Exception { final GalleryItemCategory galleryItemCategory = new GalleryItemCategory("CITY"); final String urlPath = "src/main/webapp/plugin/plugin.xml"; final PluginDefinition pluginDef = new PluginDefinition(); pluginDef.setUpdateFrequency(9L); pluginDef.setUrl(urlPath); pluginDef.setCategory(galleryItemCategory); final String username = "validuser"; final HashMap<String, Serializable> formData = new HashMap<String, Serializable>(); formData.put("url", urlPath); formData.put("category", "CITY"); context.checking(new Expectations() { { oneOf(userDetails).getParams(); will(returnValue(formData)); oneOf(pluginItemGetter).provide(userDetails, formData); will(returnValue(pluginDef)); oneOf(galleryItemCategoryMapper).findByName(GalleryItemType.PLUGIN, "CITY"); will(returnValue(galleryItemCategory)); oneOf(pluginItemPopulator).populate(pluginDef, urlPath); oneOf(pluginItemSaver).save(pluginDef); } }); Serializable[] params = { formData }; PluginDefinition actual = (PluginDefinition) sutPlugin.execute(userDetails); context.assertIsSatisfied(); assertEquals("property should be gotten", new Long(9), pluginDef.getUpdateFrequency()); assertEquals("property should be gotten", urlPath, pluginDef.getUrl()); }
@SuppressWarnings("unchecked") @Override public Serializable execute(final ServiceActionContext inActionContext) { Map<String, Serializable> fields = (Map<String, Serializable>) inActionContext.getParams(); String galleryItemUrl = (String) fields.get(URL_KEY); String category = (String) fields.get(CATEGORY_KEY); T galleryItem = galleryItemProvider.provide(inActionContext, fields); galleryItemPopulator.populate(galleryItem, galleryItemUrl); galleryItem.setUrl(galleryItemUrl); GalleryItemCategory galleryItemCategory = galleryItemCategoryMapper.findByName(galleryItemType, category); log.debug("Search for gallery item using galleryItemType: " + galleryItemType + "and category: " + category + " returned: " + galleryItemCategory); galleryItem.setCategory(galleryItemCategory); galleryItemSaver.save(galleryItem); return galleryItem; }
PersistGalleryItemExecution implements ExecutionStrategy<ServiceActionContext> { @SuppressWarnings("unchecked") @Override public Serializable execute(final ServiceActionContext inActionContext) { Map<String, Serializable> fields = (Map<String, Serializable>) inActionContext.getParams(); String galleryItemUrl = (String) fields.get(URL_KEY); String category = (String) fields.get(CATEGORY_KEY); T galleryItem = galleryItemProvider.provide(inActionContext, fields); galleryItemPopulator.populate(galleryItem, galleryItemUrl); galleryItem.setUrl(galleryItemUrl); GalleryItemCategory galleryItemCategory = galleryItemCategoryMapper.findByName(galleryItemType, category); log.debug("Search for gallery item using galleryItemType: " + galleryItemType + "and category: " + category + " returned: " + galleryItemCategory); galleryItem.setCategory(galleryItemCategory); galleryItemSaver.save(galleryItem); return galleryItem; } }
PersistGalleryItemExecution implements ExecutionStrategy<ServiceActionContext> { @SuppressWarnings("unchecked") @Override public Serializable execute(final ServiceActionContext inActionContext) { Map<String, Serializable> fields = (Map<String, Serializable>) inActionContext.getParams(); String galleryItemUrl = (String) fields.get(URL_KEY); String category = (String) fields.get(CATEGORY_KEY); T galleryItem = galleryItemProvider.provide(inActionContext, fields); galleryItemPopulator.populate(galleryItem, galleryItemUrl); galleryItem.setUrl(galleryItemUrl); GalleryItemCategory galleryItemCategory = galleryItemCategoryMapper.findByName(galleryItemType, category); log.debug("Search for gallery item using galleryItemType: " + galleryItemType + "and category: " + category + " returned: " + galleryItemCategory); galleryItem.setCategory(galleryItemCategory); galleryItemSaver.save(galleryItem); return galleryItem; } PersistGalleryItemExecution(final GalleryItemProvider<T> inGalleryItemProvider,
            final GalleryItemPopulator<T> inGalleryItemPopulator, final GalleryItemSaver<T> inGalleryItemSaver,
            final GalleryItemCategoryMapper inGalleryItemCategoryMapper, final GalleryItemType inGalleryItemType); }
PersistGalleryItemExecution implements ExecutionStrategy<ServiceActionContext> { @SuppressWarnings("unchecked") @Override public Serializable execute(final ServiceActionContext inActionContext) { Map<String, Serializable> fields = (Map<String, Serializable>) inActionContext.getParams(); String galleryItemUrl = (String) fields.get(URL_KEY); String category = (String) fields.get(CATEGORY_KEY); T galleryItem = galleryItemProvider.provide(inActionContext, fields); galleryItemPopulator.populate(galleryItem, galleryItemUrl); galleryItem.setUrl(galleryItemUrl); GalleryItemCategory galleryItemCategory = galleryItemCategoryMapper.findByName(galleryItemType, category); log.debug("Search for gallery item using galleryItemType: " + galleryItemType + "and category: " + category + " returned: " + galleryItemCategory); galleryItem.setCategory(galleryItemCategory); galleryItemSaver.save(galleryItem); return galleryItem; } PersistGalleryItemExecution(final GalleryItemProvider<T> inGalleryItemProvider,
            final GalleryItemPopulator<T> inGalleryItemPopulator, final GalleryItemSaver<T> inGalleryItemSaver,
            final GalleryItemCategoryMapper inGalleryItemCategoryMapper, final GalleryItemType inGalleryItemType); @SuppressWarnings("unchecked") @Override Serializable execute(final ServiceActionContext inActionContext); }
PersistGalleryItemExecution implements ExecutionStrategy<ServiceActionContext> { @SuppressWarnings("unchecked") @Override public Serializable execute(final ServiceActionContext inActionContext) { Map<String, Serializable> fields = (Map<String, Serializable>) inActionContext.getParams(); String galleryItemUrl = (String) fields.get(URL_KEY); String category = (String) fields.get(CATEGORY_KEY); T galleryItem = galleryItemProvider.provide(inActionContext, fields); galleryItemPopulator.populate(galleryItem, galleryItemUrl); galleryItem.setUrl(galleryItemUrl); GalleryItemCategory galleryItemCategory = galleryItemCategoryMapper.findByName(galleryItemType, category); log.debug("Search for gallery item using galleryItemType: " + galleryItemType + "and category: " + category + " returned: " + galleryItemCategory); galleryItem.setCategory(galleryItemCategory); galleryItemSaver.save(galleryItem); return galleryItem; } PersistGalleryItemExecution(final GalleryItemProvider<T> inGalleryItemProvider,
            final GalleryItemPopulator<T> inGalleryItemPopulator, final GalleryItemSaver<T> inGalleryItemSaver,
            final GalleryItemCategoryMapper inGalleryItemCategoryMapper, final GalleryItemType inGalleryItemType); @SuppressWarnings("unchecked") @Override Serializable execute(final ServiceActionContext inActionContext);  }