package com.oguerreiro.resilient.domain;

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

public class UnitConverterAsserts {

    /**
     * Asserts that the entity has all properties (fields/relationships) set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertUnitConverterAllPropertiesEquals(UnitConverter expected, UnitConverter actual) {
        assertUnitConverterAutoGeneratedPropertiesEquals(expected, actual);
        assertUnitConverterAllUpdatablePropertiesEquals(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 assertUnitConverterAllUpdatablePropertiesEquals(UnitConverter expected, UnitConverter actual) {
        assertUnitConverterUpdatableFieldsEquals(expected, actual);
        assertUnitConverterUpdatableRelationshipsEquals(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 assertUnitConverterAutoGeneratedPropertiesEquals(UnitConverter expected, UnitConverter actual) {
        assertThat(expected)
            .as("Verify UnitConverter 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 assertUnitConverterUpdatableFieldsEquals(UnitConverter expected, UnitConverter actual) {
        assertThat(expected)
            .as("Verify UnitConverter 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.getConvertionFormula()).as("check convertionFormula").isEqualTo(actual.getConvertionFormula()))
            .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 assertUnitConverterUpdatableRelationshipsEquals(UnitConverter expected, UnitConverter actual) {
        assertThat(expected)
            .as("Verify UnitConverter relationships")
            .satisfies(e -> assertThat(e.getFromUnit()).as("check fromUnit").isEqualTo(actual.getFromUnit()))
            .satisfies(e -> assertThat(e.getToUnit()).as("check toUnit").isEqualTo(actual.getToUnit()));
    }
}
