public void RegisterSerializer_CustomSerializerForKnownJanusGraphType_SerializerRegistered() { var customSerializer = SerializerFake.Register("janusgraph:Geoshape", Geoshape.Point(1, 2)); var writer = JanusGraphSONWriterBuilder.Build().RegisterSerializer(typeof(Point), customSerializer) .Create(); Assert.Equal(customSerializer.DeserializationResult, writer.WriteObject(Geoshape.Point(1, 2))); }
public void Build_DisabledJanusGraphPredicates_UsesTinkerPopPredicateSerializationForJanusGraphPredicate() { var janusgraphPredicate = Text.TextContainsFuzzy("test"); var tinkerpopPredicate = new P(janusgraphPredicate.OperatorName, janusgraphPredicate.Value); // ReSharper disable once RedundantArgumentDefaultValue var writer = JanusGraphSONWriterBuilder.Build(false).Create(); Assert.Equal(writer.WriteObject(tinkerpopPredicate), writer.WriteObject(janusgraphPredicate)); }
public void RegisterSerializer_CustomSerializerForGivenType_SerializerRegistered(object dataToSerialize, string graphSonTypeToUse) { var customSerializer = SerializerFake.Register(graphSonTypeToUse, dataToSerialize); var writer = JanusGraphSONWriterBuilder.Build().RegisterSerializer(dataToSerialize.GetType(), customSerializer) .Create(); Assert.Equal(customSerializer.DeserializationResult, writer.WriteObject(dataToSerialize)); }
public void SerializeAndDeserialize_ValidRelationIdentifier_SameRelationIdentifier() { var relationIdentifier = new RelationIdentifier("someRelationId"); var writer = JanusGraphSONWriterBuilder.Build().Create(); var reader = JanusGraphSONReaderBuilder.Build().Create(); var graphSon = writer.WriteObject(relationIdentifier); var readRelationIdentifier = reader.ToObject(JToken.Parse(graphSon)); Assert.Equal(relationIdentifier, readRelationIdentifier); }
public void SerializeAndDeserialize_ValidPoint_SamePoint() { var point = Geoshape.Point(1.234, 9.87); var writer = JanusGraphSONWriterBuilder.Build().Create(); var reader = JanusGraphSONReaderBuilder.Build().Create(); var graphSon = writer.WriteObject(point); var readPoint = reader.ToObject(JsonDocument.Parse(graphSon).RootElement); Assert.Equal(point, readPoint); }
public void SerializeAndDeserialize_ValidRelationIdentifier_SameRelationIdentifier() { var relationIdentifier = new RelationIdentifier("4qp-360-7x1-3aw"); var writer = JanusGraphSONWriterBuilder.Build().Create(); var reader = JanusGraphSONReaderBuilder.Build().Create(); var graphSon = writer.WriteObject(relationIdentifier); var readRelationIdentifier = reader.ToObject(JsonDocument.Parse(graphSon).RootElement); Assert.Equal(relationIdentifier, readRelationIdentifier); }
public void Build_EnabledJanusGraphPredicates_UsesJanusGraphPredicateSerializationForJanusGraphPredicate() { var janusgraphPredicate = Text.TextContainsFuzzy("test"); var writer = JanusGraphSONWriterBuilder.Build(true).Create(); const string janusgraphPredicateGraphSon = "{\"@type\":\"janusgraph:JanusGraphP\",\"@value\":{\"predicate\":\"textContainsFuzzy\",\"value\":\"test\"}}"; Assert.Equal(janusgraphPredicateGraphSon, writer.WriteObject(janusgraphPredicate)); }
public void Write_PointWithGivenCoordinates_ExpectedGraphSon(double latitude, double longitude) { var point = Geoshape.Point(latitude, longitude); var writer = JanusGraphSONWriterBuilder.Build().Create(); var graphSon = writer.WriteObject(point); var expectedGraphSon = "{\"@type\":\"janusgraph:Geoshape\",\"@value\":{\"coordinates\":[" + longitude.ToString(CultureInfo.InvariantCulture) + "," + latitude.ToString(CultureInfo.InvariantCulture) + "]}}"; Assert.Equal(expectedGraphSon, graphSon); }
public void Write_RelationIdentifier_ExpectedGraphSon() { const string relationId = "4qp-360-7x1-3aw"; var relationIdentifier = new RelationIdentifier(relationId); var writer = JanusGraphSONWriterBuilder.Build().Create(); var graphSon = writer.WriteObject(relationIdentifier); var expectedGraphSon = $"{{\"@type\":\"janusgraph:RelationIdentifier\",\"@value\":{{\"relationId\":\"{relationId}\"}}}}"; Assert.Equal(expectedGraphSon, graphSon); }
private JanusGraphClientBuilder(GremlinServer server, bool janusGraphPredicates) { _server = server; _writerBuilder = JanusGraphSONWriterBuilder.Build(janusGraphPredicates); }