use of com.datastax.dse.driver.api.core.graph.GraphNode in project java-driver by datastax.
the class GraphNodeTest method should_create_graph_node_for_map_for_non_string_key.
@Test
@UseDataProvider("graphson1_0and2_0")
public void should_create_graph_node_for_map_for_non_string_key(GraphProtocol graphProtocol) throws IOException {
// when
GraphNode graphNode = serdeAndCreateGraphNode(ImmutableMap.of(12, 1234), graphProtocol);
// then
assertThat(graphNode.isMap()).isTrue();
Map<String, Integer> result = graphNode.asMap();
assertThat(result).isEqualTo(ImmutableMap.of("12", 1234));
}
use of com.datastax.dse.driver.api.core.graph.GraphNode in project java-driver by datastax.
the class GraphNodeTest method should_create_graph_node_for_list.
@Test
@UseDataProvider(value = "allGraphProtocols")
public void should_create_graph_node_for_list(GraphProtocol graphVersion) throws IOException {
// when
GraphNode graphNode = serdeAndCreateGraphNode(ImmutableList.of("value"), graphVersion);
// then
assertThat(graphNode.isList()).isTrue();
List<String> result = graphNode.asList();
assertThat(result).isEqualTo(ImmutableList.of("value"));
}
use of com.datastax.dse.driver.api.core.graph.GraphNode 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();
}
use of com.datastax.dse.driver.api.core.graph.GraphNode in project java-driver by datastax.
the class GraphNodeTest method should_not_support_set_for_graphson_2_0.
@Test
public void should_not_support_set_for_graphson_2_0() throws IOException {
// when
GraphNode graphNode = serdeAndCreateGraphNode(ImmutableSet.of("value"), GRAPHSON_2_0);
// then
assertThat(graphNode.isSet()).isFalse();
}
use of com.datastax.dse.driver.api.core.graph.GraphNode in project java-driver by datastax.
the class GraphNodeTest method should_throw_for_set_for_graphson_1_0.
@Test
public void should_throw_for_set_for_graphson_1_0() throws IOException {
// when
GraphNode graphNode = serdeAndCreateGraphNode(ImmutableSet.of("value"), GRAPHSON_1_0);
// then
assertThat(graphNode.isSet()).isFalse();
assertThatThrownBy(graphNode::asSet).isExactlyInstanceOf(UnsupportedOperationException.class);
}
Aggregations