package de.avatic.lcc.config;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

import javax.sql.DataSource;

/**
 * Test configuration that provides only the beans needed for repository tests.
 * Does NOT load the full LccApplication context.
 *
 * Uses @SpringBootConfiguration to prevent Spring Boot from searching for and loading LccApplication.
 *
 * Excludes repositories with external dependencies (transformers/services) since we're only testing JDBC layer.
 */
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(
    basePackages = {
        "de.avatic.lcc.repositories",
        "de.avatic.lcc.database.dialect"
    },
    excludeFilters = @ComponentScan.Filter(
        type = FilterType.ASSIGNABLE_TYPE,
        classes = {
            de.avatic.lcc.repositories.error.DumpRepository.class
        }
    )
)
public class RepositoryTestConfig {

    @Bean
    public JdbcTemplate jdbcTemplate(DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }

    @Bean
    public NamedParameterJdbcTemplate namedParameterJdbcTemplate(DataSource dataSource) {
        return new NamedParameterJdbcTemplate(dataSource);
    }

    // SqlDialectProvider beans are now provided by @Component annotations in
    // MySQLDialectProvider and MSSQLDialectProvider classes
}
