package it.sw.pa.comune.artegna.domain;

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

public class AuditLogAsserts {

    /**
     * Asserts that the entity has all properties (fields/relationships) set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertAuditLogAllPropertiesEquals(AuditLog expected, AuditLog actual) {
        assertAuditLogAutoGeneratedPropertiesEquals(expected, actual);
        assertAuditLogAllUpdatablePropertiesEquals(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 assertAuditLogAllUpdatablePropertiesEquals(AuditLog expected, AuditLog actual) {
        assertAuditLogUpdatableFieldsEquals(expected, actual);
        assertAuditLogUpdatableRelationshipsEquals(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 assertAuditLogAutoGeneratedPropertiesEquals(AuditLog expected, AuditLog actual) {
        assertThat(actual)
            .as("Verify AuditLog auto generated properties")
            .satisfies(a -> assertThat(a.getId()).as("check id").isEqualTo(expected.getId()));
    }

    /**
     * Asserts that the entity has all the updatable fields set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertAuditLogUpdatableFieldsEquals(AuditLog expected, AuditLog actual) {
        assertThat(actual)
            .as("Verify AuditLog relevant properties")
            .satisfies(a -> assertThat(a.getEntitaTipo()).as("check entitaTipo").isEqualTo(expected.getEntitaTipo()))
            .satisfies(a -> assertThat(a.getEntitaId()).as("check entitaId").isEqualTo(expected.getEntitaId()))
            .satisfies(a -> assertThat(a.getAzione()).as("check azione").isEqualTo(expected.getAzione()))
            .satisfies(a -> assertThat(a.getDettagli()).as("check dettagli").isEqualTo(expected.getDettagli()))
            .satisfies(a -> assertThat(a.getIpAddress()).as("check ipAddress").isEqualTo(expected.getIpAddress()))
            .satisfies(a -> assertThat(a.getCreatedAt()).as("check createdAt").isEqualTo(expected.getCreatedAt()));
    }

    /**
     * Asserts that the entity has all the updatable relationships set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertAuditLogUpdatableRelationshipsEquals(AuditLog expected, AuditLog actual) {
        assertThat(actual)
            .as("Verify AuditLog relationships")
            .satisfies(a -> assertThat(a.getUtente()).as("check utente").isEqualTo(expected.getUtente()));
    }
}
