package com.oguerreiro.resilient.domain;

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

public class VariableAsserts {

    /**
     * Asserts that the entity has all properties (fields/relationships) set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertVariableAllPropertiesEquals(Variable expected, Variable actual) {
        assertVariableAutoGeneratedPropertiesEquals(expected, actual);
        assertVariableAllUpdatablePropertiesEquals(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 assertVariableAllUpdatablePropertiesEquals(Variable expected, Variable actual) {
        assertVariableUpdatableFieldsEquals(expected, actual);
        assertVariableUpdatableRelationshipsEquals(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 assertVariableAutoGeneratedPropertiesEquals(Variable expected, Variable actual) {
        assertThat(expected)
            .as("Verify Variable 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 assertVariableUpdatableFieldsEquals(Variable expected, Variable actual) {
        assertThat(expected)
            .as("Verify Variable relevant properties")
            .satisfies(e -> assertThat(e.getCode()).as("check code").isEqualTo(actual.getCode()))
            .satisfies(e -> assertThat(e.getVariableIndex()).as("check variableIndex").isEqualTo(actual.getVariableIndex()))
            .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.getInput()).as("check input").isEqualTo(actual.getInput()))
            .satisfies(e -> assertThat(e.getInputMode()).as("check inputMode").isEqualTo(actual.getInputMode()))
            .satisfies(e -> assertThat(e.getOutput()).as("check output").isEqualTo(actual.getOutput()))
            .satisfies(e -> assertThat(e.getOutputFormula()).as("check outputFormula").isEqualTo(actual.getOutputFormula()))
            .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 assertVariableUpdatableRelationshipsEquals(Variable expected, Variable actual) {
        assertThat(expected)
            .as("Verify Variable relationships")
            .satisfies(e -> assertThat(e.getBaseUnit()).as("check baseUnit").isEqualTo(actual.getBaseUnit()))
            .satisfies(e -> assertThat(e.getVariableScope()).as("check variableScope").isEqualTo(actual.getVariableScope()))
            .satisfies(e -> assertThat(e.getVariableCategory()).as("check variableCategory").isEqualTo(actual.getVariableCategory()));
    }
}
