Refactored integration tests for NomenclatureRepository to ensure test data cleanup and alignment with updated table structure. Removed unused beans and dependencies in RepositoryTestConfig.

This commit is contained in:
Jan 2026-01-28 00:15:02 +01:00
parent 3f8453f93b
commit a5fd03cc68
3 changed files with 21 additions and 33 deletions

View file

@ -1,7 +1,6 @@
package de.avatic.lcc.repositories; package de.avatic.lcc.repositories;
import de.avatic.lcc.database.dialect.SqlDialectProvider; import de.avatic.lcc.database.dialect.SqlDialectProvider;
import de.avatic.lcc.service.api.EUTaxationApiService;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

View file

@ -1,15 +1,10 @@
package de.avatic.lcc.config; package de.avatic.lcc.config;
import de.avatic.lcc.database.dialect.MySQLDialectProvider;
import de.avatic.lcc.database.dialect.MSSQLDialectProvider;
import de.avatic.lcc.database.dialect.SqlDialectProvider;
import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Profile;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
@ -26,12 +21,14 @@ import javax.sql.DataSource;
@SpringBootConfiguration @SpringBootConfiguration
@EnableAutoConfiguration @EnableAutoConfiguration
@ComponentScan( @ComponentScan(
basePackages = "de.avatic.lcc.repositories", basePackages = {
"de.avatic.lcc.repositories",
"de.avatic.lcc.database.dialect"
},
excludeFilters = @ComponentScan.Filter( excludeFilters = @ComponentScan.Filter(
type = FilterType.ASSIGNABLE_TYPE, type = FilterType.ASSIGNABLE_TYPE,
classes = { classes = {
de.avatic.lcc.repositories.error.DumpRepository.class, de.avatic.lcc.repositories.error.DumpRepository.class,
de.avatic.lcc.repositories.NomenclatureRepository.class,
de.avatic.lcc.repositories.premise.DestinationRepository.class de.avatic.lcc.repositories.premise.DestinationRepository.class
} }
) )
@ -48,17 +45,6 @@ public class RepositoryTestConfig {
return new NamedParameterJdbcTemplate(dataSource); return new NamedParameterJdbcTemplate(dataSource);
} }
@Bean // SqlDialectProvider beans are now provided by @Component annotations in
@Profile("mysql") // MySQLDialectProvider and MSSQLDialectProvider classes
public SqlDialectProvider mysqlDialectProvider() {
System.out.println("RepositoryTestConfig: Creating MySQLDialectProvider");
return new MySQLDialectProvider();
}
@Bean
@Profile("mssql")
public SqlDialectProvider mssqlDialectProvider() {
System.out.println("RepositoryTestConfig: Creating MSSQLDialectProvider");
return new MSSQLDialectProvider();
}
} }

View file

@ -29,19 +29,22 @@ class NomenclatureRepositoryIntegrationTest extends AbstractRepositoryIntegratio
@BeforeEach @BeforeEach
void setupTestData() { void setupTestData() {
// Insert test HS codes into the nomenclature table // Clean up nomenclature table
String sql = "INSERT INTO nomenclature (hs_code, description) VALUES (?, ?)"; jdbcTemplate.update("DELETE FROM nomenclature");
executeRawSql(sql, "8471300000", "Portable automatic data processing machines, weighing not more than 10 kg"); // Insert test HS codes into the nomenclature table (only hs_code column exists)
executeRawSql(sql, "8471410000", "Comprising in the same housing at least a central processing unit"); String sql = "INSERT INTO nomenclature (hs_code) VALUES (?)";
executeRawSql(sql, "8471420000", "Other, presented in the form of systems");
executeRawSql(sql, "8471490000", "Other automatic data processing machines"); executeRawSql(sql, "8471300000");
executeRawSql(sql, "8471500000", "Processing units other than those of subheading 8471.41 or 8471.49"); executeRawSql(sql, "8471410000");
executeRawSql(sql, "8471600000", "Input or output units"); executeRawSql(sql, "8471420000");
executeRawSql(sql, "8471700000", "Storage units"); executeRawSql(sql, "8471490000");
executeRawSql(sql, "8471800000", "Other units of automatic data processing machines"); executeRawSql(sql, "8471500000");
executeRawSql(sql, "9403200000", "Other metal furniture"); executeRawSql(sql, "8471600000");
executeRawSql(sql, "9403300000", "Wooden furniture of a kind used in offices"); executeRawSql(sql, "8471700000");
executeRawSql(sql, "8471800000");
executeRawSql(sql, "9403200000");
executeRawSql(sql, "9403300000");
} }
@Test @Test