FlorianHockmann closed pull request #972: TINKERPOP-2067 Allow getting raw JToken data from Gremlin.Net.Driver.GremlinClient. URL: https://github.com/apache/tinkerpop/pull/972
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs index b79f0e620f..23d76c6f5a 100644 --- a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs +++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs @@ -100,7 +100,10 @@ private async Task<IReadOnlyCollection<T>> ReceiveAsync<T>() } else if (status.Code != ResponseStatusCode.NoContent) { - var receivedData = _graphSONReader.ToObject(receivedMsg.Result.Data); + var receivedData = typeof(T) == typeof(JToken) + ? new[] { receivedMsg.Result.Data } + : _graphSONReader.ToObject(receivedMsg.Result.Data); + foreach (var d in receivedData) if (receivedMsg.Result.Meta.ContainsKey(Tokens.ArgsSideEffectKey)) { diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs index 9a421d59b3..56ebfc3fa8 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs @@ -29,6 +29,7 @@ using Gremlin.Net.Driver.Exceptions; using Gremlin.Net.Driver.Messages; using Gremlin.Net.IntegrationTest.Util; +using Newtonsoft.Json.Linq; using Xunit; namespace Gremlin.Net.IntegrationTest.Driver @@ -68,6 +69,34 @@ public async Task ShouldHandleBigResponse() } } + [Fact] + public async Task ShouldReturnResultWithoutDeserializingItForJTokenType() + { + var gremlinServer = new GremlinServer(TestHost, TestPort); + using (var gremlinClient = new GremlinClient(gremlinServer)) + { + var gremlinScript = "'someString'"; + + var response = await gremlinClient.SubmitWithSingleResultAsync<JToken>(gremlinScript); + + //Expected: + /* { + "@type": "g:List", + "@value": [ + "someString" + ] + }*/ + + Assert.IsType<JObject>(response); + Assert.Equal("g:List", response["@type"]); + + var jArray = response["@value"] as JArray; + Assert.NotNull(jArray); + Assert.Equal(1, jArray.Count); + Assert.Equal("someString", (jArray[0] as JValue)?.Value); + } + } + [Fact] public async Task ShouldHandleResponseWithoutContent() { ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services