Sha256: 69a266adf0b415aaf72941bed504542d99ac2e83f2f3d518b6d83d9b79b4fc15

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

#
# Testing OpenWFE
#
# John Mettraux at openwfe.org
#
# Sun Oct 29 15:41:44 JST 2006
#
# Kita Yokohama
#

require 'test/unit'

#require 'openwfe/workitem'
require 'openwfe/flowexpressionid'
require 'openwfe/engine/engine'
require 'openwfe/expressions/raw_prog'
require 'openwfe/worklist/storeparticipant'

include OpenWFE


class HParticipantTest < Test::Unit::TestCase

    def setup
        @engine = Engine.new()
    end

    #def teardown
    #end

    class HpDefinition0 < ProcessDefinition
        def make
            process_definition :name => "hp0", :revision => "0" do
                sequence do
                    participant :alice
                    participant :bob
                end
            end
        end
    end

    def test_hp_0

        hpAlice = HashParticipant.new
        hpBob = HashParticipant.new

        @engine.register_participant(:alice, hpAlice)
        @engine.register_participant(:bob, hpBob)

        id = @engine.launch(HpDefinition0)

        assert \
            (id.kind_of? FlowExpressionId),
            "engine.launch() doesn't return an instance of FlowExpressionId "+
            "but of #{id.class}"

        #puts id.to_s

        assert \
            hpBob.size == 0
        assert \
            hpAlice.size == 1

        wi = hpAlice.list_workitems(id.workflow_instance_id)[0]

        assert \
            wi != nil,
            "didn't find wi for flow #{id.workflow_instance_id}"

        wi.message = "Hello bob !"

        hpAlice.forward(wi)

        assert \
            hpAlice.size == 0
        assert \
            hpBob.size == 1

        wi = hpBob.list_workitems(id.workflow_instance_id)[0]

        assert \
            wi.message == "Hello bob !"

        hpBob.proceed(wi)

        assert \
            hpAlice.size == 0
        assert \
            hpBob.size == 0

        assert \
            @engine.get_expression_storage.size == 1
    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openwferu-0.9.3 test/hparticipant_test.rb
openwferu-0.9.4 test/hparticipant_test.rb