Skip to content

Commit

Permalink
Fix searching all checkpoints for ZaakBrug case (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhdirkse authored May 1, 2024
1 parent 4e88c3e commit b7c9e83
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Object extractMetadata(Report report) {
}
}
Iterator iterator = extractFromList.iterator();
while (value == null && iterator.hasNext()) {
while (StringUtils.isBlank(value) && iterator.hasNext()) {
String message = ((Checkpoint)iterator.next()).getMessage();
if (message != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ public void whenXpathFindsSomethingThenDelegateNotAccessed() throws Exception {
assertEquals("My second value", instance.extractMetadata(report));
}

@Test
public void whenXpathProducesBlankForFirstThenLastStillSearched() throws Exception {
Report report = getReportToTestBlankXpathMatch();
XpathMetadataFieldExtractor instance = new XpathMetadataFieldExtractor();
instance.setExtractFrom("all");
instance.setXpath("/one/two");
assertEquals("My second value", instance.extractMetadata(report));
}

private Report getReport() {
TestTool testTool = new TestTool();
Report report = new Report();
Expand All @@ -86,4 +95,25 @@ private Report getReport() {
report.setCheckpoints(checkpoints);
return report;
}

private Report getReportToTestBlankXpathMatch() {
TestTool testTool = new TestTool();
Report report = new Report();
List<Checkpoint> checkpoints = new ArrayList<>();
report.setTestTool(testTool);
Checkpoint checkpoint = new Checkpoint();
checkpoints.add(checkpoint);
checkpoint.setReport(report);
checkpoint.setName("SessionKey anotherKey");
checkpoint.setMessage("<one><two></two></one>");
checkpoint.setType(Checkpoint.TYPE_STARTPOINT);
checkpoint = new Checkpoint();
checkpoints.add(checkpoint);
checkpoint.setReport(report);
checkpoint.setName("SessionKey mySessionKey");
checkpoint.setMessage("<one><two>My second value</two></one>");
checkpoint.setType(Checkpoint.TYPE_ENDPOINT);
report.setCheckpoints(checkpoints);
return report;
}
}

0 comments on commit b7c9e83

Please sign in to comment.