-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring tests for #171, as they are failing, and may not be fixed…
… immediately
- Loading branch information
1 parent
02c4523
commit 63ff547
Showing
2 changed files
with
53 additions
and
28 deletions.
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
53 changes: 53 additions & 0 deletions
53
src/test/java/com/fasterxml/jackson/failing/TestUnwrappedWithPrefix.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,53 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.annotation.JsonUnwrapped; | ||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
// Tests for [#171] | ||
public class TestUnwrappedWithPrefix extends BaseMapTest | ||
{ | ||
static class MapUnwrap { | ||
|
||
public MapUnwrap() { } | ||
public MapUnwrap(String key, Object value) { | ||
map = Collections.singletonMap(key, value); | ||
} | ||
|
||
@JsonUnwrapped(prefix="map.") | ||
public Map<String, Object> map; | ||
} | ||
|
||
// // // Reuse mapper to keep tests bit faster | ||
|
||
private final ObjectMapper mapper = new ObjectMapper(); | ||
|
||
/* | ||
/********************************************************** | ||
/* Tests, serialization | ||
/********************************************************** | ||
*/ | ||
|
||
public void testMapUnwrapSerialize() throws Exception | ||
{ | ||
String json = mapper.writeValueAsString(new MapUnwrap("test", 6)); | ||
assertEquals("{\"map.test\": 6}", json); | ||
} | ||
|
||
/* | ||
/********************************************************** | ||
/* Tests, deserialization | ||
/********************************************************** | ||
*/ | ||
|
||
public void testMapUnwrapDeserialize() throws Exception | ||
{ | ||
MapUnwrap root = mapper.readValue("{\"map.test\": 6}", MapUnwrap.class); | ||
|
||
assertEquals(1, root.map.size()); | ||
assertEquals(6, ((Number)root.map.get("test")).intValue()); | ||
} | ||
} |