Skip to content

Commit

Permalink
Review comments and minor cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
systay committed Dec 14, 2015
1 parent 81504fa commit 37014b6
Show file tree
Hide file tree
Showing 36 changed files with 283 additions and 272 deletions.
Expand Up @@ -73,7 +73,7 @@ class CreateAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsT

test("create a single node with properties") {
val result = updateWithBothPlanners("create (n {prop: 'foo'}) return n.prop as p")
assertStats(result, nodesCreated = 1, propertiesSet = 1)
assertStats(result, nodesCreated = 1, propertiesWritten = 1)
// then
result.toList should equal(List(Map("p" -> "foo")))
}
Expand All @@ -85,7 +85,7 @@ class CreateAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsT
test("create node using null properties should just ignore those properties") {
// when
val result = updateWithBothPlanners("create (n {id: 12, property: null}) return n.id as id")
assertStats(result, nodesCreated = 1, propertiesSet = 1)
assertStats(result, nodesCreated = 1, propertiesWritten = 1)

// then
result.toList should equal(List(Map("id" -> 12)))
Expand All @@ -94,7 +94,7 @@ class CreateAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsT
test("create relationship using null properties should just ignore those properties") {
// when
val result = updateWithBothPlanners("create ()-[r:X {id: 12, property: null}]->() return r.id")
assertStats(result, nodesCreated = 2, relationshipsCreated = 1, propertiesSet = 1)
assertStats(result, nodesCreated = 2, relationshipsCreated = 1, propertiesWritten = 1)

// then
result.toList should equal(List(Map("r.id" -> 12)))
Expand Down Expand Up @@ -128,7 +128,7 @@ class CreateAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsT
test("create relationship with property") {
val result = updateWithBothPlanners("CREATE (a)-[r:R {prop: 42}]->(b)")

assertStats(result, nodesCreated = 2, relationshipsCreated = 1, propertiesSet = 1)
assertStats(result, nodesCreated = 2, relationshipsCreated = 1, propertiesWritten = 1)
}

test("creates relationship in correct direction") {
Expand Down Expand Up @@ -733,7 +733,7 @@ class CreateAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsT

val result = updateWithBothPlanners(query)

assertStats(result, nodesCreated = 171, relationshipsCreated = 253, propertiesSet = 564, labelsAdded = 171)
assertStats(result, nodesCreated = 171, relationshipsCreated = 253, propertiesWritten = 564, labelsAdded = 171)

}
}
Expand Up @@ -67,8 +67,8 @@ class CreateUniqueAcceptanceTest extends ExecutionEngineFunSuite with QueryStati
val res2 = execute(query, "param" -> nodeProps2)

//then
assertStats(res1, nodesCreated = 1, relationshipsCreated = 1, propertiesSet = 1, labelsAdded = 1)
assertStats(res2, nodesCreated = 0, relationshipsCreated = 0, propertiesSet = 0, labelsAdded = 0)
assertStats(res1, nodesCreated = 1, relationshipsCreated = 1, propertiesWritten = 1, labelsAdded = 1)
assertStats(res2, nodesCreated = 0, relationshipsCreated = 0, propertiesWritten = 0, labelsAdded = 0)
}

test("create_new_node_with_labels_on_the_left") {
Expand Down Expand Up @@ -139,7 +139,7 @@ class CreateUniqueAcceptanceTest extends ExecutionEngineFunSuite with QueryStati
val result = execute("match (a) where id(a) = 0 create unique (a)-[r:X]->({p}) return r", "p" -> nodeProps)
val createdRel = result.columnAs[Relationship]("r").toList.head

assertStats(result, relationshipsCreated = 1, nodesCreated = 1, propertiesSet = 1)
assertStats(result, relationshipsCreated = 1, nodesCreated = 1, propertiesWritten = 1)

val r = graph.inTx(a.getRelationships.asScala.head)

Expand All @@ -157,7 +157,7 @@ class CreateUniqueAcceptanceTest extends ExecutionEngineFunSuite with QueryStati
val result = execute("match (a) where id(a) = 0 create unique path=(a)-[:X]->({p}) return last(nodes(path))", "p" -> nodeProps)
val endNode = result.columnAs[Node]("last(nodes(path))").toList.head

assertStats(result, relationshipsCreated = 1, nodesCreated = 1, propertiesSet = 1)
assertStats(result, relationshipsCreated = 1, nodesCreated = 1, propertiesWritten = 1)
graph.inTx {
endNode.getProperty("name") should equal("Lasse")
}
Expand All @@ -170,7 +170,7 @@ class CreateUniqueAcceptanceTest extends ExecutionEngineFunSuite with QueryStati

val result = execute("match (n) where id(n) = 0 create unique (n)-[:REL]->(a {props1})-[:LER]->(b {props2}) return a,b", "props1"->props1, "props2"->props2)

assertStats(result, relationshipsCreated = 2, nodesCreated = 2, propertiesSet = 4)
assertStats(result, relationshipsCreated = 2, nodesCreated = 2, propertiesWritten = 4)
val resultMap = result.toList.head

graph.inTx {
Expand All @@ -189,7 +189,7 @@ class CreateUniqueAcceptanceTest extends ExecutionEngineFunSuite with QueryStati

val result = execute("match (n) where id(n) = 0 create unique p=(n)-[:REL]->({props1})-[:LER]->({props2}) return p", "props1"->props1, "props2"->props2)

assertStats(result, relationshipsCreated = 2, nodesCreated = 2, propertiesSet = 4)
assertStats(result, relationshipsCreated = 2, nodesCreated = 2, propertiesWritten = 4)
val path = result.toList.head("p").asInstanceOf[Path]

val lasse = path.endNode()
Expand Down Expand Up @@ -385,7 +385,7 @@ FOREACH(name in ['a','b','c'] |
return book
""")

assertStats(result, nodesCreated = 2, relationshipsCreated = 4, propertiesSet = 1)
assertStats(result, nodesCreated = 2, relationshipsCreated = 4, propertiesWritten = 1)

val book = result.toList.head("book").asInstanceOf[Node]

Expand Down Expand Up @@ -417,7 +417,7 @@ FOREACH(name in ['a','b','c'] |
)
""")

assertStats(result, nodesCreated = 1, relationshipsCreated = 1, propertiesSet = 1)
assertStats(result, nodesCreated = 1, relationshipsCreated = 1, propertiesWritten = 1)

graph.inTx {
val bookTags = tagRoot.getRelationships.asScala.map(_.getOtherNode(tagRoot)).map(_.getProperty("name")).toSet
Expand All @@ -438,7 +438,7 @@ CREATE UNIQUE
(b)-[:X]->(x)
RETURN x""")

assertStats(result, nodesCreated = 2, relationshipsCreated = 3, propertiesSet = 1)
assertStats(result, nodesCreated = 2, relationshipsCreated = 3, propertiesWritten = 1)
}

test("should_not_create_unnamed_parts_unnecessarily") {
Expand Down Expand Up @@ -466,7 +466,7 @@ CREATE UNIQUE
(b)-[:X]->(x)-[:X]->(z {foo:'buzz'})
RETURN x""")

assertStats(result, nodesCreated = 2, relationshipsCreated = 4, propertiesSet = 2)
assertStats(result, nodesCreated = 2, relationshipsCreated = 4, propertiesWritten = 2)
}

test("should_work_well_inside_foreach") {
Expand Down Expand Up @@ -521,15 +521,15 @@ RETURN value;""")
v1
*/

assertStats(result, nodesCreated = 4, relationshipsCreated = 4, propertiesSet = 6)
assertStats(result, nodesCreated = 4, relationshipsCreated = 4, propertiesWritten = 6)

val result2 = execute("""match (root) where id(root) = 0
CREATE (value { year:2012, month:5, day:12 })
WITH root,value
CREATE UNIQUE (root)-[:X]->(year {value:value.year})-[:X]->(month {value:value.month})-[:X]->(day {value:value.day})-[:X]->(value)
RETURN value;""")

assertStats(result2, nodesCreated = 2, relationshipsCreated = 2, propertiesSet = 4)
assertStats(result2, nodesCreated = 2, relationshipsCreated = 2, propertiesWritten = 4)

/*
root
Expand Down
Expand Up @@ -51,7 +51,7 @@ class LoadCsvAcceptanceTest

for (url <- urls) {
val result = execute(s"LOAD CSV FROM '$url' AS line CREATE (a {name: line[0]}) RETURN a.name")
assertStats(result, nodesCreated = 3, propertiesSet = 3)
assertStats(result, nodesCreated = 3, propertiesWritten = 3)
}
}

Expand All @@ -65,7 +65,7 @@ class LoadCsvAcceptanceTest
for (url <- urls) {
val result =
execute(s"LOAD CSV FROM '$url' AS line CREATE (a {number: line[0]}) RETURN a.number")
assertStats(result, nodesCreated = 3, propertiesSet = 3)
assertStats(result, nodesCreated = 3, propertiesWritten = 3)

result.columnAs[Long]("a.number").toList === List("")
}
Expand All @@ -80,7 +80,7 @@ class LoadCsvAcceptanceTest
})
for (url <- urls) {
val result = execute(s"LOAD CSV FROM '$url' AS line CREATE (a {name: line[0]}) RETURN a.name")
assertStats(result, nodesCreated = 3, propertiesSet = 3)
assertStats(result, nodesCreated = 3, propertiesWritten = 3)
}
}

Expand All @@ -97,7 +97,7 @@ class LoadCsvAcceptanceTest
s"LOAD CSV WITH HEADERS FROM '$url' AS line CREATE (a {id: line.id, name: line.name}) RETURN a.name"
)

assertStats(result, nodesCreated = 3, propertiesSet = 6)
assertStats(result, nodesCreated = 3, propertiesWritten = 6)
}
}

Expand Down Expand Up @@ -255,7 +255,7 @@ class LoadCsvAcceptanceTest
).cypherEscape

val result = execute(s"LOAD CSV FROM '$url' AS line CREATE (a {name: line[0]}) RETURN a.name")
assertStats(result, nodesCreated = 1, propertiesSet = 1)
assertStats(result, nodesCreated = 1, propertiesWritten = 1)
}

test("should be able to open relative paths with dotdot") {
Expand All @@ -265,7 +265,7 @@ class LoadCsvAcceptanceTest
).cypherEscape

val result = execute(s"LOAD CSV FROM '$url' AS line CREATE (a {name: line[0]}) RETURN a.name")
assertStats(result, nodesCreated = 1, propertiesSet = 1)
assertStats(result, nodesCreated = 1, propertiesWritten = 1)
}

test("should handle null keys in maps as result value") {
Expand Down Expand Up @@ -444,7 +444,7 @@ class LoadCsvAcceptanceTest
createNode(Map("prop" -> second))

val result = execute(s"MATCH (n) WITH n, '$first' as prefix LOAD CSV FROM prefix + n.prop AS line CREATE (a {name: line[0]}) RETURN a.name")
assertStats(result, nodesCreated = 3, propertiesSet = 3)
assertStats(result, nodesCreated = 3, propertiesWritten = 3)
}

private def ensureNoIllegalCharsInWindowsFilePath(filename: String) = {
Expand Down

0 comments on commit 37014b6

Please sign in to comment.