GremlinExecutor { <T> List<T> executeGremlin(GraphTraversalSource traversalSource, String gremlin) { return executeGremlin(traversalSource, gremlin, Collections.emptyMap()); } GremlinExecutor(GraphConverter converter);   }
@Test public void shouldExecuteQueryEdges() { List<EdgeEntity> edges = executor.executeGremlin(graph.traversal(), "g.E()"); assertFalse(edges.isEmpty()); EdgeEntity edgeEntity = edges.get(0); Person person = edgeEntity.getIncoming(); Person person2 = edgeEntity.getOutgoing(); assertEquals("loves", edgeEntity.getLabel()); assertEquals("Bruce Banner", person2.getName()); assertEquals("Natasha Romanoff", person.getName()); }
@Test public void shouldExecuteQueryEdges2() { List<EdgeEntity> edges = executor.executeGremlin(graph.traversal(), "g.E().toList()"); assertFalse(edges.isEmpty()); EdgeEntity edgeEntity = edges.get(0); Person person = edgeEntity.getIncoming(); Person person2 = edgeEntity.getOutgoing(); assertEquals("loves", edgeEntity.getLabel()); assertEquals("Bruce Banner", person2.getName()); assertEquals("Natasha Romanoff", person.getName()); }
@Test public void shouldExecuteQueryVertex() { List<Person> people = executor.executeGremlin(graph.traversal(), "g.V()"); assertFalse(people.isEmpty()); List<String> names = people.stream().map(Person::getName).collect(Collectors.toList()); assertThat(names, containsInAnyOrder("Bruce Banner", "Natasha Romanoff")); }
@Test public void shouldExecuteQueryVertex2() { List<Person> people = executor.executeGremlin(graph.traversal(), "g.V().toList()"); assertFalse(people.isEmpty()); List<String> names = people.stream().map(Person::getName).collect(Collectors.toList()); assertThat(names, containsInAnyOrder("Bruce Banner", "Natasha Romanoff")); }
@Test public void shouldExecuteQueryVertex3() { List<Person> people = executor.executeGremlin(graph.traversal(), "g.V().in('loves').toList()"); assertFalse(people.isEmpty()); List<String> names = people.stream().map(Person::getName).collect(Collectors.toList()); assertThat(names, containsInAnyOrder("Bruce Banner")); }
@Test public void shouldExecuteQueryCount() { List<Long> count = executor.executeGremlin(graph.traversal(), "g.V().count().toList()"); assertFalse(count.isEmpty()); assertThat(count, containsInAnyOrder(2L)); }
@Test public void shouldExecuteQueryCoun2() { List<Long> count = executor.executeGremlin(graph.traversal(), "g.V().count()"); assertFalse(count.isEmpty()); assertThat(count, containsInAnyOrder(2L)); }
@Test public void shouldExecuteQueryProperties() { List<Object> properties = executor.executeGremlin(graph.traversal(), "g.V().values()"); assertFalse(properties.isEmpty()); assertEquals(4, properties.size()); assertThat(properties, containsInAnyOrder("Bruce Banner", 30, 30, "Natasha Romanoff")); }
@Test public void shouldExecuteQueryProperties2() { List<Object> properties = executor.executeGremlin(graph.traversal(), "g.V().values().toList()"); assertFalse(properties.isEmpty()); assertEquals(4, properties.size()); assertThat(properties, containsInAnyOrder("Bruce Banner", 30, 30, "Natasha Romanoff")); }
@Test public void shouldExecuteQueryPropertiesMap() { List<Map<String, List<String>>> properties = executor.executeGremlin(graph.traversal(), "g.V().valueMap('name')"); assertFalse(properties.isEmpty()); assertEquals(2, properties.size()); List<String> names = properties.stream().map(p -> p.get("name")).flatMap(List::stream).collect(Collectors.toList()); assertThat(names, containsInAnyOrder("Bruce Banner", "Natasha Romanoff")); }
@Test public void shouldExecuteQueryPropertiesMap2() { List<Map<String, List<String>>> properties = executor.executeGremlin(graph.traversal(), "g.V().valueMap('name').toList()"); assertFalse(properties.isEmpty()); assertEquals(2, properties.size()); List<String> names = properties.stream().map(p -> p.get("name")).flatMap(List::stream).collect(Collectors.toList()); assertThat(names, containsInAnyOrder("Bruce Banner", "Natasha Romanoff")); }
@Test public void shouldExecuteWithParams() { List<Person> people = executor.executeGremlin(graph.traversal(), "g.V().in(param).toList()",singletonMap("param", "loves")); assertFalse(people.isEmpty()); List<String> names = people.stream().map(Person::getName).collect(Collectors.toList()); assertThat(names, containsInAnyOrder("Bruce Banner")); }