/** If valid tournament entered. The tournament should be saved in the database. */
  @Test
  public final void validateTournamentStartDateFieldCreate() {

    // Validation field with invalid data type.
    tournamentListPage = homePage.getNavigationPage().getTournamentListPage();
    final List<String> invalidDates = TournamentTestObjects.getInvalidTypeForDate();
    for (String invalidDate : invalidDates) {
      tuornamentsInDBBeforTest = TournamentRepository.countAllTournaments();
      if (!TournamentRepository.isTournamentPresent(validTournament)) {
        TournamentRepository.insertTournament(validTournament);
        editTournamentPage =
            tournamentListPage.showTournamentInfo(validTournament).pressEditButton();
        editTournamentPage.getData().getTournamentEndInput().clear();
        editTournamentPage.getData().getTournamentEndInput().type(invalidDate);
        editTournamentPage.unsuccessfulPressSave();

        specification.For(editTournamentPage.getData().getErrorMessageLabelTournamentEnd())
            .valueMatch(TestsConstants.VALIDATION_ERROR_TEXT_WRONG_TYPE_DATE)
            .next()
            .For(repository)
            .isTournamentPresent(validTournament)
            .numberOfTournamentsHasNotChanged(tuornamentsInDBBeforTest);

        tournamentListPage = TournamentListPage.refreshTournamentList();
      }

      // Validation empty field.
      invalidDate = TournamentTestObjects.getInvalidEmptyTypeForDate();
      tuornamentsInDBBeforTest = TournamentRepository.countAllTournaments();
      editTournamentPage = tournamentListPage.showTournamentInfo(validTournament).pressEditButton();
      editTournamentPage.getData().getTournamentEndInput().clear();
      editTournamentPage.getData().getTournamentEndInput().type(invalidDate);
      editTournamentPage.unsuccessfulPressSave();

      specification.For(editTournamentPage.getData().getErrorMessageLabelTournamentEnd())
          .valueMatch(TestsConstants.VALIDATION_ERROR_TEXT_EMPTY_NAME_FIELD)
          .next()
          .For(repository)
          .isTournamentPresent(validTournament)
          .numberOfTournamentsHasNotChanged(tuornamentsInDBBeforTest);

      tournamentListPage = TournamentListPage.refreshTournamentList();

      // Validation field with out of range data.
      // TODO after receive more information about dates.

      // Validation field with two values on edges  of range.
      // TODO after receive more information about dates.

      specification.check();
    }
  }
 /** This method performs the operations necessary to run the test. */
 @BeforeClass
 public final void setUp() {
   DALTools.startConnection(TestsConstants.CONNECT_DB_STRING);
   tournamentsData = SetPreconditions.forValidationTournamentFieldsTest();
   validTournament = TournamentTestObjects.getValidTournament();
   TournamentRepository.insertTournament(validTournament);
   WebDriverUtils.load(TestsConstants.HOME_PAGE);
   homePage = new HomePage();
   specification = Specification.get();
 }