Sha256: be6834abdebd2443b664a1b388e5b3be327b99695eda17d08820cedf6e8de776

Contents?: true

Size: 1.96 KB

Versions: 1

Compression:

Stored size: 1.96 KB

Contents

# Provide service methods for running a a set of validation scenarios for an authority.
module QaServer
  class AuthorityValidatorService
    class_attribute :validator_class,
                    :term_validator_class,
                    :search_validator_class,
                    :scenarios_loader_class

    self.validator_class = ScenarioValidator
    self.term_validator_class = TermScenarioValidator
    self.search_validator_class = SearchScenarioValidator
    self.scenarios_loader_class = ScenariosLoaderService

    VALIDATE_CONNECTIONS = validator_class::VALIDATE_CONNECTION
    VALIDATE_ACCURACY = validator_class::VALIDATE_ACCURACY
    ALL_VALIDATIONS = validator_class::ALL_VALIDATIONS
    DEFAULT_VALIDATION_TYPE = validator_class::DEFAULT_VALIDATION_TYPE

    # Run the set of validation scenarios for an authority logging the results
    # @param authority_name [String] the name of the authority
    # @param status_log [ScenarioLogger] the log that will hold the data about the scenarios and test results
    # @param validation_type [Symbol] the type of scenarios to run (e.g. VALIDATE_CONNECTIONS, VALIDATE_ACCURACY, ALL_VALIDATIONS)
    def self.run(authority_name:, status_log:, validation_type: DEFAULT_VALIDATION_TYPE)
      scenarios = scenarios_loader_class.load(authority_name: authority_name, status_log: status_log)
      return if scenarios.blank?
      run_terms(scenarios, status_log, validation_type)
      run_searches(scenarios, status_log, validation_type)
    end


    private

      def self.run_terms(scenarios, status_log, validation_type)
        scenarios.term_scenarios.each { |scenario| term_validator_class.new(scenario: scenario, status_log: status_log, validation_type: validation_type).run }
      end

      def self.run_searches(scenarios, status_log, validation_type)
        scenarios.search_scenarios.each { |scenario| search_validator_class.new(scenario: scenario, status_log: status_log, validation_type: validation_type).run }
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qa_server-0.1.99 app/services/qa_server/authority_validator_service.rb