forked from FasterXML/jackson-dataformat-csv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test from FasterXML#33 to failing unit tests folder
- Loading branch information
Paul Magrath
committed
Mar 11, 2014
1 parent
e3275c5
commit eff9210
Showing
3 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ target | |
*.iml | ||
*.ipr | ||
*.iws | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/test/java/com/fasterxml/jackson/dataformat/csv/failing/TestWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.fasterxml.jackson.dataformat.csv.failing; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectWriter; | ||
import com.fasterxml.jackson.dataformat.csv.CsvMapper; | ||
import com.fasterxml.jackson.dataformat.csv.CsvSchema; | ||
import com.google.common.collect.ImmutableMap; | ||
import org.junit.Test; | ||
|
||
import java.lang.String;import static org.junit.Assert.assertEquals; | ||
|
||
public class TestWriter { | ||
|
||
@Test | ||
public void testWrite_NoNulls() throws JsonProcessingException { | ||
final CsvSchema.Builder csvSchemaBuilder = new CsvSchema.Builder(); | ||
csvSchemaBuilder.addColumn("timestamp", CsvSchema.ColumnType.STRING); | ||
csvSchemaBuilder.addColumn("value", CsvSchema.ColumnType.NUMBER); | ||
csvSchemaBuilder.addColumn("id", CsvSchema.ColumnType.STRING); | ||
final CsvSchema schema = csvSchemaBuilder.build(); | ||
final ObjectWriter writer = new CsvMapper().writer().withSchema(schema); | ||
|
||
final String string = writer.writeValueAsString( | ||
ImmutableMap.of("timestamp", "2014-03-10T23:32:47+00:00", | ||
"value", 42, "id", "hello")); | ||
|
||
assertEquals("\"2014-03-10T23:32:47+00:00\",42,hello\n", string); | ||
} | ||
|
||
@Test | ||
public void testWrite_NullFirstColumn() throws JsonProcessingException { | ||
final CsvSchema.Builder csvSchemaBuilder = new CsvSchema.Builder(); | ||
csvSchemaBuilder.addColumn("timestamp", CsvSchema.ColumnType.STRING); | ||
csvSchemaBuilder.addColumn("value", CsvSchema.ColumnType.NUMBER); | ||
csvSchemaBuilder.addColumn("id", CsvSchema.ColumnType.STRING); | ||
final CsvSchema schema = csvSchemaBuilder.build(); | ||
final ObjectWriter writer = new CsvMapper().writer().withSchema(schema); | ||
|
||
final String string = writer.writeValueAsString( | ||
ImmutableMap.of("value", 42, "id", "hello")); | ||
|
||
assertEquals(",42,hello\n", string); | ||
} | ||
|
||
@Test | ||
public void testWrite_NullSecondColumn() throws JsonProcessingException { | ||
final CsvSchema.Builder csvSchemaBuilder = new CsvSchema.Builder(); | ||
csvSchemaBuilder.addColumn("timestamp", CsvSchema.ColumnType.STRING); | ||
csvSchemaBuilder.addColumn("value", CsvSchema.ColumnType.NUMBER); | ||
csvSchemaBuilder.addColumn("id", CsvSchema.ColumnType.STRING); | ||
final CsvSchema schema = csvSchemaBuilder.build(); | ||
final ObjectWriter writer = new CsvMapper().writer().withSchema(schema); | ||
|
||
final String string = writer.writeValueAsString( | ||
ImmutableMap.of("timestamp", "2014-03-10T23:32:47+00:00", | ||
"id", "hello")); | ||
|
||
assertEquals("\"2014-03-10T23:32:47+00:00\",,hello\n", string); | ||
} | ||
|
||
@Test | ||
public void testWrite_NullThirdColumn() throws JsonProcessingException { | ||
final CsvSchema.Builder csvSchemaBuilder = new CsvSchema.Builder(); | ||
csvSchemaBuilder.addColumn("timestamp", CsvSchema.ColumnType.STRING); | ||
csvSchemaBuilder.addColumn("value", CsvSchema.ColumnType.NUMBER); | ||
csvSchemaBuilder.addColumn("id", CsvSchema.ColumnType.STRING); | ||
final CsvSchema schema = csvSchemaBuilder.build(); | ||
final ObjectWriter writer = new CsvMapper().writer().withSchema(schema); | ||
|
||
final String string = writer.writeValueAsString( | ||
ImmutableMap.of("timestamp", "2014-03-10T23:32:47+00:00", | ||
"value", 42)); | ||
|
||
assertEquals("\"2014-03-10T23:32:47+00:00\",42\n", string); | ||
} | ||
|
||
} |