Skip to content

Commit

Permalink
Exclude update-process for tests #462
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasNx committed Oct 12, 2023
1 parent bddc3fe commit 780d575
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
10 changes: 7 additions & 3 deletions app/transformation/TransformAll.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,19 @@ public static void process(final String startOfUpdates,
String sigelBulkOutput = outputPath + "-sigelBulk";
String sigelUpdatesOutput = outputPath + "-sigelUpdates";
TransformSigel.processBulk(sigelBulkOutput, geoServer, wikidataLookupFilename); //Start processing Sigel pica binary bulk.
TransformSigel.processUpdates(startOfUpdates, sigelUpdatesOutput, geoServer, wikidataLookupFilename); //Start process Sigel Pica XML Updates via OAI-PMH.
TransformDbs.process(dbsOutput, geoServer,wikidataLookupFilename); //Start process DBS data.
if (startOfUpdates != "") { // exclude updates for the tests, which set startOfUpdates to ""
TransformSigel.processUpdates(startOfUpdates, sigelUpdatesOutput, geoServer, wikidataLookupFilename); //Start process Sigel Pica XML Updates via OAI-PMH.
}
TransformDbs.process(dbsOutput, geoServer,wikidataLookupFilename); //Start process DBS CSV data.

// DBS-Data, Sigel Bulk and Updates are joined in a single ES-Bulk-file.
// DBS data first, so that ES prefers Sigel entries that come later and overwrite DBS entries if available.
try (FileWriter resultWriter = new FileWriter(outputPath)) {
writeAll(dbsOutput, resultWriter);
writeAll(sigelBulkOutput, resultWriter);
writeAll(sigelUpdatesOutput, resultWriter);
if (startOfUpdates != "") { // exclude updates for the tests, which set startOfUpdates to ""
writeAll(sigelUpdatesOutput, resultWriter);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/index/ElasticsearchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class ElasticsearchTest {

@BeforeClass
public static void makeIndex() throws IOException {
TransformAll.process("", 0, TransformAll.DATA_OUTPUT_FILE, "", "../test/conf/wikidataLookup.tsv");
TransformAll.process("", TransformAll.DATA_OUTPUT_FILE, "", "../test/conf/wikidataLookup.tsv");
Index.initialize(TransformAll.DATA_OUTPUT_FILE);
}

Expand Down
10 changes: 4 additions & 6 deletions test/transformation/TestTransformAll.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@ public class TestTransformAll {

private static final String SIGEL_DUMP_LOCATION =
TransformAll.DATA_INPUT_DIR + "sigel.dat";
private static final String DUMP_XPATH =
"/" + TransformSigel.DUMP_TOP_LEVEL_TAG + "/" + TransformSigel.XPATH;
private static final String wikidataLookupFilename = "../test/conf/wikidataLookup.tsv";

@BeforeClass
public static void setUp() throws IOException {
File output = new File(TransformAll.DATA_OUTPUT_FILE);
assertThat(!output.exists() || output.delete()).as("no output file")
.isTrue();
TransformAll.process("", 0, TransformAll.DATA_OUTPUT_FILE, "", wikidataLookupFilename);
TransformAll.process("", TransformAll.DATA_OUTPUT_FILE, "", wikidataLookupFilename);
}

@AfterClass
Expand All @@ -61,15 +59,15 @@ public static void tearDown() {

@Test
public void multiLangAlternateName() throws IOException {
assertThat(new String(
assertThat(new String(
Files.readAllBytes(Paths.get(TransformAll.DATA_OUTPUT_FILE))))
.as("transformation output with multiLangAlternateName")
.contains("Leibniz Institute").contains("Berlin SBB");
}

@Test
public void separateUrlAndProvidesFields() throws IOException {
assertThat(new String(
assertThat(new String(
Files.readAllBytes(Paths.get(TransformAll.DATA_OUTPUT_FILE))))
.as("transformation output with `url` and `provides`")
.contains("https://www.livivo.de/?idb=ZBMED")
Expand All @@ -78,7 +76,7 @@ public void separateUrlAndProvidesFields() throws IOException {

@Test
public void preferSigelData() throws IOException {
assertThat(new String(
assertThat(new String(
Files.readAllBytes(Paths.get(TransformAll.DATA_OUTPUT_FILE))))
.as("transformation output with preferred Sigel data")
.contains("Hauptabteilung")//
Expand Down
Loading

0 comments on commit 780d575

Please sign in to comment.