Skip to content

Commit

Permalink
The graph-model on the default environment should be invalid. Working…
Browse files Browse the repository at this point in the history
… without a model is useless and a pitfall for incorrect code.
  • Loading branch information
danielcweber committed May 11, 2023
1 parent f51b125 commit 09a2cbd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/Core/Environment/GremlinQueryEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public bool TryConvert(TSource source, ITransformer recurse, out TimeSpan value)
NullLogger.Instance);

public static readonly IGremlinQueryEnvironment Default = Empty
.UseModel(GraphModel.Invalid)
.UseSerializer(Serializer.Default)
.UseExecutor(GremlinQueryExecutor.Invalid)
.UseDeserializer(Deserializer.Default);
Expand Down
16 changes: 8 additions & 8 deletions test/Support.NewtonsoftJson.Tests/TansformerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,35 +135,35 @@ public Task Transform_to_List()
{
var token = JObject.Parse("{ \"@type\": \"g:List\", \"@value\": [ { \"@type\": \"g:Traverser\", \"@value\": { \"bulk\": { \"@type\": \"g:Int64\", \"@value\": 3 }, \"value\": { \"@type\": \"g:Map\", \"@value\": [ \"id\", { \"@type\": \"g:Int64\", \"@value\": 184 }, \"label\", \"Label\", \"properties\", { \"@type\": \"g:Map\", \"@value\": [] } ] } } } ]}");

return Verify(GremlinQueryEnvironment.Default
return Verify(GremlinQueryEnvironment.Empty
.UseNewtonsoftJson()
.Deserializer
.TransformTo<List<object>>()
.From(token, GremlinQueryEnvironment.Default));
.From(token, GremlinQueryEnvironment.Empty));
}

[Fact]
public Task Transform_to_array()
{
var token = JObject.Parse("{ \"@type\": \"g:List\", \"@value\": [ { \"@type\": \"g:Traverser\", \"@value\": { \"bulk\": { \"@type\": \"g:Int64\", \"@value\": 3 }, \"value\": { \"@type\": \"g:Map\", \"@value\": [ \"id\", { \"@type\": \"g:Int64\", \"@value\": 184 }, \"label\", \"Label\", \"properties\", { \"@type\": \"g:Map\", \"@value\": [] } ] } } } ]}");

return Verify(GremlinQueryEnvironment.Default
return Verify(GremlinQueryEnvironment.Empty
.UseNewtonsoftJson()
.Deserializer
.TransformTo<object[]>()
.From(token, GremlinQueryEnvironment.Default));
.From(token, GremlinQueryEnvironment.Empty));
}

[Fact]
public Task Transform_to_IEnumerable()
{
var token = JObject.Parse("{ \"@type\": \"g:List\", \"@value\": [ { \"@type\": \"g:Traverser\", \"@value\": { \"bulk\": { \"@type\": \"g:Int64\", \"@value\": 3 }, \"value\": { \"@type\": \"g:Map\", \"@value\": [ \"id\", { \"@type\": \"g:Int64\", \"@value\": 184 }, \"label\", \"Label\", \"properties\", { \"@type\": \"g:Map\", \"@value\": [] } ] } } } ]}");

var result = GremlinQueryEnvironment.Default
var result = GremlinQueryEnvironment.Empty
.UseNewtonsoftJson()
.Deserializer
.TransformTo<IEnumerable<object>>()
.From(token, GremlinQueryEnvironment.Default);
.From(token, GremlinQueryEnvironment.Empty);

return Verify(result);
}
Expand All @@ -173,11 +173,11 @@ public Task Transform_from_JArray_to_object()
{
var token = JObject.Parse("{ \"@type\": \"g:List\", \"@value\": [ { \"@type\": \"g:Traverser\", \"@value\": { \"bulk\": { \"@type\": \"g:Int64\", \"@value\": 3 }, \"value\": { \"@type\": \"g:Map\", \"@value\": [ \"id\", { \"@type\": \"g:Int64\", \"@value\": 184 }, \"label\", \"Label\", \"properties\", { \"@type\": \"g:Map\", \"@value\": [] } ] } } } ]}");

return Verify(GremlinQueryEnvironment.Default
return Verify(GremlinQueryEnvironment.Empty
.UseNewtonsoftJson()
.Deserializer
.TransformTo<object>()
.From(token, GremlinQueryEnvironment.Default));
.From(token, GremlinQueryEnvironment.Empty));
}
}
}

0 comments on commit 09a2cbd

Please sign in to comment.