Class: DaVinciPlanNetTestKit::Generator::SearchNoParamsTestGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group_metadata, base_output_dir) ⇒ SearchNoParamsTestGenerator

Returns a new instance of SearchNoParamsTestGenerator.



20
21
22
23
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 20

def initialize(, base_output_dir)
  self. = 
  self.base_output_dir = base_output_dir
end

Instance Attribute Details

#base_output_dirObject

Returns the value of attribute base_output_dir.



18
19
20
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 18

def base_output_dir
  @base_output_dir
end

#group_metadataObject

Returns the value of attribute group_metadata.



18
19
20
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 18

def 
  @group_metadata
end

Class Method Details

.generate(ig_metadata, base_output_dir) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 8

def generate(, base_output_dir)
  .groups
    .reject { |group| SpecialCases.exclude_group? group }
    .select { |group| group.searches.present? }
    .each do |group|
      new(group, base_output_dir).generate
    end
end

Instance Method Details

#base_output_file_nameObject



33
34
35
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 33

def base_output_file_name
  "#{class_name.underscore}.rb"
end

#class_nameObject



57
58
59
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 57

def class_name
  "#{Naming.upper_camel_case_for_profile()}NoParamsSearchTest"
end

#conformance_expectationObject



69
70
71
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 69

def conformance_expectation
  'SHALL'
end

#descriptionObject



114
115
116
117
118
119
120
121
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 114

def description
  <<~DESCRIPTION.gsub(/\n{3,}/, "\n\n")
  This test gathers instances expected to conform to the target profile
  for use in the rest of the tests in this sequence. It will perform
  an unparameterized search and/or read instance ids provided by the tester
  as described in the "Instance Gathering" section of the group description above.
  DESCRIPTION
end

#first_search?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 73

def first_search?
  true
end

#generateObject



104
105
106
107
108
109
110
111
112
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 104

def generate
  FileUtils.mkdir_p(output_file_directory)
  File.open(output_file_name, 'w') { |f| f.write(output) }

  .add_test(
    id: test_id,
    file_name: base_output_file_name
  )
end

#module_nameObject



61
62
63
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 61

def module_name
  "DaVinciPlanNet#{.reformatted_version.upcase}"
end

#optional?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 77

def optional?
  false
end

#outputObject



29
30
31
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 29

def output
  @output ||= ERB.new(template).result(binding)
end

#output_file_directoryObject



37
38
39
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 37

def output_file_directory
  File.join(base_output_dir, profile_identifier)
end

#output_file_nameObject



41
42
43
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 41

def output_file_name
  File.join(output_file_directory, base_output_file_name)
end

#profile_identifierObject



49
50
51
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 49

def profile_identifier
  Naming.snake_case_for_profile()
end

#profile_nameObject



45
46
47
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 45

def profile_name
  .profile_name
end

#resource_typeObject



65
66
67
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 65

def resource_type
  .resource
end

#saves_delayed_references?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 81

def saves_delayed_references?
  first_search? && .delayed_references.present?
end

#search_propertiesObject



89
90
91
92
93
94
95
96
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 89

def search_properties
  {}.tap do |properties|
    properties[:first_search] = 'true' if first_search?
    properties[:resource_type] = "'#{resource_type}'"
    properties[:saves_delayed_references] = 'true' if saves_delayed_references?
    properties[:test_post_search] = 'false'
  end
end

#search_test_properties_stringObject



98
99
100
101
102
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 98

def search_test_properties_string
  search_properties
    .map { |key, value| "#{' ' * 8}#{key}: #{value}" }
    .join(",\n")
end

#templateObject



25
26
27
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 25

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

#test_idObject



53
54
55
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 53

def test_id
  "davinci_plan_net_#{.reformatted_version}_#{profile_identifier}_no_params_search_test"
end

#test_post_search?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/davinci_plan_net_test_kit/generator/search_no_params_test_generator.rb', line 85

def test_post_search?
  false
end