-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1989 add JsonSerializerTest, add new detach method to document to fi…
…lter hidden properties, add tests to HTTPGraphIT, fix Projection
- Loading branch information
Showing
16 changed files
with
265 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
engine/src/test/java/com/arcadedb/serializer/JsonGraphSerializerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.arcadedb.serializer; | ||
|
||
import com.arcadedb.TestHelper; | ||
import com.arcadedb.graph.MutableEdge; | ||
import com.arcadedb.graph.MutableVertex; | ||
import com.arcadedb.schema.DocumentType; | ||
import com.jayway.jsonpath.JsonPath; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Map; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class JsonGraphSerializerTest extends TestHelper { | ||
|
||
private JsonGraphSerializer jsonGraphSerializer; | ||
private MutableEdge edge; | ||
private MutableVertex vertex1; | ||
private MutableVertex vertex2; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
jsonGraphSerializer = JsonGraphSerializer.createJsonGraphSerializer(); | ||
|
||
database.transaction(() -> { | ||
DocumentType vertexType = database.getSchema().createVertexType("TestVertexType"); | ||
DocumentType edgeType = database.getSchema().createEdgeType("TestEdgeType"); | ||
|
||
vertex1 = database.newVertex("TestVertexType").save(); | ||
vertex2 = database.newVertex("TestVertexType").save(); | ||
|
||
edge = vertex1.newEdge("TestEdgeType", vertex2, true).save(); | ||
}); | ||
} | ||
|
||
@Test | ||
void testSerializeEdge() { | ||
|
||
String json = jsonGraphSerializer.serializeGraphElement(edge).toString(); | ||
|
||
assertThat(JsonPath.<String>read(json, "$.p.@rid")).isNotEmpty(); | ||
assertThat(JsonPath.<String>read(json, "$.p.@type")).isEqualTo("TestEdgeType"); | ||
assertThat(JsonPath.<String>read(json, "$.p.@cat")).isEqualTo("e"); | ||
assertThat(JsonPath.<String>read(json, "$.p.@in")).isNotEmpty(); | ||
assertThat(JsonPath.<String>read(json, "$.p.@out")).isNotEmpty(); | ||
assertThat(JsonPath.<String>read(json, "$.r")).isNotEmpty(); | ||
assertThat(JsonPath.<String>read(json, "$.t")).isEqualTo("TestEdgeType"); | ||
assertThat(JsonPath.<String>read(json, "$.i")).isNotEmpty(); | ||
assertThat(JsonPath.<String>read(json, "$.o")).isNotEmpty(); | ||
|
||
} | ||
|
||
@Test | ||
void testSerializeEdgeWithoutMetadata() { | ||
jsonGraphSerializer.setIncludeMetadata(false); | ||
|
||
String json = jsonGraphSerializer.serializeGraphElement(edge).toString(); | ||
|
||
//nometadata | ||
assertThat(JsonPath.<Map<?, ?>>read(json, "$.p")).isEmpty(); | ||
|
||
assertThat(JsonPath.<String>read(json, "$.r")).isNotEmpty(); | ||
assertThat(JsonPath.<String>read(json, "$.t")).isEqualTo("TestEdgeType"); | ||
assertThat(JsonPath.<String>read(json, "$.i")).isNotEmpty(); | ||
assertThat(JsonPath.<String>read(json, "$.o")).isNotEmpty(); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.