/**
 * 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.DateTimePickerWidget;

import static java.lang.String.format;

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

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

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

    /**
     * Verifies that the actual DateTimePickerWidget's dateFormat is equal to the given one.
     *
     * @param dateFormat the given dateFormat to compare the actual DateTimePickerWidget's dateFormat to.
     * @return this assertion object.
     * @throws AssertionError - if the actual DateTimePickerWidget's dateFormat is not equal to the given one.
     */
    public DateTimePickerWidgetAssert 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;
    }

    /**
     * Verifies that the actual DateTimePickerWidget's timeFormat is equal to the given one.
     *
     * @param timeFormat the given dateFormat to compare the actual DateTimePickerWidget's timeFormat to.
     * @return this assertion object.
     * @throws AssertionError - if the actual DateTimePickerWidget's timeFormat is not equal to the given one.
     */
    public DateTimePickerWidgetAssert hasTimeFormat(String timeFormat) {
        // 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> timeFormat to be:\n  <%s>\n but was:\n  <%s>", actual, timeFormat, actual.getTimeFormat());

        if (!actual.getTimeFormat().equals(timeFormat)) {
            throw new AssertionError(errorMessage);
        }

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

    public DateTimePickerWidgetAssert hasDatePlaceholder() {
        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;
    }

    public DateTimePickerWidgetAssert hasTimePlaceholder() {
        isNotNull();

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

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

        return this;
    }
}
