@Test public void testResolveMainPanelRendererLabelFilteredCategoryTypeNoTemplate() throws Exception { final CategoryService categoryService = context.mock(CategoryService.class, "categoryService"); final AttributeService attributeService = context.mock(AttributeService.class, "attributeService"); final ShopService shopService = context.mock(ShopService.class, "shopService"); CentralViewResolverSearchImpl resolver = new CentralViewResolverSearchImpl(shopService, attributeService, categoryService); context.checking(new Expectations() {{ oneOf(attributeService).getAllNavigatableAttributeCodes(); will(returnValue(NAV)); oneOf(shopService).getShopCategorySearchTemplate(2L, 1L); will(returnValue("")); }}); try { ApplicationDirector.setShoppingCart(CART); final Pair<String, String> resolved = resolver.resolveMainPanelRendererLabel(new HashMap<String, String>() {{ put("nav1", "1"); put(WebParametersKeys.CATEGORY_ID, "1"); }}); assertNotNull(resolved); assertEquals(CentralViewLabel.SEARCH_LIST, resolved.getFirst()); assertEquals(CentralViewLabel.SEARCH_LIST, resolved.getSecond()); } finally { ApplicationDirector.clear(); } context.assertIsSatisfied(); }
@Override public Pair<String, String> resolveMainPanelRendererLabel(final Map parameters) { if (parameters.containsKey(WebParametersKeys.QUERY) || isAttributiveFilteredNavigation(attributeService.getAllNavigatableAttributeCodes(), parameters)) { if (parameters.containsKey(WebParametersKeys.CATEGORY_ID)) { final long categoryId = NumberUtils.toLong(HttpUtil.getSingleValue(parameters.get(WebParametersKeys.CATEGORY_ID))); if (categoryId > 0L) { final long shopId = ApplicationDirector.getShoppingCart().getShoppingContext().getShopId(); final String searchTemplate = shopService.getShopCategorySearchTemplate(shopId, categoryId); if (StringUtils.isNotBlank(searchTemplate)) { return new Pair<>(searchTemplate, CentralViewLabel.SEARCH_LIST); } } } return DEFAULT; } return null; }
CentralViewResolverSearchImpl implements CentralViewResolver { @Override public Pair<String, String> resolveMainPanelRendererLabel(final Map parameters) { if (parameters.containsKey(WebParametersKeys.QUERY) || isAttributiveFilteredNavigation(attributeService.getAllNavigatableAttributeCodes(), parameters)) { if (parameters.containsKey(WebParametersKeys.CATEGORY_ID)) { final long categoryId = NumberUtils.toLong(HttpUtil.getSingleValue(parameters.get(WebParametersKeys.CATEGORY_ID))); if (categoryId > 0L) { final long shopId = ApplicationDirector.getShoppingCart().getShoppingContext().getShopId(); final String searchTemplate = shopService.getShopCategorySearchTemplate(shopId, categoryId); if (StringUtils.isNotBlank(searchTemplate)) { return new Pair<>(searchTemplate, CentralViewLabel.SEARCH_LIST); } } } return DEFAULT; } return null; } }
CentralViewResolverSearchImpl implements CentralViewResolver { @Override public Pair<String, String> resolveMainPanelRendererLabel(final Map parameters) { if (parameters.containsKey(WebParametersKeys.QUERY) || isAttributiveFilteredNavigation(attributeService.getAllNavigatableAttributeCodes(), parameters)) { if (parameters.containsKey(WebParametersKeys.CATEGORY_ID)) { final long categoryId = NumberUtils.toLong(HttpUtil.getSingleValue(parameters.get(WebParametersKeys.CATEGORY_ID))); if (categoryId > 0L) { final long shopId = ApplicationDirector.getShoppingCart().getShoppingContext().getShopId(); final String searchTemplate = shopService.getShopCategorySearchTemplate(shopId, categoryId); if (StringUtils.isNotBlank(searchTemplate)) { return new Pair<>(searchTemplate, CentralViewLabel.SEARCH_LIST); } } } return DEFAULT; } return null; } CentralViewResolverSearchImpl(final ShopService shopService,
                                         final AttributeService attributeService,
                                         final CategoryService categoryService); }
CentralViewResolverSearchImpl implements CentralViewResolver { @Override public Pair<String, String> resolveMainPanelRendererLabel(final Map parameters) { if (parameters.containsKey(WebParametersKeys.QUERY) || isAttributiveFilteredNavigation(attributeService.getAllNavigatableAttributeCodes(), parameters)) { if (parameters.containsKey(WebParametersKeys.CATEGORY_ID)) { final long categoryId = NumberUtils.toLong(HttpUtil.getSingleValue(parameters.get(WebParametersKeys.CATEGORY_ID))); if (categoryId > 0L) { final long shopId = ApplicationDirector.getShoppingCart().getShoppingContext().getShopId(); final String searchTemplate = shopService.getShopCategorySearchTemplate(shopId, categoryId); if (StringUtils.isNotBlank(searchTemplate)) { return new Pair<>(searchTemplate, CentralViewLabel.SEARCH_LIST); } } } return DEFAULT; } return null; } CentralViewResolverSearchImpl(final ShopService shopService,
                                         final AttributeService attributeService,
                                         final CategoryService categoryService); @Override Pair<String, String> resolveMainPanelRendererLabel(final Map parameters); }
CentralViewResolverSearchImpl implements CentralViewResolver { @Override public Pair<String, String> resolveMainPanelRendererLabel(final Map parameters) { if (parameters.containsKey(WebParametersKeys.QUERY) || isAttributiveFilteredNavigation(attributeService.getAllNavigatableAttributeCodes(), parameters)) { if (parameters.containsKey(WebParametersKeys.CATEGORY_ID)) { final long categoryId = NumberUtils.toLong(HttpUtil.getSingleValue(parameters.get(WebParametersKeys.CATEGORY_ID))); if (categoryId > 0L) { final long shopId = ApplicationDirector.getShoppingCart().getShoppingContext().getShopId(); final String searchTemplate = shopService.getShopCategorySearchTemplate(shopId, categoryId); if (StringUtils.isNotBlank(searchTemplate)) { return new Pair<>(searchTemplate, CentralViewLabel.SEARCH_LIST); } } } return DEFAULT; } return null; } CentralViewResolverSearchImpl(final ShopService shopService,
                                         final AttributeService attributeService,
                                         final CategoryService categoryService); @Override Pair<String, String> resolveMainPanelRendererLabel(final Map parameters);  }