Class: USCoreTestKit::Client::Generator::GroupGenerator

Inherits:
Generator::GroupGenerator show all
Defined in:
lib/us_core_test_kit/client/generator/group_generator.rb

Instance Attribute Summary

Attributes inherited from Generator::GroupGenerator

#base_output_dir, #group_metadata

Instance Method Summary collapse

Methods inherited from Generator::GroupGenerator

#add_special_tests, #base_metadata_file_name, #base_output_file_name, generate, #initialize, #metadata_file_name, #optional?, #output_file_name, #profile_identifier, #profile_name, #profile_url, #required_searches, #resource_type, #search_description, #search_param_name_string, #search_validation_resource_type, #short_description, #test_file_list, #test_id_list, #title

Constructor Details

This class inherits a constructor from USCoreTestKit::Generator::GroupGenerator

Instance Method Details

#class_nameObject



19
20
21
# File 'lib/us_core_test_kit/client/generator/group_generator.rb', line 19

def class_name
  "#{profile_identifier.camelize}ClientGroup"
end

#conformance_optional?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/us_core_test_kit/client/generator/group_generator.rb', line 78

def conformance_optional?
  .resource_conformance_expectation != 'SHALL'
end

#descriptionObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/us_core_test_kit/client/generator/group_generator.rb', line 31

def description
  "\n    # Background\n\n    This test group verifies that the client can access \#{resource_type} data\n    conforming to the \#{profile_name}.\n\n    # Testing Methodology\n    \n    ## Data Access Supported\n\n    Clients may not be required to support the \#{resource_type} FHIR resource type. However, if they\n    do support it, they must support the \#{profile_name} and the resource type's search parameters.\n    The tests in this group will not execute if client makes no attempt to access data for the\n    \#{resource_type} resource type. In this case, the test will be marked as skip if support\n    for the resource type is required, and omitted otherwise.\n\n    ## Reading\n    This test will check that the client performed a read of the following id:\n\n    * `us-core-client-tests-\#{profile_identifier.underscore.dasherize}`\n\n    ## Searching\n    These tests will check that the client performed searches agains the\n    \#{resource_type} resource type with the following required parameters:\n\n    \#{search_param_name_string}\n    \n    Inferno will also look for searches using the following optional parameters:\n\n    \#{optional_search_param_name_string}\n    \n  DESCRIPTION\nend\n"

#generateObject



82
83
84
85
86
# File 'lib/us_core_test_kit/client/generator/group_generator.rb', line 82

def generate
  File.write(output_file_name, output)
  .id = group_id
  .file_name = base_output_file_name
end

#group_idObject



27
28
29
# File 'lib/us_core_test_kit/client/generator/group_generator.rb', line 27

def group_id
  "us_core_client_#{group_metadata.reformatted_version}_#{profile_identifier}"
end

#module_nameObject



23
24
25
# File 'lib/us_core_test_kit/client/generator/group_generator.rb', line 23

def module_name
  "USCoreClient#{group_metadata.reformatted_version.upcase}"
end

#optional_search_param_name_stringObject



71
72
73
74
75
76
# File 'lib/us_core_test_kit/client/generator/group_generator.rb', line 71

def optional_search_param_name_string
  optional_searches
    .map { |search| search[:names].join(' + ') }
    .map { |names| "* #{names}" }
    .join("\n")
end

#optional_searchesObject



67
68
69
# File 'lib/us_core_test_kit/client/generator/group_generator.rb', line 67

def optional_searches
  .searches.select { |search| search[:expectation] != 'SHALL' }
end

#outputObject



15
16
17
# File 'lib/us_core_test_kit/client/generator/group_generator.rb', line 15

def output
  @output ||= ERB.new(template, trim_mode: '-').result(binding)
end

#templateObject



11
12
13
# File 'lib/us_core_test_kit/client/generator/group_generator.rb', line 11

def template
  @template ||= File.read(File.join(__dir__, 'templates', 'group.rb.erb'))
end