package at.procon.dip.testsupport;

import at.procon.dip.config.JacksonConfig;
import at.procon.dip.domain.document.service.DocumentContentService;

import at.procon.dip.domain.document.service.DocumentRepresentationService;
import at.procon.dip.domain.document.service.DocumentService;
import at.procon.dip.ingestion.config.DipIngestionProperties;
import at.procon.dip.search.engine.fulltext.PostgresFullTextSearchEngine;
import at.procon.dip.search.engine.trigram.PostgresTrigramSearchEngine;
import at.procon.dip.search.plan.DefaultSearchPlanner;
import at.procon.dip.search.rank.DefaultSearchResultFusionService;
import at.procon.dip.search.rank.DefaultSearchScoreNormalizer;
import at.procon.dip.search.repository.DocumentFullTextSearchRepositoryImpl;
import at.procon.dip.search.repository.DocumentTrigramSearchRepositoryImpl;
import at.procon.dip.search.service.DefaultSearchOrchestrator;
import at.procon.dip.search.service.DocumentLexicalIndexService;
import at.procon.dip.search.service.SearchMetricsService;
import at.procon.dip.search.web.GenericSearchController;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.context.annotation.Import;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

/**
 * Narrow test application for generic lexical search slices.
 *
 * Important: this class does not component-scan the whole application. Every
 * test support bean that should exist in the test context must therefore be
 * imported explicitly.
 */
@SpringBootConfiguration
@AutoConfigureMockMvc
@ImportAutoConfiguration({
        DataSourceAutoConfiguration.class,
        HibernateJpaAutoConfiguration.class,
        TransactionAutoConfiguration.class,
        JdbcTemplateAutoConfiguration.class
})
@EnableConfigurationProperties(DipIngestionProperties.class)
@EntityScan(basePackages = {
        "at.procon.dip.domain.document.entity",
        "at.procon.dip.domain.tenant.entity"
})
@EnableJpaRepositories(basePackages = {
        "at.procon.dip.domain.document.repository",
        "at.procon.dip.domain.tenant.repository"
})
@Import({
        DocumentService.class,
        DocumentContentService.class,
        DocumentRepresentationService.class,
        DocumentLexicalIndexService.class,
        SearchTestDataFactory.class,
        DefaultSearchPlanner.class,
        DocumentFullTextSearchRepositoryImpl.class,
        DocumentTrigramSearchRepositoryImpl.class,
        PostgresFullTextSearchEngine.class,
        PostgresTrigramSearchEngine.class,
        DefaultSearchScoreNormalizer.class,
        DefaultSearchResultFusionService.class,
        SearchMetricsService.class,
        DefaultSearchOrchestrator.class,
        GenericSearchController.class,
        DocumentLexicalIndexService.class
})
public class SearchTestApplication {
}
