### Question:
CurrentColorThemeGetter { public String getCurrentColorTheme(String fallbackValue) { return getCurrentColorTheme(true, fallbackValue); }  String getCurrentColorTheme(String fallbackValue); String getCurrentColorTheme(boolean checkRights, String fallbackValue);  }### Answer:
@Test public void getCurrentColorThemeTestWhenRequestParameter() throws Exception { when(request.getParameter("colorTheme")).thenReturn("myColorTheme"); assertEquals("wikiId:ColorTheme.MyColorTheme", mocker.getComponentUnderTest().getCurrentColorTheme("default")); }
@Test public void getCurrentColorThemeTestWhenNoRequestParameter() throws Exception { when(xwiki.getUserPreference(eq("colorTheme"), any(XWikiContext.class))).thenReturn("myColorTheme"); assertEquals("wikiId:ColorTheme.MyColorTheme", mocker.getComponentUnderTest().getCurrentColorTheme("default")); }
@Test public void getCurrentColorThemeFallbackTest() throws Exception { when(request.getParameter("colorTheme")).thenReturn("myColorTheme"); when(xwiki.exists(any(DocumentReference.class), eq(xcontext))).thenReturn(false); assertEquals("fallback", mocker.getComponentUnderTest().getCurrentColorTheme("fallback")); assertEquals("error", mocker.getComponentUnderTest().getCurrentColorTheme("error")); }
@Test public void getCurrentColorWithAndWithoutRight() throws Exception { when(request.getParameter("colorTheme")).thenReturn("myColorTheme"); when(authorizationManager.hasAccess(eq(Right.VIEW), any(DocumentReference.class), any(DocumentReference.class))) .thenReturn(false); assertEquals("fallback", mocker.getComponentUnderTest().getCurrentColorTheme(true, "fallback")); assertEquals("wikiId:ColorTheme.MyColorTheme", mocker.getComponentUnderTest().getCurrentColorTheme(false, "fallback")); }