public void FixtureSetup() { foreach (var type in TraversalClassicIntegrationTest.PropertyItems.Select(i => i.Item1).Distinct()) { var typeDef = $"{type}()"; if (TestClusterManager.DseVersion >= new Version(5, 1)) { switch (type) { case "Point": typeDef = $"{type}().withBounds(-40, -40, 40, 40)"; break; case "Linestring": case "Polygon": typeDef = $"{type}().withGeoBounds()"; break; } } else { if (type == "Date" || type == "Time") { continue; } } var schemaQuery = $"schema.propertyKey(propertyName).{typeDef}.ifNotExists().create();\n" + "schema.vertexLabel(vertexLabel).properties(propertyName).ifNotExists().create();"; var statement = new SimpleGraphStatement(schemaQuery, new { vertexLabel = $"vertex{type}", propertyName = $"prop{type}" }); Session.ExecuteGraph(statement.SetGraphLanguage("gremlin-groovy")); } }
public async Task With_GraphSON2_It_Should_Parse_Bulked_Results() { var statement = new SimpleGraphStatement("{\"@type\": \"g:Bytecode\", \"@value\": {" + " \"step\": [[\"V\"], [\"hasLabel\", \"person\"]," + " [\"has\", \"name\", \"marko\"], [\"outE\"], [\"label\"]]}}"); statement.SetGraphLanguage(GraphTests.GraphSON2Language); var rs = await _session.ExecuteGraphAsync(statement).ConfigureAwait(false); Assert.That(rs.To <string>(), Is.EqualTo(new [] { "created", "knows", "knows" })); }
public void Should_Retrieve_Vertex_Properties(string graphsonLanguage, string graphQuery) { var statement = new SimpleGraphStatement(graphQuery); statement.SetGraphLanguage(graphsonLanguage); var rs = _session.ExecuteGraph(statement); var results = rs.To <IVertexProperty>().ToArray(); Assert.Greater(results.Length, 1); Assert.True(results.Any(prop => prop.Label == "name" && prop.Value.ToString() == "marko")); }
public void Should_Retrieve_Edge_Properties(string graphsonLanguage, string graphQuery) { var statement = new SimpleGraphStatement(graphQuery); statement.SetGraphLanguage(graphsonLanguage); var rs = _session.ExecuteGraph(statement); var results = rs.To <IProperty>().ToArray(); Assert.Greater(results.Length, 1); Assert.True(results.Any(prop => prop.Name == "weight" && Math.Abs(prop.Value.To <double>() - 0.5) < 0.001)); }
public void FixtureSetup() { foreach (var type in TraversalCoreIntegrationTest.PropertyItems.Select(i => i.Item1).Distinct()) { var typeDef = $"{type}"; var schemaQuery = $"schema.vertexLabel(vertexLabel).partitionBy('pk', UUID).property(propertyName, {typeDef}).create();"; var statement = new SimpleGraphStatement(schemaQuery, new { vertexLabel = $"vertex{type}", propertyName = $"prop{type}" }); Session.ExecuteGraph(statement.SetGraphLanguage("gremlin-groovy")); } }
public async Task With_GraphSON2_It_Should_Retrieve_Edge_Instances() { var statement = new SimpleGraphStatement("{\"@type\": \"g:Bytecode\", \"@value\": {" + " \"step\": [[\"E\"], [\"hasLabel\", \"created\"]]}}"); statement.SetGraphLanguage(GraphTests.GraphSON2Language); var rs = await _session.ExecuteGraphAsync(statement).ConfigureAwait(false); var results = rs.To <IEdge>().ToArray(); Assert.Greater(results.Length, 0); foreach (var edge in results) { Assert.AreEqual("created", edge.Label); } }
public async Task With_GraphSON2_It_Should_Retrieve_Vertex_Name_Marko() { var statement = new SimpleGraphStatement("{\"@type\": \"g:Bytecode\", \"@value\": {" + " \"step\": [[\"V\"], [\"has\", \"person\", \"name\", \"marko\"]]}}"); statement.SetGraphLanguage(GraphSON2Language); var rs = await _session.ExecuteGraphAsync(statement).ConfigureAwait(false); var results = rs.ToArray(); Assert.AreEqual(1, results.Length); var markoVertex = results.FirstOrDefault().ToVertex(); Assert.AreEqual("person", markoVertex.Label); Assert.AreEqual("marko", markoVertex.Properties["name"].ToArray()[0].Get <string>("value")); }
public async Task With_GraphSON2_It_Should_Retrieve_Vertex_Instances() { var statement = new SimpleGraphStatement("{\"@type\": \"g:Bytecode\", \"@value\": {" + " \"step\": [[\"V\"], [\"hasLabel\", \"person\"]]}}"); statement.SetGraphLanguage(GraphSON2Language); var rs = await _session.ExecuteGraphAsync(statement).ConfigureAwait(false); var results = rs.ToArray(); Assert.Greater(results.Length, 0); foreach (var graphNode in results) { var vertex = graphNode.ToVertex(); Assert.AreEqual("person", vertex.Label); } }
public async Task With_GraphSON2_It_Should_Insert_And_Retrieve_LocalDate_LocalTime() { const string schemaQuery = "schema.propertyKey('localdate').Date().ifNotExists().create();\n" + "schema.propertyKey('localtime').Time().ifNotExists().create();\n" + "schema.vertexLabel('typetests').properties('name', 'localdate', 'localtime').ifNotExists().create();\n"; _session.ExecuteGraph(new SimpleGraphStatement(schemaQuery)); var deleteStatement = new SimpleGraphStatement("{\"@type\": \"g:Bytecode\", \"@value\": {" + " \"step\": [[\"V\"], " + " [\"has\", \"typetests\", \"name\", \"stephen\"]," + " [\"drop\"]]}}"); deleteStatement.SetGraphLanguage(GraphTests.GraphSON2Language); _session.ExecuteGraph(deleteStatement); var addStatement = new SimpleGraphStatement("{\"@type\":\"g:Bytecode\", \"@value\": {\"step\":[" + "[\"addV\", \"typetests\"],[\"property\",\"name\",\"stephen\"]," + "[\"property\",\"localdate\", {\"@type\":\"gx:LocalDate\",\"@value\":\"1981-09-14\"}]," + "[\"property\",\"localtime\", {\"@type\":\"gx:LocalTime\",\"@value\":\"12:50\"}]]}}"); addStatement.SetGraphLanguage(GraphTests.GraphSON2Language); await _session.ExecuteGraphAsync(addStatement).ConfigureAwait(false); var statement = new SimpleGraphStatement("{\"@type\": \"g:Bytecode\", \"@value\": {" + " \"step\": [[\"V\"], [\"has\", \"typetests\", \"name\", \"stephen\"]]}}"); statement.SetGraphLanguage(GraphTests.GraphSON2Language); var rs = await _session.ExecuteGraphAsync(statement).ConfigureAwait(false); var results = rs.ToArray(); Assert.AreEqual(1, results.Length); var stephen = results.First().To <IVertex>(); Assert.AreEqual("stephen", stephen.GetProperty("name").Value.ToString()); Assert.AreEqual(LocalDate.Parse("1981-09-14"), stephen.GetProperty("localdate").Value.To <LocalDate>()); Assert.AreEqual(LocalTime.Parse("12:50"), stephen.GetProperty("localtime").Value.To <LocalTime>()); }