Skip to content

Commit d43f900

Browse files
committed
date serde tests
1 parent 4a1778b commit d43f900

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/test/java/com/arangodb/serde/SerdeTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
import com.arangodb.util.RawBytes;
44
import com.arangodb.util.RawJson;
5+
import com.fasterxml.jackson.databind.JsonNode;
56
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
67
import com.fasterxml.jackson.databind.node.ObjectNode;
78
import org.junit.jupiter.params.ParameterizedTest;
89
import org.junit.jupiter.params.provider.EnumSource;
910

1011

12+
import java.sql.Date;
13+
1114
import static org.assertj.core.api.Assertions.assertThat;
1215

1316

@@ -35,4 +38,32 @@ void rawBytesSerde(DataType type) {
3538
assertThat(deserialized).isEqualTo(raw);
3639
}
3740

41+
@ParameterizedTest
42+
@EnumSource(DataType.class)
43+
void utilDateSerde(DataType type) {
44+
InternalSerde s = InternalSerde.of(type, null);
45+
long ts = 1000000000000L;
46+
java.util.Date date = new java.util.Date(ts);
47+
byte[] ser = s.serialize(date);
48+
JsonNode node = s.parse(ser);
49+
assertThat(node.isLong()).isTrue();
50+
assertThat(node.longValue()).isEqualTo(ts);
51+
java.util.Date deser = s.deserialize(ser, java.util.Date.class);
52+
assertThat(deser).isEqualTo(date);
53+
}
54+
55+
@ParameterizedTest
56+
@EnumSource(DataType.class)
57+
void sqlDateSerde(DataType type) {
58+
InternalSerde s = InternalSerde.of(type, null);
59+
long ts = 1000000000000L;
60+
java.sql.Date date = new Date(ts);
61+
byte[] ser = s.serialize(date);
62+
JsonNode node = s.parse(ser);
63+
assertThat(node.isLong()).isTrue();
64+
assertThat(node.longValue()).isEqualTo(ts);
65+
java.sql.Date deser = s.deserialize(ser, java.sql.Date.class);
66+
assertThat(deser).isEqualTo(date);
67+
}
68+
3869
}

0 commit comments

Comments
 (0)