@Test public void testGetPromotions() throws Exception { VoSearchContext ctxAll = new VoSearchContext(); ctxAll.setParameters(createSearchContextParams( "shopCode", "SHOIP1", "currency", "EUR" )); ctxAll.setSize(10); List<VoPromotion> promoNoFilter = voPromotionService.getFilteredPromotion(ctxAll).getItems(); assertNotNull(promoNoFilter); assertFalse(promoNoFilter.isEmpty()); VoSearchContext ctxFind = new VoSearchContext(); ctxFind.setParameters(createSearchContextParams( "filter", "Promo 002", "shopCode", "SHOIP1", "currency", "EUR" )); ctxFind.setSize(10); List<VoPromotion> promoFind = voPromotionService.getFilteredPromotion(ctxFind).getItems(); assertNotNull(promoFind); assertFalse(promoFind.isEmpty()); final VoPromotion promo2 = promoFind.get(0); assertEquals("PROMO002", promo2.getCode()); VoSearchContext ctxByCode = new VoSearchContext(); ctxByCode.setParameters(createSearchContextParams( "filter", "#PROMO002", "shopCode", "SHOIP1", "currency", "EUR" )); ctxByCode.setSize(10); List<VoPromotion> ptExact = voPromotionService.getFilteredPromotion(ctxByCode).getItems(); assertNotNull(ptExact); assertFalse(ptExact.isEmpty()); assertEquals("PROMO002", ptExact.get(0).getCode()); VoSearchContext ctxByConditions = new VoSearchContext(); ctxByConditions.setParameters(createSearchContextParams( "filter", "?true", "shopCode", "SHOIP1", "currency", "EUR" )); ctxByConditions.setSize(10); List<VoPromotion> promoByConditionOrContext1 = voPromotionService.getFilteredPromotion(ctxByConditions).getItems(); assertNotNull(promoByConditionOrContext1); assertFalse(promoByConditionOrContext1.isEmpty()); VoSearchContext ctxByConditionsEnabled = new VoSearchContext(); ctxByConditionsEnabled.setParameters(createSearchContextParams( "filter", "+?true", "shopCode", "SHOIP1", "currency", "EUR" )); ctxByConditionsEnabled.setSize(10); List<VoPromotion> promoEnabled = voPromotionService.getFilteredPromotion(ctxByConditionsEnabled).getItems(); assertNotNull(promoEnabled); assertTrue(promoEnabled.isEmpty()); VoSearchContext ctxByConditionsDisabled = new VoSearchContext(); ctxByConditionsDisabled.setParameters(createSearchContextParams( "filter", "-?true", "shopCode", "SHOIP1", "currency", "EUR" )); ctxByConditionsDisabled.setSize(10); List<VoPromotion> promoDisabled = voPromotionService.getFilteredPromotion(ctxByConditionsDisabled).getItems(); assertNotNull(promoDisabled); assertFalse(promoDisabled.isEmpty()); }
@Override public VoSearchResult<VoPromotion> getFilteredPromotion(final VoSearchContext filter) throws Exception { final VoSearchResult<VoPromotion> result = new VoSearchResult<>(); final List<VoPromotion> results = new ArrayList<>(); result.setSearchContext(filter); result.setItems(results); final String shopCode = FilterSearchUtils.getStringFilter(filter.getParameters().get("shopCode")); final String currency = FilterSearchUtils.getStringFilter(filter.getParameters().get("currency")); if (federationFacade.isManageable(shopCode, ShopDTO.class) && StringUtils.isNotBlank(currency)) { final SearchContext searchContext = new SearchContext( filter.getParameters(), filter.getStart(), filter.getSize(), filter.getSortBy(), filter.isSortDesc(), "filter", "types", "actions", "shopCode", "currency" ); final SearchResult<PromotionDTO> batch = dtoPromotionService.findPromotions(searchContext); if (!batch.getItems().isEmpty()) { results.addAll(voAssemblySupport.assembleVos(VoPromotion.class, PromotionDTO.class, batch.getItems())); } result.setTotal(batch.getTotal()); } return result; }
VoPromotionServiceImpl implements VoPromotionService { @Override public VoSearchResult<VoPromotion> getFilteredPromotion(final VoSearchContext filter) throws Exception { final VoSearchResult<VoPromotion> result = new VoSearchResult<>(); final List<VoPromotion> results = new ArrayList<>(); result.setSearchContext(filter); result.setItems(results); final String shopCode = FilterSearchUtils.getStringFilter(filter.getParameters().get("shopCode")); final String currency = FilterSearchUtils.getStringFilter(filter.getParameters().get("currency")); if (federationFacade.isManageable(shopCode, ShopDTO.class) && StringUtils.isNotBlank(currency)) { final SearchContext searchContext = new SearchContext( filter.getParameters(), filter.getStart(), filter.getSize(), filter.getSortBy(), filter.isSortDesc(), "filter", "types", "actions", "shopCode", "currency" ); final SearchResult<PromotionDTO> batch = dtoPromotionService.findPromotions(searchContext); if (!batch.getItems().isEmpty()) { results.addAll(voAssemblySupport.assembleVos(VoPromotion.class, PromotionDTO.class, batch.getItems())); } result.setTotal(batch.getTotal()); } return result; } }
VoPromotionServiceImpl implements VoPromotionService { @Override public VoSearchResult<VoPromotion> getFilteredPromotion(final VoSearchContext filter) throws Exception { final VoSearchResult<VoPromotion> result = new VoSearchResult<>(); final List<VoPromotion> results = new ArrayList<>(); result.setSearchContext(filter); result.setItems(results); final String shopCode = FilterSearchUtils.getStringFilter(filter.getParameters().get("shopCode")); final String currency = FilterSearchUtils.getStringFilter(filter.getParameters().get("currency")); if (federationFacade.isManageable(shopCode, ShopDTO.class) && StringUtils.isNotBlank(currency)) { final SearchContext searchContext = new SearchContext( filter.getParameters(), filter.getStart(), filter.getSize(), filter.getSortBy(), filter.isSortDesc(), "filter", "types", "actions", "shopCode", "currency" ); final SearchResult<PromotionDTO> batch = dtoPromotionService.findPromotions(searchContext); if (!batch.getItems().isEmpty()) { results.addAll(voAssemblySupport.assembleVos(VoPromotion.class, PromotionDTO.class, batch.getItems())); } result.setTotal(batch.getTotal()); } return result; } VoPromotionServiceImpl(final DtoPromotionService dtoPromotionService,
                                  final DtoPromotionCouponService dtoPromotionCouponService,
                                  final FederationFacade federationFacade,
                                  final VoAssemblySupport voAssemblySupport); }
VoPromotionServiceImpl implements VoPromotionService { @Override public VoSearchResult<VoPromotion> getFilteredPromotion(final VoSearchContext filter) throws Exception { final VoSearchResult<VoPromotion> result = new VoSearchResult<>(); final List<VoPromotion> results = new ArrayList<>(); result.setSearchContext(filter); result.setItems(results); final String shopCode = FilterSearchUtils.getStringFilter(filter.getParameters().get("shopCode")); final String currency = FilterSearchUtils.getStringFilter(filter.getParameters().get("currency")); if (federationFacade.isManageable(shopCode, ShopDTO.class) && StringUtils.isNotBlank(currency)) { final SearchContext searchContext = new SearchContext( filter.getParameters(), filter.getStart(), filter.getSize(), filter.getSortBy(), filter.isSortDesc(), "filter", "types", "actions", "shopCode", "currency" ); final SearchResult<PromotionDTO> batch = dtoPromotionService.findPromotions(searchContext); if (!batch.getItems().isEmpty()) { results.addAll(voAssemblySupport.assembleVos(VoPromotion.class, PromotionDTO.class, batch.getItems())); } result.setTotal(batch.getTotal()); } return result; } VoPromotionServiceImpl(final DtoPromotionService dtoPromotionService,
                                  final DtoPromotionCouponService dtoPromotionCouponService,
                                  final FederationFacade federationFacade,
                                  final VoAssemblySupport voAssemblySupport); @Override VoSearchResult<VoPromotion> getFilteredPromotion(final VoSearchContext filter); @Override VoPromotion getPromotionById(final long id); @Override VoPromotion updatePromotion(final VoPromotion vo); @Override VoPromotion createPromotion(final VoPromotion vo); @Override void removePromotion(final long id); @Override void updateDisabledFlag(final long id, final boolean disabled); @Override VoSearchResult<VoPromotionCoupon> getFilteredPromotionCoupons(final VoSearchContext filter); @Override void createPromotionCoupons(final VoPromotionCoupon vo); @Override void removePromotionCoupon(final long id); @Override VoCart testPromotions(final String shopCode,
                                 final String currency,
                                 final VoPromotionTest testData); }
VoPromotionServiceImpl implements VoPromotionService { @Override public VoSearchResult<VoPromotion> getFilteredPromotion(final VoSearchContext filter) throws Exception { final VoSearchResult<VoPromotion> result = new VoSearchResult<>(); final List<VoPromotion> results = new ArrayList<>(); result.setSearchContext(filter); result.setItems(results); final String shopCode = FilterSearchUtils.getStringFilter(filter.getParameters().get("shopCode")); final String currency = FilterSearchUtils.getStringFilter(filter.getParameters().get("currency")); if (federationFacade.isManageable(shopCode, ShopDTO.class) && StringUtils.isNotBlank(currency)) { final SearchContext searchContext = new SearchContext( filter.getParameters(), filter.getStart(), filter.getSize(), filter.getSortBy(), filter.isSortDesc(), "filter", "types", "actions", "shopCode", "currency" ); final SearchResult<PromotionDTO> batch = dtoPromotionService.findPromotions(searchContext); if (!batch.getItems().isEmpty()) { results.addAll(voAssemblySupport.assembleVos(VoPromotion.class, PromotionDTO.class, batch.getItems())); } result.setTotal(batch.getTotal()); } return result; } VoPromotionServiceImpl(final DtoPromotionService dtoPromotionService,
                                  final DtoPromotionCouponService dtoPromotionCouponService,
                                  final FederationFacade federationFacade,
                                  final VoAssemblySupport voAssemblySupport); @Override VoSearchResult<VoPromotion> getFilteredPromotion(final VoSearchContext filter); @Override VoPromotion getPromotionById(final long id); @Override VoPromotion updatePromotion(final VoPromotion vo); @Override VoPromotion createPromotion(final VoPromotion vo); @Override void removePromotion(final long id); @Override void updateDisabledFlag(final long id, final boolean disabled); @Override VoSearchResult<VoPromotionCoupon> getFilteredPromotionCoupons(final VoSearchContext filter); @Override void createPromotionCoupons(final VoPromotionCoupon vo); @Override void removePromotionCoupon(final long id); @Override VoCart testPromotions(final String shopCode,
                                 final String currency,
                                 final VoPromotionTest testData);  }