Class: Crucible::Tests::ConnectathonTerminologyTrackTest

Inherits:
BaseSuite show all
Defined in:
lib/tests/suites/connectathon_terminology_track.rb

Constant Summary

Constants inherited from BaseTest

BaseTest::BASE_SPEC_LINK, BaseTest::JSON_FIELDS, BaseTest::METADATA_FIELDS, BaseTest::REST_SPEC_LINK, BaseTest::STATUS

Instance Attribute Summary

Attributes inherited from BaseTest

#category, #tags, #tests_subset

Instance Method Summary collapse

Methods inherited from BaseSuite

#build_messages, #collect_metadata, #fhir_resources, #links, #metadata, #parse_operation_outcome, #requires, #resource_category, test, #title, #validates

Methods inherited from BaseTest

#author, #details, #execute, #execute_test_method, #execute_test_methods, #multiserver, #requires_authorization, #tests, #warning

Methods included from Assertions

#assert, #assert_bundle_entry_count, #assert_bundle_response, #assert_bundle_transactions_okay, #assert_equal, #assert_etag_present, #assert_last_modified_present, #assert_minimum, #assert_navigation_links, #assert_operator, #assert_resource_content_type, #assert_resource_type, #assert_response_bad, #assert_response_code, #assert_response_created, #assert_response_gone, #assert_response_not_found, #assert_response_ok, #assert_valid_content_location_present, #assert_valid_profile, #assert_valid_resource_content_type_present, #assertion_negated, #skip

Constructor Details

#initialize(client1, client2 = nil) ⇒ ConnectathonTerminologyTrackTest

Returns a new instance of ConnectathonTerminologyTrackTest.



13
14
15
16
# File 'lib/tests/suites/connectathon_terminology_track.rb', line 13

def initialize(client1, client2=nil)
  super(client1, client2)
  @category = {id: 'connectathon', title: 'Connectathon'}
end

Instance Method Details

#check_expansion_for_concepts(vs) ⇒ Object

[‘GET’,‘POST’].each



208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/tests/suites/connectathon_terminology_track.rb', line 208

def check_expansion_for_concepts(vs)
  assert(vs.expansion,'ValueSet should contain expansion.')
  assert(vs.expansion.contains,'ValueSet.expansion.contains elements are missing.')

  concepts = vs.expansion.contains.map{|c|c.code}

  expansion_missing = FHIR::ElementDefinition::TypeRefComponent::VALID_CODES[:code] - concepts
  expansion_added = concepts - FHIR::ElementDefinition::TypeRefComponent::VALID_CODES[:code]

  assert(expansion_missing.empty?,"ValueSet expansion is missing the following concepts: #{expansion_missing}")
  assert(expansion_added.empty?,"ValueSet expansion contained some unexpected concepts: #{expansion_added}")        
end

#check_response_params(contents, name, attribute, value) ⇒ Object



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/tests/suites/connectathon_terminology_track.rb', line 221

def check_response_params(contents,name,attribute,value)
  begin
    doc = Nokogiri::XML(contents)
    if doc.errors.empty?
      doc.root.add_namespace_definition('fhir', 'http://hl7.org/fhir')
      doc.root.add_namespace_definition('xhtml', 'http://www.w3.org/1999/xhtml')
      e = doc.root.xpath("./fhir:parameter[fhir:name[@value=\"#{name}\"]]/fhir:#{attribute}").first
      assert(e[:value]==value,"Output parameters do not contain #{name}=#{value}")
    else
      hash = JSON.parse(contents)
      params = hash['parameter']
      p = params.select{|p|p['name']==name}.first
      assert(p[attribute]==value,"Output parameters do not contain #{name}=#{value}")
    end
  rescue Exception => e
    raise AssertionException.new 'Unable to parse response parameters', e.message
  end
end

#descriptionObject



9
10
11
# File 'lib/tests/suites/connectathon_terminology_track.rb', line 9

def description
  'Connectathon Terminology Track focuses on the $expand, $validate-code, $lookup, and $translate operations.'
end

#idObject



5
6
7
# File 'lib/tests/suites/connectathon_terminology_track.rb', line 5

def id
  'ConnectathonTerminologyTrackTest'
end

#setupObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/tests/suites/connectathon_terminology_track.rb', line 18

def setup
  # find FHIRDefinedType valueset
  options = {
    :search => {
      :flag => false,
      :compartment => nil,
      :parameters => {
        'name' => 'FHIRDefinedType'
      }
    }
  }
  @valueset = nil
  reply = @client.search(FHIR::ValueSet, options)
  if reply.code==200 && !reply.resource.nil?
    bundle = reply.resource
    @valueset = bundle.entry[0].resource if bundle.entry.size > 0
  end
end

#teardownObject



37
38
39
# File 'lib/tests/suites/connectathon_terminology_track.rb', line 37

def teardown
  # not required
end