Module: SubscriptionsTestKit::SubscriptionsR5BackportR4Server::SubscriptionStatusOperation
- Included in:
- StatusInvocationTest
- Defined in:
- lib/subscriptions_test_kit/suites/subscriptions_r5_backport_r4_server/common/subscription_status_operation.rb
Instance Method Summary collapse
- #execute_subscription_status_operation(subscription_id) ⇒ Object
- #find_elem(resource_array, param_name) ⇒ Object
- #no_error_verification(message) ⇒ Object
- #perform_subscription_status_test(subscription_id, status = nil) ⇒ Object
- #subscription_ref_found?(entry, subscription_id) ⇒ Boolean
Instance Method Details
#execute_subscription_status_operation(subscription_id) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/subscriptions_test_kit/suites/subscriptions_r5_backport_r4_server/common/subscription_status_operation.rb', line 14 def execute_subscription_status_operation(subscription_id) fhir_operation("Subscription/#{subscription_id}/$status", operation_method: :get) assert_response_status(200) assert_resource_type('Bundle') unless resource.type == 'searchset' ('error', "Bundle returned from $status operation should be type 'searchset', was #{resource.type}") end assert_valid_resource resource.entry end |
#find_elem(resource_array, param_name) ⇒ Object
8 9 10 11 12 |
# File 'lib/subscriptions_test_kit/suites/subscriptions_r5_backport_r4_server/common/subscription_status_operation.rb', line 8 def find_elem(resource_array, param_name) resource_array.find do |param| param.name == param_name end end |
#no_error_verification(message) ⇒ Object
4 5 6 |
# File 'lib/subscriptions_test_kit/suites/subscriptions_r5_backport_r4_server/common/subscription_status_operation.rb', line 4 def no_error_verification() assert .none? { |msg| msg[:type] == 'error' }, end |
#perform_subscription_status_test(subscription_id, status = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/subscriptions_test_kit/suites/subscriptions_r5_backport_r4_server/common/subscription_status_operation.rb', line 37 def perform_subscription_status_test(subscription_id, status = nil) bundle_entries = execute_subscription_status_operation(subscription_id) subscription_status_entry = bundle_entries.find do |entry| entry.resource.resourceType == 'Parameters' && subscription_ref_found?(entry, subscription_id) end assert(subscription_status_entry, "No Subscription status with id #{subscription_id} returned from $status operation") subscription_status_resource = subscription_status_entry.resource assert_valid_resource(resource: subscription_status_resource, profile_url: 'http://hl7.org/fhir/uv/subscriptions-backport/StructureDefinition/backport-subscription-status-r4') subscription_status = find_elem(subscription_status_resource.parameter, 'status') return unless status.present? assert(subscription_status.valueCode == status, %( The Subscription resource should have it's `status` set to #{status}, was `#{subscription_status.valueCode}`)) end |
#subscription_ref_found?(entry, subscription_id) ⇒ Boolean
29 30 31 32 33 34 35 |
# File 'lib/subscriptions_test_kit/suites/subscriptions_r5_backport_r4_server/common/subscription_status_operation.rb', line 29 def subscription_ref_found?(entry, subscription_id) subscription_param = find_elem(entry.resource.parameter, 'subscription') subscription_ref = subscription_param.valueReference.reference return false if subscription_ref.blank? subscription_ref.split('/').last == subscription_id end |