neo4j/community — Issue #238: Support collecting of properties in Cypher
Author: peterneubauer
Created: 2012-02-14 11:01:48+00:00
State: open
Labels: cypher, feature

Here a sample test case, see https://groups.google.com/forum/?fromgroups#!topic/neo4j/y1vnfX3Hdaw

package org.neo4j.cypher.docgen.cookbook

import org.junit.Test
import org.junit.Assert._
import org.neo4j.cypher.docgen.DocumentingTestBase

class TreeInheritanceTest extends DocumentingTestBase {
def graphDescription = List("Top has Middle", "Middle has Leaf1","Middle has Leaf2")
override val properties: Map[String, Map[String, Any]] = Map(
"Top" -> Map("color" -> "red"),
"Middle" -> Map("age" -> 23),
"Leaf2" -> Map("color" -> "brown")
)
def section = "cookbook"

@Test def basicCollborativeFiltering() {
testQuery(
title = "",
text = """To extract the resulting color of Leaf2 if nodes higher up in the path are allowed to contribute to the result if it is null:""",
queryText = "start leaf=node:node_auto_index(name = \"Leaf1\") " +
"match p=leaf<-[:has*0..]-top " +
"return first(filter(x in extract(n in nodes(p) : n.color?) : x IS NOT NULL) as color)",
returns = "The resulting color for Leaf2, in this case red, collected from Top",
(p) => assertEquals(List(
Map("color" -> "red" -> 1)), p.toList))
}
}