package dev.lions.unionflow.server.api.dto.notification;

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

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;

@DisplayName("Tests pour PreferenceCanalNotificationDTO")
class PreferenceCanalNotificationDTOTest {

  @Test
  @DisplayName("Test de base - classe peut être instanciée")
  void testClasseInstanciable() {
    PreferenceCanalNotificationDTO dto = new PreferenceCanalNotificationDTO();
    assertThat(dto).isNotNull();
  }

  @Nested
  @DisplayName("Tests de construction")
  class ConstructionTests {

    @Test
    @DisplayName("Constructeur par défaut")
    void testConstructeurParDefaut() {
      PreferenceCanalNotificationDTO dto = new PreferenceCanalNotificationDTO();

      assertThat(dto).isNotNull();
    }
  }

  @Nested
  @DisplayName("Tests getters/setters")
  class GettersSettersTests {

    @Test
    @DisplayName("Test tous les getters/setters")
    void testTousLesGettersSetters() {
      PreferenceCanalNotificationDTO dto = new PreferenceCanalNotificationDTO();
      long[] patternVibration = new long[]{100, 200, 100};

      dto.setActive(true);
      dto.setImportance(4);
      dto.setSonPersonnalise("custom_sound.mp3");
      dto.setPatternVibration(patternVibration);
      dto.setCouleurLED("#FF0000");
      dto.setSonActive(true);
      dto.setVibrationActive(false);
      dto.setLedActive(true);
      dto.setPeutEtreDesactive(false);

      assertThat(dto.getActive()).isTrue();
      assertThat(dto.getImportance()).isEqualTo(4);
      assertThat(dto.getSonPersonnalise()).isEqualTo("custom_sound.mp3");
      assertThat(dto.getPatternVibration()).isEqualTo(patternVibration);
      assertThat(dto.getCouleurLED()).isEqualTo("#FF0000");
      assertThat(dto.getSonActive()).isTrue();
      assertThat(dto.getVibrationActive()).isFalse();
      assertThat(dto.getLedActive()).isTrue();
      assertThat(dto.getPeutEtreDesactive()).isFalse();
    }

    @ParameterizedTest
    @ValueSource(booleans = {true, false})
    @DisplayName("active - toutes les valeurs")
    void testActive(Boolean valeur) {
      PreferenceCanalNotificationDTO dto = new PreferenceCanalNotificationDTO();
      dto.setActive(valeur);
      assertThat(dto.getActive()).isEqualTo(valeur);
    }

    @ParameterizedTest
    @CsvSource({
        "1, 1",
        "3, 3",
        "5, 5"
    })
    @DisplayName("importance - toutes les valeurs")
    void testImportance(Integer importance, Integer expected) {
      PreferenceCanalNotificationDTO dto = new PreferenceCanalNotificationDTO();
      dto.setImportance(importance);
      assertThat(dto.getImportance()).isEqualTo(expected);
    }

    @ParameterizedTest
    @ValueSource(booleans = {true, false})
    @DisplayName("sonActive - toutes les valeurs")
    void testSonActive(Boolean valeur) {
      PreferenceCanalNotificationDTO dto = new PreferenceCanalNotificationDTO();
      dto.setSonActive(valeur);
      assertThat(dto.getSonActive()).isEqualTo(valeur);
    }

    @ParameterizedTest
    @ValueSource(booleans = {true, false})
    @DisplayName("vibrationActive - toutes les valeurs")
    void testVibrationActive(Boolean valeur) {
      PreferenceCanalNotificationDTO dto = new PreferenceCanalNotificationDTO();
      dto.setVibrationActive(valeur);
      assertThat(dto.getVibrationActive()).isEqualTo(valeur);
    }

    @ParameterizedTest
    @ValueSource(booleans = {true, false})
    @DisplayName("ledActive - toutes les valeurs")
    void testLedActive(Boolean valeur) {
      PreferenceCanalNotificationDTO dto = new PreferenceCanalNotificationDTO();
      dto.setLedActive(valeur);
      assertThat(dto.getLedActive()).isEqualTo(valeur);
    }

    @ParameterizedTest
    @ValueSource(booleans = {true, false})
    @DisplayName("peutEtreDesactive - toutes les valeurs")
    void testPeutEtreDesactive(Boolean valeur) {
      PreferenceCanalNotificationDTO dto = new PreferenceCanalNotificationDTO();
      dto.setPeutEtreDesactive(valeur);
      assertThat(dto.getPeutEtreDesactive()).isEqualTo(valeur);
    }
  }
}

