Skip to content

Commit a6b1a73

Browse files
authored
Merge pull request #13760 from SORMAS-Foundation/bugfix-history_tables_test
Fixed issue with history tables test
2 parents 4123206 + 1073e18 commit a6b1a73

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

sormas-backend/src/test/java/de/symeda/sormas/backend/common/HistoryTablesTest.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@
1212
import java.nio.file.Paths;
1313
import java.time.Duration;
1414
import java.util.Arrays;
15+
import java.util.Collections;
1516
import java.util.HashMap;
17+
import java.util.HashSet;
1618
import java.util.List;
1719
import java.util.Map;
1820
import java.util.Objects;
21+
import java.util.Set;
22+
import java.util.stream.Collectors;
1923

2024
import javax.persistence.EntityManager;
2125
import javax.persistence.EntityManagerFactory;
@@ -27,25 +31,28 @@
2731
import org.testcontainers.containers.JdbcDatabaseContainer;
2832
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
2933
import org.testcontainers.images.builder.ImageFromDockerfile;
30-
import org.testcontainers.shaded.org.apache.commons.lang3.StringUtils;
3134

3235
import de.hilling.junit.cdi.CdiTestJunitExtension;
3336
import de.hilling.junit.cdi.annotations.BypassTestInterceptor;
3437
import de.symeda.sormas.backend.adverseeventsfollowingimmunization.entity.Aefi;
3538
import de.symeda.sormas.backend.adverseeventsfollowingimmunization.entity.AefiInvestigation;
3639
import de.symeda.sormas.backend.epipulse.EpipulseDatasourceConfiguration;
40+
import de.symeda.sormas.backend.epipulse.EpipulseExport;
3741
import de.symeda.sormas.backend.epipulse.EpipulseLocationConfiguration;
3842
import de.symeda.sormas.backend.epipulse.EpipulseSubjectcodeConfiguration;
3943

4044
@ExtendWith(CdiTestJunitExtension.class)
4145
public class HistoryTablesTest {
4246

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)));
4956

5057
/**
5158
* Test that the *_history tables have the same columns as the corresponding production tables
@@ -84,7 +91,7 @@ public void testHistoryTablesMatch() throws IOException, URISyntaxException {
8491
Files.readAllBytes(Paths.get(Objects.requireNonNull(getClass().getClassLoader().getResource("checkHistoryTables.sql")).toURI())));
8592
@SuppressWarnings("unchecked")
8693
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());
8895
StringBuilder result = new StringBuilder();
8996
results.forEach(objects -> {
9097
result.append("\n");

0 commit comments

Comments
 (0)