use of org.janusgraph.graphdb.query.vertex.VertexLongList in project janusgraph by JanusGraph.
the class VertexListTest method testLists.
@Test
public void testLists() {
int num = 13;
JanusGraph g = JanusGraphFactory.open("inmemory");
StandardJanusGraphTx tx = (StandardJanusGraphTx) g.newTransaction();
VertexLongList vll = new VertexLongList(tx);
VertexArrayList val = new VertexArrayList(tx);
for (int i = 0; i < num; i++) {
JanusGraphVertex v = tx.addVertex();
vll.add(v);
val.add(v);
}
assertEquals(num, Iterables.size(vll));
assertEquals(num, Iterables.size(val));
vll.sort();
val.sort();
assertTrue(vll.isSorted());
assertTrue(val.isSorted());
for (Iterable<JanusGraphVertex> iterable : new Iterable[] { val, vll }) {
Iterator<JanusGraphVertex> iterator = iterable.iterator();
JanusGraphVertex previous = null;
for (int i = 0; i < num; i++) {
JanusGraphVertex next = iterator.next();
if (previous != null)
assertTrue(previous.longId() < next.longId());
previous = next;
}
try {
iterator.next();
fail();
} catch (NoSuchElementException ignored) {
}
}
tx.commit();
g.close();
}
Aggregations