package de.accso.flexinale.backoffice.application.services.mapper;

import de.accso.flexinale.backoffice.domain.model.Kino;
import de.accso.flexinale.backoffice_api_contract.api_contract.model.KinoTO;
import de.accso.flexinale.common.shared_kernel.Identifiable;
import de.accso.flexinale.common.shared_kernel.DoNotCheckInArchitectureTests;
import de.accso.flexinale.shared_code_for_test.TestDataBuilder;
import org.junit.jupiter.api.Test;

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

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

@DoNotCheckInArchitectureTests
class KinoKinoSaal2KinoKinoSaalTOMapperTest {

    @Test
    void testMapKinoToKinoTO() {
        // arrange
        Kino kino = TestDataBuilder.createKinoWithKinosaele();

        // act
        KinoTO kinoTO = KinoKinoSaal2KinoKinoSaalTOMapper.mapKino(kino);

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