Search in sources :

Example 31 with SchemaManager

use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.

the class VertexLabelTest method testEliminateVertexLabelWithUserData.

@Test
public void testEliminateVertexLabelWithUserData() {
    SchemaManager schema = schema();
    VertexLabel player = schema.vertexLabel("player").properties("name").userdata("super_vl", "person").userdata("icon", "picture1").create();
    Assert.assertEquals(3, player.userdata().size());
    Assert.assertEquals("person", player.userdata().get("super_vl"));
    Assert.assertEquals("picture1", player.userdata().get("icon"));
    String time = (String) player.userdata().get("~create_time");
    Date createTime = DateUtil.parse(time);
    Assert.assertTrue(createTime.before(DateUtil.now()));
    player = schema.vertexLabel("player").userdata("icon", "").eliminate();
    Assert.assertEquals(2, player.userdata().size());
    Assert.assertEquals("person", player.userdata().get("super_vl"));
    time = (String) player.userdata().get("~create_time");
    Assert.assertEquals(createTime, DateUtil.parse(time));
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) Date(java.util.Date) Test(org.junit.Test)

Example 32 with SchemaManager

use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.

the class VertexLabelTest method testAddVertexLabelWithUserData.

@Test
public void testAddVertexLabelWithUserData() {
    SchemaManager schema = schema();
    VertexLabel player = schema.vertexLabel("player").properties("name").userdata("super_vl", "person").create();
    Assert.assertEquals(2, player.userdata().size());
    Assert.assertEquals("person", player.userdata().get("super_vl"));
    String time = (String) player.userdata().get("~create_time");
    Date createTime = DateUtil.parse(time);
    Assert.assertTrue(createTime.before(DateUtil.now()));
    VertexLabel runner = schema.vertexLabel("runner").properties("name").userdata("super_vl", "person").userdata("super_vl", "player").create();
    // The same key user data will be overwritten
    Assert.assertEquals(2, runner.userdata().size());
    Assert.assertEquals("player", runner.userdata().get("super_vl"));
    time = (String) runner.userdata().get("~create_time");
    createTime = DateUtil.parse(time);
    Assert.assertTrue(createTime.before(DateUtil.now()));
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) Date(java.util.Date) Test(org.junit.Test)

Example 33 with SchemaManager

use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.

the class VertexLabelTest method testRemoveVertexLabelSync.

@Test
public void testRemoveVertexLabelSync() {
    SchemaManager schema = schema();
    schema.vertexLabel("player").properties("name").create();
    // Remove vertex label sync
    schema.removeVertexLabel("player");
    schema.vertexLabel("player").properties("name").create();
    // Remove vertex label sync with timeout
    schema.removeVertexLabel("player", 10);
}
Also used : SchemaManager(com.baidu.hugegraph.driver.SchemaManager) Test(org.junit.Test)

Example 34 with SchemaManager

use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.

the class VertexLabelTest method testListByNames.

@Test
public void testListByNames() {
    SchemaManager schema = schema();
    VertexLabel player = schema.vertexLabel("player").create();
    VertexLabel runner = schema.vertexLabel("runner").create();
    List<VertexLabel> vertexLabels;
    vertexLabels = schema.getVertexLabels(ImmutableList.of("player"));
    Assert.assertEquals(1, vertexLabels.size());
    assertContains(vertexLabels, player);
    vertexLabels = schema.getVertexLabels(ImmutableList.of("runner"));
    Assert.assertEquals(1, vertexLabels.size());
    assertContains(vertexLabels, runner);
    vertexLabels = schema.getVertexLabels(ImmutableList.of("player", "runner"));
    Assert.assertEquals(2, vertexLabels.size());
    assertContains(vertexLabels, player);
    assertContains(vertexLabels, runner);
}
Also used : VertexLabel(com.baidu.hugegraph.structure.schema.VertexLabel) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) Test(org.junit.Test)

Example 35 with SchemaManager

use of com.baidu.hugegraph.driver.SchemaManager in project incubator-hugegraph-toolchain by apache.

the class VertexLabelTest method testRemoveVertexLabelASync.

@Test
public void testRemoveVertexLabelASync() {
    SchemaManager schema = schema();
    schema.vertexLabel("player").properties("name").create();
    // Remove vertex label async and wait
    long taskId = schema.removeVertexLabelAsync("player");
    Task task = task().waitUntilTaskCompleted(taskId, 10);
    Assert.assertTrue(task.completed());
}
Also used : Task(com.baidu.hugegraph.structure.Task) SchemaManager(com.baidu.hugegraph.driver.SchemaManager) Test(org.junit.Test)

Aggregations

SchemaManager (com.baidu.hugegraph.driver.SchemaManager)61 Test (org.junit.Test)39 Vertex (com.baidu.hugegraph.structure.graph.Vertex)18 Date (java.util.Date)14 GraphManager (com.baidu.hugegraph.driver.GraphManager)11 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)11 EdgeLabel (com.baidu.hugegraph.structure.schema.EdgeLabel)9 HugeClient (com.baidu.hugegraph.driver.HugeClient)8 BeforeClass (org.junit.BeforeClass)8 PropertyKey (com.baidu.hugegraph.structure.schema.PropertyKey)7 VertexLabel (com.baidu.hugegraph.structure.schema.VertexLabel)6 Edge (com.baidu.hugegraph.structure.graph.Edge)4 ArrayList (java.util.ArrayList)3 PropertyIndex (com.baidu.hugegraph.entity.schema.PropertyIndex)2 Task (com.baidu.hugegraph.structure.Task)2 Result (com.baidu.hugegraph.structure.gremlin.Result)2 ResultSet (com.baidu.hugegraph.structure.gremlin.ResultSet)2 BaseClientTest (com.baidu.hugegraph.BaseClientTest)1 GremlinManager (com.baidu.hugegraph.driver.GremlinManager)1 LoadOptions (com.baidu.hugegraph.loader.executor.LoadOptions)1