return empty Oaf list if record cannot be parsed

This commit is contained in:
Alessia Bardi 2022-09-13 11:51:55 +02:00
parent 27af5122d2
commit b99a011345
2 changed files with 2 additions and 5 deletions

View File

@ -143,7 +143,7 @@ public abstract class AbstractMdRecordToOafMapper {
return createOafs(doc, type, instances, collectedFrom, info, lastUpdateTimestamp); return createOafs(doc, type, instances, collectedFrom, info, lastUpdateTimestamp);
} catch (DocumentException e) { } catch (DocumentException e) {
log.error("Error with record:\n" + xml); log.error("Error with record:\n" + xml);
throw e; return Lists.newArrayList();
} }
} }

View File

@ -931,11 +931,8 @@ class MappersTest {
void testNotWellFormed() throws IOException, DocumentException { void testNotWellFormed() throws IOException, DocumentException {
final String xml = IOUtils final String xml = IOUtils
.toString(Objects.requireNonNull(getClass().getResourceAsStream("oaf_notwellformed.xml"))); .toString(Objects.requireNonNull(getClass().getResourceAsStream("oaf_notwellformed.xml")));
final DocumentException generalEx = new DocumentException(); assertEquals(0, new OafToOafMapper(vocs, false, true).processMdRecord(xml).size());
DocumentException exception = assertThrows(DocumentException.class, () -> {
new OafToOafMapper(vocs, false, true).processMdRecord(xml);
});
} }
private void assertValidId(final String id) { private void assertValidId(final String id) {