Class: DaVinciPASTestKit::Generator::ClientMustSupportGroupGenerator
- Inherits:
-
Object
- Object
- DaVinciPASTestKit::Generator::ClientMustSupportGroupGenerator
- Defined in:
- lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb
Instance Attribute Summary collapse
-
#base_output_dir ⇒ Object
Returns the value of attribute base_output_dir.
-
#ig_metadata ⇒ Object
Returns the value of attribute ig_metadata.
-
#operation ⇒ Object
Returns the value of attribute operation.
-
#profiles ⇒ Object
Returns the value of attribute profiles.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#attestation_profiles_block(profile_metadatas) ⇒ Object
Formats a profiles list for an attestation test's config, one hash literal per line.
- #base_output_file_name ⇒ Object
-
#claim_profiles ⇒ Object
Collapsed request groups: the mandatory Claim profile(s) kept as standalone tests.
- #class_name ⇒ Object
- #description ⇒ Object
- #generate ⇒ Object
- #group_id ⇒ Object
- #ig_version ⇒ Object
- #ig_version_for_id ⇒ Object
-
#initialize(ig_metadata, operation, profiles, base_output_dir, type = 'request') ⇒ ClientMustSupportGroupGenerator
constructor
A new instance of ClientMustSupportGroupGenerator.
-
#mandatory_profile?(profile_metadata) ⇒ Boolean
The Claim (request) / ClaimResponse (response) profiles remain mandatory standalone tests.
- #module_name ⇒ Object
-
#optional_must_support_enabled? ⇒ Boolean
The collapsed attestation structure / optional response tests are only applied to v2.2.1.
-
#other_profiles ⇒ Object
Collapsed request groups: every other supporting profile, assessed by the attestation test.
- #other_profiles_title ⇒ Object
- #output ⇒ Object
- #output_file_name ⇒ Object
- #profile_identifier(profile_metadata) ⇒ Object
- #profile_identifier_for_profile(profile_metadata) ⇒ Object
- #profile_test_files ⇒ Object
- #profile_test_ids ⇒ Object
-
#profile_tests ⇒ Object
Response groups: pairs each per-profile test id with whether it should be marked optional.
- #request_profiles ⇒ Object
- #request_type ⇒ Object
- #required_profiles ⇒ Object
- #template ⇒ Object
- #template_file_name ⇒ Object
- #test_file_for_profile(profile_metadata) ⇒ Object
- #test_id_for_profile(profile_metadata) ⇒ Object
- #title ⇒ Object
- #verifies_requirements ⇒ Object
Constructor Details
#initialize(ig_metadata, operation, profiles, base_output_dir, type = 'request') ⇒ ClientMustSupportGroupGenerator
Returns a new instance of ClientMustSupportGroupGenerator.
33 34 35 36 37 38 39 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 33 def initialize(, operation, profiles, base_output_dir, type = 'request') self. = self.operation = operation self.profiles = profiles self.base_output_dir = base_output_dir self.type = type end |
Instance Attribute Details
#base_output_dir ⇒ Object
Returns the value of attribute base_output_dir.
31 32 33 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 31 def base_output_dir @base_output_dir end |
#ig_metadata ⇒ Object
Returns the value of attribute ig_metadata.
31 32 33 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 31 def @ig_metadata end |
#operation ⇒ Object
Returns the value of attribute operation.
31 32 33 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 31 def operation @operation end |
#profiles ⇒ Object
Returns the value of attribute profiles.
31 32 33 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 31 def profiles @profiles end |
#type ⇒ Object
Returns the value of attribute type.
31 32 33 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 31 def type @type end |
Class Method Details
.generate(ig_metadata, base_client_output_dir) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 8 def generate(, base_client_output_dir) submit_request_profiles = .profiles.select do |profile| MustSupportTargetProfiles.submit_request_profile?(profile) end new(, 'submit', submit_request_profiles, base_client_output_dir).generate submit_response_profiles = .profiles.select do |profile| MustSupportTargetProfiles.submit_response_profile?(profile) end new(, 'submit', submit_response_profiles, base_client_output_dir, 'response').generate inquire_request_profiles = .profiles.select do |profile| MustSupportTargetProfiles.inquire_request_profile?(profile) end new(, 'inquire', inquire_request_profiles, base_client_output_dir).generate inquire_response_profiles = .profiles.select do |profile| MustSupportTargetProfiles.inquire_response_profile?(profile) end new(, 'inquire', inquire_response_profiles, base_client_output_dir, 'response').generate end |
Instance Method Details
#attestation_profiles_block(profile_metadatas) ⇒ Object
Formats a profiles list for an attestation test's config, one hash literal per line.
181 182 183 184 185 186 187 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 181 def attestation_profiles_block() .map do || " { resource_type: '#{.resource}', " \ "profile_key: '#{profile_identifier()}', " \ "title: '#{.profile_name}' }" end.join(",\n") end |
#base_output_file_name ⇒ Object
53 54 55 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 53 def base_output_file_name "#{class_name.underscore}.rb" end |
#claim_profiles ⇒ Object
Collapsed request groups: the mandatory Claim profile(s) kept as standalone tests.
166 167 168 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 166 def claim_profiles required_profiles.select { || .resource == 'Claim' } end |
#class_name ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 57 def class_name if type == 'response' "PASClient#{operation.camelize}ResponseMustSupportGroup" else "PASClient#{operation.camelize}MustSupportGroup" end end |
#description ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 204 def description if type == 'response' <<~DESCRIPTION Check that `$#{operation}` responses provided to the client contain all PAS-defined profiles and their must support elements. **USER INPUT VALIDATION**: These tests validate responses provided by the tester, not the system under test. Errors will be treated as skips instead of failures. For `$#{operation}` responses, this includes the following profiles: #{Descriptions.profile_links_list(profiles, ig_version)} DESCRIPTION else <<~DESCRIPTION Check that the client can demonstrate `$#{operation}` requests that contain all PAS-defined profiles and their must support elements. For `$#{operation}` requests, this includes the following profiles: #{Descriptions.profile_links_list(required_profiles, ig_version, request_profiles: operation == 'submit' ? request_profiles : nil)} DESCRIPTION end end |
#generate ⇒ Object
109 110 111 112 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 109 def generate FileUtils.mkdir_p(base_output_dir) File.write(output_file_name, output) end |
#group_id ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 93 def group_id if type == 'response' "pas_client_#{ig_version_for_id}_#{operation}_response_must_support" else "pas_client_#{ig_version_for_id}_#{operation}_must_support" end end |
#ig_version ⇒ Object
101 102 103 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 101 def ig_version .ig_version end |
#ig_version_for_id ⇒ Object
105 106 107 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 105 def ig_version_for_id .reformatted_version end |
#mandatory_profile?(profile_metadata) ⇒ Boolean
The Claim (request) / ClaimResponse (response) profiles remain mandatory standalone tests.
151 152 153 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 151 def mandatory_profile?() %w[Claim ClaimResponse].include?(.resource) end |
#module_name ⇒ Object
65 66 67 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 65 def module_name "DaVinciPAS#{ig_version_for_id.upcase}" end |
#optional_must_support_enabled? ⇒ Boolean
The collapsed attestation structure / optional response tests are only applied to v2.2.1.
146 147 148 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 146 def optional_must_support_enabled? ig_version == 'v2.2.1' end |
#other_profiles ⇒ Object
Collapsed request groups: every other supporting profile, assessed by the attestation test.
171 172 173 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 171 def other_profiles required_profiles.reject { || .resource == 'Claim' } end |
#other_profiles_title ⇒ Object
175 176 177 178 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 175 def other_profiles_title 'All must support elements for other profiles referenced by Claim ' \ "#{operation == 'submit' ? 'submissions' : 'inquiries'} are observed on $#{operation} requests" end |
#output ⇒ Object
49 50 51 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 49 def output @output ||= ERB.new(template, trim_mode: '-').result(binding) end |
#output_file_name ⇒ Object
85 86 87 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 85 def output_file_name File.join(base_output_dir, base_output_file_name) end |
#profile_identifier(profile_metadata) ⇒ Object
89 90 91 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 89 def profile_identifier() .snake_case_for_profile() end |
#profile_identifier_for_profile(profile_metadata) ⇒ Object
136 137 138 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 136 def profile_identifier_for_profile() .snake_case_for_profile() end |
#profile_test_files ⇒ Object
189 190 191 192 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 189 def profile_test_files target_profiles = type == 'response' ? profiles : required_profiles target_profiles.map { || test_file_for_profile() } end |
#profile_test_ids ⇒ Object
140 141 142 143 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 140 def profile_test_ids target_profiles = type == 'response' ? profiles : required_profiles target_profiles.map { || test_id_for_profile() } end |
#profile_tests ⇒ Object
Response groups: pairs each per-profile test id with whether it should be marked optional.
156 157 158 159 160 161 162 163 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 156 def profile_tests profiles.map do || { id: test_id_for_profile(), optional: optional_must_support_enabled? && !mandatory_profile?() } end end |
#request_profiles ⇒ Object
120 121 122 123 124 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 120 def request_profiles @request_profiles = profiles.select do || MustSupportTargetProfiles.request_profile?() end end |
#request_type ⇒ Object
81 82 83 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 81 def request_type "#{operation}_#{type}" end |
#required_profiles ⇒ Object
114 115 116 117 118 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 114 def required_profiles @required_profiles = profiles.reject do || MustSupportTargetProfiles.request_profile?() end end |
#template ⇒ Object
41 42 43 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 41 def template @template ||= File.read(File.join(__dir__, 'templates', template_file_name)) end |
#template_file_name ⇒ Object
45 46 47 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 45 def template_file_name type == 'response' ? 'client_must_support_response_group.rb.erb' : 'client_must_support_group.rb.erb' end |
#test_file_for_profile(profile_metadata) ⇒ Object
131 132 133 134 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 131 def test_file_for_profile() profile_id = profile_identifier_for_profile() File.join(profile_id, "client_#{request_type}_must_support_#{profile_id}_test") end |
#test_id_for_profile(profile_metadata) ⇒ Object
126 127 128 129 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 126 def test_id_for_profile() "pas_client_#{.reformatted_version}_#{request_type}_" \ "must_support_#{profile_identifier_for_profile()}" end |
#title ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 69 def title if type == 'response' return '$submit Response Must Support Coverage' if operation == 'submit' '$inquire Response Must Support Coverage' else return '$submit Request Must Support Coverage' if operation == 'submit' '$inquire Request Must Support Coverage' end end |
#verifies_requirements ⇒ Object
194 195 196 197 198 199 200 201 202 |
# File 'lib/davinci_pas_test_kit/generator/client_must_support_group_generator.rb', line 194 def verifies_requirements case "#{operation}_#{ig_version}" when 'submit_v2.0.1' return nil if type == 'response' ['hl7.fhir.us.davinci-pas_2.0.1@58', 'hl7.fhir.us.davinci-pas_2.0.1@62', 'hl7.fhir.us.davinci-pas_2.0.1@70', 'hl7.fhir.us.davinci-pas_2.0.1@202'] end end |