Skip to content

Instantly share code, notes, and snippets.

@eugene-kamenev
Created July 30, 2015 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eugene-kamenev/c8c44373ef0b6a9167cb to your computer and use it in GitHub Desktop.
Save eugene-kamenev/c8c44373ef0b6a9167cb to your computer and use it in GitHub Desktop.
Reproducing issue with orientdb-groovy
@OrientDocument
@CompileStatic
class Process {
String name
ProcessNode startNode
ProcessNode endNode
Set<Tag> tags
static mapping = {
tags(type: OType.EMBEDDEDLIST)
}
}
@Vertex
@CompileStatic
class ProcessNode {
String name
}
@Vertex
@CompileStatic
class Tag {
String title
}
class TestSpec extends Specification {
@Shared
OrientGraphFactory factory
@Shared
ODatabaseDocumentTx db
def setup() {
factory = new OrientGraphFactory('memory:test', 'admin', 'admin')
db = factory.getDatabase()
if (!db.exists()) {
db.create()
}
}
def cleanup() {
factory.close()
}
def 'test entity persistence'() {
given: 'persist entities'
def processes = []
10.times {
processes << new Process(name: "Simple Name ${it}")
}
when: 'commit'
db.begin()
processes*.save()
db.commit()
then: 'query database with extension method transaction'
processes.clear()
factory.withTransaction { graph ->
processes = Process.executeQuery('select from Process')
}
expect:
processes.size() == 10
processes[0].name == 'Simple Name 0'
processes[1].name == 'Simple Name 1'
processes[2].name == 'Simple Name 2'
processes[3].name == 'Simple Name 3'
processes[4].name == 'Simple Name 4'
processes[5].name == 'Simple Name 5'
processes[6].name == 'Simple Name 6'
processes[7].name == 'Simple Name 7'
processes[8].name == 'Simple Name 8'
processes[9].name == 'Simple Name 9'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment