Module: Gauge::Processors Private

Includes:
ExecutionHandler
Included in:
MessageProcessor
Defined in:
lib/processors/kill_request_processor.rb,
lib/processors/execution_handler.rb,
lib/processors/datastore_init_processor.rb,
lib/processors/execution_hook_processors.rb,
lib/processors/step_name_request_processor.rb,
lib/processors/step_names_request_processor.rb,
lib/processors/execute_step_request_processor.rb,
lib/processors/refactor_step_request_processor.rb,
lib/processors/step_validation_request_processor.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Modules: ExecutionHandler

Instance Method Summary collapse

Methods included from ExecutionHandler

#create_param_values, #handle_failure, #handle_hooks_execution, #handle_pass, #screenshot_bytes, #time_elapsed_since

Instance Method Details

#get_step(step_text) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



38
39
40
41
42
# File 'lib/processors/refactor_step_request_processor.rb', line 38

def get_step(step_text)
  blocks = MethodCache.get_steps step_text
  raise "Multiple step implementations found for => '#{step_text}'" if blocks.length > 1
  blocks[0]
end

#process_datastore_init(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/processors/datastore_init_processor.rb', line 23

def process_datastore_init(message)
  case message.messageType
    when Messages::Message::MessageType::SuiteDataStoreInit
      DataStoreFactory.suite_datastore.clear
    when Messages::Message::MessageType::SpecDataStoreInit
      DataStoreFactory.spec_datastore.clear
    when Messages::Message::MessageType::ScenarioDataStoreInit
      DataStoreFactory.scenario_datastore.clear
  end
  execution_status_response = Messages::ExecutionStatusResponse.new(:executionResult => Messages::ProtoExecutionResult.new(:failed => false, :executionTime => 0))
  Messages::Message.new(:messageType => Messages::Message::MessageType::ExecutionStatusResponse, :messageId => message.messageId, :executionStatusResponse => execution_status_response)
end

#process_execute_step_request(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/processors/execute_step_request_processor.rb', line 24

def process_execute_step_request(message)
  step_text = message.executeStepRequest.parsedStepText
  parameters = message.executeStepRequest.parameters
  args = create_param_values parameters
  start_time= Time.now
  begin
    Executor.execute_step step_text, args
  rescue Exception => e
    return handle_failure message, e, time_elapsed_since(start_time), MethodCache.is_recoverable?(step_text)
  end
  handle_pass message, time_elapsed_since(start_time)
end

#process_execution_end_request(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/processors/execution_hook_processors.rb', line 29

def process_execution_end_request(message)
  handle_hooks_execution(MethodCache.get_after_suite_hooks, message, message.executionEndingRequest.currentExecutionInfo, false)
end

#process_execution_start_request(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
# File 'lib/processors/execution_hook_processors.rb', line 25

def process_execution_start_request(message)
  handle_hooks_execution(MethodCache.get_before_suite_hooks, message, message.executionStartingRequest.currentExecutionInfo,false)
end

#process_kill_processor_request(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
# File 'lib/processors/kill_request_processor.rb', line 21

def process_kill_processor_request(message)
  return message
end

#process_scenario_execution_end_request(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



45
46
47
# File 'lib/processors/execution_hook_processors.rb', line 45

def process_scenario_execution_end_request(message)
  handle_hooks_execution(MethodCache.get_after_scenario_hooks, message, message.scenarioExecutionEndingRequest.currentExecutionInfo)
end

#process_scenario_execution_start_request(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



41
42
43
# File 'lib/processors/execution_hook_processors.rb', line 41

def process_scenario_execution_start_request(message)
  handle_hooks_execution(MethodCache.get_before_scenario_hooks, message, message.scenarioExecutionStartingRequest.currentExecutionInfo)
end

#process_spec_execution_end_request(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



37
38
39
# File 'lib/processors/execution_hook_processors.rb', line 37

def process_spec_execution_end_request(message)
  handle_hooks_execution(MethodCache.get_after_spec_hooks, message, message.specExecutionEndingRequest.currentExecutionInfo)
end

#process_spec_execution_start_request(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



33
34
35
# File 'lib/processors/execution_hook_processors.rb', line 33

def process_spec_execution_start_request(message)
  handle_hooks_execution(MethodCache.get_before_spec_hooks, message, message.specExecutionStartingRequest.currentExecutionInfo)
end

#process_step_execution_end_request(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



54
55
56
57
58
# File 'lib/processors/execution_hook_processors.rb', line 54

def process_step_execution_end_request(message)
  response = handle_hooks_execution(MethodCache.get_after_step_hooks, message, message.stepExecutionEndingRequest.currentExecutionInfo)
  response.executionStatusResponse.executionResult.message = Gauge::GaugeMessages.instance.get
  return response
end

#process_step_execution_start_request(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



49
50
51
52
# File 'lib/processors/execution_hook_processors.rb', line 49

def process_step_execution_start_request(message)
  Gauge::GaugeMessages.instance.clear
  handle_hooks_execution(MethodCache.get_before_step_hooks, message, message.stepExecutionStartingRequest.currentExecutionInfo)
end

#process_step_name_request(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
23
24
25
26
27
# File 'lib/processors/step_name_request_processor.rb', line 20

def process_step_name_request(message)
  parsed_step_text = message.stepNameRequest.stepValue
  is_valid = MethodCache.valid_step?(parsed_step_text)
  step_text = is_valid ? MethodCache.get_step_text(parsed_step_text) : ""
  has_alias = MethodCache.has_alias?(step_text)
  get_step_name_response = Messages::StepNameResponse.new(isStepPresent: is_valid, stepName: [step_text], hasAlias: has_alias)
  Messages::Message.new(:messageType => Messages::Message::MessageType::StepNameResponse, :messageId => message.messageId, :stepNameResponse => get_step_name_response)
end

#process_step_names_request(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
23
24
# File 'lib/processors/step_names_request_processor.rb', line 20

def process_step_names_request(message)
  step_names_response = Messages::StepNamesResponse.new(:steps => MethodCache.all_steps)
  Messages::Message.new(:messageType => Messages::Message::MessageType::StepNamesResponse,
    :messageId => message.messageId, :stepNamesResponse => step_names_response)
end

#process_step_validation_request(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/processors/step_validation_request_processor.rb', line 20

def process_step_validation_request(message)
  step_validate_request = message.stepValidateRequest
  is_valid = true
  msg = ''
  err_type = nil
  blocks = MethodCache.get_steps(step_validate_request.stepText)
  if blocks.length > 1
    is_valid = false
    msg = "Multiple step implementations found for => '#{step_validate_request.stepText}'"
    err_type = Messages::StepValidateResponse::ErrorType::DUPLICATE_STEP_IMPLEMENTATION
  elsif blocks.length == 0
    is_valid = false
    msg = 'Step implementation not found'
    err_type = Messages::StepValidateResponse::ErrorType::STEP_IMPLEMENTATION_NOT_FOUND
  end
  step_validate_response = Messages::StepValidateResponse.new(:isValid => is_valid, :errorMessage => msg, :errorType => err_type)
  Messages::Message.new(:messageType => Messages::Message::MessageType::StepValidateResponse,
    :messageId => message.messageId, 
    :stepValidateResponse => step_validate_response)
end

#refactor_step(message) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/processors/refactor_step_request_processor.rb', line 22

def refactor_step(message)
  oldStepValue = message.refactorRequest.oldStepValue.stepValue
  newStep = message.refactorRequest.newStepValue
  refactor_response = Messages::RefactorResponse.new(success: true)
  begin
    stepBlock = get_step oldStepValue
    CodeParser.refactor stepBlock, message.refactorRequest.paramPositions, newStep.parameters, newStep.parameterizedStepValue
    file, _ = stepBlock.source_location
    refactor_response.filesChanged = [file]
  rescue Exception => e
    refactor_response.success=false
    refactor_response.error=e.message
  end
  Messages::Message.new(:messageType => Messages::Message::MessageType::RefactorResponse, :messageId => message.messageId, refactorResponse: refactor_response)
end