use of org.xwiki.lesscss.internal.colortheme.NamedColorThemeReference in project xwiki-platform by xwiki.
the class DefaultLESSResourcesCacheTest method clearFromLESSResource.
@Test
public void clearFromLESSResource() throws Exception {
// Mocks
LESSSkinFileResourceReference file1 = createLESSSkinFileResourceReference("file1");
LESSSkinFileResourceReference file2 = createLESSSkinFileResourceReference("file2");
when(cacheKeyFactory.getCacheKey(eq(file1), eq(new FSSkinReference("skin1")), eq(new NamedColorThemeReference("colorTheme1")), eq(true))).thenReturn("k1");
when(cacheKeyFactory.getCacheKey(eq(file2), eq(new FSSkinReference("skin1")), eq(new NamedColorThemeReference("colorTheme1")), eq(true))).thenReturn("k3");
when(cacheKeyFactory.getCacheKey(eq(file1), eq(new FSSkinReference("skin2")), eq(new NamedColorThemeReference("colorTheme1")), eq(true))).thenReturn("k4");
// Add the first one twice
mocker.getComponentUnderTest().set(createLESSSkinFileResourceReference("file1"), new FSSkinReference("skin1"), new NamedColorThemeReference("colorTheme1"), "css1");
mocker.getComponentUnderTest().set(createLESSSkinFileResourceReference("file1"), new FSSkinReference("skin1"), new NamedColorThemeReference("colorTheme1"), "css1");
// Others
mocker.getComponentUnderTest().set(createLESSSkinFileResourceReference("file2"), new FSSkinReference("skin1"), new NamedColorThemeReference("colorTheme1"), "css");
mocker.getComponentUnderTest().set(createLESSSkinFileResourceReference("file1"), new FSSkinReference("skin2"), new NamedColorThemeReference("colorTheme1"), "css3");
// Test
mocker.getComponentUnderTest().clearFromLESSResource(createLESSSkinFileResourceReference("file1"));
// Verify
verify(cache, times(1)).remove("k1");
verify(cache).remove("k4");
verify(cache, never()).remove("k3");
}
use of org.xwiki.lesscss.internal.colortheme.NamedColorThemeReference in project xwiki-platform by xwiki.
the class DefaultLESSResourcesCacheTest method get.
@Test
public void get() throws Exception {
// Mock
when(cache.get("12_lessResource_4_skin_10_colorTheme")).thenReturn("Expected output");
// Test
String result = mocker.getComponentUnderTest().get(new LESSSkinFileResourceReference("lessResource", null, null), new FSSkinReference("skin"), new NamedColorThemeReference("colorTheme"));
// Verify
assertEquals("Expected output", result);
}
use of org.xwiki.lesscss.internal.colortheme.NamedColorThemeReference in project xwiki-platform by xwiki.
the class DefaultLESSColorThemeConverterTest method setUp.
@Before
public void setUp() throws Exception {
cache = mocker.getInstance(ColorThemeCache.class);
currentColorThemeGetter = mocker.getInstance(CurrentColorThemeGetter.class);
skinReferenceFactory = mocker.getInstance(SkinReferenceFactory.class);
colorThemeReferenceFactory = mocker.getInstance(ColorThemeReferenceFactory.class);
lessResourceReferenceFactory = mocker.getInstance(LESSResourceReferenceFactory.class);
xcontextProvider = mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
xcontext = mock(XWikiContext.class);
when(xcontextProvider.get()).thenReturn(xcontext);
xwiki = mock(XWiki.class);
when(xcontext.getWiki()).thenReturn(xwiki);
when(xwiki.getSkin(xcontext)).thenReturn("skin");
when(currentColorThemeGetter.getCurrentColorTheme(true, "default")).thenReturn("colorTheme");
when(skinReferenceFactory.createReference("skin")).thenReturn(new FSSkinReference("skin"));
when(colorThemeReferenceFactory.createReference("colorTheme")).thenReturn(new NamedColorThemeReference("colorTheme"));
when(cache.getMutex(eq(new LESSSkinFileResourceReference("file", null, null)), eq(new FSSkinReference("skin")), eq(new NamedColorThemeReference("colorTheme")))).thenReturn("mutex");
}
Aggregations