Skip to content

Commit 106f33b

Browse files
committed
Per [FasterXML#106] added allowNullFields to provide the option of processing null elements of lists as empty fields or the nullCharacter during serialization instead of the default behavior which skips null elements.
1 parent b6c7a0a commit 106f33b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/test/java/com/fasterxml/jackson/dataformat/csv/ser/NullWritingTest.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ public void testCustomNullValueInObjectListIssue106() throws Exception
9393

9494
String result = mapper.writer(schema).writeValueAsString(list);
9595
assertEquals("d0,n/a,d2\n", result);
96+
97+
list = Arrays.asList(null, "d1", "d2");
98+
result = mapper.writer(schema).writeValueAsString(list);
99+
assertEquals("n/a,d1,d2\n", result);
100+
101+
list = Arrays.asList("d0", "d1", null);
102+
result = mapper.writer(schema).writeValueAsString(list);
103+
assertEquals("d0,d1,n/a\n", result);
96104
}
97105

98106
public void testDefaultNullValueInObjectListIssue106() throws Exception
@@ -104,8 +112,15 @@ public void testDefaultNullValueInObjectListIssue106() throws Exception
104112
.build();
105113

106114
List list = Arrays.asList("d0", null, "d2");
107-
108115
String result = mapper.writer(schema).writeValueAsString(list);
109116
assertEquals("d0,,d2\n", result);
117+
118+
list = Arrays.asList(null, "d1", "d2");
119+
result = mapper.writer(schema).writeValueAsString(list);
120+
assertEquals(",d1,d2\n", result);
121+
122+
list = Arrays.asList("d0", "d1", null);
123+
result = mapper.writer(schema).writeValueAsString(list);
124+
assertEquals("d0,d1,\n", result);
110125
}
111126
}

0 commit comments

Comments
 (0)