package com.oguerreiro.resilient.domain;

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

public class OrganizationAsserts {

    /**
     * Asserts that the entity has all properties (fields/relationships) set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertOrganizationAllPropertiesEquals(Organization expected, Organization actual) {
        assertOrganizationAutoGeneratedPropertiesEquals(expected, actual);
        assertOrganizationAllUpdatablePropertiesEquals(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 assertOrganizationAllUpdatablePropertiesEquals(Organization expected, Organization actual) {
        assertOrganizationUpdatableFieldsEquals(expected, actual);
        assertOrganizationUpdatableRelationshipsEquals(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 assertOrganizationAutoGeneratedPropertiesEquals(Organization expected, Organization actual) {
        assertThat(expected)
            .as("Verify Organization 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 assertOrganizationUpdatableFieldsEquals(Organization expected, Organization actual) {
        assertThat(expected)
            .as("Verify Organization relevant properties")
            .satisfies(e -> assertThat(e.getCode()).as("check code").isEqualTo(actual.getCode()))
            .satisfies(e -> assertThat(e.getName()).as("check name").isEqualTo(actual.getName()))
            .satisfies(e -> assertThat(e.getImage()).as("check image").isEqualTo(actual.getImage()))
            .satisfies(e -> assertThat(e.getImageContentType()).as("check image contenty type").isEqualTo(actual.getImageContentType()))
            .satisfies(e -> assertThat(e.getInputInventory()).as("check inputInventory").isEqualTo(actual.getInputInventory()))
            .satisfies(e -> assertThat(e.getOutputInventory()).as("check outputInventory").isEqualTo(actual.getOutputInventory()))
            .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 assertOrganizationUpdatableRelationshipsEquals(Organization expected, Organization actual) {
        assertThat(expected)
            .as("Verify Organization relationships")
            .satisfies(e -> assertThat(e.getParent()).as("check parent").isEqualTo(actual.getParent()))
            .satisfies(e -> assertThat(e.getOrganizationType()).as("check organizationType").isEqualTo(actual.getOrganizationType()));
    }
}
