Class: SubscriptionsTestKit::SubscriptionsR5BackportR4Client::InteractionTest

Inherits:
Inferno::Test
  • Object
show all
Defined in:
lib/subscriptions_test_kit/suites/subscriptions_r5_backport_r4_client/workflow/interaction_test.rb

Instance Method Summary collapse

Instance Method Details

#minimally_validate_notification(notification_bundle) ⇒ Object

Perform only the verification necessary for the Inferno test to function



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/subscriptions_test_kit/suites/subscriptions_r5_backport_r4_client/workflow/interaction_test.rb', line 109

def minimally_validate_notification(notification_bundle)
  assert_valid_json(notification_bundle)
  begin
    bundle = FHIR.from_contents(notification_bundle)
  rescue StandardError
    assert(false, 'Notification bundle input is not a conformant FHIR Bundle')
  end
  assert_resource_type(:bundle, resource: bundle)
  subscription_status = bundle.entry&.first&.resource
  assert(subscription_status.present?, 'Notification bundle input must contain a subscription status entry')
  assert_resource_type(:parameters, resource: subscription_status)

  # Require the subscription param, just because we need something to later identify the subscription status
  # bundle entry. Note we could just as easily use a different required param, like status or type.
  subscription_param = subscription_status.parameter&.find { |p| p.name == 'subscription' }
  assert(subscription_param.present?, 'Subscription status entry in notification bundle input must contain a' \
                                      'subscription parameter')
rescue Inferno::Exceptions::AssertionException => e
  add_message('error', e.message)
end