package io.fundreqest.platform.tweb.infrastructure.mav;

import io.fundrequest.core.request.RequestService;
import io.fundrequest.core.request.statistics.StatisticsService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.event.ContextRefreshedEvent;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

public class IniitalizerTest {

    private Iniitalizer iniitalizer;

    @BeforeEach
    void setUp() {
        iniitalizer = new Iniitalizer();
    }

    @Test
    void initializesCachedData() {
        ContextRefreshedEvent event = mock(ContextRefreshedEvent.class);
        ApplicationContext context = mock(ApplicationContext.class);
        when(event.getApplicationContext()).thenReturn(context);
        RequestService requestService = mock(RequestService.class);
        when(context.getBean(RequestService.class)).thenReturn(requestService);
        StatisticsService statisticsService = mock(StatisticsService.class);
        when(context.getBean(StatisticsService.class)).thenReturn(statisticsService);

        iniitalizer.onApplicationEvent(event);

        verify(requestService).findAll();
        verify(requestService).findAllTechnologies();
        verify(requestService).findAllProjects();
        verify(statisticsService).getStatistics();
    }
}
@@ -50,16 +50,134 @@
 e.mav;%0A%0A
+import io.fundreqest.platform.tweb.fund.FundController;%0Aimport io.fundreqest.platform.tweb.request.RequestController;%0A
 import i
@@ -280,24 +280,71 @@
 icsService;%0A
+import io.fundrequest.platform.faq.FAQService;%0A
 import org.j
@@ -1365,16 +1365,144 @@
 ervice);
+%0A        FAQService faqService = mock(FAQService.class);%0A        when(context.getBean(FAQService.class)).thenReturn(faqService);
 %0A%0A      
@@ -1736,19 +1736,260 @@
 atistics();%0A
+        verify(faqService).getFAQsForPage(RequestController.FAQ_REQUEST_DETAIL_PAGE);%0A        verify(faqService).getFAQsForPage(RequestController.FAQ_REQUESTS_PAGE);%0A        verify(faqService).getFAQsForPage(FundController.FAQ_FUND_GITHUB);%0A
     %7D%0A%7D

verify faqs initialized