Search in sources :

Example 1 with TasksWithPage

use of com.baidu.hugegraph.api.task.TasksWithPage in project incubator-hugegraph-toolchain by apache.

the class TaskApiTest method testListByStatusAndPage.

@Test
public void testListByStatusAndPage() {
    IndexLabel personByCity = schema().getIndexLabel("personByCity");
    IndexLabel personByAge = schema().getIndexLabel("personByAge");
    IndexLabel knowsByDate = schema().getIndexLabel("knowsByDate");
    IndexLabel createdByDate = schema().getIndexLabel("createdByDate");
    Set<Long> taskIds = new HashSet<>();
    taskIds.add(rebuildAPI.rebuild(personByCity));
    taskIds.add(rebuildAPI.rebuild(personByAge));
    taskIds.add(rebuildAPI.rebuild(knowsByDate));
    taskIds.add(rebuildAPI.rebuild(createdByDate));
    taskIds.forEach(BaseApiTest::waitUntilTaskCompleted);
    TasksWithPage tasksWithPage = taskAPI.list("SUCCESS", "", 2);
    List<Task> tasks = tasksWithPage.tasks();
    Assert.assertEquals(2, tasks.size());
    Set<Long> listedTaskIds = new HashSet<>();
    for (Task task : tasks) {
        listedTaskIds.add(task.id());
    }
    tasksWithPage = taskAPI.list("SUCCESS", tasksWithPage.page(), 2);
    List<Task> tasks1 = tasksWithPage.tasks();
    Assert.assertEquals(2, tasks1.size());
    Assert.assertNull(tasksWithPage.page());
    for (Task task : tasks1) {
        listedTaskIds.add(task.id());
    }
    Assert.assertEquals(taskIds.size(), listedTaskIds.size());
    Assert.assertTrue(taskIds.containsAll(listedTaskIds));
}
Also used : Task(com.baidu.hugegraph.structure.Task) TasksWithPage(com.baidu.hugegraph.api.task.TasksWithPage) IndexLabel(com.baidu.hugegraph.structure.schema.IndexLabel) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

TasksWithPage (com.baidu.hugegraph.api.task.TasksWithPage)1 Task (com.baidu.hugegraph.structure.Task)1 IndexLabel (com.baidu.hugegraph.structure.schema.IndexLabel)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1