CategoryMediaFileNameStrategyImpl extends AbstractMediaFileNameStrategyImpl { @Override public String resolveObjectCode(final String url) { if (StringUtils.isNotBlank(url)) { final String code = resolveObjectCodeInternal(url); if (code != null) { return code; } } return Constants.NO_IMAGE; } CategoryMediaFileNameStrategyImpl(final String urlPath,
                                             final String relativeInternalRootDirectory,
                                             final GenericDAO<AttrValueCategory, Long> attrValueCategoryDao,
                                             final LanguageService languageService); @Override String resolveObjectCode(final String url);  }
@Test public void testGetCodeFromActualObject() { assertEquals("313", mediaFileNameStrategy.resolveObjectCode("category.jpeg")); assertEquals("313", mediaFileNameStrategy.resolveObjectCode("imgvault/category/category.jpeg")); assertEquals("313", mediaFileNameStrategy.resolveObjectCode("imgvault/category/category.jpeg?w=10&h=4")); final Category cat313 = categoryService.findById(313L); cat313.getSeo().setUri("CC-TEST-products"); categoryService.update(cat313); cacheManager.getCache("imageNameStrategy-resolveObjectCode").clear(); assertEquals("CC-TEST-products", mediaFileNameStrategy.resolveObjectCode("category.jpeg")); assertEquals("CC-TEST-products", mediaFileNameStrategy.resolveObjectCode("imgvault/category/category.jpeg")); assertEquals("CC-TEST-products", mediaFileNameStrategy.resolveObjectCode("imgvault/category/category.jpeg?w=10&h=4")); assertEquals(Constants.NO_IMAGE, mediaFileNameStrategy.resolveObjectCode("imgvault/category/unknown-category.jpeg")); }