package dev.lions.unionflow.server.entity;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.UUID;

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

@DisplayName("Configuration")
class ConfigurationTest {

    @Test
    @DisplayName("getters/setters")
    void gettersSetters() {
        Configuration c = new Configuration();
        c.setCle("app.name");
        c.setValeur("UnionFlow");
        c.setType("STRING");
        c.setCategorie("SYSTEME");
        c.setDescription("Nom de l'application");
        c.setModifiable(true);
        c.setVisible(true);
        c.setMetadonnees("{}");

        assertThat(c.getCle()).isEqualTo("app.name");
        assertThat(c.getValeur()).isEqualTo("UnionFlow");
        assertThat(c.getType()).isEqualTo("STRING");
        assertThat(c.getCategorie()).isEqualTo("SYSTEME");
        assertThat(c.getDescription()).isEqualTo("Nom de l'application");
        assertThat(c.getModifiable()).isTrue();
        assertThat(c.getVisible()).isTrue();
        assertThat(c.getMetadonnees()).isEqualTo("{}");
    }

    @Test
    @DisplayName("modifiable et visible par défaut true")
    void defauts() {
        Configuration c = new Configuration();
        c.setCle("x");
        assertThat(c.getModifiable()).isTrue();
        assertThat(c.getVisible()).isTrue();
    }

    @Test
    @DisplayName("equals et hashCode")
    void equalsHashCode() {
        UUID id = UUID.randomUUID();
        Configuration a = new Configuration();
        a.setId(id);
        a.setCle("k1");
        a.setValeur("v1");
        Configuration b = new Configuration();
        b.setId(id);
        b.setCle("k1");
        b.setValeur("v1");
        assertThat(a).isEqualTo(b);
        assertThat(a.hashCode()).isEqualTo(b.hashCode());
    }

    @Test
    @DisplayName("toString non null")
    void toString_nonNull() {
        Configuration c = new Configuration();
        c.setCle("x");
        assertThat(c.toString()).isNotNull().isNotEmpty();
    }
}
