Skip to content

Commit a7fe304

Browse files
committed
Fix notification_config
1 parent 98c8715 commit a7fe304

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

jruby/neo4j/driver/ext/config_converter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def notification_config(minimum_severity: nil, disabled_categories: nil)
7070
org.neo4j.driver.internal.InternalNotificationConfig.new(
7171
value_of(org.neo4j.driver.internal.InternalNotificationSeverity, minimum_severity),
7272
disabled_categories
73-
&.map { |value| value_of(org.neo4j.driver.internal.InternalNotificationCategory, value) }
73+
&.map { |value| org.neo4j.driver.NotificationCategory.const_get(value.to_s.upcase) }
7474
&.then(&java.util.HashSet.method(:new)))
7575
end
7676

spec/neo4j/driver/dev_manual_examples_spec.rb

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,15 @@
8787

8888
it { is_expected.to be true }
8989
end
90+
91+
context 'Example 2.12. Notification config' do
92+
let(:config) { { notification_config: { minimum_severity: :warning, disabled_categories: [:hint, :generic] } } }
93+
94+
it { is_expected.to be true }
95+
end
9096
end
9197

92-
context 'Example 2.12. Service unavailable' do
98+
context 'Example 2.13. Service unavailable' do
9399
def add_item(driver)
94100
session = driver.session
95101
session.write_transaction { |tx| tx.run('CREATE (a:Item)') }
@@ -293,4 +299,27 @@ def match_person_nodes(tx)
293299
expect(add_employees('abc')).to eq(2)
294300
end
295301
end
302+
303+
context '5. Notification config' do
304+
subject do
305+
driver.session do |session|
306+
result = session.run(
307+
'MATCH p=shortestPath((:Person {name: $start})-[*]->(:Person {name: $end})) RETURN p',
308+
start: 'Alice',
309+
end: 'Bob'
310+
)
311+
result.consume.notifications.first&.code
312+
end
313+
end
314+
315+
context 'Example 5.1. Default severity and categories' do
316+
it { is_expected.to eq('Neo.ClientNotification.Statement.UnboundedVariableLengthPattern') }
317+
end
318+
319+
context 'Example 5.2. Custom severity and categories' do
320+
let(:config) { { notification_config: { minimum_severity: :warning, disabled_categories: [:hint, :generic] } } }
321+
322+
it { is_expected.not_to be nil }
323+
end
324+
end
296325
end

0 commit comments

Comments
 (0)