test/ft_84_updateexp.rb in ruote-0.9.18 vs test/ft_84_updateexp.rb in ruote-0.9.19
- old
+ new
@@ -13,186 +13,186 @@
require 'openwfe/participants/storeparticipants'
require 'openwfe/storage/yamlcustom'
class FlowTest84 < Test::Unit::TestCase
- include FlowTestBase
+ include FlowTestBase
- #def teardown
- #end
+ #def teardown
+ #end
- #def setup
- #end
+ #def setup
+ #end
- #
- # TEST 0
+ #
+ # TEST 0
- class TestDefinition0 < OpenWFE::ProcessDefinition
- sequence do
- set :var => "v0", :val => "val0"
- store_p
- end
- end
+ class TestDefinition0 < OpenWFE::ProcessDefinition
+ sequence do
+ set :var => "v0", :val => "val0"
+ store_p
+ end
+ end
- def test_0
+ def test_0
- #sp = @engine.register_participant("store_p", OpenWFE::YamlParticipant)
- sp = @engine.register_participant("store_p", OpenWFE::HashParticipant)
+ #sp = @engine.register_participant("store_p", OpenWFE::YamlParticipant)
+ sp = @engine.register_participant("store_p", OpenWFE::HashParticipant)
- fei = launch TestDefinition0
+ fei = launch TestDefinition0
- sleep 0.350
+ sleep 0.350
- s = @engine.process_stack fei, true
+ s = @engine.process_stack fei, true
- env = s.find { |fexp| fexp.is_a?(OpenWFE::Environment) }
- par = s.find { |fexp| fexp.is_a?(OpenWFE::ParticipantExpression) }
+ env = s.find { |fexp| fexp.is_a?(OpenWFE::Environment) }
+ par = s.find { |fexp| fexp.is_a?(OpenWFE::ParticipantExpression) }
- #
- # testing update on env
+ #
+ # testing update on env
- assert_equal "val0", @engine.lookup_variable("v0", fei)
+ assert_equal "val0", @engine.lookup_variable("v0", fei)
- @engine.update_expression_data(
- env.fei, { "v0" => "val0b", "v1" => "val1" })
+ @engine.update_expression_data(
+ env.fei, { "v0" => "val0b", "v1" => "val1" })
- assert_equal "val0b", @engine.lookup_variable("v0", fei)
- assert_equal "val1", @engine.lookup_variable("v1", fei)
+ assert_equal "val0b", @engine.lookup_variable("v0", fei)
+ assert_equal "val1", @engine.lookup_variable("v1", fei)
- #
- # testing update on participant expression
+ #
+ # testing update on participant expression
- assert [ 1, 2 ], par.applied_workitem.attributes
+ assert [ 1, 2 ], par.applied_workitem.attributes
- @engine.update_expression_data par.fei, { 'f0' => 'val0' }
+ @engine.update_expression_data par.fei, { 'f0' => 'val0' }
- s = @engine.process_stack fei
- par = s.find { |fexp| fexp.is_a?(OpenWFE::ParticipantExpression) }
+ s = @engine.process_stack fei
+ par = s.find { |fexp| fexp.is_a?(OpenWFE::ParticipantExpression) }
- assert_equal 'val0', par.applied_workitem.attributes['f0']
+ assert_equal 'val0', par.applied_workitem.attributes['f0']
- @engine.cancel_process fei.wfid
+ @engine.cancel_process fei.wfid
- sleep 0.350
- end
+ sleep 0.350
+ end
- #
- # TEST 1
+ #
+ # TEST 1
- class TestDefinition1 < OpenWFE::ProcessDefinition
- sequence do
- participant "alpha"
- participant "bravo"
- end
- end
+ class TestDefinition1 < OpenWFE::ProcessDefinition
+ sequence do
+ participant "alpha"
+ participant "bravo"
+ end
+ end
- def test_1
+ def test_1
- %w{ alpha bravo charly }.each do |pname|
- @engine.register_participant pname, OpenWFE::HashParticipant
- end
+ %w{ alpha bravo charly }.each do |pname|
+ @engine.register_participant pname, OpenWFE::HashParticipant
+ end
- fei = launch TestDefinition1
+ fei = launch TestDefinition1
- sleep 0.350
+ sleep 0.350
- assert 1, @engine.get_participant("alpha").size
- assert 0, @engine.get_participant("bravo").size
- assert 0, @engine.get_participant("charly").size
+ assert 1, @engine.get_participant("alpha").size
+ assert 0, @engine.get_participant("bravo").size
+ assert 0, @engine.get_participant("charly").size
- ps = @engine.process_stack fei.wfid, true
- #puts ps.collect { |fexp| fexp.to_yaml }.join("\n")
+ ps = @engine.process_stack fei.wfid, true
+ #puts ps.collect { |fexp| fexp.to_yaml }.join("\n")
- ebravo = ps.find { |fexp| fexp.fei.expid == '0.0.1' }
- scharly = ebravo.to_yaml.gsub /bravo/, "charly"
+ ebravo = ps.find { |fexp| fexp.fei.expid == '0.0.1' }
+ scharly = ebravo.to_yaml.gsub /bravo/, "charly"
- @engine.update_expression(YAML.load(scharly))
+ @engine.update_expression(YAML.load(scharly))
- wi = @engine.get_participant("alpha").first_workitem
- @engine.get_participant("alpha").forward(wi)
+ wi = @engine.get_participant("alpha").first_workitem
+ @engine.get_participant("alpha").forward(wi)
- sleep 0.350
+ sleep 0.350
- assert 0, @engine.get_participant("alpha").size
- assert 0, @engine.get_participant("bravo").size
- assert 1, @engine.get_participant("charly").size
+ assert 0, @engine.get_participant("alpha").size
+ assert 0, @engine.get_participant("bravo").size
+ assert 1, @engine.get_participant("charly").size
- @engine.cancel_process fei.wfid
+ @engine.cancel_process fei.wfid
- sleep 0.350
- end
+ sleep 0.350
+ end
- #
- # TEST 2
+ #
+ # TEST 2
- class TestDefinition2 < OpenWFE::ProcessDefinition
- sequence do
- participant "alpha"
- participant "alpha"
- participant "charly"
- end
- end
+ class TestDefinition2 < OpenWFE::ProcessDefinition
+ sequence do
+ participant "alpha"
+ participant "alpha"
+ participant "charly"
+ end
+ end
- def test_2
+ def test_2
- #log_level_to_debug
+ #log_level_to_debug
- %w{ alpha bravo charly }.each do |pname|
- @engine.register_participant pname, OpenWFE::HashParticipant
- end
+ %w{ alpha bravo charly }.each do |pname|
+ @engine.register_participant pname, OpenWFE::HashParticipant
+ end
- fei = launch TestDefinition2
+ fei = launch TestDefinition2
- sleep 0.350
+ sleep 0.350
- ps = @engine.process_stack fei.wfid, true
+ ps = @engine.process_stack fei.wfid, true
- s3fei = ps.find { |fexp| fexp.fei.expid == "0.0.1" }.fei
+ s3fei = ps.find { |fexp| fexp.fei.expid == "0.0.1" }.fei
- # update happens here
+ # update happens here
- @engine.update_raw_expression s3fei, ["bravo", {}, []]
+ @engine.update_raw_expression s3fei, ["bravo", {}, []]
- ps = @engine.process_stack fei.wfid, true
+ ps = @engine.process_stack fei.wfid, true
- #p ps.representation
+ #p ps.representation
- assert_equal(
- ["process-definition", {"name"=>"Test", "revision"=>"2"}, [["sequence", {}, [["participant", {}, ["alpha"]], ["bravo", {}, []], ["participant", {}, ["charly"]]]]]],
- ps.representation)
+ assert_equal(
+ ["process-definition", {"name"=>"Test", "revision"=>"2"}, [["sequence", {}, [["participant", {}, ["alpha"]], ["bravo", {}, []], ["participant", {}, ["charly"]]]]]],
+ ps.representation)
- wi = @engine.get_participant("alpha").first_workitem
- @engine.get_participant("alpha").forward(wi)
+ wi = @engine.get_participant("alpha").first_workitem
+ @engine.get_participant("alpha").forward(wi)
- sleep 0.350
+ sleep 0.350
- wi = @engine.get_participant("bravo").first_workitem
- @engine.get_participant("bravo").forward(wi)
+ wi = @engine.get_participant("bravo").first_workitem
+ @engine.get_participant("bravo").forward(wi)
- sleep 0.350
+ sleep 0.350
- ps = @engine.process_stack fei.wfid, true
+ ps = @engine.process_stack fei.wfid, true
- #puts
- #ps.each do |fexp|
- # puts "== #{fexp.fei.to_short_s}"
- # p [ fexp.raw_representation, fexp.raw_rep_updated ]
- #end
- #puts
+ #puts
+ #ps.each do |fexp|
+ # puts "== #{fexp.fei.to_short_s}"
+ # p [ fexp.raw_representation, fexp.raw_rep_updated ]
+ #end
+ #puts
- assert_equal(
- ["process-definition", {"name"=>"Test", "revision"=>"2"}, [["sequence", {}, [["participant", {}, ["alpha"]], ["bravo", {"ref"=>"bravo"}, []], ["participant", {}, ["charly"]]]]]],
- ps.representation)
+ assert_equal(
+ ["process-definition", {"name"=>"Test", "revision"=>"2"}, [["sequence", {}, [["participant", {}, ["alpha"]], ["bravo", {"ref"=>"bravo"}, []], ["participant", {}, ["charly"]]]]]],
+ ps.representation)
- # just to be sure
+ # just to be sure
- assert_equal 0, ps.find_all { |fexp| fexp.fei.expid == '0.0.1' }.size
- # making sure the 2nd participant is over
+ assert_equal 0, ps.find_all { |fexp| fexp.fei.expid == '0.0.1' }.size
+ # making sure the 2nd participant is over
- #@engine.cancel_process fei
- #sleep 0.350
+ #@engine.cancel_process fei
+ #sleep 0.350
- purge_engine
- end
+ purge_engine
+ end
end