package com.oguerreiro.resilient.domain;

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

public class MetadataValueAsserts {

    /**
     * Asserts that the entity has all properties (fields/relationships) set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertMetadataValueAllPropertiesEquals(MetadataValue expected, MetadataValue actual) {
        assertMetadataValueAutoGeneratedPropertiesEquals(expected, actual);
        assertMetadataValueAllUpdatablePropertiesEquals(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 assertMetadataValueAllUpdatablePropertiesEquals(MetadataValue expected, MetadataValue actual) {
        assertMetadataValueUpdatableFieldsEquals(expected, actual);
        assertMetadataValueUpdatableRelationshipsEquals(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 assertMetadataValueAutoGeneratedPropertiesEquals(MetadataValue expected, MetadataValue actual) {
        assertThat(expected)
            .as("Verify MetadataValue 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 assertMetadataValueUpdatableFieldsEquals(MetadataValue expected, MetadataValue actual) {
        assertThat(expected)
            .as("Verify MetadataValue relevant properties")
            .satisfies(
                e -> assertThat(e.getMetadataPropertyCode()).as("check metadataPropertyCode").isEqualTo(actual.getMetadataPropertyCode())
            )
            .satisfies(e -> assertThat(e.getTargetDomainKey()).as("check targetDomainKey").isEqualTo(actual.getTargetDomainKey()))
            .satisfies(e -> assertThat(e.getTargetDomainId()).as("check targetDomainId").isEqualTo(actual.getTargetDomainId()))
            .satisfies(e -> assertThat(e.getValue()).as("check value").isEqualTo(actual.getValue()))
            .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 assertMetadataValueUpdatableRelationshipsEquals(MetadataValue expected, MetadataValue actual) {}
}
