Search in sources :

Example 56 with Vertex

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());
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) Test(org.junit.Test) BaseClientTest(com.baidu.hugegraph.BaseClientTest)

Example 57 with Vertex

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());
    }
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) Test(org.junit.Test) BaseClientTest(com.baidu.hugegraph.BaseClientTest)

Example 58 with Vertex

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));
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex)

Example 59 with 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());
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) Test(org.junit.Test) BaseClientTest(com.baidu.hugegraph.BaseClientTest)

Example 60 with Vertex

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());
}
Also used : Vertex(com.baidu.hugegraph.structure.graph.Vertex) Test(org.junit.Test) BaseClientTest(com.baidu.hugegraph.BaseClientTest)

Aggregations

Vertex (com.baidu.hugegraph.structure.graph.Vertex)165 Test (org.junit.Test)110 Edge (com.baidu.hugegraph.structure.graph.Edge)33 HugeClient (com.baidu.hugegraph.driver.HugeClient)22 ArrayList (java.util.ArrayList)21 SchemaManager (com.baidu.hugegraph.driver.SchemaManager)18 BaseClientTest (com.baidu.hugegraph.BaseClientTest)17 BeforeClass (org.junit.BeforeClass)17 GraphManager (com.baidu.hugegraph.driver.GraphManager)14 BatchVertexRequest (com.baidu.hugegraph.structure.graph.BatchVertexRequest)13 Path (com.baidu.hugegraph.structure.graph.Path)11 Result (com.baidu.hugegraph.structure.gremlin.Result)10 ResultSet (com.baidu.hugegraph.structure.gremlin.ResultSet)10 List (java.util.List)10 BaseApiTest (com.baidu.hugegraph.api.BaseApiTest)9 ImmutableList (com.google.common.collect.ImmutableList)6 ImmutableMap (com.google.common.collect.ImmutableMap)6 Map (java.util.Map)6 RestResult (com.baidu.hugegraph.rest.RestResult)5 PathsWithVertices (com.baidu.hugegraph.structure.traverser.PathsWithVertices)5