@Test public void test() { final HashMap<String, Serializable> formData = new HashMap<String, Serializable>(); formData.put("description", "description goes here"); formData.put("category", "BLAH"); formData.put("tab", "5"); context.checking(new Expectations() { { oneOf(actionContext).getParams(); will(returnValue(formData)); oneOf(getGalleryTabTemplateByIdMapper).execute(with(any(FindByIdRequest.class))); will(returnValue(mockGalleryTabTemplate)); oneOf(findTabByIdMapper).execute(with(any(FindByIdRequest.class))); will(returnValue(mockTab)); oneOf(mockTab).getTemplate(); will(returnValue(mockTabTemplate)); allowing(mockTabTemplate).getTabName(); will(returnValue("tab name")); oneOf(mockTabTemplate).getTabLayout(); will(returnValue(Layout.THREECOLUMN)); oneOf(mockTabTemplate).getGadgets(); will(returnValue(new ArrayList<Gadget>())); oneOf(galleryItemCategoryMapper).findByName(GalleryItemType.TAB, "BLAH"); will(returnValue(mockGalleryItemCategory)); oneOf(mockGalleryTabTemplate).setCategory(mockGalleryItemCategory); oneOf(mockGalleryTabTemplate).setDescription("description goes here"); oneOf(mockGalleryTabTemplate).setTabTemplate(with(any(TabTemplate.class))); oneOf(mockGalleryTabTemplate).setTitle("tab name"); oneOf(insertMapper).execute(with(any(PersistenceRequest.class))); will(returnValue(true)); } }); sut.execute(actionContext); context.assertIsSatisfied(); }
@Override public Serializable execute(final ServiceActionContext inActionContext) { Map<String, Serializable> fields = (Map<String, Serializable>) inActionContext.getParams(); String category = (String) fields.get(CATEGORY_KEY); String description = (String) fields.get(DESCRIPTION_KEY); String tabStringId = (String) fields.get(TAB_KEY); Long tabId = StringUtils.isNotEmpty(tabStringId) && !StringUtils.equalsIgnoreCase(tabStringId, "-1") ? Long .parseLong(tabStringId) : null; String galleryTabTemplateStringId = (String) fields.get(GALLERYTABTEMPLATE_ID_KEY); Long galleryTabTemplateId = StringUtils.isNotEmpty(galleryTabTemplateStringId) ? Long .parseLong(galleryTabTemplateStringId) : null; GalleryTabTemplate gtt = getGalleryTabTemplateByIdMapper.execute(galleryTabTemplateId == null ? null : new FindByIdRequest("GalleryTabTemplate", galleryTabTemplateId)); if (tabId != null) { Tab tab = findTabByIdMapper.execute(new FindByIdRequest("Tab", tabId)); TabTemplate newTabTemplate = new TabTemplate(tab.getTemplate()); gtt.setTabTemplate(newTabTemplate); gtt.setTitle(newTabTemplate.getTabName()); } GalleryItemCategory galleryItemCategory = galleryItemCategoryMapper.findByName(GalleryItemType.TAB, category); gtt.setCategory(galleryItemCategory); gtt.setDescription(description); return persistMapper.execute(new PersistenceRequest<GalleryTabTemplate>(gtt)); }
CreateGalleryTabTemplateExecution implements ExecutionStrategy<ServiceActionContext> { @Override public Serializable execute(final ServiceActionContext inActionContext) { Map<String, Serializable> fields = (Map<String, Serializable>) inActionContext.getParams(); String category = (String) fields.get(CATEGORY_KEY); String description = (String) fields.get(DESCRIPTION_KEY); String tabStringId = (String) fields.get(TAB_KEY); Long tabId = StringUtils.isNotEmpty(tabStringId) && !StringUtils.equalsIgnoreCase(tabStringId, "-1") ? Long .parseLong(tabStringId) : null; String galleryTabTemplateStringId = (String) fields.get(GALLERYTABTEMPLATE_ID_KEY); Long galleryTabTemplateId = StringUtils.isNotEmpty(galleryTabTemplateStringId) ? Long .parseLong(galleryTabTemplateStringId) : null; GalleryTabTemplate gtt = getGalleryTabTemplateByIdMapper.execute(galleryTabTemplateId == null ? null : new FindByIdRequest("GalleryTabTemplate", galleryTabTemplateId)); if (tabId != null) { Tab tab = findTabByIdMapper.execute(new FindByIdRequest("Tab", tabId)); TabTemplate newTabTemplate = new TabTemplate(tab.getTemplate()); gtt.setTabTemplate(newTabTemplate); gtt.setTitle(newTabTemplate.getTabName()); } GalleryItemCategory galleryItemCategory = galleryItemCategoryMapper.findByName(GalleryItemType.TAB, category); gtt.setCategory(galleryItemCategory); gtt.setDescription(description); return persistMapper.execute(new PersistenceRequest<GalleryTabTemplate>(gtt)); } }
CreateGalleryTabTemplateExecution implements ExecutionStrategy<ServiceActionContext> { @Override public Serializable execute(final ServiceActionContext inActionContext) { Map<String, Serializable> fields = (Map<String, Serializable>) inActionContext.getParams(); String category = (String) fields.get(CATEGORY_KEY); String description = (String) fields.get(DESCRIPTION_KEY); String tabStringId = (String) fields.get(TAB_KEY); Long tabId = StringUtils.isNotEmpty(tabStringId) && !StringUtils.equalsIgnoreCase(tabStringId, "-1") ? Long .parseLong(tabStringId) : null; String galleryTabTemplateStringId = (String) fields.get(GALLERYTABTEMPLATE_ID_KEY); Long galleryTabTemplateId = StringUtils.isNotEmpty(galleryTabTemplateStringId) ? Long .parseLong(galleryTabTemplateStringId) : null; GalleryTabTemplate gtt = getGalleryTabTemplateByIdMapper.execute(galleryTabTemplateId == null ? null : new FindByIdRequest("GalleryTabTemplate", galleryTabTemplateId)); if (tabId != null) { Tab tab = findTabByIdMapper.execute(new FindByIdRequest("Tab", tabId)); TabTemplate newTabTemplate = new TabTemplate(tab.getTemplate()); gtt.setTabTemplate(newTabTemplate); gtt.setTitle(newTabTemplate.getTabName()); } GalleryItemCategory galleryItemCategory = galleryItemCategoryMapper.findByName(GalleryItemType.TAB, category); gtt.setCategory(galleryItemCategory); gtt.setDescription(description); return persistMapper.execute(new PersistenceRequest<GalleryTabTemplate>(gtt)); } CreateGalleryTabTemplateExecution(final DomainMapper<FindByIdRequest, Tab> inFindTabByIdMapper,
            final DomainMapper<FindByIdRequest, GalleryTabTemplate> inGetGalleryTabTemplateByIdMapper,
            final GalleryItemCategoryMapper inGalleryItemCategoryMapper,
            final DomainMapper<PersistenceRequest<GalleryTabTemplate>, Boolean> inPersistMapper); }
CreateGalleryTabTemplateExecution implements ExecutionStrategy<ServiceActionContext> { @Override public Serializable execute(final ServiceActionContext inActionContext) { Map<String, Serializable> fields = (Map<String, Serializable>) inActionContext.getParams(); String category = (String) fields.get(CATEGORY_KEY); String description = (String) fields.get(DESCRIPTION_KEY); String tabStringId = (String) fields.get(TAB_KEY); Long tabId = StringUtils.isNotEmpty(tabStringId) && !StringUtils.equalsIgnoreCase(tabStringId, "-1") ? Long .parseLong(tabStringId) : null; String galleryTabTemplateStringId = (String) fields.get(GALLERYTABTEMPLATE_ID_KEY); Long galleryTabTemplateId = StringUtils.isNotEmpty(galleryTabTemplateStringId) ? Long .parseLong(galleryTabTemplateStringId) : null; GalleryTabTemplate gtt = getGalleryTabTemplateByIdMapper.execute(galleryTabTemplateId == null ? null : new FindByIdRequest("GalleryTabTemplate", galleryTabTemplateId)); if (tabId != null) { Tab tab = findTabByIdMapper.execute(new FindByIdRequest("Tab", tabId)); TabTemplate newTabTemplate = new TabTemplate(tab.getTemplate()); gtt.setTabTemplate(newTabTemplate); gtt.setTitle(newTabTemplate.getTabName()); } GalleryItemCategory galleryItemCategory = galleryItemCategoryMapper.findByName(GalleryItemType.TAB, category); gtt.setCategory(galleryItemCategory); gtt.setDescription(description); return persistMapper.execute(new PersistenceRequest<GalleryTabTemplate>(gtt)); } CreateGalleryTabTemplateExecution(final DomainMapper<FindByIdRequest, Tab> inFindTabByIdMapper,
            final DomainMapper<FindByIdRequest, GalleryTabTemplate> inGetGalleryTabTemplateByIdMapper,
            final GalleryItemCategoryMapper inGalleryItemCategoryMapper,
            final DomainMapper<PersistenceRequest<GalleryTabTemplate>, Boolean> inPersistMapper); @Override Serializable execute(final ServiceActionContext inActionContext); }
CreateGalleryTabTemplateExecution implements ExecutionStrategy<ServiceActionContext> { @Override public Serializable execute(final ServiceActionContext inActionContext) { Map<String, Serializable> fields = (Map<String, Serializable>) inActionContext.getParams(); String category = (String) fields.get(CATEGORY_KEY); String description = (String) fields.get(DESCRIPTION_KEY); String tabStringId = (String) fields.get(TAB_KEY); Long tabId = StringUtils.isNotEmpty(tabStringId) && !StringUtils.equalsIgnoreCase(tabStringId, "-1") ? Long .parseLong(tabStringId) : null; String galleryTabTemplateStringId = (String) fields.get(GALLERYTABTEMPLATE_ID_KEY); Long galleryTabTemplateId = StringUtils.isNotEmpty(galleryTabTemplateStringId) ? Long .parseLong(galleryTabTemplateStringId) : null; GalleryTabTemplate gtt = getGalleryTabTemplateByIdMapper.execute(galleryTabTemplateId == null ? null : new FindByIdRequest("GalleryTabTemplate", galleryTabTemplateId)); if (tabId != null) { Tab tab = findTabByIdMapper.execute(new FindByIdRequest("Tab", tabId)); TabTemplate newTabTemplate = new TabTemplate(tab.getTemplate()); gtt.setTabTemplate(newTabTemplate); gtt.setTitle(newTabTemplate.getTabName()); } GalleryItemCategory galleryItemCategory = galleryItemCategoryMapper.findByName(GalleryItemType.TAB, category); gtt.setCategory(galleryItemCategory); gtt.setDescription(description); return persistMapper.execute(new PersistenceRequest<GalleryTabTemplate>(gtt)); } CreateGalleryTabTemplateExecution(final DomainMapper<FindByIdRequest, Tab> inFindTabByIdMapper,
            final DomainMapper<FindByIdRequest, GalleryTabTemplate> inGetGalleryTabTemplateByIdMapper,
            final GalleryItemCategoryMapper inGalleryItemCategoryMapper,
            final DomainMapper<PersistenceRequest<GalleryTabTemplate>, Boolean> inPersistMapper); @Override Serializable execute(final ServiceActionContext inActionContext);  }