Skip to content

Instantly share code, notes, and snippets.

@chrisfjones
Created March 17, 2012 18:26
Show Gist options
  • Save chrisfjones/2063838 to your computer and use it in GitHub Desktop.
Save chrisfjones/2063838 to your computer and use it in GitHub Desktop.
gremlin spock radiohead
@Grapes([
@Grab("com.tinkerpop.gremlin:gremlin-groovy:1.5"),
@Grab("org.spockframework:spock-maven:0.6-groovy-1.8")
])
import com.tinkerpop.gremlin.groovy.*
import spock.lang.Specification
import spock.lang.Shared
import com.tinkerpop.blueprints.pgm.Graph
import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraphFactory
class HelloSpock extends Specification {
static {
Gremlin.load()
}
@Shared Graph g = TinkerGraphFactory.createTinkerGraph()
def setupSpec() {
g.clear()
g.addEdge(
null,
g.addVertex([type: "artist", name: "Radiohead"]),
g.addVertex([type: "artist", name: "Arcade Fire"]),
"SIMILAR_TO"
)
}
def "Radiohead is similar to Arcade Fire"() {
expect:
g.getVertex(0) == g.V.filter{it.name == "Radiohead"}.next()
g.getVertex(1) == g.V.filter{it.name == "Arcade Fire"}.next()
"Arcade Fire" == g.v(0).filter{it.type == "artist"}.out("SIMILAR_TO").next().name
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment