@Test public void testGetCurrentThemeChainWhenShopUrlEmptyDefaultThemeCfgBlank() throws Exception { final ShopService shopService = mockery.mock(ShopService.class, "shopService"); final Shop shop = mockery.mock(Shop.class, "shop"); mockery.checking(new Expectations() {{ allowing(shopService).getById(1L); will(returnValue(shop)); allowing(shop).getShopUrl(); will(returnValue(Collections.emptySet())); allowing(shop).getFspointer(); will(returnValue(" ")); }}); final ThemeServiceImpl themeService = new ThemeServiceImpl(shopService); final List<String> chain0 = themeService.getThemeChainByShopId(1L, "www.default.com"); assertNotNull(chain0); assertEquals(1, chain0.size()); assertEquals("default", chain0.get(0)); mockery.assertIsSatisfied(); }
@Override @Cacheable(value = "themeService-themeChainByShopId") public List<String> getThemeChainByShopId(final Long shopId, final String domain) { if (shopId != null) { final Shop shop = shopService.getById(shopId); if (shop != null) { String themeCfg = null; if (StringUtils.isNotBlank(domain) && shop.getShopUrl() != null) { for (final ShopUrl url : shop.getShopUrl()) { if (domain.equalsIgnoreCase(url.getUrl()) && StringUtils.isNotBlank(url.getThemeChain())) { themeCfg = url.getThemeChain(); break; } } } if (StringUtils.isBlank(themeCfg)) { themeCfg = shop.getFspointer(); } if (StringUtils.isNotBlank(themeCfg)) { if (themeCfg.indexOf(';') == -1) { final List<String> tmpChain = new ArrayList<>(Collections.singletonList(themeCfg)); if (!tmpChain.contains(DEFAULT_THEME)) { tmpChain.add(DEFAULT_THEME); } return Collections.unmodifiableList(tmpChain); } final List<String> tmpChain = new ArrayList<>(Arrays.asList(StringUtils.split(themeCfg, ';'))); if (!tmpChain.contains(DEFAULT_THEME)) { tmpChain.add(DEFAULT_THEME); } return Collections.unmodifiableList(tmpChain); } } } return DEFAULT_CHAIN; }
ThemeServiceImpl implements ThemeService { @Override @Cacheable(value = "themeService-themeChainByShopId") public List<String> getThemeChainByShopId(final Long shopId, final String domain) { if (shopId != null) { final Shop shop = shopService.getById(shopId); if (shop != null) { String themeCfg = null; if (StringUtils.isNotBlank(domain) && shop.getShopUrl() != null) { for (final ShopUrl url : shop.getShopUrl()) { if (domain.equalsIgnoreCase(url.getUrl()) && StringUtils.isNotBlank(url.getThemeChain())) { themeCfg = url.getThemeChain(); break; } } } if (StringUtils.isBlank(themeCfg)) { themeCfg = shop.getFspointer(); } if (StringUtils.isNotBlank(themeCfg)) { if (themeCfg.indexOf(';') == -1) { final List<String> tmpChain = new ArrayList<>(Collections.singletonList(themeCfg)); if (!tmpChain.contains(DEFAULT_THEME)) { tmpChain.add(DEFAULT_THEME); } return Collections.unmodifiableList(tmpChain); } final List<String> tmpChain = new ArrayList<>(Arrays.asList(StringUtils.split(themeCfg, ';'))); if (!tmpChain.contains(DEFAULT_THEME)) { tmpChain.add(DEFAULT_THEME); } return Collections.unmodifiableList(tmpChain); } } } return DEFAULT_CHAIN; } }
ThemeServiceImpl implements ThemeService { @Override @Cacheable(value = "themeService-themeChainByShopId") public List<String> getThemeChainByShopId(final Long shopId, final String domain) { if (shopId != null) { final Shop shop = shopService.getById(shopId); if (shop != null) { String themeCfg = null; if (StringUtils.isNotBlank(domain) && shop.getShopUrl() != null) { for (final ShopUrl url : shop.getShopUrl()) { if (domain.equalsIgnoreCase(url.getUrl()) && StringUtils.isNotBlank(url.getThemeChain())) { themeCfg = url.getThemeChain(); break; } } } if (StringUtils.isBlank(themeCfg)) { themeCfg = shop.getFspointer(); } if (StringUtils.isNotBlank(themeCfg)) { if (themeCfg.indexOf(';') == -1) { final List<String> tmpChain = new ArrayList<>(Collections.singletonList(themeCfg)); if (!tmpChain.contains(DEFAULT_THEME)) { tmpChain.add(DEFAULT_THEME); } return Collections.unmodifiableList(tmpChain); } final List<String> tmpChain = new ArrayList<>(Arrays.asList(StringUtils.split(themeCfg, ';'))); if (!tmpChain.contains(DEFAULT_THEME)) { tmpChain.add(DEFAULT_THEME); } return Collections.unmodifiableList(tmpChain); } } } return DEFAULT_CHAIN; } ThemeServiceImpl(final ShopService shopService); }
ThemeServiceImpl implements ThemeService { @Override @Cacheable(value = "themeService-themeChainByShopId") public List<String> getThemeChainByShopId(final Long shopId, final String domain) { if (shopId != null) { final Shop shop = shopService.getById(shopId); if (shop != null) { String themeCfg = null; if (StringUtils.isNotBlank(domain) && shop.getShopUrl() != null) { for (final ShopUrl url : shop.getShopUrl()) { if (domain.equalsIgnoreCase(url.getUrl()) && StringUtils.isNotBlank(url.getThemeChain())) { themeCfg = url.getThemeChain(); break; } } } if (StringUtils.isBlank(themeCfg)) { themeCfg = shop.getFspointer(); } if (StringUtils.isNotBlank(themeCfg)) { if (themeCfg.indexOf(';') == -1) { final List<String> tmpChain = new ArrayList<>(Collections.singletonList(themeCfg)); if (!tmpChain.contains(DEFAULT_THEME)) { tmpChain.add(DEFAULT_THEME); } return Collections.unmodifiableList(tmpChain); } final List<String> tmpChain = new ArrayList<>(Arrays.asList(StringUtils.split(themeCfg, ';'))); if (!tmpChain.contains(DEFAULT_THEME)) { tmpChain.add(DEFAULT_THEME); } return Collections.unmodifiableList(tmpChain); } } } return DEFAULT_CHAIN; } ThemeServiceImpl(final ShopService shopService); @Override @Cacheable(value = "themeService-themeChainByShopId") List<String> getThemeChainByShopId(final Long shopId, final String domain); @Override @Cacheable(value = "themeService-markupChainByShopId") List<String> getMarkupChainByShopId(final Long shopId, final String domain); @Override @Cacheable(value = "themeService-mailTemplateChainByShopId") List<String> getMailTemplateChainByShopId(final Long shopId); @Override @Cacheable(value = "themeService-reportsTemplateChainByShopId") List<String> getReportsTemplateChainByShopId(final Long shopId); }
ThemeServiceImpl implements ThemeService { @Override @Cacheable(value = "themeService-themeChainByShopId") public List<String> getThemeChainByShopId(final Long shopId, final String domain) { if (shopId != null) { final Shop shop = shopService.getById(shopId); if (shop != null) { String themeCfg = null; if (StringUtils.isNotBlank(domain) && shop.getShopUrl() != null) { for (final ShopUrl url : shop.getShopUrl()) { if (domain.equalsIgnoreCase(url.getUrl()) && StringUtils.isNotBlank(url.getThemeChain())) { themeCfg = url.getThemeChain(); break; } } } if (StringUtils.isBlank(themeCfg)) { themeCfg = shop.getFspointer(); } if (StringUtils.isNotBlank(themeCfg)) { if (themeCfg.indexOf(';') == -1) { final List<String> tmpChain = new ArrayList<>(Collections.singletonList(themeCfg)); if (!tmpChain.contains(DEFAULT_THEME)) { tmpChain.add(DEFAULT_THEME); } return Collections.unmodifiableList(tmpChain); } final List<String> tmpChain = new ArrayList<>(Arrays.asList(StringUtils.split(themeCfg, ';'))); if (!tmpChain.contains(DEFAULT_THEME)) { tmpChain.add(DEFAULT_THEME); } return Collections.unmodifiableList(tmpChain); } } } return DEFAULT_CHAIN; } ThemeServiceImpl(final ShopService shopService); @Override @Cacheable(value = "themeService-themeChainByShopId") List<String> getThemeChainByShopId(final Long shopId, final String domain); @Override @Cacheable(value = "themeService-markupChainByShopId") List<String> getMarkupChainByShopId(final Long shopId, final String domain); @Override @Cacheable(value = "themeService-mailTemplateChainByShopId") List<String> getMailTemplateChainByShopId(final Long shopId); @Override @Cacheable(value = "themeService-reportsTemplateChainByShopId") List<String> getReportsTemplateChainByShopId(final Long shopId);  }