use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class EdgeTest method testAddEdgeWithMapProperties.
@Test
public void testAddEdgeWithMapProperties() {
Vertex peter = getVertex("person", "name", "peter");
Vertex lop = getVertex("software", "name", "lop");
Map<String, Object> properties = ImmutableMap.of("date", "2017-03-24", "city", "HongKong");
Edge created = graph().addEdge(peter, "created", lop, properties);
Map<String, Object> props = ImmutableMap.of("date", Utils.formatDate("2017-03-24"), "city", "HongKong");
Assert.assertEquals(props, created.properties());
}
use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class HugeClientHttpsTest method addVertexAndCheckPropertyValue.
private void addVertexAndCheckPropertyValue() {
SchemaManager schema = client.schema();
schema.propertyKey("name").asText().ifNotExist().create();
schema.propertyKey("age").asInt().ifNotExist().create();
schema.propertyKey("city").asText().ifNotExist().create();
schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").ifNotExist().create();
GraphManager graph = client.graph();
Vertex marko = graph.addVertex(T.label, "person", "name", "marko", "age", 29, "city", "Beijing");
Map<String, Object> props = ImmutableMap.of("name", "marko", "age", 29, "city", "Beijing");
Assert.assertEquals(props, marko.properties());
}
use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class VertexTest method testAddVertexPropertyValueSet.
@Test
public void testAddVertexPropertyValueSet() {
schema().propertyKey("time").asDate().valueSet().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", "2014-02-14");
props = ImmutableMap.of("name", "vadas", "age", 19, "time", ImmutableList.of(Utils.formatDate("2012-10-10"), Utils.formatDate("2014-02-14")));
Assert.assertEquals(props, vadas.properties());
}
use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class VertexTest method testGetVerticesByLabelAndPropertiesWithRangeCondition.
@Test
public void testGetVerticesByLabelAndPropertiesWithRangeCondition() {
schema().indexLabel("personByAge").range().onV("person").by("age").create();
BaseClientTest.initVertex();
Map<String, Object> properties = ImmutableMap.of("age", "P.eq(29)");
List<Vertex> vertices = graph().listVertices("person", properties);
Assert.assertEquals(2, vertices.size());
for (Vertex v : vertices) {
Assert.assertEquals("person", v.label());
Assert.assertEquals(29, v.property("age"));
}
properties = ImmutableMap.of("age", "P.gt(29)");
vertices = graph().listVertices("person", properties);
Assert.assertEquals(1, vertices.size());
for (Vertex v : vertices) {
Assert.assertEquals("person", v.label());
Assert.assertGt(29, v.property("age"));
}
properties = ImmutableMap.of("age", "P.gte(29)");
vertices = graph().listVertices("person", properties);
Assert.assertEquals(3, vertices.size());
for (Vertex v : vertices) {
Assert.assertEquals("person", v.label());
Assert.assertGte(29, v.property("age"));
}
properties = ImmutableMap.of("age", "P.lt(29)");
vertices = graph().listVertices("person", properties);
Assert.assertEquals(1, vertices.size());
for (Vertex v : vertices) {
Assert.assertEquals("person", v.label());
Assert.assertLt(29, v.property("age"));
}
properties = ImmutableMap.of("age", "P.lte(29)");
vertices = graph().listVertices("person", properties);
Assert.assertEquals(3, vertices.size());
for (Vertex v : vertices) {
Assert.assertEquals("person", v.label());
Assert.assertLte(29, v.property("age"));
}
properties = ImmutableMap.of("age", "P.between(29,32)");
vertices = graph().listVertices("person", properties);
Assert.assertEquals(2, vertices.size());
for (Vertex v : vertices) {
Assert.assertEquals("person", v.label());
Assert.assertGte(29, v.property("age"));
Assert.assertLt(31, v.property("age"));
}
properties = ImmutableMap.of("age", "P.inside(27,32)");
vertices = graph().listVertices("person", properties);
Assert.assertEquals(2, vertices.size());
for (Vertex v : vertices) {
Assert.assertEquals("person", v.label());
Assert.assertGt(27, v.property("age"));
Assert.assertLt(32, v.property("age"));
}
properties = ImmutableMap.of("age", "P.within(27,32)");
vertices = graph().listVertices("person", properties);
Assert.assertEquals(2, vertices.size());
for (Vertex v : vertices) {
Assert.assertEquals("person", v.label());
Assert.assertThat(v.property("age"), CoreMatchers.anyOf(CoreMatchers.is(27), CoreMatchers.is(32)));
}
}
use of com.baidu.hugegraph.structure.graph.Vertex in project incubator-hugegraph-toolchain by apache.
the class VertexTest method testRemoveVertexPropertyNotExist.
@Test
public void testRemoveVertexPropertyNotExist() {
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());
Assert.assertThrows(InvalidOperationException.class, () -> {
vadas.removeProperty("not-exist");
});
}
Aggregations