/**
 * Copyright (C) 2015 Bonitasoft S.A.
 * Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2.0 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.bonitasoft.web.designer.generator.assertions;

import org.assertj.core.api.AbstractAssert;
import org.bonitasoft.web.designer.generator.parametrizedWidget.DatePickerWidget;

import static java.lang.String.format;

/**
 * {@link DatePickerWidget} specific assertions - Generated by CustomAssertionGenerator.
 */
public class DatePickerWidgetAssert extends AbstractAssert<DatePickerWidgetAssert, DatePickerWidget> {

    /**
     * Creates a new </code>{@link DatePickerWidgetAssert}</code> to make assertions on actual DatePickerWidget.
     *
     * @param actual the DatePickerWidget we want to make assertions on.
     */
    public DatePickerWidgetAssert(DatePickerWidget actual) {
        super(actual, DatePickerWidgetAssert.class);
    }

    /**
     * An entry point for DatePickerWidgetAssert to follow AssertJ standard <code>assertThat()</code> statements.<br>
     * With a static import, one's can write directly : <code>assertThat(myDatePickerWidget)</code> and get specific assertion with code completion.
     *
     * @param actual the DatePickerWidget we want to make assertions on.
     * @return a new </code>{@link DatePickerWidgetAssert}</code>
     */
    public static DatePickerWidgetAssert assertThat(DatePickerWidget actual) {
        return new DatePickerWidgetAssert(actual);
    }

    /**
     * Verifies that the actual DatePickerWidget's dateFormat is equal to the given one.
     *
     * @param dateFormat the given dateFormat to compare the actual DatePickerWidget's dateFormat to.
     * @return this assertion object.
     * @throws AssertionError - if the actual DatePickerWidget's dateFormat is not equal to the given one.
     */
    public DatePickerWidgetAssert hasDateFormat(String dateFormat) {
        // check that actual DatePickerWidget we want to make assertions on is not null.
        isNotNull();

        // we overrides the default error message with a more explicit one
        String errorMessage = format("\nExpected <%s> dateFormat to be:\n  <%s>\n but was:\n  <%s>", actual, dateFormat, actual.getDateFormat());

        // check
        if (!actual.getDateFormat().equals(dateFormat)) {
            throw new AssertionError(errorMessage);
        }

        // return the current assertion for method chaining
        return this;
    }

    public DatePickerWidgetAssert hasPlaceholder(){
        isNotNull();

        String errorMessage = format("\nExpected <%s> placeHolder \n  but was:\n  <%s>", actual, actual.getPlaceholder());

        if (actual.getPlaceholder().isEmpty()) {
            throw new AssertionError(errorMessage);
        }

        return this;
    }

}
