### Question:
CacheKeyFactory { public String getCacheKey(LESSResourceReference lessResourceReference, SkinReference skinReference, ColorThemeReference colorThemeReference, boolean withContext) { String lessResource = lessResourceReference.serialize(); String skin = skinReference.serialize(); String colorTheme = colorThemeReference.serialize(); String result = lessResource.length() + CACHE_KEY_SEPARATOR + lessResource + CACHE_KEY_SEPARATOR + skin.length() + CACHE_KEY_SEPARATOR + skin + CACHE_KEY_SEPARATOR + colorTheme.length() + CACHE_KEY_SEPARATOR + colorTheme; if (withContext) { String xcontext = xcontextCacheKeyFactory.getCacheKey(); result += CACHE_KEY_SEPARATOR + xcontext.length() + CACHE_KEY_SEPARATOR + xcontext; } return result; }  String getCacheKey(LESSResourceReference lessResourceReference, SkinReference skinReference,
            ColorThemeReference colorThemeReference, boolean withContext);  }### Answer:
@Test public void getCacheKeyWithContext() throws Exception { LESSResourceReference lessResource = mock(LESSResourceReference.class); SkinReference skin = mock(SkinReference.class); ColorThemeReference colorTheme = mock(ColorThemeReference.class); when(lessResource.serialize()).thenReturn("lessResource"); when(skin.serialize()).thenReturn("skin"); when(colorTheme.serialize()).thenReturn("colorTheme"); when(xcontextCacheKeyFactory.getCacheKey()).thenReturn("XWikiContext[Mock]"); assertEquals("12_lessResource_4_skin_10_colorTheme_18_XWikiContext[Mock]", mocker.getComponentUnderTest().getCacheKey(lessResource, skin, colorTheme, true)); }
@Test public void getCacheKeyWithoutContext() throws Exception { LESSResourceReference lessResource = mock(LESSResourceReference.class); SkinReference skin = mock(SkinReference.class); ColorThemeReference colorTheme = mock(ColorThemeReference.class); when(lessResource.serialize()).thenReturn("lessResource"); when(skin.serialize()).thenReturn("skin"); when(colorTheme.serialize()).thenReturn("colorTheme"); assertEquals("12_lessResource_4_skin_10_colorTheme", mocker.getComponentUnderTest().getCacheKey(lessResource, skin, colorTheme, false)); }