Skip to content

Commit 13e3130

Browse files
committed
...
1 parent ad5d227 commit 13e3130

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/test-jdk17/java/com/fasterxml/jackson/databind/records/RecordWithReadOnlyTest.java

+16-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ record RecordWithReadOnly(int id, @JsonProperty(access = Access.READ_ONLY) Strin
1616
}
1717

1818
record RecordWithReadOnlyNamedProperty(int id,
19-
@JsonProperty(value = "name", access = Access.READ_ONLY) String name) {
19+
@JsonProperty(value = "name", access = Access.READ_ONLY) String name) {
2020
}
2121

2222
record RecordWithReadOnlyAccessor(int id, String name) {
@@ -28,8 +28,9 @@ public String name() {
2828
}
2929
}
3030

31-
record RecordWithReadOnlyComponentOverriddenAccessor(int id, @JsonProperty(access = Access.READ_ONLY) String name) {
32-
31+
record RecordWithReadOnlyComponentOverriddenAccessor(int id,
32+
@JsonProperty(access = Access.READ_ONLY) String name)
33+
{
3334
// @JsonProperty on overridden method is not automatically inherited by overriding method
3435
@Override
3536
public String name() {
@@ -85,12 +86,14 @@ public void testSerializeReadOnlyNamedProperty() throws Exception {
8586
}
8687

8788
/**
88-
* Currently documents a bug where a property was NOT ignored during deserialization if given an explicit name.
89+
* Currently documents a bug where a property was NOT ignored during deserialization
90+
* if given an explicit name.
8991
* Also reproducible in 2.14.x.
9092
*/
9193
@Test
9294
public void testDeserializeReadOnlyNamedProperty() throws Exception {
93-
RecordWithReadOnlyNamedProperty value = MAPPER.readValue(a2q("{'id':123,'name':'Bob'}"), RecordWithReadOnlyNamedProperty.class);
95+
RecordWithReadOnlyNamedProperty value = MAPPER.readValue(a2q("{'id':123,'name':'Bob'}"),
96+
RecordWithReadOnlyNamedProperty.class);
9497
assertEquals(new RecordWithReadOnlyNamedProperty(123, "Bob"), value); // BUG: should be `null` instead of "Bob"
9598
}
9699

@@ -117,7 +120,8 @@ public void testDeserializeReadOnlyAccessor() throws Exception {
117120

118121
/*
119122
/**********************************************************************
120-
/* Test methods, JsonProperty.access=READ_ONLY component, but accessor method was overridden without re-annotating with JsonProperty.access=READ_ONLY
123+
/* Test methods, JsonProperty.access=READ_ONLY component, but accessor
124+
* method was overridden without re-annotating with JsonProperty.access=READ_ONLY
121125
/**********************************************************************
122126
*/
123127

@@ -150,7 +154,8 @@ public void testSerializeReadOnlyPrimitiveTypeProperty() throws Exception {
150154

151155
@Test
152156
public void testDeserializeReadOnlyPrimitiveTypeProperty() throws Exception {
153-
RecordWithReadOnlyPrimitiveType value = MAPPER.readValue(a2q("{'id':123,'name':'Bob'}"), RecordWithReadOnlyPrimitiveType.class);
157+
RecordWithReadOnlyPrimitiveType value = MAPPER.readValue(a2q("{'id':123,'name':'Bob'}"),
158+
RecordWithReadOnlyPrimitiveType.class);
154159
assertEquals(new RecordWithReadOnlyPrimitiveType(0, "Bob"), value);
155160
}
156161

@@ -168,7 +173,8 @@ public void testSerializeReadOnlyAllProperties() throws Exception {
168173

169174
@Test
170175
public void testDeserializeReadOnlyAllProperties() throws Exception {
171-
RecordWithReadOnlyAll value = MAPPER.readValue(a2q("{'id':123,'name':'Bob'}"), RecordWithReadOnlyAll.class);
176+
RecordWithReadOnlyAll value = MAPPER.readValue(a2q("{'id':123,'name':'Bob'}"),
177+
RecordWithReadOnlyAll.class);
172178
assertEquals(new RecordWithReadOnlyAll(0, null), value);
173179
}
174180

@@ -180,7 +186,8 @@ public void testSerializeReadOnlyAllProperties_WithNoArgConstructor() throws Exc
180186

181187
@Test
182188
public void testDeserializeReadOnlyAllProperties_WithNoArgConstructor() throws Exception {
183-
RecordWithReadOnlyAllAndNoArgConstructor value = MAPPER.readValue(a2q("{'id':123,'name':'Bob'}"), RecordWithReadOnlyAllAndNoArgConstructor.class);
189+
RecordWithReadOnlyAllAndNoArgConstructor value = MAPPER.readValue(a2q("{'id':123,'name':'Bob'}"),
190+
RecordWithReadOnlyAllAndNoArgConstructor.class);
184191
assertEquals(new RecordWithReadOnlyAllAndNoArgConstructor(0, null), value);
185192
}
186193
}

0 commit comments

Comments
 (0)