Search in sources :

Example 1 with DetachedVertex

use of org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex in project java-driver by datastax.

the class GraphNodeTest method should_check_if_node_is_vertex.

@Test
@UseDataProvider("allGraphProtocols")
public void should_check_if_node_is_vertex(GraphProtocol graphProtocol) throws IOException {
    // when
    GraphNode vertexNode = serdeAndCreateGraphNode(new DetachedVertex("a", "l", null), graphProtocol);
    // then
    assertThat(vertexNode.isVertex()).isTrue();
    assertThat(vertexNode.asVertex()).isNotNull();
}
Also used : DetachedVertex(org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex) GraphNode(com.datastax.dse.driver.api.core.graph.GraphNode) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 2 with DetachedVertex

use of org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex in project java-driver by datastax.

the class GraphNodeTest method should_return_is_value_only_for_scalar_value.

@Test
@UseDataProvider(value = "allGraphProtocols")
public void should_return_is_value_only_for_scalar_value(GraphProtocol graphProtocol) throws IOException {
    // when
    GraphNode mapNode = serdeAndCreateGraphNode(ImmutableMap.of(12, 1234), graphProtocol);
    GraphNode setNode = serdeAndCreateGraphNode(ImmutableMap.of(12, 1234), graphProtocol);
    GraphNode listNode = serdeAndCreateGraphNode(ImmutableMap.of(12, 1234), graphProtocol);
    GraphNode vertexNode = serdeAndCreateGraphNode(new DetachedVertex("a", "l", null), graphProtocol);
    GraphNode edgeNode = serdeAndCreateGraphNode(new DetachedEdge("a", "l", Collections.emptyMap(), "v1", "l1", "v2", "l2"), graphProtocol);
    GraphNode pathNode = serdeAndCreateGraphNode(EmptyPath.instance(), graphProtocol);
    GraphNode propertyNode = serdeAndCreateGraphNode(new DetachedProperty<>("a", 1), graphProtocol);
    GraphNode vertexPropertyNode = serdeAndCreateGraphNode(new DetachedVertexProperty<>("id", "l", "v", null, new DetachedVertex("a", "l", null)), graphProtocol);
    GraphNode scalarValueNode = serdeAndCreateGraphNode(true, graphProtocol);
    // then
    assertThat(mapNode.isValue()).isFalse();
    assertThat(setNode.isValue()).isFalse();
    assertThat(listNode.isValue()).isFalse();
    assertThat(vertexNode.isValue()).isFalse();
    assertThat(edgeNode.isValue()).isFalse();
    assertThat(pathNode.isValue()).isFalse();
    assertThat(propertyNode.isValue()).isFalse();
    assertThat(vertexPropertyNode.isValue()).isFalse();
    assertThat(scalarValueNode.isValue()).isTrue();
}
Also used : DetachedVertex(org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex) DetachedEdge(org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge) GraphNode(com.datastax.dse.driver.api.core.graph.GraphNode) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 3 with DetachedVertex

use of org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex in project java-driver by datastax.

the class GraphNodeTest method should_check_if_node_is_vertex_property.

@Test
@UseDataProvider("allGraphProtocols")
public void should_check_if_node_is_vertex_property(GraphProtocol graphProtocol) throws IOException {
    // when
    GraphNode vertexPropertyNode = serdeAndCreateGraphNode(new DetachedVertexProperty<>("id", "l", "v", null, new DetachedVertex("a", "l", null)), graphProtocol);
    // then
    assertThat(vertexPropertyNode.isVertexProperty()).isTrue();
    assertThat(vertexPropertyNode.isVertexProperty()).isNotNull();
}
Also used : DetachedVertex(org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex) GraphNode(com.datastax.dse.driver.api.core.graph.GraphNode) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Aggregations

GraphNode (com.datastax.dse.driver.api.core.graph.GraphNode)3 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)3 DetachedVertex (org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex)3 Test (org.junit.Test)3 DetachedEdge (org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge)1