Skip to content

Commit 9132a13

Browse files
authored
Remove deprecated constructor usage for JsonCloudEventData (#483)
Fixes #482 Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
1 parent a491c85 commit 9132a13

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

formats/json-jackson/src/main/java/io/cloudevents/jackson/CloudEventDeserializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public <T extends CloudEventWriter<V>, V> V read(CloudEventWriterFactory<T, V> w
118118
if (JsonFormat.dataIsJsonContentType(contentType)) {
119119
// This solution is quite bad, but i see no alternatives now.
120120
// Hopefully in future we can improve it
121-
data = new JsonCloudEventData(node.remove("data"));
121+
data = JsonCloudEventData.wrap(node.remove("data"));
122122
} else {
123123
JsonNode dataNode = node.remove("data");
124124
assertNodeType(dataNode, JsonNodeType.STRING, "data", "Because content type is not a json, only a string is accepted as data");
@@ -136,7 +136,7 @@ public <T extends CloudEventWriter<V>, V> V read(CloudEventWriterFactory<T, V> w
136136
if (JsonFormat.dataIsJsonContentType(contentType)) {
137137
// This solution is quite bad, but i see no alternatives now.
138138
// Hopefully in future we can improve it
139-
data = new JsonCloudEventData(node.remove("data"));
139+
data = JsonCloudEventData.wrap(node.remove("data"));
140140
} else {
141141
JsonNode dataNode = node.remove("data");
142142
assertNodeType(dataNode, JsonNodeType.STRING, "data", "Because content type is not a json, only a string is accepted as data");

formats/json-jackson/src/test/java/io/cloudevents/jackson/JsonCloudEventDataTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class JsonCloudEventDataTest {
3737
@MethodSource("textContentArguments")
3838
public void testMapper(String contentType) {
3939
CloudEvent event = CloudEventBuilder.v1(Data.V1_MIN)
40-
.withData(contentType, new JsonCloudEventData(JsonNodeFactory.instance.numberNode(10)))
40+
.withData(contentType, JsonCloudEventData.wrap(JsonNodeFactory.instance.numberNode(10)))
4141
.build();
4242

4343
byte[] serialized = EventFormatProvider.getInstance().resolveFormat(JsonFormat.CONTENT_TYPE)

formats/json-jackson/src/test/java/io/cloudevents/jackson/JsonFormatTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ private static CloudEvent normalizeToJsonValueIfNeeded(CloudEvent event) {
330330
builder = CloudEventBuilder.v03(event);
331331
}
332332
return builder
333-
.withData(new JsonCloudEventData(JsonNodeFactory.instance.objectNode()))
333+
.withData(JsonCloudEventData.wrap(JsonNodeFactory.instance.objectNode()))
334334
.build();
335335
} else {
336336
return event;

formats/json-jackson/src/test/java/io/cloudevents/jackson/PojoCloudEventDataMapperTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void testWithBytes(PojoCloudEventDataMapper<MyPojo> mapper) {
4646
public void testWithJson(PojoCloudEventDataMapper<MyPojo> mapper) {
4747

4848
CloudEvent event = CloudEventBuilder.v1(Data.V1_MIN)
49-
.withData("application/json", new JsonCloudEventData(myPojoJson))
49+
.withData("application/json", JsonCloudEventData.wrap(myPojoJson))
5050
.build();
5151

5252
PojoCloudEventData<MyPojo> mappedData = CloudEventUtils.mapData(

0 commit comments

Comments
 (0)