### Question:
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();  }### Answer:
@Test public void testGetCategoryByPath() throws Exception { String query = getResource("graphql-queries/categorylist-by-urlkey.txt"); Utils.setupHttpResponse("magento-graphql-categorylist-dresses.json", httpClient, HttpStatus.SC_OK, query); CategoryTree category = dataService.getCategoryByPath("venia-dresses", null); assertEquals(37, category.getId().intValue()); assertEquals("Dresses", category.getName()); assertNull(dataService.getCategoryByPath(null, null)); }
@Test(expected = RuntimeException.class) public void testGetCategoryByPathError() throws Exception { Utils.setupHttpResponse("magento-graphql-error.json", httpClient, HttpStatus.SC_OK); dataService.getCategoryByPath(SKU, null); }
@Test public void testGetCategoryByPathEmpty() throws Exception { Utils.setupHttpResponse("magento-graphql-error.json", httpClient, HttpStatus.SC_OK); assertNull(dataService.getCategoryByPath("/", null)); }