collect errors to the end

This commit is contained in:
Michael Hoennig 2024-07-22 10:30:15 +02:00
parent ccb0ee9c0f
commit 4b0fe5eb82
3 changed files with 15 additions and 4 deletions

View File

@ -20,15 +20,14 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Reader; import java.io.Reader;
import java.io.StringReader; import java.io.StringReader;
import java.io.StringWriter; import java.io.StringWriter;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
@ -69,6 +68,8 @@ public class CsvDataImport extends ContextBasedTest {
@MockBean @MockBean
HttpServletRequest request; HttpServletRequest request;
private static final List<AssertionError> errors = new ArrayList<>();
public List<String[]> readAllLines(Reader reader) throws Exception { public List<String[]> readAllLines(Reader reader) throws Exception {
final var parser = new CSVParserBuilder() final var parser = new CSVParserBuilder()
@ -211,12 +212,17 @@ public class CsvDataImport extends ContextBasedTest {
} }
void logError(final Runnable assertion) { void logError(final Runnable assertion) {
assertion.run();
try { try {
assertion.run(); assertion.run();
} catch (final AssertionError exc) { } catch (final AssertionError exc) {
System.err.println(exc); errors.add(exc);
} }
} }
void logErrors() {
assumeThat(errors).isEmpty();
}
} }
class Columns { class Columns {

View File

@ -310,6 +310,12 @@ public class ImportHostingAssets extends ImportOfficeData {
persistHostingAssetsOfType(IPV4_NUMBER); persistHostingAssetsOfType(IPV4_NUMBER);
} }
@Test
@Order(99999)
void logErrors() {
super.logErrors();
}
private void persistRecursively(final Integer key, final HsBookingItemEntity bi) { private void persistRecursively(final Integer key, final HsBookingItemEntity bi) {
if (bi.getParentItem() != null) { if (bi.getParentItem() != null) {
persistRecursively(key, HsBookingItemEntityValidatorRegistry.validated(bi.getParentItem())); persistRecursively(key, HsBookingItemEntityValidatorRegistry.validated(bi.getParentItem()));

View File

@ -500,7 +500,6 @@ public class ImportOfficeData extends CsvDataImport {
@Test @Test
@Order(2000) @Order(2000)
// @Disabled // FIXME
void verifyAllPartnersHavePersons() { void verifyAllPartnersHavePersons() {
partners.forEach((id, p) -> { partners.forEach((id, p) -> {
final var partnerRel = p.getPartnerRel(); final var partnerRel = p.getPartnerRel();