You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2018/09/25 00:07:53 UTC
[03/22] tinkerpop git commit: Addressing review comments
Addressing review comments
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/6310dabb
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/6310dabb
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/6310dabb
Branch: refs/heads/master
Commit: 6310dabb7fc33c44b97ef75e9a8663aa17e51319
Parents: 705ce4e
Author: Ashwini Singh <as...@gmail.com>
Authored: Wed May 16 12:14:01 2018 -0700
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 18 12:58:42 2018 -0400
----------------------------------------------------------------------
.../src/Gremlin.Net/Driver/Connection.cs | 10 +++++---
.../src/Gremlin.Net/Driver/ResultSet.cs | 27 ++++++++++++++------
.../Driver/GremlinClientTests.cs | 12 ++++-----
3 files changed, 31 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6310dabb/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
index 3663191..5b4be20 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/Connection.cs
@@ -78,9 +78,10 @@ namespace Gremlin.Net.Driver
await _webSocketConnection.SendMessageAsync(serializedMsg).ConfigureAwait(false);
}
- private async Task<IReadOnlyCollection<T>> ReceiveAsync<T>()
+ private async Task<ResultSet<T>> ReceiveAsync<T>()
{
- ResultSet<T> resultSet = new ResultSet<T>();
+ ResultSet<T> resultSet = null;
+ Dictionary<string, object> statusAttributes = null;
ResponseStatus status;
IAggregator aggregator = null;
var isAggregatingSideEffects = false;
@@ -118,12 +119,13 @@ namespace Gremlin.Net.Driver
if (status.Code == ResponseStatusCode.Success || status.Code == ResponseStatusCode.NoContent)
{
- resultSet.StatusAttributes = receivedMsg.Status.Attributes;
+ statusAttributes = receivedMsg.Status.Attributes;
}
} while (status.Code == ResponseStatusCode.PartialContent || status.Code == ResponseStatusCode.Authenticate);
- resultSet.Data = isAggregatingSideEffects ? new List<T> {(T) aggregator.GetAggregatedResult()} : result;
+
+ resultSet = new ResultSet<T>(isAggregatingSideEffects ? new List<T> { (T)aggregator.GetAggregatedResult() } : result, statusAttributes);
return resultSet;
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6310dabb/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
index 2b1edfb..5d4a145 100644
--- a/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Driver/ResultSet.cs
@@ -31,18 +31,29 @@ namespace Gremlin.Net.Driver
/// A ResultSet is returned from the submission of a Gremlin script to the server and represents the results provided by the server
/// ResultSet includes enumerable data and status attributes.
/// </summary>
- /// <typeparam name="T"></typeparam>
+ /// <typeparam name="T">Type of the result elements</typeparam>
public sealed class ResultSet<T> : IReadOnlyCollection<T>
{
/// <summary>
- /// Gets and Sets the read only collection
+ /// Gets or sets the data from the response
/// </summary>
- public IReadOnlyCollection<T> Data { get; set; }
+ public IReadOnlyCollection<T> Data { get; }
/// <summary>
- /// Gets or Sets the status attributes from the gremlin response
+ /// Gets or sets the status attributes from the gremlin response
/// </summary>
- public Dictionary<string, object> StatusAttributes { get; set; }
+ public Dictionary<string, object> StatusAttributes { get; }
+
+ /// <summary>
+ /// Initializes a new instance of the ResultSet class for the specified data and status attributes.
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="attributes"></param>
+ public ResultSet(IReadOnlyCollection<T> data, Dictionary<string, object> attributes)
+ {
+ this.Data = data;
+ this.StatusAttributes = attributes;
+ }
/// <summary>Returns an enumerator that iterates through the collection.</summary>
/// <returns>An enumerator that can be used to iterate through the collection.</returns>
@@ -71,9 +82,9 @@ namespace Gremlin.Net.Driver
/// <summary>
/// Casts a IReadOnlyCollection to ResultSet
/// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="data"></param>
- /// <returns></returns>
+ /// <typeparam name="T">Type of the result elements</typeparam>
+ /// <param name="data"> result data</param>
+ /// <returns>IReadOnlyCollection as ResultSet</returns>
public static ResultSet<T> AsResultSet<T>(this IReadOnlyCollection<T> data)
{
if (!(data is ResultSet<T> resultSet))
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6310dabb/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
index a7e191f..bcb76e7 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Driver/GremlinClientTests.cs
@@ -30,6 +30,8 @@ using Gremlin.Net.Driver.Messages;
using Gremlin.Net.IntegrationTest.Util;
using Xunit;
using Gremlin.Net.Structure.IO.GraphSON;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
namespace Gremlin.Net.IntegrationTest.Driver
{
@@ -174,16 +176,14 @@ namespace Gremlin.Net.IntegrationTest.Driver
var gremlinServer = new GremlinServer(TestHost, TestPort);
using (var gremlinClient = new GremlinClient(gremlinServer))
{
- var expectedResult = new List<int> { 1, 2, 3, 4, 5 };
- var requestMsg = $"{nameof(expectedResult)}";
- var bindings = new Dictionary<string, object> { { nameof(expectedResult), expectedResult } };
-
- var response = await gremlinClient.SubmitAsync<int>(requestMsg, bindings);
+ var requestMsg = _requestMessageProvider.GetDummyMessage();
+ var response = await gremlinClient.SubmitAsync<int>(requestMsg);
var resultSet = response.AsResultSet();
-
Assert.NotNull(resultSet.StatusAttributes);
+ var values= resultSet.StatusAttributes["@value"] as JArray;
+ Assert.True(values.First.ToString().Equals("host"));
}
}