use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class VertexTest method testAddVertexWithMapProperties.
@Test
public void testAddVertexWithMapProperties() {
Map<String, Object> properties = ImmutableMap.of("name", "vadas", "age", 19, "city", "Beijing");
// 1st param is label
Vertex vadas = graph().addVertex("person", properties);
Map<String, Object> props = ImmutableMap.of("name", "vadas", "age", 19, "city", "Beijing");
Assert.assertEquals(props, vadas.properties());
properties = ImmutableMap.of("name", "java in action", "price", 88);
// 1st param is label, 2nd param is id
Vertex java = graph().addVertex("book", "ISBN-1", properties);
props = ImmutableMap.of("name", "java in action", "price", 88);
Assert.assertEquals(props, java.properties());
}
use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class VertexTest method testGetVerticesByLabelWithLimit2.
@Test
public void testGetVerticesByLabelWithLimit2() {
BaseClientTest.initVertex();
List<Vertex> vertices = graph().listVertices("person", 2);
Assert.assertEquals(2, vertices.size());
for (Vertex vertex : vertices) {
Assert.assertEquals("person", vertex.label());
}
}
use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class VertexTest method assertContains.
private static void assertContains(List<Vertex> vertices, Object... keyValues) {
String label = Utils.getLabelValue(keyValues).get();
Map<String, Object> properties = Utils.asMap(keyValues);
Vertex vertex = new Vertex(label);
for (String key : properties.keySet()) {
if (key.equals(T.label)) {
continue;
}
vertex.property(key, properties.get(key));
}
Assert.assertTrue(Utils.contains(vertices, vertex));
}
use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class VertexTest method testRemoveVertexProperty.
@Test
public void testRemoveVertexProperty() {
Vertex vadas = graph().addVertex(T.label, "person", "name", "vadas", "age", 19, "city", "Beijing");
Map<String, Object> props = ImmutableMap.of("name", "vadas", "age", 19, "city", "Beijing");
Assert.assertEquals(props, vadas.properties());
vadas.removeProperty("city");
props = ImmutableMap.of("name", "vadas", "age", 19);
Assert.assertEquals(props, vadas.properties());
}
use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class VertexTest method testAddVertexPropertyValueListWithSameValue.
@Test
public void testAddVertexPropertyValueListWithSameValue() {
schema().propertyKey("time").asDate().valueList().ifNotExist().create();
schema().vertexLabel("person").properties("time").nullableKeys("time").append();
Vertex vadas = graph().addVertex(T.label, "person", "name", "vadas", "age", 19, "time", "2012-10-10");
Map<String, Object> props = ImmutableMap.of("name", "vadas", "age", 19, "time", ImmutableList.of(Utils.formatDate("2012-10-10")));
Assert.assertEquals(props, vadas.properties());
vadas.property("time", "2012-10-10");
props = ImmutableMap.of("name", "vadas", "age", 19, "time", ImmutableList.of(Utils.formatDate("2012-10-10"), Utils.formatDate("2012-10-10")));
Assert.assertEquals(props, vadas.properties());
}
Aggregations