@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 themeUrl = "src/main/webapp/themes/vegas.xml"; final String themeCategory = "CITY"; final Theme theme = new Theme(themeUrl, themeName, themeDesc, null, null, null, personName, personEmail); final HashMap<String, Serializable> formData = new HashMap<String, Serializable>(); formData.put("url", themeUrl); formData.put("category", themeCategory); final GalleryItemCategory galleryItemCategory = new GalleryItemCategory(themeCategory); final String url = themeUrl; final String category = themeCategory; final Map<String, Serializable> fields = new HashMap<String, Serializable>(); fields.put("url", url); fields.put("category", category); context.checking(new Expectations() { { oneOf(userDetails).getParams(); will(returnValue(fields)); oneOf(galleryItemGetter).provide(userDetails, formData); will(returnValue(theme)); oneOf(galleryItemPopulator).populate(theme, url); oneOf(galleryItemCategoryMapper).findByName(GalleryItemType.THEME, category); will(returnValue(galleryItemCategory)); oneOf(galleryItemSaver).save(theme); } }); Theme actual = (Theme) sutTheme.execute(userDetails); context.assertIsSatisfied(); assertSame(theme, actual); 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", themeUrl, theme.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);  }