Sha256: 822975719d11d3fddfc3955dd5c39bc29f6ce6abcaddcb4ca0cfa20b5c7cbc8c

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true
module Dynflow
  module Testing
    class DummyWorld
      extend Mimic
      mimic! World

      attr_reader :clock, :executor, :middleware, :coordinator
      attr_accessor :action

      def initialize(_config = nil)
        @logger_adapter = Testing.logger_adapter
        @clock          = ManagedClock.new
        @executor       = DummyExecutor.new(self)
        @middleware     = Middleware::World.new
        @coordinator    = DummyCoordinator.new
      end

      def action_logger
        @logger_adapter.action_logger
      end

      def logger
        @logger_adapter.dynflow_logger
      end

      def silence_logger!
        action_logger.level = 4
      end

      def subscribed_actions(klass)
        []
      end

      def event(execution_plan_id, step_id, event, future = Concurrent::Promises.resolvable_future)
        executor.event execution_plan_id, step_id, event, future
      end

      def plan_event(execution_plan_id, step_id, event, time, accepted = Concurrent::Promises.resolvable_future)
        if time.nil? || time < Time.now
          event(execution_plan_id, step_id, event, accepted)
        else
          clock.ping(executor, time, Director::Event[SecureRandom.uuid, execution_plan_id, step_id, event, accepted], :delayed_event)
        end
      end

      def persistence
        nil
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dynflow-1.6.8 lib/dynflow/testing/dummy_world.rb
dynflow-1.6.7 lib/dynflow/testing/dummy_world.rb
dynflow-1.6.6 lib/dynflow/testing/dummy_world.rb
dynflow-1.6.5 lib/dynflow/testing/dummy_world.rb
dynflow-1.6.4 lib/dynflow/testing/dummy_world.rb
dynflow-1.6.3 lib/dynflow/testing/dummy_world.rb
dynflow-1.6.2 lib/dynflow/testing/dummy_world.rb
dynflow-1.6.1 lib/dynflow/testing/dummy_world.rb