package at.procon.eventhub.importing;

import at.procon.eventhub.dto.AcquisitionStrategy;
import at.procon.eventhub.dto.EventFamily;
import at.procon.eventhub.dto.EventSourceDto;
import at.procon.eventhub.dto.ImportMode;
import at.procon.eventhub.dto.ImportScopeDto;
import at.procon.eventhub.dto.SourceGroupRefDto;
import at.procon.eventhub.yellowfox.dto.YellowFoxD8ImportRequest;
import java.time.OffsetDateTime;
import java.util.EnumSet;
import org.junit.jupiter.api.Test;

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

class ImportChunkPlannerTest {

    @Test
    void keepsScheduledRowWatermarkImportsAsSingleChunkEvenWhenScopeHasWindow() {
        ImportChunkPlanner planner = new ImportChunkPlanner();
        YellowFoxD8ImportRequest request = new YellowFoxD8ImportRequest(
                "tenant-1",
                new EventSourceDto("YELLOWFOX", "TELEMATICS_PLATFORM", "YELLOWFOX_D8", "instance-1", "setting-1", null),
                (SourceGroupRefDto) null,
                ImportScopeDto.tenantAll(
                        OffsetDateTime.parse("2026-04-01T00:00:00+02:00"),
                        OffsetDateTime.parse("2026-04-10T00:00:00+02:00")
                ),
                EnumSet.noneOf(EventFamily.class),
                ImportMode.INCREMENTAL_UPDATE,
                false,
                AcquisitionStrategy.SOURCE_ROW_WATERMARK
        );

        assertThat(planner.chunksFor(request, 1))
                .containsExactly(new ImportTimeChunkDto(
                        1,
                        OffsetDateTime.parse("2026-04-01T00:00:00+02:00"),
                        OffsetDateTime.parse("2026-04-10T00:00:00+02:00")
                ));
    }
}
