|
12 | 12 | import java.nio.file.Paths; |
13 | 13 | import java.time.Duration; |
14 | 14 | import java.util.Arrays; |
| 15 | +import java.util.Collections; |
15 | 16 | import java.util.HashMap; |
| 17 | +import java.util.HashSet; |
16 | 18 | import java.util.List; |
17 | 19 | import java.util.Map; |
18 | 20 | import java.util.Objects; |
| 21 | +import java.util.Set; |
| 22 | +import java.util.stream.Collectors; |
19 | 23 |
|
20 | 24 | import javax.persistence.EntityManager; |
21 | 25 | import javax.persistence.EntityManagerFactory; |
|
27 | 31 | import org.testcontainers.containers.JdbcDatabaseContainer; |
28 | 32 | import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; |
29 | 33 | import org.testcontainers.images.builder.ImageFromDockerfile; |
30 | | -import org.testcontainers.shaded.org.apache.commons.lang3.StringUtils; |
31 | 34 |
|
32 | 35 | import de.hilling.junit.cdi.CdiTestJunitExtension; |
33 | 36 | import de.hilling.junit.cdi.annotations.BypassTestInterceptor; |
34 | 37 | import de.symeda.sormas.backend.adverseeventsfollowingimmunization.entity.Aefi; |
35 | 38 | import de.symeda.sormas.backend.adverseeventsfollowingimmunization.entity.AefiInvestigation; |
36 | 39 | import de.symeda.sormas.backend.epipulse.EpipulseDatasourceConfiguration; |
| 40 | +import de.symeda.sormas.backend.epipulse.EpipulseExport; |
37 | 41 | import de.symeda.sormas.backend.epipulse.EpipulseLocationConfiguration; |
38 | 42 | import de.symeda.sormas.backend.epipulse.EpipulseSubjectcodeConfiguration; |
39 | 43 |
|
40 | 44 | @ExtendWith(CdiTestJunitExtension.class) |
41 | 45 | public class HistoryTablesTest { |
42 | 46 |
|
43 | | - private static final List<String> NO_HISTORY_REQUIRED_TABLES = Arrays.asList( |
44 | | - Aefi.AEFI_VACCINATIONS_TABLE_NAME, |
45 | | - AefiInvestigation.AEFI_INVESTIGATION_VACCINATIONS_TABLE_NAME, |
46 | | - EpipulseSubjectcodeConfiguration.TABLE_NAME, |
47 | | - EpipulseDatasourceConfiguration.TABLE_NAME, |
48 | | - EpipulseLocationConfiguration.TABLE_NAME); |
| 47 | + private static final Set<String> NO_HISTORY_REQUIRED_TABLES = Collections.unmodifiableSet( |
| 48 | + new HashSet<>( |
| 49 | + Arrays.asList( |
| 50 | + Aefi.AEFI_VACCINATIONS_TABLE_NAME, |
| 51 | + AefiInvestigation.AEFI_INVESTIGATION_VACCINATIONS_TABLE_NAME, |
| 52 | + EpipulseSubjectcodeConfiguration.TABLE_NAME, |
| 53 | + EpipulseDatasourceConfiguration.TABLE_NAME, |
| 54 | + EpipulseLocationConfiguration.TABLE_NAME, |
| 55 | + EpipulseExport.TABLE_NAME))); |
49 | 56 |
|
50 | 57 | /** |
51 | 58 | * Test that the *_history tables have the same columns as the corresponding production tables |
@@ -84,7 +91,7 @@ public void testHistoryTablesMatch() throws IOException, URISyntaxException { |
84 | 91 | Files.readAllBytes(Paths.get(Objects.requireNonNull(getClass().getClassLoader().getResource("checkHistoryTables.sql")).toURI()))); |
85 | 92 | @SuppressWarnings("unchecked") |
86 | 93 | List<Object[]> results = (List<Object[]>) em.createNativeQuery(checkHistoryTablesSql).getResultList(); |
87 | | - results.removeIf(o -> StringUtils.containsAny(o[1].toString(), NO_HISTORY_REQUIRED_TABLES.toArray(String[]::new))); |
| 94 | + results = results.stream().filter(objects -> !NO_HISTORY_REQUIRED_TABLES.contains(objects[1].toString())).collect(Collectors.toList()); |
88 | 95 | StringBuilder result = new StringBuilder(); |
89 | 96 | results.forEach(objects -> { |
90 | 97 | result.append("\n"); |
|
0 commit comments