From 149f8ad71ff0059671356ec26e8a029c93ec08fd Mon Sep 17 00:00:00 2001 From: der Date: Sat, 17 Sep 2022 18:47:08 +0100 Subject: [PATCH] Test case and fix for missing mapped values in array Addresses: #43 --- src/main/java/com/epimorphics/dclib/values/ValueArray.java | 7 ++++++- .../epimorphics/dclib/framework/TestBasicConverters.java | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/epimorphics/dclib/values/ValueArray.java b/src/main/java/com/epimorphics/dclib/values/ValueArray.java index 316711a..809bb61 100644 --- a/src/main/java/com/epimorphics/dclib/values/ValueArray.java +++ b/src/main/java/com/epimorphics/dclib/values/ValueArray.java @@ -10,6 +10,7 @@ package com.epimorphics.dclib.values; import com.epimorphics.dclib.framework.ConverterProcess; +import com.epimorphics.dclib.framework.NullResult; import com.epimorphics.util.NameUtils; import java.util.ArrayList; @@ -333,7 +334,11 @@ public interface MapValue { public ValueArray applyFunction(MapValue map) { Value[] result = new Value[ value.length ]; for (int i = 0; i < value.length; i++) { - result[i] = map.map( value[i]); + try { + result[i] = map.map( value[i]); + } catch (NullResult n) { + result[i] = new ValueNull(); + } } return new ValueArray(result); } diff --git a/src/test/java/com/epimorphics/dclib/framework/TestBasicConverters.java b/src/test/java/com/epimorphics/dclib/framework/TestBasicConverters.java index 8ae5523..6a68d26 100644 --- a/src/test/java/com/epimorphics/dclib/framework/TestBasicConverters.java +++ b/src/test/java/com/epimorphics/dclib/framework/TestBasicConverters.java @@ -269,7 +269,11 @@ public void testBugs() throws IOException { checkAgainstExpected("test/bugCases/accidental-lang.yaml", "test/bugCases/accidental-lang.csv", "test/bugCases/accidental-lang.ttl"); } - + + @Test + public void testArrayMap() throws IOException { + checkAgainstExpected("test/arrayMap/resource-media-type.yaml", "test/arrayMap/resource_media_types.csv", "test/arrayMap/expected.ttl"); + } @Test public void testDateParseFailure() throws IOException { // A failure to parse a date shouldn't break the whole template, or should it