package com.mosquito.project.job;

import com.mosquito.project.domain.Activity;
import com.mosquito.project.domain.DailyActivityStats;
import com.mosquito.project.service.ActivityService;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.util.List;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.when;

@ExtendWith(MockitoExtension.class)
class StatisticsAggregationJobTest {

    @Mock
    private ActivityService activityService;

    @Mock
    private com.mosquito.project.persistence.repository.DailyActivityStatsRepository dailyActivityStatsRepository;

    @InjectMocks
    private StatisticsAggregationJob statisticsAggregationJob;

    @Test
    void whenAggregateStatsForActivity_thenCreatesStats() {
        // Arrange
        Activity activity = new Activity();
        activity.setId(1L);
        activity.setName("Test Activity");
        activity.setStartTime(ZonedDateTime.now());
        activity.setEndTime(ZonedDateTime.now().plusDays(1));

        LocalDate testDate = LocalDate.now();

        // Act
        DailyActivityStats stats = statisticsAggregationJob.aggregateStatsForActivity(activity, testDate);

        // Assert
        assertNotNull(stats);
        assertEquals(activity.getId(), stats.getActivityId());
        assertEquals(testDate, stats.getStatDate());
        assertTrue(stats.getViews() >= 1000);
        assertTrue(stats.getShares() >= 200);
        assertTrue(stats.getNewRegistrations() >= 50);
        assertTrue(stats.getConversions() >= 10);
    }
}
