@Test public void testGetCategoryByPathEmpty() throws Exception { Utils.setupHttpResponse("magento-graphql-error.json", httpClient, HttpStatus.SC_OK); assertNull(dataService.getCategoryByPath("/", null)); }
@Override public CategoryTree getCategoryByPath(String urlPath, String storeView) { if (StringUtils.isBlank(urlPath)) { return null; } String mainPart = null; String[] parts = urlPath.split("/"); for (int i = parts.length; i > 0;) { String part = parts[--i]; if (StringUtils.isNotBlank(part)) { mainPart = part; break; } } if (mainPart == null) { return null; } try { String urlKey = mainPart; ArrayKey key = toCategoryDataCacheKey(urlKey, storeView); List<CategoryTree> categories = categoryDataCache.get(key, () -> getCategoryByKeyImpl(urlKey, storeView)).orElse(null); if (categories == null) { return null; } for (CategoryTree category : categories) { if (urlPath.equals(category.getUrlPath())) { return category; } } return null; } catch (Exception e) { throw new RuntimeException(e); } }
GraphqlDataServiceImpl implements GraphqlDataService { @Override public CategoryTree getCategoryByPath(String urlPath, String storeView) { if (StringUtils.isBlank(urlPath)) { return null; } String mainPart = null; String[] parts = urlPath.split("/"); for (int i = parts.length; i > 0;) { String part = parts[--i]; if (StringUtils.isNotBlank(part)) { mainPart = part; break; } } if (mainPart == null) { return null; } try { String urlKey = mainPart; ArrayKey key = toCategoryDataCacheKey(urlKey, storeView); List<CategoryTree> categories = categoryDataCache.get(key, () -> getCategoryByKeyImpl(urlKey, storeView)).orElse(null); if (categories == null) { return null; } for (CategoryTree category : categories) { if (urlPath.equals(category.getUrlPath())) { return category; } } return null; } catch (Exception e) { throw new RuntimeException(e); } } }
GraphqlDataServiceImpl implements GraphqlDataService { @Override public CategoryTree getCategoryByPath(String urlPath, String storeView) { if (StringUtils.isBlank(urlPath)) { return null; } String mainPart = null; String[] parts = urlPath.split("/"); for (int i = parts.length; i > 0;) { String part = parts[--i]; if (StringUtils.isNotBlank(part)) { mainPart = part; break; } } if (mainPart == null) { return null; } try { String urlKey = mainPart; ArrayKey key = toCategoryDataCacheKey(urlKey, storeView); List<CategoryTree> categories = categoryDataCache.get(key, () -> getCategoryByKeyImpl(urlKey, storeView)).orElse(null); if (categories == null) { return null; } for (CategoryTree category : categories) { if (urlPath.equals(category.getUrlPath())) { return category; } } return null; } catch (Exception e) { throw new RuntimeException(e); } }  }
GraphqlDataServiceImpl implements GraphqlDataService { @Override public CategoryTree getCategoryByPath(String urlPath, String storeView) { if (StringUtils.isBlank(urlPath)) { return null; } String mainPart = null; String[] parts = urlPath.split("/"); for (int i = parts.length; i > 0;) { String part = parts[--i]; if (StringUtils.isNotBlank(part)) { mainPart = part; break; } } if (mainPart == null) { return null; } try { String urlKey = mainPart; ArrayKey key = toCategoryDataCacheKey(urlKey, storeView); List<CategoryTree> categories = categoryDataCache.get(key, () -> getCategoryByKeyImpl(urlKey, storeView)).orElse(null); if (categories == null) { return null; } for (CategoryTree category : categories) { if (urlPath.equals(category.getUrlPath())) { return category; } } return null; } catch (Exception e) { throw new RuntimeException(e); } }  @Activate void activate(GraphqlDataServiceConfiguration conf); @Override ProductInterface getProductBySku(String sku, String storeView); @Override CategoryTree getCategoryById(Integer id, String storeView); @Override CategoryTree getCategoryByPath(String urlPath, String storeView); @Override List<ProductInterface> searchProducts(String text, Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override List<CategoryTree> searchCategories(String text, Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override CategoryProducts getCategoryProducts(Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override String getIdentifier(); }
GraphqlDataServiceImpl implements GraphqlDataService { @Override public CategoryTree getCategoryByPath(String urlPath, String storeView) { if (StringUtils.isBlank(urlPath)) { return null; } String mainPart = null; String[] parts = urlPath.split("/"); for (int i = parts.length; i > 0;) { String part = parts[--i]; if (StringUtils.isNotBlank(part)) { mainPart = part; break; } } if (mainPart == null) { return null; } try { String urlKey = mainPart; ArrayKey key = toCategoryDataCacheKey(urlKey, storeView); List<CategoryTree> categories = categoryDataCache.get(key, () -> getCategoryByKeyImpl(urlKey, storeView)).orElse(null); if (categories == null) { return null; } for (CategoryTree category : categories) { if (urlPath.equals(category.getUrlPath())) { return category; } } return null; } catch (Exception e) { throw new RuntimeException(e); } }  @Activate void activate(GraphqlDataServiceConfiguration conf); @Override ProductInterface getProductBySku(String sku, String storeView); @Override CategoryTree getCategoryById(Integer id, String storeView); @Override CategoryTree getCategoryByPath(String urlPath, String storeView); @Override List<ProductInterface> searchProducts(String text, Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override List<CategoryTree> searchCategories(String text, Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override CategoryProducts getCategoryProducts(Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override String getIdentifier();  }