@Test
  @Templates("plain")
  public void testLocale() {
    String locale = "ru";
    calendarAttributes.set(CalendarAttributes.locale, locale);
    DayPicker dayPicker = popupCalendar.openPopup().getDayPicker();
    List<String> weekDayShortNames = dayPicker.getWeekDayShortNames();
    List<String> expectedShortNames = Arrays.asList("Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб");
    assertEquals(weekDayShortNames, expectedShortNames);

    setCurrentDateWithCalendarsTodayButtonAction.perform();
    DateTime parsedDateTime =
        dateTimeFormatter
            .withLocale(new Locale(locale))
            .parseDateTime(popupCalendar.getInput().getStringValue());

    assertEquals(
        parsedDateTime.getDayOfMonth(),
        todayMidday.getDayOfMonth(),
        "Input doesn't contain selected date.");
    assertEquals(
        parsedDateTime.getMonthOfYear(),
        todayMidday.getMonthOfYear(),
        "Input doesn't contain selected date.");
    assertEquals(
        parsedDateTime.getYear(), todayMidday.getYear(), "Input doesn't contain selected date.");
  }
  @Test
  @UseWithField(field = "boundaryDatesMode", valuesFrom = FROM_ENUM, value = "")
  @Templates("plain")
  public void testBoundaryDatesMode() {
    calendarAttributes.set(CalendarAttributes.boundaryDatesMode, boundaryDatesMode.value);
    DayPicker dayPicker = popupCalendar.openPopup().getDayPicker();
    MetamerPage.waitRequest(popupCalendar, WaitRequestType.XHR).setDateTime(firstOfNovember2012);
    PopupFooterControls footerControls = popupCalendar.openPopup().getFooterControls();
    HeaderControls headerControls = popupCalendar.openPopup().getHeaderControls();
    DateTime yearAndMonth;
    String firstOfNovember2012String = firstOfNovember2012.toString(dateTimeFormatter);
    switch (boundaryDatesMode) {
      case INACTIVE:
      case NULL:
        try {
          MetamerPage.waitRequest(dayPicker.getBoundaryDays().get(0), WaitRequestType.NONE)
              .select();
          fail("Item should not be selected.");
        } catch (TimeoutException ex) { // ok
        }
        // apply and check, that the date has not changed
        footerControls = popupCalendar.openPopup().getFooterControls();
        MetamerPage.waitRequest(footerControls, WaitRequestType.NONE).applyDate();
        assertEquals(popupCalendar.getInput().getStringValue(), firstOfNovember2012String);
        break;
      case SCROLL:
        // scroll to 28th of October 2012
        try {
          MetamerPage.waitRequest(dayPicker.getBoundaryDays().get(0), WaitRequestType.NONE)
              .select();
          fail("Item should not be selected.");
        } catch (TimeoutException ex) { // ok
        }
        yearAndMonth = headerControls.getYearAndMonth();
        assertEquals(yearAndMonth.getYear(), 2012);
        assertEquals(yearAndMonth.getMonthOfYear(), 10);
        // apply and check, that the date has not changed
        footerControls = popupCalendar.openPopup().getFooterControls();
        MetamerPage.waitRequest(footerControls, WaitRequestType.NONE).applyDate();
        assertEquals(popupCalendar.getInput().getStringValue(), firstOfNovember2012String);
        break;
      case SELECT:
        // select 28th of October 2012
        CalendarDay day = dayPicker.getBoundaryDays().get(0);
        MetamerPage.waitRequest(day.getDayElement(), WaitRequestType.NONE).click();
        yearAndMonth = headerControls.getYearAndMonth();
        assertEquals(yearAndMonth.getYear(), 2012);
        assertEquals(yearAndMonth.getMonthOfYear(), 10);

        MetamerPage.waitRequest(footerControls, WaitRequestType.XHR).applyDate();
        DateTime parsedDateTime =
            dateTimeFormatter.parseDateTime(popupCalendar.getInput().getStringValue());
        assertEquals(parsedDateTime.getYear(), 2012);
        assertEquals(parsedDateTime.getMonthOfYear(), 10);
        assertEquals(parsedDateTime.getDayOfMonth(), 28);
        break;
    }
  }
 @Test
 @UseWithField(field = "booleanValue", valuesFrom = FROM_FIELD, value = "booleans")
 public void testShowWeeksBar() {
   calendarAttributes.set(CalendarAttributes.showWeeksBar, booleanValue);
   DayPicker dayPicker = popupCalendar.openPopup().getDayPicker();
   if (booleanValue) {
     assertVisible(dayPicker.getWeek(1).getWeekNumberElement());
   } else {
     assertNotVisible(dayPicker.getWeek(1).getWeekNumberElement());
   }
 }
  @Test
  @RegressionTest("https://issues.jboss.org/browse/RF-9646")
  public void testFirstWeekDay() {
    DayPicker dayPicker = popupCalendar.openPopup().getDayPicker();
    List<String> weekDays = Arrays.asList("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");

    assertEquals(dayPicker.getWeekDayShortNames(), weekDays);

    // wrong input, nothing changes, RF-9646
    calendarAttributes.set(CalendarAttributes.firstWeekDay, 7);
    dayPicker = popupCalendar.openPopup().getDayPicker();
    assertEquals(dayPicker.getWeekDayShortNames(), weekDays);

    calendarAttributes.set(CalendarAttributes.firstWeekDay, 1);
    dayPicker = popupCalendar.openPopup().getDayPicker();
    Collections.rotate(weekDays, -1);
    assertEquals(dayPicker.getWeekDayShortNames(), weekDays);
  }
  @Test
  public void testDayDisableFunction() {
    calendarAttributes.set(CalendarAttributes.dayDisableFunction, "disableTuesdays");
    int tuesdayDay = 3;
    // switch to next month to refresh classes
    popupCalendar.openPopup().getHeaderControls().nextMonth();
    DayPicker dayPicker = popupCalendar.openPopup().getDayPicker();

    List<CalendarDay> tuesdays =
        filterOutBoundaryDays(Lists.newArrayList(dayPicker.getSpecificDays(tuesdayDay)));
    for (CalendarDay tuesday : tuesdays) {
      assertFalse(tuesday.is(DayType.selectableDay), "All tuesdays should not be enabled.");
    }

    calendarAttributes.set(CalendarAttributes.dayDisableFunction, "null");
    dayPicker = popupCalendar.openPopup().getDayPicker();
    tuesdays = filterOutBoundaryDays(Lists.newArrayList(dayPicker.getSpecificDays(tuesdayDay)));
    for (CalendarDay tuesday : tuesdays) {
      assertTrue(tuesday.is(DayType.selectableDay), "All tuesdays should be enabled.");
    }
  }
  @Test
  @Templates(value = "plain")
  public void testDayClassFunction() {
    int tuesdayDay = 3;
    calendarAttributes.set(CalendarAttributes.dayClassFunction, "yellowTuesdays");
    // switch to next month to refresh classes
    popupCalendar.openPopup().getHeaderControls().nextMonth();
    DayPicker dayPicker = popupCalendar.openPopup().getDayPicker();
    List<CalendarDay> tuesdays =
        filterOutBoundaryDays(Lists.newArrayList(dayPicker.getSpecificDays(tuesdayDay)));
    for (CalendarDay tuesday : tuesdays) {
      assertTrue(tuesday.containsStyleClass("yellowDay"), "All tuesdays should be yellow.");
    }

    calendarAttributes.set(CalendarAttributes.dayClassFunction, "null");
    dayPicker = popupCalendar.openPopup().getDayPicker();
    tuesdays = filterOutBoundaryDays(Lists.newArrayList(dayPicker.getSpecificDays(tuesdayDay)));
    for (CalendarDay tuesday : tuesdays) {
      assertFalse(tuesday.containsStyleClass("yellowDay"), "All tuesdays should not be yellow.");
    }
  }