Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testkit backend implementation #217

Draft
wants to merge 2 commits into
base: 5.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions testkit-backend/lib/testkit/backend/custom_driver_error.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Testkit
module Backend
class CustomDriverError < RuntimeError
def initialize(cause)
super
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Testkit::Backend::Messages
class AbstractResultNext < Request
def process
result = fetch(result_id)
result.has_next? ? named_entity('Record', values: result.peek.values.map(&method(:to_testkit))) : named_entity('NullRecord')
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Testkit::Backend::Messages
module Requests
class BookmarkManagerClose < Request
def process
reference('BookmarkManager')
end

def to_object
delete(id).tap(&:close)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Testkit::Backend::Messages
module Requests
class BookmarksSupplierCompleted < Request
def process
bookmarks = fetch(request_id).bookmarks
named_entity('BookmarksSupplierRequest', id: bookmarks.id, bookmarkManagerId: bookmarks.bookmark_manager_id, database: bookmarks.database)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Testkit::Backend::Messages
module Requests
class CypherTypeField < AbstractResultNext
def process
reference('BookmarkManager')
end

def to_object
delete(id).tap(&:close)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Testkit::Backend::Messages
module Requests
class NewBookmarkManager < Request
def process
reference('NewBookmarkManager')
end

def to_object
fetch(id).bookmarks(initial_bookmarks: initial_bookmarks,
bookmarks_supplier_registered: bookmarks_supplier_registered,
bookmarks_consumer_registered:bookmarks_consumer_registered)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Testkit::Backend::Messages
module Requests
class TestkitBookmarksConsumer
def accept(database, bookmarks)
fetch(request_id).bookmarks(id: id, bookmark_manager_id: bookmark_manager_id, database: database)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Testkit::Backend::Messages
module Requests
class TestkitBookmarksSupplier
def bookmarks_from_testkit(database)
fetch(request_id).bookmarks(id: id, bookmark_manager_id: bookmark_manager_id, database: database)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module Testkit
module Backend
class ReactiveTransactionContextAdapter
def initialize(delegate)
@delegate = delegate
end

def run(query, parameters = {})
parameters.present? ? @delegate.run(query, parameters) : @delegate.run(query)
end

def commit
raise java.lang.UnsupportedOperationException, "commit is not allowed on transaction context"
end

def roll_back
raise java.lang.UnsupportedOperationException, "roll_back is not allowed on transaction context"
end

def close
raise java.lang.UnsupportedOperationException, "close is not allowed on transaction context"
end

def open?
raise java.lang.UnsupportedOperationException, "open? is not allowed on transaction context"
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module Testkit
module Backend
class ReactiveTransactionContextStreamsAdapter
def initialize(delegate)
@delegate = delegate
end

def run(query, parameters = {})
parameters.present? ? @delegate.run(query, parameters) : @delegate.run(query)
end

def commit
raise java.lang.UnsupportedOperationException, "commit is not allowed on transaction context"
end

def roll_back
raise java.lang.UnsupportedOperationException, "roll_back is not allowed on transaction context"
end

def close
raise java.lang.UnsupportedOperationException, "close is not allowed on transaction context"
end

def open?
raise java.lang.UnsupportedOperationException, "open? is not allowed on transaction context"
end
end
end
end