Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -35,7 +36,9 @@
* @author Mark Vollmary
* @author Michele Rastelli
*/
abstract class AbstractBaseDocument {
abstract class AbstractBaseDocument implements Serializable {

private static final long serialVersionUID = 6985324876843525239L;

private static final String[] META_PROPS = new String[]{
DocumentFields.ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,17 @@
},
{
"name": "com.arangodb.internal.net.ArangoDBRedirectException"
},
{
"name": "com.arangodb.entity.AbstractBaseDocument"
},
{
"name": "com.arangodb.entity.BaseDocument"
},
{
"name": "com.arangodb.entity.BaseEdgeDocument"
},
{
"name": "java.util.HashMap"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,17 @@
},
{
"name": "com.arangodb.internal.net.ArangoDBRedirectException"
},
{
"name": "com.arangodb.entity.AbstractBaseDocument"
},
{
"name": "com.arangodb.entity.BaseDocument"
},
{
"name": "com.arangodb.entity.BaseEdgeDocument"
},
{
"name": "java.util.HashMap"
}
]
26 changes: 26 additions & 0 deletions test-functional/src/test/java/com/arangodb/SerializableTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.arangodb;

import com.arangodb.entity.BaseDocument;
import com.arangodb.entity.BaseEdgeDocument;
import com.arangodb.entity.ErrorEntity;
import com.arangodb.internal.net.ArangoDBRedirectException;
import com.fasterxml.jackson.databind.JsonNode;
Expand Down Expand Up @@ -50,6 +52,30 @@ void serializeArangoDBMultipleException() throws IOException, ClassNotFoundExcep
assertThat(e2.getExceptions().iterator().next().getMessage()).isEqualTo("foo");
}

@Test
void serializeBaseDocument() throws IOException, ClassNotFoundException {
BaseDocument doc = new BaseDocument();
doc.setKey("test");
doc.setId("id");
doc.setRevision("revision");
doc.addAttribute("foo", "bar");
BaseDocument doc2 = roundTrip(doc);
assertThat(doc2).isEqualTo(doc);
}

@Test
void serializeBaseEdgeDocument() throws IOException, ClassNotFoundException {
BaseEdgeDocument doc = new BaseEdgeDocument();
doc.setKey("test");
doc.setId("id");
doc.setRevision("revision");
doc.setFrom("from");
doc.setTo("to");
doc.addAttribute("foo", "bar");
BaseDocument doc2 = roundTrip(doc);
assertThat(doc2).isEqualTo(doc);
}

private <T> T roundTrip(T input) throws IOException, ClassNotFoundException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(os);
Expand Down