This repository has been archived by the owner on Nov 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trying to reproduce issue #42, no luck yet.
- Loading branch information
1 parent
c23198a
commit b368866
Showing
2 changed files
with
57 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
56 changes: 56 additions & 0 deletions
56
src/test/java/com/fasterxml/jackson/module/afterburner/deser/TestFinalFields.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,56 @@ | ||
package com.fasterxml.jackson.module.afterburner.deser; | ||
|
||
import com.fasterxml.jackson.annotation.*; | ||
import com.fasterxml.jackson.databind.*; | ||
import com.fasterxml.jackson.module.afterburner.AfterburnerTestBase; | ||
|
||
public class TestFinalFields extends AfterburnerTestBase | ||
{ | ||
static class Address { | ||
public int zip1, zip2; | ||
|
||
public Address() { } | ||
public Address(int z1, int z2) { | ||
zip1 = z1; | ||
zip2 = z2; | ||
} | ||
} | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
static class Organization | ||
{ | ||
public final long id; | ||
public final String name; | ||
public final Address address; | ||
|
||
@JsonCreator | ||
public Organization(@JsonProperty("id") long id, | ||
@JsonProperty("name") String name, | ||
@JsonProperty("address") Address address) | ||
{ | ||
this.id = id; | ||
this.name = name; | ||
this.address = address; | ||
} | ||
} | ||
|
||
/* | ||
/********************************************************** | ||
/* Unit tests | ||
/********************************************************** | ||
*/ | ||
|
||
public void testFinalFields() throws Exception | ||
{ | ||
ObjectMapper mapper = mapperWithModule(); | ||
String json = mapper.writeValueAsString(new Organization[] { | ||
new Organization(123L, "Corp", new Address(98040, 98021)) | ||
}); | ||
Organization[] result = mapper.readValue(json, Organization[].class); | ||
assertNotNull(result); | ||
assertEquals(1, result.length); | ||
assertNotNull(result[0]); | ||
assertNotNull(result[0].address); | ||
assertEquals(98021, result[0].address.zip2); | ||
} | ||
} |