diff --git a/pom.xml b/pom.xml
index f7516c7..eb577d7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -159,6 +159,13 @@
test
+
+ edu.stanford.protege
+ webprotege-jackson
+ 0.9.2
+ test
+
+
diff --git a/src/main/java/edu/stanford/protege/webprotege/hierarchy/AddEdge.java b/src/main/java/edu/stanford/protege/webprotege/hierarchy/AddEdge.java
index 055968d..9a22fdb 100644
--- a/src/main/java/edu/stanford/protege/webprotege/hierarchy/AddEdge.java
+++ b/src/main/java/edu/stanford/protege/webprotege/hierarchy/AddEdge.java
@@ -2,6 +2,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
import com.google.common.base.MoreObjects;
/**
@@ -9,6 +10,7 @@
* Stanford Center for Biomedical Informatics Research
* 2021-04-20
*/
+@JsonTypeName("webprotege.events.graph.AddEdge")
public class AddEdge extends EdgeChange {
@JsonCreator
diff --git a/src/main/java/edu/stanford/protege/webprotege/hierarchy/RemoveEdge.java b/src/main/java/edu/stanford/protege/webprotege/hierarchy/RemoveEdge.java
index c6314aa..f1d13d1 100644
--- a/src/main/java/edu/stanford/protege/webprotege/hierarchy/RemoveEdge.java
+++ b/src/main/java/edu/stanford/protege/webprotege/hierarchy/RemoveEdge.java
@@ -2,6 +2,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
import com.google.common.base.MoreObjects;
/**
@@ -9,6 +10,7 @@
* Stanford Center for Biomedical Informatics Research
* 2021-04-20
*/
+@JsonTypeName("webprotege.events.graph.RemoveEdge")
public class RemoveEdge extends EdgeChange {
@JsonCreator
diff --git a/src/test/java/edu/stanford/protege/webprotege/hierarchy/AddEdge_Serialization_Test.java b/src/test/java/edu/stanford/protege/webprotege/hierarchy/AddEdge_Serialization_Test.java
new file mode 100644
index 0000000..13cdf80
--- /dev/null
+++ b/src/test/java/edu/stanford/protege/webprotege/hierarchy/AddEdge_Serialization_Test.java
@@ -0,0 +1,55 @@
+package edu.stanford.protege.webprotege.hierarchy;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import edu.stanford.protege.webprotege.MockingUtils;
+import edu.stanford.protege.webprotege.entity.EntityNode;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.json.AutoConfigureJsonTesters;
+import org.springframework.boot.test.autoconfigure.json.JsonTest;
+import org.springframework.boot.test.json.JacksonTester;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@JsonTest
+@AutoConfigureJsonTesters
+class AddEdge_Serialization_Test {
+
+ @Autowired
+ JacksonTester> tester;
+
+ @Autowired
+ ObjectMapper objectMapper;
+
+ @BeforeEach
+ void setUp() throws JsonProcessingException {
+ }
+
+ @Test
+ void shouldSerializeAsJson() throws IOException {
+ var written = tester.write(new AddEdge<>(
+ new GraphEdge<>(
+ GraphNode.getForEntityNode(MockingUtils.mockOWLClassNode(),
+ false),
+ GraphNode.getForEntityNode(MockingUtils.mockOWLClassNode(),
+ false)
+ )
+ ));
+ assertThat(written).hasJsonPathStringValue("type", "webprotege.events.graph.AddEdge");
+ assertThat(written).hasJsonPath("edge");
+ }
+
+ @Test
+ void shouldDeserializeFromJson() throws IOException {
+ var json = """
+ {"type":"webprotege.events.graph.AddEdge","edge":{"predecessor":{"userObject":{"entity":{"@type":"Class","iri":"http://stuff.com/I0"},"browserText":"","tags":[],"deprecated":false,"watches":[],"openCommentCount":0,"shortForms":[]},"sink":false},"successor":{"userObject":{"entity":{"@type":"Class","iri":"http://stuff.com/I1"},"browserText":"","tags":[],"deprecated":false,"watches":[],"openCommentCount":0,"shortForms":[]},"sink":false}}}
+ """;
+ var read = tester.readObject(new StringReader(json));
+ assertThat(read).isInstanceOf(AddEdge.class);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/edu/stanford/protege/webprotege/hierarchy/RemoveEdge_Serialization_Test.java b/src/test/java/edu/stanford/protege/webprotege/hierarchy/RemoveEdge_Serialization_Test.java
new file mode 100644
index 0000000..e354b78
--- /dev/null
+++ b/src/test/java/edu/stanford/protege/webprotege/hierarchy/RemoveEdge_Serialization_Test.java
@@ -0,0 +1,60 @@
+package edu.stanford.protege.webprotege.hierarchy;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import edu.stanford.protege.webprotege.MockingUtils;
+import edu.stanford.protege.webprotege.entity.EntityNode;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.json.AutoConfigureJsonTesters;
+import org.springframework.boot.test.autoconfigure.json.JsonTest;
+import org.springframework.boot.test.json.JacksonTester;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Matthew Horridge
+ * Stanford Center for Biomedical Informatics Research
+ * 2024-04-18
+ */
+@JsonTest
+@AutoConfigureJsonTesters
+class RemoveEdge_Serialization_Test {
+
+ @Autowired
+ JacksonTester> tester;
+
+ @Autowired
+ ObjectMapper objectMapper;
+
+ @BeforeEach
+ void setUp() throws JsonProcessingException {
+ }
+
+ @Test
+ void shouldSerializeAsJson() throws IOException {
+ var written = tester.write(new RemoveEdge<>(
+ new GraphEdge<>(
+ GraphNode.getForEntityNode(MockingUtils.mockOWLClassNode(),
+ false),
+ GraphNode.getForEntityNode(MockingUtils.mockOWLClassNode(),
+ false)
+ )
+ ));
+ assertThat(written).hasJsonPathStringValue("type", "webprotege.events.graph.RemoveEdge");
+ assertThat(written).hasJsonPath("edge");
+ }
+
+ @Test
+ void shouldDeserializeFromJson() throws IOException {
+ var json = """
+ {"type":"webprotege.events.graph.RemoveEdge","edge":{"predecessor":{"userObject":{"entity":{"@type":"Class","iri":"http://stuff.com/I0"},"browserText":"","tags":[],"deprecated":false,"watches":[],"openCommentCount":0,"shortForms":[]},"sink":false},"successor":{"userObject":{"entity":{"@type":"Class","iri":"http://stuff.com/I1"},"browserText":"","tags":[],"deprecated":false,"watches":[],"openCommentCount":0,"shortForms":[]},"sink":false}}}
+ """;
+ var read = tester.readObject(new StringReader(json));
+ assertThat(read).isInstanceOf(RemoveEdge.class);
+ }
+}