| ... |
... |
@@ -26,19 +26,21 @@ import com.google.gson.Gson; |
|
26
|
26
|
import com.google.gson.GsonBuilder;
|
|
27
|
27
|
import fr.ird.observe.dto.ObserveUtil;
|
|
28
|
28
|
import fr.ird.observe.dto.ProgressionModel;
|
|
29
|
|
-import fr.ird.observe.services.service.data.ps.AvdthDataImportConfiguration;
|
|
30
|
|
-import fr.ird.observe.services.service.data.ps.AvdthDataImportResult;
|
|
31
|
|
-import fr.ird.observe.services.service.data.ps.MissingReferentialException;
|
|
32
|
29
|
import fr.ird.observe.dto.referential.ReferentialLocale;
|
|
33
|
30
|
import fr.ird.observe.entities.ObserveTopiaPersistenceContext;
|
|
34
|
31
|
import fr.ird.observe.entities.data.ps.common.Trip;
|
|
35
|
32
|
import fr.ird.observe.persistence.avdth.AvdthFixtures;
|
|
36
|
33
|
import fr.ird.observe.persistence.test.PersistenceTestSupportWrite;
|
|
|
34
|
+import fr.ird.observe.services.service.data.ps.AvdthDataImportConfiguration;
|
|
|
35
|
+import fr.ird.observe.services.service.data.ps.AvdthDataImportResult;
|
|
|
36
|
+import fr.ird.observe.services.service.data.ps.MissingReferentialException;
|
|
37
|
37
|
import fr.ird.observe.test.DatabaseName;
|
|
38
|
38
|
import fr.ird.observe.test.IgnoreTestClassRule;
|
|
39
|
39
|
import fr.ird.observe.test.spi.CopyDatabaseConfiguration;
|
|
40
|
40
|
import fr.ird.observe.test.spi.DatabaseNameConfiguration;
|
|
41
|
41
|
import io.ultreia.java4all.util.SortedProperties;
|
|
|
42
|
+import org.apache.logging.log4j.LogManager;
|
|
|
43
|
+import org.apache.logging.log4j.Logger;
|
|
42
|
44
|
import org.junit.AfterClass;
|
|
43
|
45
|
import org.junit.Assert;
|
|
44
|
46
|
import org.junit.Assume;
|
| ... |
... |
@@ -56,6 +58,7 @@ import java.util.Collections; |
|
56
|
58
|
import java.util.List;
|
|
57
|
59
|
import java.util.Map;
|
|
58
|
60
|
import java.util.stream.Collectors;
|
|
|
61
|
+import java.util.stream.Stream;
|
|
59
|
62
|
|
|
60
|
63
|
/**
|
|
61
|
64
|
* Created on 24/05/2021.
|
| ... |
... |
@@ -65,7 +68,7 @@ import java.util.stream.Collectors; |
|
65
|
68
|
*/
|
|
66
|
69
|
@RunWith(Parameterized.class)
|
|
67
|
70
|
public abstract class AvdthDataBuilderTestSupport extends PersistenceTestSupportWrite {
|
|
68
|
|
-
|
|
|
71
|
+ private static final Logger log = LogManager.getLogger(AvdthDataBuilderTestSupport.class);
|
|
69
|
72
|
@ClassRule
|
|
70
|
73
|
public static final IgnoreTestClassRule IGNORE2 = new IgnoreTestClassRule("Persistence Avdth", "persistence.avdth.test.skip");
|
|
71
|
74
|
|
| ... |
... |
@@ -95,8 +98,8 @@ public abstract class AvdthDataBuilderTestSupport extends PersistenceTestSupport |
|
95
|
98
|
}
|
|
96
|
99
|
|
|
97
|
100
|
public static List<String> allDatabases(Path path) {
|
|
98
|
|
- try {
|
|
99
|
|
- List<String> collect = Files.find(path, 1, (p, b) -> p.toFile().getName().endsWith(".mdb")).map(p -> p.toFile().getName()).sorted().collect(Collectors.toList());
|
|
|
101
|
+ try (Stream<Path> pathStream = Files.find(path, 1, (p, b) -> p.toFile().getName().endsWith(".mdb"))) {
|
|
|
102
|
+ List<String> collect = pathStream.map(p -> p.toFile().getName()).sorted().collect(Collectors.toList());
|
|
100
|
103
|
Collections.reverse(collect);
|
|
101
|
104
|
return collect;
|
|
102
|
105
|
} catch (IOException e) {
|
| ... |
... |
@@ -142,8 +145,12 @@ public abstract class AvdthDataBuilderTestSupport extends PersistenceTestSupport |
|
142
|
145
|
try {
|
|
143
|
146
|
result = ImportEngine.run(configuration, localTestMethodResource.getTopiaApplicationContext());
|
|
144
|
147
|
String resultAsGson = gson.toJson(result);
|
|
145
|
|
- log.info(String.format("Import result:\n%s", resultAsGson));
|
|
146
|
|
- log.info(String.format("Import messages:\n%s", result.getMessageFile()));
|
|
|
148
|
+ log.debug(String.format("Import result:\n%s", resultAsGson));
|
|
|
149
|
+ // Used for debugging...
|
|
|
150
|
+ Map<String, Integer> exportResult = result.getExportResult();
|
|
|
151
|
+ if (!exportResult.isEmpty()) {
|
|
|
152
|
+ log.info(String.format("Export result:\n%s", exportResult.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining("\n"))));
|
|
|
153
|
+ }
|
|
147
|
154
|
} finally {
|
|
148
|
155
|
ObserveUtil.cleanMemory();
|
|
149
|
156
|
}
|