Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Fix #157: handle Record parameters in any order #160

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions jr-record-test/src/test-jdk17/java/jr/Java17RecordTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,23 @@ public void testJava14RecordSerialization() throws Exception {
assertEquals(expectedDoc, json.asString(input));
}

// [jackson-jr#148]
public void testJava14RecordDeserialization() throws Exception {
JSON json = JSON.std;
// [jackson-jr#148]: simple deserialization
public void testRecordDeserializationSimple() throws Exception {
String inputDoc = "{\"message\":\"MOO\",\"object\":{\"Foo\":\"Bar\"}}";
assertEquals(new Cow("MOO", Map.of("Foo", "Bar")),
JSON.std.beanFrom(Cow.class, inputDoc));
}

Cow expected = new Cow("MOO", Map.of("Foo", "Bar"));

Cow actual = json.beanFrom(Cow.class, inputDoc);
assertEquals(expected, actual);
// [jackson-jr#157]: deserialization should work with different ordering
public void testRecordDeserializationReordered() throws Exception {
String inputDoc = "{\"object\":{\"Foo\":\"Bar\"}, \"message\":\"MOO\"}";
assertEquals(new Cow("MOO", Map.of("Foo", "Bar")),
JSON.std.beanFrom(Cow.class, inputDoc));
}
// [jackson-jr#157]: deserialization should work with missing, as well
public void testRecordDeserializationPartial() throws Exception {
String inputDoc = "{\"message\":\"MOO\"}";
assertEquals(new Cow("MOO", null),
JSON.std.beanFrom(Cow.class, inputDoc));
}
}