Skip to content

Instantly share code, notes, and snippets.

View okram's full-sized avatar
🏠
Working from home

Marko A. Rodriguez okram

🏠
Working from home
View GitHub Profile
[
[
"marko",
{
"author": "stephen",
"time": 1
}
],
[
"mrodriguez",
"marko"
[
"marko",
{
"author": "stephen",
"time": 1
}
]
Gremlin.of(g).V()
.match("a", "b",
Gremlin.of().as("a").out("knows").has("name", "josh"),
Gremlin.of().as("a").out("created").has("name", "lop"),
Gremlin.of().as("a").out("created").as("b"))
.value("name").path()
Stream.of(gremlinTestBaseClass.getDeclaredMethods())
.forEach(m -> {
try {
assertNotNull(testClass.getDeclaredMethod(m.getName()).getAnnotation(Test.class));
} catch (final NoSuchMethodException e) {
fail(String.format("Base test method from gremlin-test [%s] not found in test implementation %s",
m.getName(), testClass));
}
});
Gremlin.of(g).V().as("x").out().jump("x", o -> o.getLoops() < 2).path().forEach(System.out::println);
Gremlin.of(g).V().as("x").jump("y", o -> o.getLoops() > 1).out().jump("x").path().as("y").forEach(System.out::println);
@Test
public void g_V_hasXname_markoX() {
super.g_V_hasXname_markoX(new GremlinResultIterable<Vertex>(g, () -> Gremlin.of().has("name", "marko")).iterator());
}
@Test
public void shouldSerializeLambda() throws Exception {
ByteArrayOutputStream outBytes = new ByteArrayOutputStream(10);
ObjectOutputStream out = new ObjectOutputStream(outBytes);
out.writeObject((Predicate) e -> true);
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(outBytes.toByteArray()));
Predicate predicate = (Predicate) in.readObject();
assertTrue(predicate.test(null));
}
@Test
public void shouldSerializeLambda() throws Exception {
ByteArrayOutputStream outBytes = new ByteArrayOutputStream(10);
ObjectOutputStream out = new ObjectOutputStream(outBytes);
final SerializedPredicate predicate = e -> true;
out.writeObject(predicate);
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(outBytes.toByteArray()));
Predicate p = (Predicate) in.readObject();
assertTrue(p.test(null));
@Test
public void testUnion() {
Graph g = TinkerFactory.createClassic();
Gremlin.of(g).v(1).union(
Gremlin.of().out("knows"),
Gremlin.of().out("created").in("created")
).value("name").forEach(System.out::println);
}