Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Commit 2c216cb

Browse files
committed
Add a test for #125
1 parent 89cdde4 commit 2c216cb

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/main/java/com/fasterxml/jackson/dataformat/csv/CsvGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ public final void writeEndObject() throws IOException
540540
// not 100% fool-proof, but chances are row should be done now
541541
finishRow();
542542
}
543-
543+
544544
/*
545545
/**********************************************************
546546
/* Output method implementations, textual
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.fasterxml.jackson.dataformat.csv.ser;
2+
3+
import com.fasterxml.jackson.annotation.*;
4+
5+
import com.fasterxml.jackson.dataformat.csv.*;
6+
7+
public class UnwrappedWriteTest extends ModuleTestBase
8+
{
9+
@JsonPropertyOrder({ "f1", "f2", "f3" })
10+
static class Inner {
11+
public String f1;
12+
public String f2;
13+
public String f3;
14+
}
15+
16+
@JsonPropertyOrder({ "a", "inner" })
17+
static class Outer {
18+
public String a;
19+
20+
@JsonUnwrapped
21+
public Inner inner = new Inner();
22+
}
23+
24+
// for [dataformat-csv#125]
25+
public void testWriteUnwrapped() throws Exception
26+
{
27+
CsvMapper mapper = mapperForCsv();
28+
29+
// Set null value to 'null'
30+
final CsvSchema schema = mapper.schemaFor(Outer.class).withNullValue("null");
31+
32+
// Create an object. All the fields are NULLs
33+
String csv = mapper.writer(schema).writeValueAsString(new Outer());
34+
assertEquals("null,null,null,null", csv.trim());
35+
}
36+
}

0 commit comments

Comments
 (0)