AbstractImageServiceImpl implements AttributableImageService { @Override public List<Pair<String, String>> getImageAttributeFileNames(final Attributable attributable, final String lang) { final String prefix = getAttributePrefix(attributable); final String cacheKey = createCacheKey(getEntityObjectCacheKey(attributable), prefix, lang); List<Pair<String, String>> images = getFromValueWrapper(OBJECT_IMAGES_CACHE.get(cacheKey)); if (images == null) { images = getImageAttributeFileNamesInternal(attributable, lang, prefix); OBJECT_IMAGES_CACHE.put(cacheKey, images); } return images; } AbstractImageServiceImpl(); protected  AbstractImageServiceImpl(final CacheManager cacheManager); @Override String getImageURI(final Object object,
                              final String servletContextPath,
                              final String locale,
                              final String width,
                              final String height,
                              final String imageName); @Override String getImage(final Attributable attributable,
                           final String httpServletContextPath,
                           final String locale,
                           final String width,
                           final String height,
                           final String attrName,
                           String attrVal); @Override List<Pair<String, String>> getImageAttributeFileNames(final Attributable attributable, final String lang);  }
@Test public void testGetImageAttributeFileNames() throws Exception { final Attributable attributable = context.mock(Attributable.class, "attributable"); final AttrValue av1 = context.mock(AttrValue.class, "av1"); final AttrValue av2 = context.mock(AttrValue.class, "av2"); final AttrValue av3 = context.mock(AttrValue.class, "av3"); final AttrValue av4 = context.mock(AttrValue.class, "av4"); final List<AttrValue> avs = Arrays.asList(av1, av2, av3, av4); context.checking(new Expectations() {{ oneOf(attributable).getAllAttributes(); will(returnValue(avs)); oneOf(av1).getAttributeCode(); will(returnValue("MY_IMAGE1_en")); exactly(2).of(av1).getVal(); will(returnValue("image1_en.jpg")); oneOf(av2).getAttributeCode(); will(returnValue("MY_IMAGE2")); exactly(2).of(av2).getVal(); will(returnValue("image2.jpg")); oneOf(av3).getAttributeCode(); will(returnValue("MY_IMAGE1")); oneOf(av3).getVal(); will(returnValue("image1.jpg")); oneOf(av4).getAttributeCode(); will(returnValue("MY_IMAGE2_en")); exactly(2).of(av4).getVal(); will(returnValue("image2_en.jpg")); }}); final List<Pair<String, String>> pairs = service.getImageAttributeFileNamesInternal(attributable, "en", "MY_IMAGE"); assertNotNull(pairs); assertEquals(2, pairs.size()); assertEquals("MY_IMAGE1_en", pairs.get(0).getFirst()); assertEquals("image1_en.jpg", pairs.get(0).getSecond()); assertEquals("MY_IMAGE2_en", pairs.get(1).getFirst()); assertEquals("image2_en.jpg", pairs.get(1).getSecond()); context.assertIsSatisfied(); }