mirror of https://github.com/dapr/java-sdk.git
Add additional CloudEvent fields (pubsubname, topic, time, etc) (#866)
* Added additional CloudEvent fields (pubsubname, topic, time, traceid, traceparent, & tracestate) Added the com.fasterxml.jackson:jackson-datatype-jsr310 dependency to handle serdes of OffsetDateTime for the CloudEvent time field via ObjectMapper settings .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) & .findAndRegisterModules() Updated com.fasterxml.jackson dependencies to the latest 2.15.1 Added OffsetDateTime as timeValue to test the DefaultObjectSerializer Added more tests for new & old CloudEvent fields in CloudEventTest & DefaultObjectSerializerTest Signed-off-by: Luke Sieben <siebenluke@gmail.com> * Refactored new field names to be camelCase Removed the 2 new constructors Signed-off-by: Luke Sieben <siebenluke@gmail.com> * Added @JsonProperty("{lowercasename}")s to properly serdes camelCaseNames as JSON/OBJECT_MAPPER are case-sensitive Signed-off-by: Luke Sieben <siebenluke@gmail.com> * Removed com.fasterxml.jackson.datatype:jackson-datatype-jsr310 dependency in favor of custom field level serdes for time Signed-off-by: Luke Sieben <siebenluke@gmail.com> * Fixed "Line is longer than 120 characters" build issue by pushing the end of the offending lines to a new line Signed-off-by: Luke Sieben <siebenluke@gmail.com> * Added more CloudEvent test cases to appease Codecov Signed-off-by: Luke Sieben <siebenluke@gmail.com> * Added null binaryData test case for Codecov Signed-off-by: Luke Sieben <siebenluke@gmail.com> * Added cloudEventDifferent test cases for Codecov Signed-off-by: Luke Sieben <siebenluke@gmail.com> * Removed extraneous ; Signed-off-by: Luke Sieben <siebenluke@gmail.com> * Added comments for time test cases Signed-off-by: Luke Sieben <siebenluke@gmail.com> --------- Signed-off-by: Luke Sieben <siebenluke@gmail.com> Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com> Co-authored-by: Cassie Coyle <cassie@diagrid.io>
This commit is contained in:
parent
3dc2a90711
commit
fdb4200a2c
|
@ -39,7 +39,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.13.4.1</version>
|
<version>2.15.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.projectreactor</groupId>
|
<groupId>io.projectreactor</groupId>
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
<artifactId>jackson-dataformat-xml</artifactId>
|
<artifactId>jackson-dataformat-xml</artifactId>
|
||||||
<version>2.11.3</version>
|
<version>2.15.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -15,10 +15,20 @@ package io.dapr.client.domain;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
|
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -76,6 +86,43 @@ public class CloudEvent<T> {
|
||||||
@JsonProperty("data_base64")
|
@JsonProperty("data_base64")
|
||||||
private byte[] binaryData;
|
private byte[] binaryData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The pubsub component this CloudEvent came from.
|
||||||
|
*/
|
||||||
|
@JsonProperty("pubsubname")
|
||||||
|
private String pubsubName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The topic this CloudEvent came from.
|
||||||
|
*/
|
||||||
|
private String topic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time this CloudEvent was created.
|
||||||
|
*/
|
||||||
|
@JsonSerialize(using = OffsetDateTimeSerializer.class)
|
||||||
|
@JsonDeserialize(using = OffsetDateTimeDeserializer.class)
|
||||||
|
private OffsetDateTime time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The trace id is the legacy name for trace parent.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@JsonProperty("traceid")
|
||||||
|
private String traceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The trace parent.
|
||||||
|
*/
|
||||||
|
@JsonProperty("traceparent")
|
||||||
|
private String traceParent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The trace state.
|
||||||
|
*/
|
||||||
|
@JsonProperty("tracestate")
|
||||||
|
private String traceState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a CloudEvent.
|
* Instantiates a CloudEvent.
|
||||||
*/
|
*/
|
||||||
|
@ -125,7 +172,7 @@ public class CloudEvent<T> {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.specversion = specversion;
|
this.specversion = specversion;
|
||||||
this.datacontenttype = "application/octet-stream";
|
this.datacontenttype = "application/octet-stream";
|
||||||
this.binaryData = binaryData == null ? null : Arrays.copyOf(binaryData, binaryData.length);;
|
this.binaryData = binaryData == null ? null : Arrays.copyOf(binaryData, binaryData.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -255,6 +302,104 @@ public class CloudEvent<T> {
|
||||||
this.binaryData = binaryData == null ? null : Arrays.copyOf(binaryData, binaryData.length);
|
this.binaryData = binaryData == null ? null : Arrays.copyOf(binaryData, binaryData.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the pubsub component name.
|
||||||
|
* @return the pubsub component name.
|
||||||
|
*/
|
||||||
|
public String getPubsubName() {
|
||||||
|
return pubsubName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the pubsub component name.
|
||||||
|
* @param pubsubName the pubsub component name.
|
||||||
|
*/
|
||||||
|
public void setPubsubName(String pubsubName) {
|
||||||
|
this.pubsubName = pubsubName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the topic name.
|
||||||
|
* @return the topic name.
|
||||||
|
*/
|
||||||
|
public String getTopic() {
|
||||||
|
return topic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the topic name.
|
||||||
|
* @param topic the topic name.
|
||||||
|
*/
|
||||||
|
public void setTopic(String topic) {
|
||||||
|
this.topic = topic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the time.
|
||||||
|
* @return the time.
|
||||||
|
*/
|
||||||
|
public OffsetDateTime getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the time.
|
||||||
|
* @param time the time.
|
||||||
|
*/
|
||||||
|
public void setTime(OffsetDateTime time) {
|
||||||
|
this.time = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the trace id which is the legacy name for trace parent.
|
||||||
|
* @return the trace id.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public String getTraceId() {
|
||||||
|
return traceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the trace id which is the legacy name for trace parent.
|
||||||
|
* @param traceId the trace id.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public void setTraceId(String traceId) {
|
||||||
|
this.traceId = traceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the trace parent.
|
||||||
|
* @return the trace parent.
|
||||||
|
*/
|
||||||
|
public String getTraceParent() {
|
||||||
|
return traceParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the trace parent.
|
||||||
|
* @param traceParent the trace parent.
|
||||||
|
*/
|
||||||
|
public void setTraceParent(String traceParent) {
|
||||||
|
this.traceParent = traceParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the trace state.
|
||||||
|
* @return the trace state.
|
||||||
|
*/
|
||||||
|
public String getTraceState() {
|
||||||
|
return traceState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the trace state.
|
||||||
|
* @param traceState the trace state.
|
||||||
|
*/
|
||||||
|
public void setTraceState(String traceState) {
|
||||||
|
this.traceState = traceState;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -273,7 +418,13 @@ public class CloudEvent<T> {
|
||||||
&& Objects.equals(specversion, that.specversion)
|
&& Objects.equals(specversion, that.specversion)
|
||||||
&& Objects.equals(datacontenttype, that.datacontenttype)
|
&& Objects.equals(datacontenttype, that.datacontenttype)
|
||||||
&& Objects.equals(data, that.data)
|
&& Objects.equals(data, that.data)
|
||||||
&& Arrays.equals(binaryData, that.binaryData);
|
&& Arrays.equals(binaryData, that.binaryData)
|
||||||
|
&& Objects.equals(pubsubName, that.pubsubName)
|
||||||
|
&& Objects.equals(topic, that.topic)
|
||||||
|
&& ((time == null && that.time == null) || (time != null && that.time != null && time.isEqual(that.time)))
|
||||||
|
&& Objects.equals(traceId, that.traceId)
|
||||||
|
&& Objects.equals(traceParent, that.traceParent)
|
||||||
|
&& Objects.equals(traceState, that.traceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -281,6 +432,23 @@ public class CloudEvent<T> {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(id, source, type, specversion, datacontenttype, data, binaryData);
|
return Objects.hash(id, source, type, specversion, datacontenttype, data, binaryData, pubsubName, topic, time,
|
||||||
|
traceId, traceParent, traceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class OffsetDateTimeSerializer extends JsonSerializer<OffsetDateTime> {
|
||||||
|
@Override
|
||||||
|
public void serialize(OffsetDateTime offsetDateTime, JsonGenerator jsonGenerator,
|
||||||
|
SerializerProvider serializerProvider) throws IOException {
|
||||||
|
jsonGenerator.writeString(offsetDateTime.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class OffsetDateTimeDeserializer extends JsonDeserializer<OffsetDateTime> {
|
||||||
|
@Override
|
||||||
|
public OffsetDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
|
||||||
|
throws IOException {
|
||||||
|
return OffsetDateTime.parse(jsonParser.getText());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,18 @@ limitations under the License.
|
||||||
|
|
||||||
package io.dapr.client;
|
package io.dapr.client;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.dapr.client.domain.CloudEvent;
|
import io.dapr.client.domain.CloudEvent;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
public class CloudEventTest {
|
public class CloudEventTest {
|
||||||
|
@ -28,6 +34,24 @@ public class CloudEventTest {
|
||||||
public static class MyClass {
|
public static class MyClass {
|
||||||
public int id;
|
public int id;
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
MyClass myClass = (MyClass) o;
|
||||||
|
|
||||||
|
if (id != myClass.id) return false;
|
||||||
|
return Objects.equals(name, myClass.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = id;
|
||||||
|
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -42,7 +66,12 @@ public class CloudEventTest {
|
||||||
" \"comexampleextension1\" : \"value\",\n" +
|
" \"comexampleextension1\" : \"value\",\n" +
|
||||||
" \"comexampleothervalue\" : 5,\n" +
|
" \"comexampleothervalue\" : 5,\n" +
|
||||||
" \"datacontenttype\" : \"application/json\",\n" +
|
" \"datacontenttype\" : \"application/json\",\n" +
|
||||||
" \"data\" : {\"id\": 1, \"name\": \"hello world\"}\n" +
|
" \"data\" : {\"id\": 1, \"name\": \"hello world\"},\n" +
|
||||||
|
" \"pubsubname\" : \"mypubsubname\",\n" +
|
||||||
|
" \"topic\" : \"mytopic\",\n" +
|
||||||
|
" \"traceid\" : \"Z987-0987-0987\",\n" +
|
||||||
|
" \"traceparent\" : \"Z987-0987-0987\",\n" +
|
||||||
|
" \"tracestate\" : \"\"\n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
MyClass expected = new MyClass() {{
|
MyClass expected = new MyClass() {{
|
||||||
|
@ -51,7 +80,17 @@ public class CloudEventTest {
|
||||||
}};
|
}};
|
||||||
|
|
||||||
CloudEvent cloudEvent = CloudEvent.deserialize(content.getBytes());
|
CloudEvent cloudEvent = CloudEvent.deserialize(content.getBytes());
|
||||||
|
assertEquals("1.0", cloudEvent.getSpecversion());
|
||||||
|
assertEquals("com.github.pull_request.opened", cloudEvent.getType());
|
||||||
|
assertEquals("https://github.com/cloudevents/spec/pull", cloudEvent.getSource());
|
||||||
|
assertEquals("A234-1234-1234", cloudEvent.getId());
|
||||||
|
assertEquals(OffsetDateTime.parse("2018-04-05T17:31:00Z"), cloudEvent.getTime());
|
||||||
assertEquals("application/json", cloudEvent.getDatacontenttype());
|
assertEquals("application/json", cloudEvent.getDatacontenttype());
|
||||||
|
assertEquals("mypubsubname", cloudEvent.getPubsubName());
|
||||||
|
assertEquals("mytopic", cloudEvent.getTopic());
|
||||||
|
assertEquals("Z987-0987-0987", cloudEvent.getTraceId());
|
||||||
|
assertEquals("Z987-0987-0987", cloudEvent.getTraceParent());
|
||||||
|
assertEquals("", cloudEvent.getTraceState());
|
||||||
MyClass myObject = OBJECT_MAPPER.convertValue(cloudEvent.getData(), MyClass.class);
|
MyClass myObject = OBJECT_MAPPER.convertValue(cloudEvent.getData(), MyClass.class);
|
||||||
assertEquals(expected.id, myObject.id);
|
assertEquals(expected.id, myObject.id);
|
||||||
assertEquals(expected.name, myObject.name);
|
assertEquals(expected.name, myObject.name);
|
||||||
|
@ -179,4 +218,103 @@ public class CloudEventTest {
|
||||||
assertNull(cloudEvent.getData());
|
assertNull(cloudEvent.getData());
|
||||||
assertArrayEquals(expected, cloudEvent.getBinaryData());
|
assertArrayEquals(expected, cloudEvent.getBinaryData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void serializeObjectClass() throws Exception {
|
||||||
|
CloudEvent<MyClass> cloudEvent = new CloudEvent<>();
|
||||||
|
MyClass myClass = new MyClass();
|
||||||
|
myClass.id = 1;
|
||||||
|
myClass.name = "Hello World";
|
||||||
|
cloudEvent.setData(myClass);
|
||||||
|
OffsetDateTime now = OffsetDateTime.now();
|
||||||
|
cloudEvent.setTime(now);
|
||||||
|
|
||||||
|
String cloudEventAsString = OBJECT_MAPPER.writeValueAsString(cloudEvent);
|
||||||
|
CloudEvent<MyClass> cloudEventDeserialized = OBJECT_MAPPER.readValue(cloudEventAsString,
|
||||||
|
new TypeReference<CloudEvent<MyClass>>() {});
|
||||||
|
assertEquals(cloudEvent, cloudEventDeserialized);
|
||||||
|
assertEquals(now, cloudEventDeserialized.getTime());
|
||||||
|
MyClass myClassDeserialized = cloudEventDeserialized.getData();
|
||||||
|
assertEquals(myClass.id, myClassDeserialized.id);
|
||||||
|
assertEquals(myClass.name, myClassDeserialized.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void equalsCodecovTest() {
|
||||||
|
CloudEvent<?> cloudEvent = new CloudEvent<>();
|
||||||
|
assertFalse(cloudEvent.equals(null));
|
||||||
|
assertFalse(cloudEvent.equals(""));
|
||||||
|
|
||||||
|
CloudEvent<?> cloudEventCopy = cloudEvent;
|
||||||
|
assertEquals(cloudEvent, cloudEventCopy);
|
||||||
|
|
||||||
|
CloudEvent<String> cloudEventDifferent = new CloudEvent<>();
|
||||||
|
cloudEventDifferent.setId("id");
|
||||||
|
assertNotEquals(cloudEventCopy, cloudEventDifferent);
|
||||||
|
|
||||||
|
cloudEventDifferent = new CloudEvent<>();
|
||||||
|
cloudEventDifferent.setSource("source");
|
||||||
|
assertNotEquals(cloudEventCopy, cloudEventDifferent);
|
||||||
|
|
||||||
|
cloudEventDifferent = new CloudEvent<>();
|
||||||
|
cloudEventDifferent.setType("type");
|
||||||
|
assertNotEquals(cloudEventCopy, cloudEventDifferent);
|
||||||
|
|
||||||
|
cloudEventDifferent = new CloudEvent<>();
|
||||||
|
cloudEventDifferent.setSpecversion("specversion");
|
||||||
|
assertNotEquals(cloudEventCopy, cloudEventDifferent);
|
||||||
|
|
||||||
|
cloudEventDifferent = new CloudEvent<>();
|
||||||
|
cloudEventDifferent.setDatacontenttype("datacontenttype");
|
||||||
|
assertNotEquals(cloudEventCopy, cloudEventDifferent);
|
||||||
|
|
||||||
|
cloudEventDifferent = new CloudEvent<>();
|
||||||
|
cloudEventDifferent.setData("data");
|
||||||
|
assertNotEquals(cloudEventCopy, cloudEventDifferent);
|
||||||
|
|
||||||
|
cloudEventDifferent = new CloudEvent<>();
|
||||||
|
cloudEventDifferent.setBinaryData("binaryData".getBytes());
|
||||||
|
assertNotEquals(cloudEventCopy, cloudEventDifferent);
|
||||||
|
|
||||||
|
cloudEventDifferent = new CloudEvent<>();
|
||||||
|
cloudEventDifferent.setPubsubName("pubsubName");
|
||||||
|
assertNotEquals(cloudEventCopy, cloudEventDifferent);
|
||||||
|
|
||||||
|
cloudEventDifferent = new CloudEvent<>();
|
||||||
|
cloudEventDifferent.setTopic("topic");
|
||||||
|
assertNotEquals(cloudEventCopy, cloudEventDifferent);
|
||||||
|
|
||||||
|
OffsetDateTime now = OffsetDateTime.now();
|
||||||
|
cloudEventDifferent = new CloudEvent<>();
|
||||||
|
// cloudEvent null time, cloudEventDifferent now time
|
||||||
|
cloudEventDifferent.setTime(now);
|
||||||
|
assertNotEquals(cloudEventCopy, cloudEventDifferent);
|
||||||
|
// cloudEvent now time, cloudEventDifferent now time
|
||||||
|
cloudEvent.setTime(now);
|
||||||
|
assertEquals(cloudEventCopy, cloudEventDifferent);
|
||||||
|
// cloudEvent now time, cloudEventDifferent now time + 1 nano
|
||||||
|
cloudEventDifferent.setTime(now.plusNanos(1L));
|
||||||
|
assertNotEquals(cloudEventCopy, cloudEventDifferent);
|
||||||
|
// reset cloudEvent time
|
||||||
|
cloudEvent.setTime(null);
|
||||||
|
|
||||||
|
cloudEventDifferent = new CloudEvent<>();
|
||||||
|
cloudEventDifferent.setTraceId("traceId");
|
||||||
|
assertNotEquals(cloudEventCopy, cloudEventDifferent);
|
||||||
|
|
||||||
|
cloudEventDifferent = new CloudEvent<>();
|
||||||
|
cloudEventDifferent.setTraceParent("traceParent");
|
||||||
|
assertNotEquals(cloudEventCopy, cloudEventDifferent);
|
||||||
|
|
||||||
|
cloudEventDifferent = new CloudEvent<>();
|
||||||
|
cloudEventDifferent.setTraceState("traceState");
|
||||||
|
assertNotEquals(cloudEventCopy, cloudEventDifferent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void hashCodeCodecovTest() {
|
||||||
|
CloudEvent<?> cloudEvent = new CloudEvent<>();
|
||||||
|
final int EXPECTED_EMPTY_HASH_CODE = -505558625;
|
||||||
|
assertEquals(EXPECTED_EMPTY_HASH_CODE, cloudEvent.hashCode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,16 @@ limitations under the License.
|
||||||
|
|
||||||
package io.dapr.serializer;
|
package io.dapr.serializer;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.core.JsonParseException;
|
import com.fasterxml.jackson.core.JsonParseException;
|
||||||
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
|
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import com.google.protobuf.CodedOutputStream;
|
import com.google.protobuf.CodedOutputStream;
|
||||||
import com.google.protobuf.MessageLite;
|
import com.google.protobuf.MessageLite;
|
||||||
|
@ -28,6 +36,8 @@ import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -57,6 +67,10 @@ public class DefaultObjectSerializerTest {
|
||||||
private float floatValue;
|
private float floatValue;
|
||||||
private double doubleValue;
|
private double doubleValue;
|
||||||
|
|
||||||
|
@JsonSerialize(using = OffsetDateTimeSerializer.class)
|
||||||
|
@JsonDeserialize(using = OffsetDateTimeDeserializer.class)
|
||||||
|
private OffsetDateTime timeValue;
|
||||||
|
|
||||||
public String getStringValue() {
|
public String getStringValue() {
|
||||||
return stringValue;
|
return stringValue;
|
||||||
}
|
}
|
||||||
|
@ -129,6 +143,14 @@ public class DefaultObjectSerializerTest {
|
||||||
this.doubleValue = doubleValue;
|
this.doubleValue = doubleValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OffsetDateTime getTimeValue() {
|
||||||
|
return timeValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeValue(OffsetDateTime timeValue) {
|
||||||
|
this.timeValue = timeValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) {
|
if (this == o) {
|
||||||
|
@ -167,6 +189,9 @@ public class DefaultObjectSerializerTest {
|
||||||
if (getStringValue() != null ? !getStringValue().equals(that.getStringValue()) : that.getStringValue() != null) {
|
if (getStringValue() != null ? !getStringValue().equals(that.getStringValue()) : that.getStringValue() != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (getTimeValue() != null ? !getTimeValue().isEqual(that.getTimeValue()) : that.getTimeValue() != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -185,6 +210,7 @@ public class DefaultObjectSerializerTest {
|
||||||
result = 31 * result + (getFloatValue() != +0.0f ? Float.floatToIntBits(getFloatValue()) : 0);
|
result = 31 * result + (getFloatValue() != +0.0f ? Float.floatToIntBits(getFloatValue()) : 0);
|
||||||
temp = Double.doubleToLongBits(getDoubleValue());
|
temp = Double.doubleToLongBits(getDoubleValue());
|
||||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||||
|
result = 31 * result + getTimeValue().toInstant().hashCode();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,8 +226,23 @@ public class DefaultObjectSerializerTest {
|
||||||
", longValue=" + longValue +
|
", longValue=" + longValue +
|
||||||
", floatValue=" + floatValue +
|
", floatValue=" + floatValue +
|
||||||
", doubleValue=" + doubleValue +
|
", doubleValue=" + doubleValue +
|
||||||
|
", timeValue=" + timeValue +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class OffsetDateTimeSerializer extends JsonSerializer<OffsetDateTime> {
|
||||||
|
@Override
|
||||||
|
public void serialize(OffsetDateTime offsetDateTime, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
|
||||||
|
jsonGenerator.writeString(offsetDateTime.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class OffsetDateTimeDeserializer extends JsonDeserializer<OffsetDateTime> {
|
||||||
|
@Override
|
||||||
|
public OffsetDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
|
||||||
|
return OffsetDateTime.parse(jsonParser.getText());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -216,7 +257,8 @@ public class DefaultObjectSerializerTest {
|
||||||
obj.setLongValue(9223372036854775807L);
|
obj.setLongValue(9223372036854775807L);
|
||||||
obj.setFloatValue(1.0f);
|
obj.setFloatValue(1.0f);
|
||||||
obj.setDoubleValue(1000.0);
|
obj.setDoubleValue(1000.0);
|
||||||
String expectedResult = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0}";
|
obj.setTimeValue(OffsetDateTime.MIN);
|
||||||
|
String expectedResult = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0,\"timeValue\":\"-999999999-01-01T00:00:00+18:00\"}";
|
||||||
|
|
||||||
|
|
||||||
String serializedValue;
|
String serializedValue;
|
||||||
|
@ -437,7 +479,7 @@ public class DefaultObjectSerializerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deserializeObjectTest() {
|
public void deserializeObjectTest() {
|
||||||
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0}";
|
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0,\"timeValue\":\"+999999999-12-31T23:59:59.999999999-18:00\"}";
|
||||||
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
||||||
expectedResult.setStringValue("A String");
|
expectedResult.setStringValue("A String");
|
||||||
expectedResult.setIntValue(2147483647);
|
expectedResult.setIntValue(2147483647);
|
||||||
|
@ -448,6 +490,7 @@ public class DefaultObjectSerializerTest {
|
||||||
expectedResult.setLongValue(9223372036854775807L);
|
expectedResult.setLongValue(9223372036854775807L);
|
||||||
expectedResult.setFloatValue(1.0f);
|
expectedResult.setFloatValue(1.0f);
|
||||||
expectedResult.setDoubleValue(1000.0);
|
expectedResult.setDoubleValue(1000.0);
|
||||||
|
expectedResult.setTimeValue(OffsetDateTime.MAX);
|
||||||
MyObjectTestToSerialize result;
|
MyObjectTestToSerialize result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -460,7 +503,7 @@ public class DefaultObjectSerializerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deserializeArrayObjectTest() {
|
public void deserializeArrayObjectTest() {
|
||||||
String jsonToDeserialize = "[{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0}]";
|
String jsonToDeserialize = "[{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0,\"timeValue\":\"+999999999-12-31T23:59:59.999999999-18:00\"}]";
|
||||||
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
||||||
expectedResult.setStringValue("A String");
|
expectedResult.setStringValue("A String");
|
||||||
expectedResult.setIntValue(2147483647);
|
expectedResult.setIntValue(2147483647);
|
||||||
|
@ -471,6 +514,7 @@ public class DefaultObjectSerializerTest {
|
||||||
expectedResult.setLongValue(9223372036854775807L);
|
expectedResult.setLongValue(9223372036854775807L);
|
||||||
expectedResult.setFloatValue(1.0f);
|
expectedResult.setFloatValue(1.0f);
|
||||||
expectedResult.setDoubleValue(1000.0);
|
expectedResult.setDoubleValue(1000.0);
|
||||||
|
expectedResult.setTimeValue(OffsetDateTime.MAX);
|
||||||
List<MyObjectTestToSerialize> result;
|
List<MyObjectTestToSerialize> result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -536,7 +580,7 @@ public class DefaultObjectSerializerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deserializeObjectMissingStringPropertyTest() {
|
public void deserializeObjectMissingStringPropertyTest() {
|
||||||
String jsonToDeserialize = "{\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0}";
|
String jsonToDeserialize = "{\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0,\"timeValue\":\"+999999999-12-31T23:59:59.999999999-18:00\"}";
|
||||||
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
||||||
expectedResult.setIntValue(2147483647);
|
expectedResult.setIntValue(2147483647);
|
||||||
expectedResult.setBoolValue(true);
|
expectedResult.setBoolValue(true);
|
||||||
|
@ -546,11 +590,12 @@ public class DefaultObjectSerializerTest {
|
||||||
expectedResult.setLongValue(9223372036854775807L);
|
expectedResult.setLongValue(9223372036854775807L);
|
||||||
expectedResult.setFloatValue(1.0f);
|
expectedResult.setFloatValue(1.0f);
|
||||||
expectedResult.setDoubleValue(1000.0);
|
expectedResult.setDoubleValue(1000.0);
|
||||||
|
expectedResult.setTimeValue(OffsetDateTime.MAX);
|
||||||
MyObjectTestToSerialize result;
|
MyObjectTestToSerialize result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
||||||
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECING: [[" + expectedResult + "]]");
|
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECTING: [[" + expectedResult + "]]");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
fail(exception.getMessage());
|
fail(exception.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -558,7 +603,7 @@ public class DefaultObjectSerializerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deserializeObjectMissingIntTest() {
|
public void deserializeObjectMissingIntTest() {
|
||||||
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0}";
|
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0,\"timeValue\":\"+999999999-12-31T23:59:59.999999999-18:00\"}";
|
||||||
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
||||||
expectedResult.setStringValue("A String");
|
expectedResult.setStringValue("A String");
|
||||||
expectedResult.setBoolValue(true);
|
expectedResult.setBoolValue(true);
|
||||||
|
@ -568,11 +613,12 @@ public class DefaultObjectSerializerTest {
|
||||||
expectedResult.setLongValue(9223372036854775807L);
|
expectedResult.setLongValue(9223372036854775807L);
|
||||||
expectedResult.setFloatValue(1.0f);
|
expectedResult.setFloatValue(1.0f);
|
||||||
expectedResult.setDoubleValue(1000.0);
|
expectedResult.setDoubleValue(1000.0);
|
||||||
|
expectedResult.setTimeValue(OffsetDateTime.MAX);
|
||||||
MyObjectTestToSerialize result;
|
MyObjectTestToSerialize result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
||||||
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECING: [[" + expectedResult + "]]");
|
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECTING: [[" + expectedResult + "]]");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
fail(exception.getMessage());
|
fail(exception.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -580,7 +626,7 @@ public class DefaultObjectSerializerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deserializeObjectMissingBooleanTest() {
|
public void deserializeObjectMissingBooleanTest() {
|
||||||
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0}";
|
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0,\"timeValue\":\"+999999999-12-31T23:59:59.999999999-18:00\"}";
|
||||||
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
||||||
expectedResult.setStringValue("A String");
|
expectedResult.setStringValue("A String");
|
||||||
expectedResult.setIntValue(2147483647);
|
expectedResult.setIntValue(2147483647);
|
||||||
|
@ -590,11 +636,12 @@ public class DefaultObjectSerializerTest {
|
||||||
expectedResult.setLongValue(9223372036854775807L);
|
expectedResult.setLongValue(9223372036854775807L);
|
||||||
expectedResult.setFloatValue(1.0f);
|
expectedResult.setFloatValue(1.0f);
|
||||||
expectedResult.setDoubleValue(1000.0);
|
expectedResult.setDoubleValue(1000.0);
|
||||||
|
expectedResult.setTimeValue(OffsetDateTime.MAX);
|
||||||
MyObjectTestToSerialize result;
|
MyObjectTestToSerialize result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
||||||
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECING: [[" + expectedResult + "]]");
|
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECTING: [[" + expectedResult + "]]");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
fail(exception.getMessage());
|
fail(exception.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -602,7 +649,7 @@ public class DefaultObjectSerializerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deserializeObjectMissingCharTest() {
|
public void deserializeObjectMissingCharTest() {
|
||||||
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0}";
|
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0,\"timeValue\":\"+999999999-12-31T23:59:59.999999999-18:00\"}";
|
||||||
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
||||||
expectedResult.setStringValue("A String");
|
expectedResult.setStringValue("A String");
|
||||||
expectedResult.setIntValue(2147483647);
|
expectedResult.setIntValue(2147483647);
|
||||||
|
@ -612,11 +659,12 @@ public class DefaultObjectSerializerTest {
|
||||||
expectedResult.setLongValue(9223372036854775807L);
|
expectedResult.setLongValue(9223372036854775807L);
|
||||||
expectedResult.setFloatValue(1.0f);
|
expectedResult.setFloatValue(1.0f);
|
||||||
expectedResult.setDoubleValue(1000.0);
|
expectedResult.setDoubleValue(1000.0);
|
||||||
|
expectedResult.setTimeValue(OffsetDateTime.MAX);
|
||||||
MyObjectTestToSerialize result;
|
MyObjectTestToSerialize result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
||||||
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECING: [[" + expectedResult + "]]");
|
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECTING: [[" + expectedResult + "]]");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
fail(exception.getMessage());
|
fail(exception.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -624,7 +672,7 @@ public class DefaultObjectSerializerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deserializeObjectMissingByteTest() {
|
public void deserializeObjectMissingByteTest() {
|
||||||
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0}";
|
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0,\"timeValue\":\"+999999999-12-31T23:59:59.999999999-18:00\"}";
|
||||||
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
||||||
expectedResult.setStringValue("A String");
|
expectedResult.setStringValue("A String");
|
||||||
expectedResult.setIntValue(2147483647);
|
expectedResult.setIntValue(2147483647);
|
||||||
|
@ -634,11 +682,12 @@ public class DefaultObjectSerializerTest {
|
||||||
expectedResult.setLongValue(9223372036854775807L);
|
expectedResult.setLongValue(9223372036854775807L);
|
||||||
expectedResult.setFloatValue(1.0f);
|
expectedResult.setFloatValue(1.0f);
|
||||||
expectedResult.setDoubleValue(1000.0);
|
expectedResult.setDoubleValue(1000.0);
|
||||||
|
expectedResult.setTimeValue(OffsetDateTime.MAX);
|
||||||
MyObjectTestToSerialize result;
|
MyObjectTestToSerialize result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
||||||
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECING: [[" + expectedResult + "]]");
|
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECTING: [[" + expectedResult + "]]");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
fail(exception.getMessage());
|
fail(exception.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -646,7 +695,7 @@ public class DefaultObjectSerializerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deserializeObjectMissingShortTest() {
|
public void deserializeObjectMissingShortTest() {
|
||||||
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0}";
|
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0,\"timeValue\":\"+999999999-12-31T23:59:59.999999999-18:00\"}";
|
||||||
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
||||||
expectedResult.setStringValue("A String");
|
expectedResult.setStringValue("A String");
|
||||||
expectedResult.setIntValue(2147483647);
|
expectedResult.setIntValue(2147483647);
|
||||||
|
@ -656,11 +705,12 @@ public class DefaultObjectSerializerTest {
|
||||||
expectedResult.setLongValue(9223372036854775807L);
|
expectedResult.setLongValue(9223372036854775807L);
|
||||||
expectedResult.setFloatValue(1.0f);
|
expectedResult.setFloatValue(1.0f);
|
||||||
expectedResult.setDoubleValue(1000.0);
|
expectedResult.setDoubleValue(1000.0);
|
||||||
|
expectedResult.setTimeValue(OffsetDateTime.MAX);
|
||||||
MyObjectTestToSerialize result;
|
MyObjectTestToSerialize result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
||||||
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECING: [[" + expectedResult + "]]");
|
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECTING: [[" + expectedResult + "]]");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
fail(exception.getMessage());
|
fail(exception.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -668,7 +718,7 @@ public class DefaultObjectSerializerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deserializeObjectMissingLongTest() {
|
public void deserializeObjectMissingLongTest() {
|
||||||
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"floatValue\":1.0,\"doubleValue\":1000.0}";
|
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"floatValue\":1.0,\"doubleValue\":1000.0,\"timeValue\":\"+999999999-12-31T23:59:59.999999999-18:00\"}";
|
||||||
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
||||||
expectedResult.setStringValue("A String");
|
expectedResult.setStringValue("A String");
|
||||||
expectedResult.setIntValue(2147483647);
|
expectedResult.setIntValue(2147483647);
|
||||||
|
@ -678,11 +728,12 @@ public class DefaultObjectSerializerTest {
|
||||||
expectedResult.setShortValue((short) 32767);
|
expectedResult.setShortValue((short) 32767);
|
||||||
expectedResult.setFloatValue(1.0f);
|
expectedResult.setFloatValue(1.0f);
|
||||||
expectedResult.setDoubleValue(1000.0);
|
expectedResult.setDoubleValue(1000.0);
|
||||||
|
expectedResult.setTimeValue(OffsetDateTime.MAX);
|
||||||
MyObjectTestToSerialize result;
|
MyObjectTestToSerialize result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
||||||
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECING: [[" + expectedResult + "]]");
|
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECTING: [[" + expectedResult + "]]");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
fail(exception.getMessage());
|
fail(exception.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -690,7 +741,7 @@ public class DefaultObjectSerializerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deserializeObjectMissingFloatTest() {
|
public void deserializeObjectMissingFloatTest() {
|
||||||
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"doubleValue\":1000.0}";
|
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"doubleValue\":1000.0,\"timeValue\":\"+999999999-12-31T23:59:59.999999999-18:00\"}";
|
||||||
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
||||||
expectedResult.setStringValue("A String");
|
expectedResult.setStringValue("A String");
|
||||||
expectedResult.setIntValue(2147483647);
|
expectedResult.setIntValue(2147483647);
|
||||||
|
@ -700,11 +751,12 @@ public class DefaultObjectSerializerTest {
|
||||||
expectedResult.setShortValue((short) 32767);
|
expectedResult.setShortValue((short) 32767);
|
||||||
expectedResult.setLongValue(9223372036854775807L);
|
expectedResult.setLongValue(9223372036854775807L);
|
||||||
expectedResult.setDoubleValue(1000.0);
|
expectedResult.setDoubleValue(1000.0);
|
||||||
|
expectedResult.setTimeValue(OffsetDateTime.MAX);
|
||||||
MyObjectTestToSerialize result;
|
MyObjectTestToSerialize result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
||||||
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECING: [[" + expectedResult + "]]");
|
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECTING: [[" + expectedResult + "]]");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
fail(exception.getMessage());
|
fail(exception.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -712,6 +764,29 @@ public class DefaultObjectSerializerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deserializeObjectMissingDoubleTest() {
|
public void deserializeObjectMissingDoubleTest() {
|
||||||
|
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"timeValue\":\"+999999999-12-31T23:59:59.999999999-18:00\"}";
|
||||||
|
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
||||||
|
expectedResult.setStringValue("A String");
|
||||||
|
expectedResult.setIntValue(2147483647);
|
||||||
|
expectedResult.setBoolValue(true);
|
||||||
|
expectedResult.setCharValue('a');
|
||||||
|
expectedResult.setByteValue((byte) 65);
|
||||||
|
expectedResult.setShortValue((short) 32767);
|
||||||
|
expectedResult.setLongValue(9223372036854775807L);
|
||||||
|
expectedResult.setFloatValue(1.0f);
|
||||||
|
expectedResult.setTimeValue(OffsetDateTime.MAX);
|
||||||
|
MyObjectTestToSerialize result;
|
||||||
|
|
||||||
|
try {
|
||||||
|
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
||||||
|
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECTING: [[" + expectedResult + "]]");
|
||||||
|
} catch (IOException exception) {
|
||||||
|
fail(exception.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void deserializeObjectMissingTimeTest() {
|
||||||
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0}";
|
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0}";
|
||||||
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
MyObjectTestToSerialize expectedResult = new MyObjectTestToSerialize();
|
||||||
expectedResult.setStringValue("A String");
|
expectedResult.setStringValue("A String");
|
||||||
|
@ -726,35 +801,43 @@ public class DefaultObjectSerializerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
result = SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class);
|
||||||
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECING: [[" + expectedResult + "]]");
|
assertEquals(expectedResult, result, "FOUND:[[" + result + "]] \n but was EXPECTING: [[" + expectedResult + "]]");
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
fail(exception.getMessage());
|
fail(exception.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deserializeObjectIntExceedMaximunValueTest() throws Exception {
|
public void deserializeObjectIntExceedMaximumValueTest() {
|
||||||
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483648,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0}";
|
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483648,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0,\"timeValue\":\"+999999999-12-31T23:59:59.999999999-18:00\"}";
|
||||||
assertThrows(IOException.class, () -> SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void deserializeObjectNotACharTest() throws Exception {
|
|
||||||
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"Not A Char\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0}";
|
|
||||||
|
|
||||||
assertThrows(IOException.class, () -> SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class));
|
assertThrows(IOException.class, () -> SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deserializeObjectShortExceededMaximunValueTest() throws Exception {
|
public void deserializeObjectNotACharTest() {
|
||||||
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32768,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0}";
|
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"Not A Char\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0,\"timeValue\":\"+999999999-12-31T23:59:59.999999999-18:00\"}";
|
||||||
|
|
||||||
assertThrows(IOException.class, () -> SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class));
|
assertThrows(IOException.class, () -> SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deserializeObjectLongExceededMaximumValueTest() throws Exception {
|
public void deserializeObjectShortExceededMaximumValueTest() {
|
||||||
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775808,\"floatValue\":1.0,\"doubleValue\":1000.0}";
|
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32768,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0,\"timeValue\":\"+999999999-12-31T23:59:59.999999999-18:00\"}";
|
||||||
|
|
||||||
|
assertThrows(IOException.class, () -> SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void deserializeObjectLongExceededMaximumValueTest() {
|
||||||
|
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775808,\"floatValue\":1.0,\"doubleValue\":1000.0,\"timeValue\":\"+999999999-12-31T23:59:59.999999999-18:00\"}";
|
||||||
|
|
||||||
|
assertThrows(IOException.class, () -> SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void deserializeObjectTimeExceededMaximumValueTest() {
|
||||||
|
String jsonToDeserialize = "{\"stringValue\":\"A String\",\"intValue\":2147483647,\"boolValue\":true,\"charValue\":\"a\",\"byteValue\":65,\"shortValue\":32767,\"longValue\":9223372036854775807,\"floatValue\":1.0,\"doubleValue\":1000.0,\"timeValue\":\"+1000000000-12-31T23:59:59.999999999-18:00\"}";
|
||||||
|
|
||||||
assertThrows(IOException.class, () -> SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class));
|
assertThrows(IOException.class, () -> SERIALIZER.deserialize(jsonToDeserialize.getBytes(), MyObjectTestToSerialize.class));
|
||||||
}
|
}
|
||||||
|
@ -769,6 +852,7 @@ public class DefaultObjectSerializerTest {
|
||||||
assertEquals(0, SERIALIZER.deserialize(null, double.class), 0);
|
assertEquals(0, SERIALIZER.deserialize(null, double.class), 0);
|
||||||
assertEquals(0, SERIALIZER.deserialize(null, float.class), 0);
|
assertEquals(0, SERIALIZER.deserialize(null, float.class), 0);
|
||||||
assertEquals(false, SERIALIZER.deserialize(null, boolean.class));
|
assertEquals(false, SERIALIZER.deserialize(null, boolean.class));
|
||||||
|
assertEquals(null, SERIALIZER.deserialize(null, OffsetDateTime.class));
|
||||||
|
|
||||||
assertNull(SERIALIZER.deserialize(null, Character.class));
|
assertNull(SERIALIZER.deserialize(null, Character.class));
|
||||||
assertNull(SERIALIZER.deserialize(null, Integer.class));
|
assertNull(SERIALIZER.deserialize(null, Integer.class));
|
||||||
|
@ -777,6 +861,7 @@ public class DefaultObjectSerializerTest {
|
||||||
assertNull(SERIALIZER.deserialize(null, Double.class));
|
assertNull(SERIALIZER.deserialize(null, Double.class));
|
||||||
assertNull(SERIALIZER.deserialize(null, Float.class));
|
assertNull(SERIALIZER.deserialize(null, Float.class));
|
||||||
assertNull(SERIALIZER.deserialize(null, Boolean.class));
|
assertNull(SERIALIZER.deserialize(null, Boolean.class));
|
||||||
|
assertNull(SERIALIZER.deserialize(null, OffsetDateTime.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -789,6 +874,7 @@ public class DefaultObjectSerializerTest {
|
||||||
assertEquals(0, SERIALIZER.deserialize(new byte[0], double.class), 0);
|
assertEquals(0, SERIALIZER.deserialize(new byte[0], double.class), 0);
|
||||||
assertEquals(0, SERIALIZER.deserialize(new byte[0], float.class), 0);
|
assertEquals(0, SERIALIZER.deserialize(new byte[0], float.class), 0);
|
||||||
assertEquals(false, SERIALIZER.deserialize(new byte[0], boolean.class));
|
assertEquals(false, SERIALIZER.deserialize(new byte[0], boolean.class));
|
||||||
|
assertEquals(null, SERIALIZER.deserialize(new byte[0], OffsetDateTime.class));
|
||||||
|
|
||||||
assertNull(SERIALIZER.deserialize(new byte[0], Character.class));
|
assertNull(SERIALIZER.deserialize(new byte[0], Character.class));
|
||||||
assertNull(SERIALIZER.deserialize(new byte[0], Integer.class));
|
assertNull(SERIALIZER.deserialize(new byte[0], Integer.class));
|
||||||
|
@ -797,6 +883,7 @@ public class DefaultObjectSerializerTest {
|
||||||
assertNull(SERIALIZER.deserialize(new byte[0], Double.class));
|
assertNull(SERIALIZER.deserialize(new byte[0], Double.class));
|
||||||
assertNull(SERIALIZER.deserialize(new byte[0], Float.class));
|
assertNull(SERIALIZER.deserialize(new byte[0], Float.class));
|
||||||
assertNull(SERIALIZER.deserialize(new byte[0], Boolean.class));
|
assertNull(SERIALIZER.deserialize(new byte[0], Boolean.class));
|
||||||
|
assertNull(SERIALIZER.deserialize(new byte[0], OffsetDateTime.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -832,6 +919,20 @@ public class DefaultObjectSerializerTest {
|
||||||
"v2",
|
"v2",
|
||||||
"byte",
|
"byte",
|
||||||
Base64.getEncoder().encodeToString(new byte[] {0, 2, 99}))));
|
Base64.getEncoder().encodeToString(new byte[] {0, 2, 99}))));
|
||||||
|
assertTrue(check.apply(
|
||||||
|
new CloudEvent(
|
||||||
|
"0987-0987",
|
||||||
|
"anothersource",
|
||||||
|
"anothertype",
|
||||||
|
"v3",
|
||||||
|
"blah".getBytes())));
|
||||||
|
assertTrue(check.apply(
|
||||||
|
new CloudEvent(
|
||||||
|
"0987-0987",
|
||||||
|
"anothersource",
|
||||||
|
"anothertype",
|
||||||
|
"v3",
|
||||||
|
null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -866,9 +967,10 @@ public class DefaultObjectSerializerTest {
|
||||||
assertEquals(new TreeMap<String, String>() {{
|
assertEquals(new TreeMap<String, String>() {{
|
||||||
put("id", "123");
|
put("id", "123");
|
||||||
put("name", "Jon Doe");
|
put("name", "Jon Doe");
|
||||||
}}, deserializeData.apply("{\"id\": \"123\", \"name\": \"Jon Doe\"}"));
|
put("time", "1970-01-01-00:00:00+00:00");
|
||||||
assertEquals("{\"id\": \"123\", \"name\": \"Jon Doe\"}",
|
}}, deserializeData.apply("{\"id\": \"123\", \"name\": \"Jon Doe\", \"time\": \"1970-01-01-00:00:00+00:00\"}"));
|
||||||
deserializeData.apply(new ObjectMapper().writeValueAsString("{\"id\": \"123\", \"name\": \"Jon Doe\"}")));
|
assertEquals("{\"id\": \"123\", \"name\": \"Jon Doe\", \"time\": \"1970-01-01-00:00:00+00:00\"}",
|
||||||
|
deserializeData.apply(new ObjectMapper().writeValueAsString("{\"id\": \"123\", \"name\": \"Jon Doe\", \"time\": \"1970-01-01-00:00:00+00:00\"}")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue