Sha256: b61811219fbb3b52adf8d3d46a04479c7a7e1fca05270cc8898b77e0b8c1fd58

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

module JmeterPerf
  class DSL
    # DSL method synonymous with the JMeter Element PoissonRandomTimer
    # @see https://github.com/jlurena/jmeter_perf/wiki/1.-DSL-Documentation#poissonrandomtimer
    # @param [Hash] params Parameters for the PoissonRandomTimer element (default: `{}`).
    # @yield block to attach to the PoissonRandomTimer element
    # @return [JmeterPerf::PoissonRandomTimer], a subclass of JmeterPerf::DSL that can be chained with other DSL methods.
    def poisson_random_timer(params = {}, &)
      node = JmeterPerf::PoissonRandomTimer.new(params)
      attach_node(node, &)
    end
  end

  class PoissonRandomTimer
    attr_accessor :doc
    include Helper

    def initialize(params = {})
      testname = params.is_a?(Array) ? "PoissonRandomTimer" : (params[:name] || "PoissonRandomTimer")
      @doc = Nokogiri::XML(<<~EOS.strip_heredoc)
        <PoissonRandomTimer guiclass="PoissonRandomTimerGui" testclass="PoissonRandomTimer" testname="#{testname}" enabled="true">
          <stringProp name="ConstantTimer.delay">300</stringProp>
          <stringProp name="RandomTimer.range">100</stringProp>
        </PoissonRandomTimer>
      EOS
      update params
      update_at_xpath params if params.is_a?(Hash) && params[:update_at_xpath]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jmeter_perf-0.0.7 lib/jmeter_perf/dsl/poisson_random_timer.rb