Class: Inferno::Entities::Result

Inherits:
Entity
  • Object
show all
Includes:
Attributes, HasRunnable
Defined in:
lib/inferno/entities/result.rb

Overview

A Result represents the result of running a Test, TestGroup, or TestSuite

Constant Summary collapse

ATTRIBUTES =
[
  :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
  :test_group, :test_suite_id, :test_suite, :test_run_id,
  :test_session_id, :result, :result_message, :messages, :requests,
  :input_json, :output_json
].freeze
RESULT_OPTIONS =
['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HasRunnable

#runnable

Methods included from Attributes

included

Methods inherited from Entity

#to_hash

Constructor Details

#initialize(params) ⇒ Result



55
56
57
58
59
60
# File 'lib/inferno/entities/result.rb', line 55

def initialize(params)
  super(params, ATTRIBUTES - [:messages, :requests])

  @messages = (params[:messages] || []).map { |message| Message.new(message) }
  @requests = (params[:requests] || []).map { |request| Request.new(request) }
end

Instance Attribute Details

#created_atTime



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#idString



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#input_jsonString



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#messagesArray<Inferno::Entities::Message>

result



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#output_jsonString



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#requestsArray<Inferno::Entities::Request>

associated with this result



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#resultString

running, wait, cancel)



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#result_messageString



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#testTest?



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#test_groupTestGroup?



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#test_group_idString?



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#test_idString?



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#test_run_idString



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#test_session_idString



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#test_suiteTestSuite?



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#test_suite_idString?



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

#updated_atTime



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/inferno/entities/result.rb', line 43

class Result < Entity
  ATTRIBUTES = [
    :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
    :test_group, :test_suite_id, :test_suite, :test_run_id,
    :test_session_id, :result, :result_message, :messages, :requests,
    :input_json, :output_json
  ].freeze
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'pass', 'omit'].freeze

  include Inferno::Entities::Attributes
  include Inferno::Entities::HasRunnable

  def initialize(params)
    super(params, ATTRIBUTES - [:messages, :requests])

    @messages = (params[:messages] || []).map { |message| Message.new(message) }
    @requests = (params[:requests] || []).map { |request| Request.new(request) }
  end

  def optional?
    runnable.nil? || runnable.optional?
  end

  def required?
    !optional?
  end

  # @return [Boolean]
  def waiting?
    result == 'wait'
  end

  def inputs
    input_json.present? ? JSON.parse(input_json) : []
  end

  def outputs
    output_json.present? ? JSON.parse(output_json) : []
  end

  # Flags large inputs or outputs and replaces their values with a reference message.
  #
  # This method inspects either the `inputs` or `outputs` array and,
  # for each item whose `value` exceeds the configured size threshold, sets `is_large: true`
  # and replaces the `value` with a message pointing to the full content endpoint.
  #
  # @param io_type [String] Must be either `'inputs'` or `'outputs'`.
  # @return [Array<Hash>] The mutated list of inputs or outputs.
  def handle_large_io(io_type)
    io_array = public_send(io_type)

    io_array.each do |io|
      next unless io_is_large?(io['value'])

      io['is_large'] = true
      io['value'] = "        \#{io_type.singularize.capitalize} is too large to display, please visit\n        \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n        for details\n      MESSAGE\n    end\n\n    io_array\n  end\n\n  # @private\n  def io_is_large?(io_value)\n    size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length\n    size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i\n  end\nend\n"

Instance Method Details

#handle_large_io(io_type) ⇒ Array<Hash>

Flags large inputs or outputs and replaces their values with a reference message.

This method inspects either the inputs or outputs array and, for each item whose value exceeds the configured size threshold, sets is_large: true and replaces the value with a message pointing to the full content endpoint.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/inferno/entities/result.rb', line 91

def handle_large_io(io_type)
  io_array = public_send(io_type)

  io_array.each do |io|
    next unless io_is_large?(io['value'])

    io['is_large'] = true
    io['value'] = "      \#{io_type.singularize.capitalize} is too large to display, please visit\n      \#{Inferno::Application['base_url']}/api/test_sessions/\#{test_session_id}/results/\#{id}/io/\#{io_type}/\#{io['name']}\n      for details\n    MESSAGE\n  end\n\n  io_array\nend\n"

#inputsObject



75
76
77
# File 'lib/inferno/entities/result.rb', line 75

def inputs
  input_json.present? ? JSON.parse(input_json) : []
end

#io_is_large?(io_value) ⇒ Boolean



109
110
111
112
# File 'lib/inferno/entities/result.rb', line 109

def io_is_large?(io_value)
  size_in_char = io_value.is_a?(String) ? io_value.length : io_value.to_json.length
  size_in_char > ENV.fetch('MAX_IO_DISPLAY_CHAR', 10000).to_i
end

#optional?Boolean



62
63
64
# File 'lib/inferno/entities/result.rb', line 62

def optional?
  runnable.nil? || runnable.optional?
end

#outputsObject



79
80
81
# File 'lib/inferno/entities/result.rb', line 79

def outputs
  output_json.present? ? JSON.parse(output_json) : []
end

#required?Boolean



66
67
68
# File 'lib/inferno/entities/result.rb', line 66

def required?
  !optional?
end

#waiting?Boolean



71
72
73
# File 'lib/inferno/entities/result.rb', line 71

def waiting?
  result == 'wait'
end