### Question:
LessCompilerScriptService implements ScriptService { public boolean clearCacheFromColorTheme(String colorTheme) { XWikiContext xcontext = xcontextProvider.get(); if (!authorizationManager.hasAccess(Right.PROGRAM, xcontext.getDoc().getAuthorReference(), xcontext.getDoc().getDocumentReference())) { return false; } try { ColorThemeReference colorThemeReference = colorThemeReferenceFactory.createReference(colorTheme); lessCache.clearFromColorTheme(colorThemeReference); colorThemeCache.clearFromColorTheme(colorThemeReference); return true; } catch (LESSCompilerException e) { return false; } }  String compileSkinFile(String fileName); String compileSkinFile(String fileName, boolean force); String compileSkinFile(String fileName, String skin); String compileSkinFile(String fileName, String skin, boolean force); ColorTheme getColorThemeFromSkinFile(String filename); ColorTheme getColorThemeFromSkinFile(String filename, String skin); boolean clearCache(); boolean clearCacheFromColorTheme(String colorTheme); boolean clearCacheFromSkin(String skin);  }### Answer:
@Test public void clearCacheFromColorThemeWithRights() throws Exception { XWikiDocument doc = mock(XWikiDocument.class); DocumentReference authorReference = new DocumentReference("wiki", "Space", "User"); when(xcontext.getDoc()).thenReturn(doc); when(doc.getAuthorReference()).thenReturn(authorReference); DocumentReference currentDocReference = new DocumentReference("wiki", "Space", "Page"); when(doc.getDocumentReference()).thenReturn(currentDocReference); when(authorizationManager.hasAccess(Right.PROGRAM, authorReference, currentDocReference)).thenReturn(true); ColorThemeReference colorThemeReference = mock(ColorThemeReference.class); when(colorThemeReferenceFactory.createReference("colorTheme")).thenReturn(colorThemeReference); assertTrue(mocker.getComponentUnderTest().clearCacheFromColorTheme("colorTheme")); verify(lessCache).clearFromColorTheme(colorThemeReference); verify(colorThemeCache).clearFromColorTheme(colorThemeReference); }
@Test public void clearCacheFromColorThemeWithoutRights() throws Exception { XWikiDocument doc = mock(XWikiDocument.class); DocumentReference authorReference = new DocumentReference("wiki", "Space", "User"); when(xcontext.getDoc()).thenReturn(doc); when(doc.getAuthorReference()).thenReturn(authorReference); DocumentReference currentDocReference = new DocumentReference("wiki", "Space", "Page"); when(doc.getDocumentReference()).thenReturn(currentDocReference); when(authorizationManager.hasAccess(Right.PROGRAM, authorReference, currentDocReference)).thenReturn(false); assertFalse(mocker.getComponentUnderTest().clearCacheFromColorTheme("colorTheme")); verifyZeroInteractions(lessCache); verifyZeroInteractions(colorThemeCache); }