Permalink
Browse files

Extended the simplified property reading/writing notation to support …

…Relationships
  • Loading branch information...
1 parent 7a09bb9 commit 4dee4c58a0ac8b0852e08fe9070daae0f12332ee @jawher jawher committed Nov 1, 2009
@@ -47,11 +47,11 @@ trait NeoConverters {
implicit def stringToRelationshipType(relType: String) = DynamicRelationshipType.withName(relType)
- class RichNode(node: Node) {
- def apply(property: String) = node.getProperty(property)
- def update(property: String, value: Any) : Unit = node.setProperty(property, value)
+ class RichPropertyContainer(propertyContainer: PropertyContainer) {
+ def apply(property: String) = propertyContainer.getProperty(property)
+ def update(property: String, value: Any) : Unit = propertyContainer.setProperty(property, value)
}
- implicit def nodeToRichNode(node: Node) = new RichNode(node)
+ implicit def propertyContainerToRichPropertyContainer(propertyContainer: PropertyContainer) = new RichPropertyContainer(propertyContainer)
}
@@ -86,21 +86,40 @@ class NeoConvertersSpec extends Spec with ShouldMatchers with NeoConverters {
}
}
- it("should read a property in a node('property') notation") {
+ it("should read a property in a node in node('property') notation") {
NeoServer.exec { neo =>
val start = neo.createNode
start.setProperty("foo", "bar")
start("foo") should equal("bar")
}
}
- it("should create a property in a node('property')=value notation") {
+ it("should create a property in a node in node('property')=value notation") {
NeoServer.exec { neo =>
val start = neo.createNode
start("foo") = "bar"
start.getProperty("foo") should equal("bar")
}
}
+ it("should read a property in a relationship in rel('property') notation") {
+ NeoServer.exec { neo =>
+ val start = neo.createNode
+ val end = neo.createNode
+ val rel = start.createRelationshipTo(end, DynamicRelationshipType.withName("foo"))
+ rel.setProperty("foo", "bar")
+ rel("foo") should equal("bar")
+ }
+ }
+
+ it("should create a property in a relationship in rel('property')=value notation") {
+ NeoServer.exec { neo =>
+ val start = neo.createNode
+ val end = neo.createNode
+ val rel = start.createRelationshipTo(end, DynamicRelationshipType.withName("foo"))
+ rel("foo") = "bar"
+ rel.getProperty("foo") should equal("bar")
+ }
+ }
}
}

0 comments on commit 4dee4c5

Please sign in to comment.