package com.oguerreiro.resilient.domain;

import static org.assertj.core.api.Assertions.assertThat;

public class PeriodVersionAsserts {

    /**
     * Asserts that the entity has all properties (fields/relationships) set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertPeriodVersionAllPropertiesEquals(PeriodVersion expected, PeriodVersion actual) {
        assertPeriodVersionAutoGeneratedPropertiesEquals(expected, actual);
        assertPeriodVersionAllUpdatablePropertiesEquals(expected, actual);
    }

    /**
     * Asserts that the entity has all updatable properties (fields/relationships) set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertPeriodVersionAllUpdatablePropertiesEquals(PeriodVersion expected, PeriodVersion actual) {
        assertPeriodVersionUpdatableFieldsEquals(expected, actual);
        assertPeriodVersionUpdatableRelationshipsEquals(expected, actual);
    }

    /**
     * Asserts that the entity has all the auto generated properties (fields/relationships) set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertPeriodVersionAutoGeneratedPropertiesEquals(PeriodVersion expected, PeriodVersion actual) {
        assertThat(expected)
            .as("Verify PeriodVersion auto generated properties")
            .satisfies(e -> assertThat(e.getId()).as("check id").isEqualTo(actual.getId()));
    }

    /**
     * Asserts that the entity has all the updatable fields set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertPeriodVersionUpdatableFieldsEquals(PeriodVersion expected, PeriodVersion actual) {
        assertThat(expected)
            .as("Verify PeriodVersion relevant properties")
            .satisfies(e -> assertThat(e.getName()).as("check name").isEqualTo(actual.getName()))
            .satisfies(e -> assertThat(e.getDescription()).as("check description").isEqualTo(actual.getDescription()))
            .satisfies(e -> assertThat(e.getPeriodVersion()).as("check periodVersion").isEqualTo(actual.getPeriodVersion()))
            .satisfies(e -> assertThat(e.getState()).as("check state").isEqualTo(actual.getState()))
            .satisfies(e -> assertThat(e.getCreationDate()).as("check creationDate").isEqualTo(actual.getCreationDate()))
            .satisfies(e -> assertThat(e.getCreationUsername()).as("check creationUsername").isEqualTo(actual.getCreationUsername()))
            .satisfies(e -> assertThat(e.getVersion()).as("check version").isEqualTo(actual.getVersion()));
    }

    /**
     * Asserts that the entity has all the updatable relationships set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertPeriodVersionUpdatableRelationshipsEquals(PeriodVersion expected, PeriodVersion actual) {
        assertThat(expected)
            .as("Verify PeriodVersion relationships")
            .satisfies(e -> assertThat(e.getPeriod()).as("check period").isEqualTo(actual.getPeriod()));
    }
}
