@Test
public void fromFieldValue_multiValueCollector_stringArray() {

    String exampleContext = "{\"@context\":{\"@vocab\":\"http://example.com/\",\"test2\":{\"@id\":\"http://example.com/test2\",\"@container\":\"@list\"}}}";
    BdioContext context = new BdioContext.Builder()
            .injectDocument("http://example.com/context", exampleContext)
            .expandContext("http://example.com/context")
            .valueMapper(new StandardJavaValueMapper() {
                @Override
                public Collector<? super Object, ?, ?> getCollector(String container) {
                    // This is a collector that converts multiple values into a `String[]`
                    return collectingAndThen(mapping(o -> Objects.toString(o, null), toList()),
                            l -> l.stream().allMatch(Objects::isNull) ? null : l.toArray(new String[l.size()]));
                }
            })
            .build();
    assertThat((String[]) context.fromFieldValue("test2", ImmutableList.of("foobar"))).isEqualTo(new String[] { "foobar" });
    assertThat((String[]) context.fromFieldValue("test2", Arrays.asList((String) null))).isNull();
}