Skip to content

Commit c33ae98

Browse files
committed
test cleanup
1 parent ed351da commit c33ae98

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

src/main/java/com/fasterxml/jackson/databind/DeserializationConfig.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -863,14 +863,6 @@ public BeanDescription introspectForCreation(JavaType type) {
863863
return getClassIntrospector().forCreation(this, type, this);
864864
}
865865

866-
/**
867-
* @since 2.0
868-
* @deprecated Since 2.12 - use variant that takes both builder and value type
869-
*/
870-
public BeanDescription introspectForBuilder(JavaType type) {
871-
return getClassIntrospector().forDeserializationWithBuilder(this, type, this);
872-
}
873-
874866
/**
875867
* @since 2.12
876868
*/
@@ -879,6 +871,15 @@ public BeanDescription introspectForBuilder(JavaType builderType, BeanDescriptio
879871
builderType, this, valueTypeDesc);
880872
}
881873

874+
/**
875+
* @since 2.0
876+
* @deprecated Since 2.12 - use variant that takes both builder and value type
877+
*/
878+
@Deprecated
879+
public BeanDescription introspectForBuilder(JavaType type) {
880+
return getClassIntrospector().forDeserializationWithBuilder(this, type, this);
881+
}
882+
882883
/*
883884
/**********************************************************
884885
/* Support for polymorphic type handling

src/test-jdk14/java/com/fasterxml/jackson/databind/RecordTest.java

+22-12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import com.fasterxml.jackson.databind.util.ClassUtil;
88

99
import java.io.IOException;
10+
import java.util.Collections;
11+
import java.util.LinkedHashMap;
12+
import java.util.Map;
1013

1114
public class RecordTest extends BaseMapTest
1215
{
@@ -66,22 +69,21 @@ public void testSerializeSimpleRecord() throws JsonProcessingException {
6669
SimpleRecord record = new SimpleRecord(123, "Bob");
6770

6871
String json = MAPPER.writeValueAsString(record);
69-
70-
assertEquals("{\"id\":123,\"name\":\"Bob\"}", json);
72+
final Object EXP = map("id", Integer.valueOf(123), "name", "Bob");
73+
assertEquals(EXP, MAPPER.readValue(json, Object.class));
7174
}
7275

7376
public void testDeserializeSimpleRecord() throws IOException {
7477
SimpleRecord value = MAPPER.readValue("{\"id\":123,\"name\":\"Bob\"}", SimpleRecord.class);
75-
7678
assertEquals(new SimpleRecord(123, "Bob"), value);
7779
}
7880

7981
public void testSerializeRecordOfRecord() throws JsonProcessingException {
8082
RecordOfRecord record = new RecordOfRecord(new SimpleRecord(123, "Bob"));
81-
8283
String json = MAPPER.writeValueAsString(record);
83-
84-
assertEquals("{\"record\":{\"id\":123,\"name\":\"Bob\"}}", json);
84+
final Object EXP = Collections.singletonMap("record",
85+
map("id", Integer.valueOf(123), "name", "Bob"));
86+
assertEquals(EXP, MAPPER.readValue(json, Object.class));
8587
}
8688

8789
/*
@@ -125,22 +127,30 @@ public void testSerializeJsonIgnoreRecord() throws JsonProcessingException {
125127
}
126128

127129
public void testDeserializeRecordWithConstructor() throws IOException {
128-
RecordWithConstructor value = MAPPER.readValue("{\"id\":123,\"name\":\"Bob\"}", RecordWithConstructor.class);
129-
130+
RecordWithConstructor value = MAPPER.readValue("{\"id\":123,\"name\":\"Bob\"}",
131+
RecordWithConstructor.class);
130132
assertEquals(new RecordWithConstructor(123, "Bob"), value);
131133
}
132134

133135
public void testSerializeJsonRenameRecord() throws JsonProcessingException {
134136
JsonPropertyRenameRecord record = new JsonPropertyRenameRecord(123, "Bob");
135137

136138
String json = MAPPER.writeValueAsString(record);
137-
138-
assertEquals("{\"id\":123,\"rename\":\"Bob\"}", json);
139+
final Object EXP = map("id", Integer.valueOf(123), "rename", "Bob");
140+
assertEquals(EXP, MAPPER.readValue(json, Object.class));
139141
}
140142

141143
public void testDeserializeJsonRenameRecord() throws IOException {
142-
JsonPropertyRenameRecord value = MAPPER.readValue("{\"id\":123,\"rename\":\"Bob\"}", JsonPropertyRenameRecord.class);
143-
144+
JsonPropertyRenameRecord value = MAPPER.readValue("{\"id\":123,\"rename\":\"Bob\"}",
145+
JsonPropertyRenameRecord.class);
144146
assertEquals(new JsonPropertyRenameRecord(123, "Bob"), value);
145147
}
148+
149+
private Map<String,Object> map(String key1, Object value1,
150+
String key2, Object value2) {
151+
final Map<String, Object> result = new LinkedHashMap<>();
152+
result.put(key1, value1);
153+
result.put(key2, value2);
154+
return result;
155+
}
146156
}

0 commit comments

Comments
 (0)