package de.accso.flexinale.infrastructure.persistence.mapper;

import de.accso.flexinale.domain.model.Kino;
import de.accso.flexinale.infrastructure.persistence.KinoEntity;
import de.accso.flexinale.shared_code_for_test.TestDataBuilder;
import de.accso.flexinale.shared_kernel.Identifiable;
import org.junit.jupiter.api.Test;

import java.util.Set;
import java.util.stream.Collectors;

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

class KinoKinoSaalEntity2KinoKinoSaalMapperTest {

    @Test
    void testMapKinoEntityToKino() {
        // arrange
        KinoEntity kinoEntity = TestDataBuilder.createKinoEntityWithKinosaele(120, 111, 112);

        // act
        Kino kino = KinoKinoSaalEntity2KinoKinoSaalMapper.mapKino(kinoEntity);

        // assert
        assertThat(kino).isNotNull();
        assertThat(kino.id).isEqualTo(kino.id);
        assertThat(kino.kinoSaele.size()).isEqualTo(kino.kinoSaele.size());
        Set<Identifiable.Id> ksEntityIds = kinoEntity.kinoSaele.stream().map(ksE -> ksE.id()).collect(Collectors.toSet());
        Set<Identifiable.Id>       ksIds = kino.kinoSaele      .stream().map(ks  -> ks.id)   .collect(Collectors.toSet());
        assertThat(ksIds).isEqualTo(ksEntityIds);
    }
}