Esempio n. 1
0
  @Test
  public void
      ifTheUsersPrefferedThemeIsNotDefinedThenThenTheFirstAvailableThemeIsChoosenAsThePrefferedTheme() {

    when(userSession.getUserPrefferedTheme()).thenReturn(Optional.empty());

    String expected = controller.getThemes().values().iterator().next();

    String currentTheme = controller.getCurrentThemeOrElse("aristo");

    assertThat(currentTheme, is(equalTo(expected)));
  }
Esempio n. 2
0
  @Test
  public void
      ifTheUserPrefferedThemeIsNotInTheListOfPredefinedThemesThentheFirstEntryOfTheMapShouldReturned() {

    when(userSession.getUserPrefferedTheme())
        .thenReturn(Optional.of(controller.getThemes().keySet().iterator().next() + "XXX"));

    String expected = controller.getThemes().values().iterator().next();

    String currentTheme = controller.getCurrentThemeOrElse("aristo");

    assertThat(currentTheme, is(equalTo(expected)));
  }
Esempio n. 3
0
  @Test
  public void shouldChooseVaderThemeBecauseOfTheContextFiltersDecreeSequence() {
    final String SUNNY = "sunny";
    final String ARISTO = "aristo";
    final String VADER = "vader";

    final DecreeSequence ds142 = mock(DecreeSequence.class);
    final DecreeSequence ds475 = mock(DecreeSequence.class);
    final User currentUser = mock(User.class);
    final PerDecreePreference pref142 = mock(PerDecreePreference.class);
    final PerDecreePreference pref475 = mock(PerDecreePreference.class);

    when(userSession.getCurrentUser()).thenReturn(currentUser);
    when(pref142.getDecreeSequence()).thenReturn(ds142);
    when(pref475.getDecreeSequence()).thenReturn(ds475);
    when(pref142.getTheme()).thenReturn(SUNNY);
    when(pref475.getTheme()).thenReturn(VADER);

    when(userSession.getUserPrefferedTheme()).thenReturn(Optional.of(ARISTO));

    when(contextualFilter.getDecreeSequence()).thenReturn(ds475);
    when(perDecreePreferenceRepository.findByUser(currentUser))
        .thenReturn(asList(pref142, pref475));

    String theme = controller.getCurrentThemeOrElse("aristo");

    assertThat(theme, is(VADER));
  }
Esempio n. 4
0
  @Test
  public void delegateTheSwitchOfTheThemeToTheUserSession() {
    final String theme = "aristo";

    controller.setCurrentTheme(theme);

    verify(userSession).updateUserPrefferedTheme(theme);
  }
Esempio n. 5
0
  @Test
  public void theAvailableThemesShouldContainAtListAristoTheme() {

    Map<String, String> themes = controller.getThemes();

    assertThat(themes.entrySet(), is(not(empty())));
    assertThat(themes.values(), hasItem("aristo"));
  }
Esempio n. 6
0
  @Test
  public void currentUserSessuinShouldBeAskedForTheUserPrefferedThme() {

    when(userSession.getUserPrefferedTheme()).thenReturn(Optional.of("sunny"));

    String currentTheme = controller.getCurrentThemeOrElse("aristo");

    assertThat(currentTheme, is(equalTo(userSession.getUserPrefferedTheme().get())));
  }