Exemplo n.º 1
0
 @Test
 public void shouldBeAbleToTraverseWithMaxDepthAndPruneEvaluatorCombined() {
   long startNode = createBasicTraversableGraph();
   List<Object> hits =
       serialize(
           actions.traverse(
               startNode,
               MapUtil.map(
                   "max_depth",
                   2,
                   "prune_evaluator",
                   MapUtil.map(
                       "language",
                       "javascript",
                       "body",
                       "position.endNode().getProperty('name').equals('Emil')")),
               TraverserReturnType.node));
   assertEquals(3, hits.size());
   hits =
       serialize(
           actions.traverse(
               startNode,
               MapUtil.map(
                   "max_depth",
                   1,
                   "prune_evaluator",
                   MapUtil.map(
                       "language",
                       "javascript",
                       "body",
                       "position.endNode().getProperty('name').equals('Emil')")),
               TraverserReturnType.node));
   assertEquals(2, hits.size());
 }
Exemplo n.º 2
0
 @Test
 public void shouldBeAbleToTraverseEverything() {
   long startNode = createBasicTraversableGraph();
   List<Object> hits =
       serialize(
           actions.traverse(
               startNode,
               MapUtil.map(
                   "return_filter",
                   MapUtil.map("language", "javascript", "body", "true;"),
                   "max_depth",
                   10),
               TraverserReturnType.node));
   assertEquals(6, hits.size());
   hits =
       serialize(
           actions.traverse(
               startNode,
               MapUtil.map(
                   "return_filter",
                   MapUtil.map("language", "builtin", "name", "all"),
                   "max_depth",
                   10),
               TraverserReturnType.node));
   assertEquals(6, hits.size());
 }
Exemplo n.º 3
0
 @Test
 public void shouldBeAbleToTraverseDepthTwo() {
   long startNode = createBasicTraversableGraph();
   List<Object> hits =
       serialize(
           actions.traverse(startNode, MapUtil.map("max_depth", 2), TraverserReturnType.node));
   assertEquals(3, hits.size());
 }
Exemplo n.º 4
0
 @Test
 public void shouldBeAbleToTraverseWithDefaultParameters() {
   long startNode = createBasicTraversableGraph();
   List<Object> hits =
       serialize(
           actions.traverse(startNode, new HashMap<String, Object>(), TraverserReturnType.node));
   assertEquals(2, hits.size());
 }
Exemplo n.º 5
0
 @Test
 public void shouldBeAbleToGetRelationshipsIfSpecified() {
   long startNode = createBasicTraversableGraph();
   ListRepresentation traverse =
       actions.traverse(
           startNode, new HashMap<String, Object>(), TraverserReturnType.relationship);
   List<Object> hits = serialize(traverse);
   for (Object hit : hits) {
     RelationshipRepresentationTest.verifySerialisation((Map<String, Object>) hit);
   }
 }
Exemplo n.º 6
0
  @Test
  public void shouldBeAbleToGetPathsIfSpecified() {
    long startNode = createBasicTraversableGraph();
    List<Object> hits =
        serialize(
            actions.traverse(startNode, new HashMap<String, Object>(), TraverserReturnType.path));

    for (Object hit : hits) {
      Map<String, Object> map = (Map<String, Object>) hit;
      assertThat(map, hasKey("start"));
      assertThat(map, hasKey("end"));
      assertThat(map, hasKey("length"));
    }
  }
Exemplo n.º 7
0
 @Test
 public void shouldBeAbleToUseCustomReturnFilter() {
   long startNode = createBasicTraversableGraph();
   List<Object> hits =
       serialize(
           actions.traverse(
               startNode,
               MapUtil.map(
                   "prune_evaluator",
                   MapUtil.map("language", "builtin", "name", "none"),
                   "return_filter",
                   MapUtil.map(
                       "language",
                       "javascript",
                       "body",
                       "position.endNode().getProperty( 'name' ).contains( 'o' )")),
               TraverserReturnType.node));
   assertEquals(3, hits.size());
 }
Exemplo n.º 8
0
  @Test
  public void shouldBeAbleToGetFullPathsIfSpecified() {
    long startNode = createBasicTraversableGraph();
    List<Object> hits =
        serialize(
            actions.traverse(
                startNode, new HashMap<String, Object>(), TraverserReturnType.fullpath));

    for (Object hit : hits) {
      Map<String, Object> map = (Map<String, Object>) hit;
      Collection<Object> relationships = (Collection<Object>) map.get("relationships");
      for (Object relationship : relationships) {
        RelationshipRepresentationTest.verifySerialisation((Map<String, Object>) relationship);
      }
      Collection<Object> nodes = (Collection<Object>) map.get("nodes");
      for (Object node : nodes) {
        NodeRepresentationTest.verifySerialisation((Map<String, Object>) node);
      }
      assertThat(map, hasKey("start"));
      assertThat(map, hasKey("end"));
      assertThat(map, hasKey("length"));
    }
  }