ruote-maestrodev 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +290 -0
- data/CREDITS.txt +99 -0
- data/LICENSE.txt +21 -0
- data/README.rdoc +88 -0
- data/Rakefile +108 -0
- data/TODO.txt +488 -0
- data/lib/ruote.rb +7 -0
- data/lib/ruote/context.rb +194 -0
- data/lib/ruote/engine.rb +1062 -0
- data/lib/ruote/engine/process_error.rb +122 -0
- data/lib/ruote/engine/process_status.rb +448 -0
- data/lib/ruote/exp/command.rb +87 -0
- data/lib/ruote/exp/commanded.rb +69 -0
- data/lib/ruote/exp/condition.rb +227 -0
- data/lib/ruote/exp/fe_add_branches.rb +138 -0
- data/lib/ruote/exp/fe_apply.rb +154 -0
- data/lib/ruote/exp/fe_cancel_process.rb +78 -0
- data/lib/ruote/exp/fe_command.rb +156 -0
- data/lib/ruote/exp/fe_concurrence.rb +321 -0
- data/lib/ruote/exp/fe_concurrent_iterator.rb +219 -0
- data/lib/ruote/exp/fe_cron.rb +141 -0
- data/lib/ruote/exp/fe_cursor.rb +324 -0
- data/lib/ruote/exp/fe_define.rb +112 -0
- data/lib/ruote/exp/fe_echo.rb +60 -0
- data/lib/ruote/exp/fe_equals.rb +115 -0
- data/lib/ruote/exp/fe_error.rb +82 -0
- data/lib/ruote/exp/fe_filter.rb +648 -0
- data/lib/ruote/exp/fe_forget.rb +88 -0
- data/lib/ruote/exp/fe_given.rb +154 -0
- data/lib/ruote/exp/fe_if.rb +127 -0
- data/lib/ruote/exp/fe_inc.rb +205 -0
- data/lib/ruote/exp/fe_iterator.rb +234 -0
- data/lib/ruote/exp/fe_let.rb +75 -0
- data/lib/ruote/exp/fe_listen.rb +304 -0
- data/lib/ruote/exp/fe_lose.rb +110 -0
- data/lib/ruote/exp/fe_noop.rb +45 -0
- data/lib/ruote/exp/fe_once.rb +215 -0
- data/lib/ruote/exp/fe_participant.rb +287 -0
- data/lib/ruote/exp/fe_read.rb +69 -0
- data/lib/ruote/exp/fe_redo.rb +82 -0
- data/lib/ruote/exp/fe_ref.rb +152 -0
- data/lib/ruote/exp/fe_registerp.rb +110 -0
- data/lib/ruote/exp/fe_reserve.rb +126 -0
- data/lib/ruote/exp/fe_restore.rb +102 -0
- data/lib/ruote/exp/fe_save.rb +72 -0
- data/lib/ruote/exp/fe_sequence.rb +59 -0
- data/lib/ruote/exp/fe_set.rb +154 -0
- data/lib/ruote/exp/fe_subprocess.rb +211 -0
- data/lib/ruote/exp/fe_that.rb +92 -0
- data/lib/ruote/exp/fe_undo.rb +67 -0
- data/lib/ruote/exp/fe_unregisterp.rb +69 -0
- data/lib/ruote/exp/fe_wait.rb +95 -0
- data/lib/ruote/exp/flowexpression.rb +886 -0
- data/lib/ruote/exp/iterator.rb +81 -0
- data/lib/ruote/exp/merge.rb +118 -0
- data/lib/ruote/exp/ro_attributes.rb +212 -0
- data/lib/ruote/exp/ro_filters.rb +136 -0
- data/lib/ruote/exp/ro_persist.rb +154 -0
- data/lib/ruote/exp/ro_variables.rb +189 -0
- data/lib/ruote/exp/ro_vf.rb +68 -0
- data/lib/ruote/fei.rb +260 -0
- data/lib/ruote/id/mnemo_wfid_generator.rb +43 -0
- data/lib/ruote/id/wfid_generator.rb +81 -0
- data/lib/ruote/log/default_history.rb +122 -0
- data/lib/ruote/log/pretty.rb +176 -0
- data/lib/ruote/log/storage_history.rb +159 -0
- data/lib/ruote/log/test_logger.rb +208 -0
- data/lib/ruote/log/wait_logger.rb +64 -0
- data/lib/ruote/part/block_participant.rb +137 -0
- data/lib/ruote/part/code_participant.rb +81 -0
- data/lib/ruote/part/engine_participant.rb +189 -0
- data/lib/ruote/part/local_participant.rb +138 -0
- data/lib/ruote/part/no_op_participant.rb +60 -0
- data/lib/ruote/part/null_participant.rb +54 -0
- data/lib/ruote/part/rev_participant.rb +169 -0
- data/lib/ruote/part/smtp_participant.rb +116 -0
- data/lib/ruote/part/storage_participant.rb +392 -0
- data/lib/ruote/part/template.rb +84 -0
- data/lib/ruote/participant.rb +7 -0
- data/lib/ruote/reader.rb +278 -0
- data/lib/ruote/reader/json.rb +49 -0
- data/lib/ruote/reader/radial.rb +290 -0
- data/lib/ruote/reader/ruby_dsl.rb +186 -0
- data/lib/ruote/reader/xml.rb +99 -0
- data/lib/ruote/receiver/base.rb +212 -0
- data/lib/ruote/storage/base.rb +364 -0
- data/lib/ruote/storage/composite_storage.rb +121 -0
- data/lib/ruote/storage/fs_storage.rb +139 -0
- data/lib/ruote/storage/hash_storage.rb +211 -0
- data/lib/ruote/svc/dispatch_pool.rb +158 -0
- data/lib/ruote/svc/dollar_sub.rb +298 -0
- data/lib/ruote/svc/error_handler.rb +138 -0
- data/lib/ruote/svc/expression_map.rb +97 -0
- data/lib/ruote/svc/participant_list.rb +397 -0
- data/lib/ruote/svc/tracker.rb +172 -0
- data/lib/ruote/svc/treechecker.rb +141 -0
- data/lib/ruote/tree_dot.rb +85 -0
- data/lib/ruote/util/filter.rb +525 -0
- data/lib/ruote/util/hashdot.rb +79 -0
- data/lib/ruote/util/look.rb +128 -0
- data/lib/ruote/util/lookup.rb +127 -0
- data/lib/ruote/util/misc.rb +167 -0
- data/lib/ruote/util/ometa.rb +71 -0
- data/lib/ruote/util/serializer.rb +103 -0
- data/lib/ruote/util/subprocess.rb +88 -0
- data/lib/ruote/util/time.rb +100 -0
- data/lib/ruote/util/tree.rb +58 -0
- data/lib/ruote/version.rb +29 -0
- data/lib/ruote/worker.rb +386 -0
- data/lib/ruote/workitem.rb +394 -0
- data/phil.txt +14 -0
- data/ruote.gemspec +44 -0
- data/test/bm/ci.rb +55 -0
- data/test/bm/ici.rb +71 -0
- data/test/bm/juuman.rb +54 -0
- data/test/bm/launch_bench.rb +37 -0
- data/test/bm/load_26c.rb +97 -0
- data/test/bm/mega.rb +64 -0
- data/test/bm/seq_thousand.rb +31 -0
- data/test/bm/t.rb +35 -0
- data/test/functional/base.rb +247 -0
- data/test/functional/concurrent_base.rb +98 -0
- data/test/functional/crunner.rb +31 -0
- data/test/functional/ct_0_concurrence.rb +65 -0
- data/test/functional/ct_1_iterator.rb +67 -0
- data/test/functional/ct_2_cancel.rb +81 -0
- data/test/functional/eft_0_process_definition.rb +65 -0
- data/test/functional/eft_10_cancel_process.rb +46 -0
- data/test/functional/eft_11_wait.rb +109 -0
- data/test/functional/eft_12_listen.rb +500 -0
- data/test/functional/eft_13_iterator.rb +342 -0
- data/test/functional/eft_14_cursor.rb +456 -0
- data/test/functional/eft_15_loop.rb +69 -0
- data/test/functional/eft_16_if.rb +183 -0
- data/test/functional/eft_17_equals.rb +55 -0
- data/test/functional/eft_18_concurrent_iterator.rb +410 -0
- data/test/functional/eft_19_reserve.rb +136 -0
- data/test/functional/eft_1_echo.rb +68 -0
- data/test/functional/eft_20_save.rb +116 -0
- data/test/functional/eft_21_restore.rb +61 -0
- data/test/functional/eft_22_noop.rb +28 -0
- data/test/functional/eft_23_apply.rb +168 -0
- data/test/functional/eft_24_add_branches.rb +98 -0
- data/test/functional/eft_25_command.rb +28 -0
- data/test/functional/eft_26_error.rb +77 -0
- data/test/functional/eft_27_inc.rb +280 -0
- data/test/functional/eft_28_once.rb +135 -0
- data/test/functional/eft_29_cron.rb +64 -0
- data/test/functional/eft_2_sequence.rb +58 -0
- data/test/functional/eft_30_ref.rb +155 -0
- data/test/functional/eft_31_registerp.rb +130 -0
- data/test/functional/eft_32_lose.rb +93 -0
- data/test/functional/eft_33_let.rb +31 -0
- data/test/functional/eft_34_given.rb +123 -0
- data/test/functional/eft_35_filter.rb +375 -0
- data/test/functional/eft_36_read.rb +95 -0
- data/test/functional/eft_3_participant.rb +149 -0
- data/test/functional/eft_4_set.rb +296 -0
- data/test/functional/eft_5_subprocess.rb +163 -0
- data/test/functional/eft_6_concurrence.rb +304 -0
- data/test/functional/eft_7_forget.rb +61 -0
- data/test/functional/eft_8_undo.rb +114 -0
- data/test/functional/eft_9_redo.rb +138 -0
- data/test/functional/ft_0_worker.rb +65 -0
- data/test/functional/ft_10_dollar.rb +304 -0
- data/test/functional/ft_11_recursion.rb +109 -0
- data/test/functional/ft_12_launchitem.rb +43 -0
- data/test/functional/ft_13_variables.rb +151 -0
- data/test/functional/ft_14_re_apply.rb +324 -0
- data/test/functional/ft_15_timeout.rb +226 -0
- data/test/functional/ft_16_participant_params.rb +98 -0
- data/test/functional/ft_17_conditional.rb +102 -0
- data/test/functional/ft_18_kill.rb +138 -0
- data/test/functional/ft_19_participant_code.rb +67 -0
- data/test/functional/ft_1_process_status.rb +796 -0
- data/test/functional/ft_20_storage_participant.rb +543 -0
- data/test/functional/ft_21_forget.rb +153 -0
- data/test/functional/ft_22_process_definitions.rb +90 -0
- data/test/functional/ft_23_load_defs.rb +79 -0
- data/test/functional/ft_24_block_participant.rb +235 -0
- data/test/functional/ft_25_receiver.rb +207 -0
- data/test/functional/ft_26_participant_rtimeout.rb +179 -0
- data/test/functional/ft_27_var_indirection.rb +128 -0
- data/test/functional/ft_28_null_noop_participants.rb +51 -0
- data/test/functional/ft_29_part_template.rb +60 -0
- data/test/functional/ft_2_errors.rb +380 -0
- data/test/functional/ft_30_smtp_participant.rb +122 -0
- data/test/functional/ft_31_part_blocking.rb +72 -0
- data/test/functional/ft_33_participant_subprocess_priority.rb +32 -0
- data/test/functional/ft_34_cursor_rewind.rb +101 -0
- data/test/functional/ft_35_add_service.rb +56 -0
- data/test/functional/ft_36_storage_history.rb +150 -0
- data/test/functional/ft_37_default_history.rb +109 -0
- data/test/functional/ft_38_participant_more.rb +193 -0
- data/test/functional/ft_39_wait_for.rb +136 -0
- data/test/functional/ft_3_participant_registration.rb +574 -0
- data/test/functional/ft_40_wait_logger.rb +62 -0
- data/test/functional/ft_41_participants.rb +91 -0
- data/test/functional/ft_42_storage_copy.rb +71 -0
- data/test/functional/ft_43_participant_on_reply.rb +87 -0
- data/test/functional/ft_44_var_participant.rb +35 -0
- data/test/functional/ft_45_participant_accept.rb +64 -0
- data/test/functional/ft_46_launch_single.rb +83 -0
- data/test/functional/ft_47_wfid_generator.rb +54 -0
- data/test/functional/ft_48_lose.rb +112 -0
- data/test/functional/ft_49_engine_on_error.rb +201 -0
- data/test/functional/ft_4_cancel.rb +132 -0
- data/test/functional/ft_50_engine_config.rb +22 -0
- data/test/functional/ft_51_misc.rb +67 -0
- data/test/functional/ft_52_case.rb +134 -0
- data/test/functional/ft_53_engine_on_terminate.rb +95 -0
- data/test/functional/ft_54_patterns.rb +104 -0
- data/test/functional/ft_55_engine_participant.rb +303 -0
- data/test/functional/ft_56_filter_attribute.rb +259 -0
- data/test/functional/ft_57_rev_participant.rb +252 -0
- data/test/functional/ft_58_workitem.rb +69 -0
- data/test/functional/ft_59_pause.rb +343 -0
- data/test/functional/ft_5_on_error.rb +384 -0
- data/test/functional/ft_60_code_participant.rb +45 -0
- data/test/functional/ft_61_trailing_fields.rb +34 -0
- data/test/functional/ft_62_exp_name_and_dollar_substitution.rb +35 -0
- data/test/functional/ft_6_on_cancel.rb +221 -0
- data/test/functional/ft_7_tags.rb +177 -0
- data/test/functional/ft_8_participant_consumption.rb +124 -0
- data/test/functional/ft_9_subprocesses.rb +146 -0
- data/test/functional/restart_base.rb +34 -0
- data/test/functional/rt_0_wait.rb +55 -0
- data/test/functional/rt_1_listen.rb +56 -0
- data/test/functional/rt_2_errors.rb +56 -0
- data/test/functional/rt_3_once.rb +70 -0
- data/test/functional/rt_4_cron.rb +64 -0
- data/test/functional/rt_5_timeout.rb +60 -0
- data/test/functional/rtest.rb +8 -0
- data/test/functional/storage_helper.rb +93 -0
- data/test/functional/test.rb +44 -0
- data/test/functional/vertical.rb +46 -0
- data/test/path_helper.rb +15 -0
- data/test/test.rb +13 -0
- data/test/test_helper.rb +28 -0
- data/test/unit/storage.rb +428 -0
- data/test/unit/storages.rb +37 -0
- data/test/unit/test.rb +28 -0
- data/test/unit/ut_0_ruby_reader.rb +223 -0
- data/test/unit/ut_11_lookup.rb +122 -0
- data/test/unit/ut_13_serializer.rb +65 -0
- data/test/unit/ut_14_is_uri.rb +28 -0
- data/test/unit/ut_15_util.rb +57 -0
- data/test/unit/ut_16_reader.rb +225 -0
- data/test/unit/ut_18_engine.rb +47 -0
- data/test/unit/ut_19_part_template.rb +86 -0
- data/test/unit/ut_1_fei.rb +165 -0
- data/test/unit/ut_20_composite_storage.rb +74 -0
- data/test/unit/ut_21_svc_participant_list.rb +46 -0
- data/test/unit/ut_22_filter.rb +1094 -0
- data/test/unit/ut_23_svc_tracker.rb +48 -0
- data/test/unit/ut_24_radial_reader.rb +332 -0
- data/test/unit/ut_25_merge.rb +113 -0
- data/test/unit/ut_3_wait_logger.rb +39 -0
- data/test/unit/ut_4_expmap.rb +20 -0
- data/test/unit/ut_5_tree.rb +54 -0
- data/test/unit/ut_6_condition.rb +303 -0
- data/test/unit/ut_7_workitem.rb +99 -0
- data/test/unit/ut_8_tree_to_dot.rb +72 -0
- data/test/unit/ut_9_xml_reader.rb +61 -0
- metadata +504 -0
@@ -0,0 +1,93 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Thu Nov 25 10:05:28 JST 2010
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
require 'ruote/participant'
|
11
|
+
|
12
|
+
|
13
|
+
class EftLoseTest < Test::Unit::TestCase
|
14
|
+
include FunctionalBase
|
15
|
+
|
16
|
+
def test_lose_alone
|
17
|
+
|
18
|
+
pdef = Ruote.process_definition do
|
19
|
+
lose
|
20
|
+
end
|
21
|
+
|
22
|
+
#@engine.noisy = true
|
23
|
+
|
24
|
+
wfid = @engine.launch(pdef)
|
25
|
+
|
26
|
+
@engine.wait_for(2)
|
27
|
+
# wait until the process reaches the 'lose' expression
|
28
|
+
|
29
|
+
sleep 0.500
|
30
|
+
|
31
|
+
ps = @engine.process(wfid)
|
32
|
+
|
33
|
+
assert_equal 0, ps.errors.size
|
34
|
+
assert_equal 2, ps.expressions.size
|
35
|
+
|
36
|
+
# the process is just stuck at the 'lose' expression
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_losing_child
|
40
|
+
|
41
|
+
pdef = Ruote.process_definition do
|
42
|
+
lose do
|
43
|
+
alpha
|
44
|
+
end
|
45
|
+
charly
|
46
|
+
end
|
47
|
+
|
48
|
+
@engine.register_participant '.+' do |wi|
|
49
|
+
@tracer << wi.participant_name
|
50
|
+
end
|
51
|
+
|
52
|
+
#@engine.noisy = true
|
53
|
+
|
54
|
+
wfid = @engine.launch(pdef)
|
55
|
+
|
56
|
+
@engine.wait_for(7)
|
57
|
+
# wait until 'alpha' replies to its parent 'lose'
|
58
|
+
|
59
|
+
sleep 0.500
|
60
|
+
|
61
|
+
assert_equal 'alpha', @tracer.to_s
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_cancelling_lose
|
65
|
+
|
66
|
+
pdef = Ruote.process_definition do
|
67
|
+
lose do
|
68
|
+
alpha
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
@engine.register_participant '.+', Ruote::StorageParticipant
|
73
|
+
|
74
|
+
#@engine.noisy = true
|
75
|
+
|
76
|
+
wfid = @engine.launch(pdef)
|
77
|
+
|
78
|
+
@engine.wait_for(6)
|
79
|
+
# wait until 'alpha' replies to its parent 'lose'
|
80
|
+
|
81
|
+
sleep 0.500
|
82
|
+
|
83
|
+
assert_equal 1, @engine.storage_participant.size
|
84
|
+
|
85
|
+
@engine.cancel_process(wfid)
|
86
|
+
|
87
|
+
sleep 0.500
|
88
|
+
|
89
|
+
assert_equal 0, @engine.storage_participant.size
|
90
|
+
assert_nil @engine.process(wfid)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Fri Dec 24 15:35:17 JST 2010
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
|
11
|
+
class EftLetTest < Test::Unit::TestCase
|
12
|
+
include FunctionalBase
|
13
|
+
|
14
|
+
def test_let
|
15
|
+
|
16
|
+
pdef = Ruote.process_definition do
|
17
|
+
set 'v:var' => 'val'
|
18
|
+
echo "out:${v:var}"
|
19
|
+
let do
|
20
|
+
set 'v:var' => 'val1'
|
21
|
+
echo "in:${v:var}"
|
22
|
+
end
|
23
|
+
echo "out:${v:var}"
|
24
|
+
end
|
25
|
+
|
26
|
+
#noisy
|
27
|
+
|
28
|
+
assert_trace %w[ out:val in:val1 out:val ], pdef
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,123 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Sat Dec 25 12:21:00 JST 2010
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
|
11
|
+
class EftGivenTest < Test::Unit::TestCase
|
12
|
+
include FunctionalBase
|
13
|
+
|
14
|
+
def test_given_that
|
15
|
+
|
16
|
+
pdef = Ruote.process_definition do
|
17
|
+
given do
|
18
|
+
that "${state} == ready" do
|
19
|
+
echo "a"
|
20
|
+
end
|
21
|
+
that "${location} == nichoume" do
|
22
|
+
echo "b"
|
23
|
+
end
|
24
|
+
# anything that follows is "else"
|
25
|
+
echo "c"
|
26
|
+
echo "d"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
#noisy
|
31
|
+
|
32
|
+
assert_trace %w[ c d ], pdef, :clear
|
33
|
+
assert_trace %w[ a ], { 'state' => 'ready' }, pdef, :clear
|
34
|
+
assert_trace %w[ b ], { 'location' => 'nichoume' }, pdef, :clear
|
35
|
+
assert_trace %w[ a ], { 'state' => 'ready', 'location' => 'nichoume' }, pdef, :clear
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_given_x_of
|
39
|
+
|
40
|
+
pdef = Ruote.process_definition do
|
41
|
+
given "${status}" do
|
42
|
+
of "ready" do
|
43
|
+
echo "a"
|
44
|
+
end
|
45
|
+
of "dead" do
|
46
|
+
echo "b"
|
47
|
+
end
|
48
|
+
echo "c"
|
49
|
+
echo "d"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
#noisy
|
54
|
+
|
55
|
+
assert_trace %w[ c d ], pdef, :clear
|
56
|
+
assert_trace %w[ a ], { 'status' => 'ready' }, pdef, :clear
|
57
|
+
assert_trace %w[ b ], { 'status' => 'dead' }, pdef, :clear
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_given_x_of_and_that
|
61
|
+
|
62
|
+
pdef = Ruote.process_definition do
|
63
|
+
given "${status}" do
|
64
|
+
that "${location} == higashiyama" do
|
65
|
+
echo "a"
|
66
|
+
end
|
67
|
+
of "ready" do
|
68
|
+
echo "b"
|
69
|
+
end
|
70
|
+
of "dead" do
|
71
|
+
echo "c"
|
72
|
+
end
|
73
|
+
echo "d"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
assert_trace %w[ d ], {}, pdef, :clear
|
78
|
+
assert_trace %w[ b ], { 'status' => 'ready' }, pdef, :clear
|
79
|
+
assert_trace %w[ a ], { 'status' => 'dead', 'location' => 'higashiyama' }, pdef, :clear
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_attributes
|
83
|
+
|
84
|
+
pdef = Ruote.process_definition do
|
85
|
+
given :t => "${status}" do
|
86
|
+
that :t => "${location} == higashiyama" do
|
87
|
+
echo "a"
|
88
|
+
end
|
89
|
+
of :t => "ready" do
|
90
|
+
echo "b"
|
91
|
+
end
|
92
|
+
of "dead" do
|
93
|
+
echo "c"
|
94
|
+
end
|
95
|
+
echo "d"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
assert_trace %w[ d ], {}, pdef, :clear
|
100
|
+
assert_trace %w[ b ], { 'status' => 'ready' }, pdef, :clear
|
101
|
+
assert_trace %w[ a ], { 'status' => 'dead', 'location' => 'higashiyama' }, pdef, :clear
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_match
|
105
|
+
|
106
|
+
pdef = Ruote.define do
|
107
|
+
given "${status}" do
|
108
|
+
of "/^a/" do
|
109
|
+
echo 'a'
|
110
|
+
end
|
111
|
+
of /^b/ do
|
112
|
+
echo 'b'
|
113
|
+
end
|
114
|
+
echo 'z'
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
assert_trace %w[ z ], {}, pdef, :clear
|
119
|
+
assert_trace %w[ a ], { 'status' => 'alpha' }, pdef, :clear
|
120
|
+
assert_trace %w[ b ], { 'status' => 'bravo' }, pdef, :clear
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
@@ -0,0 +1,375 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Mon Jan 31 14:45:09 JST 2011
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
|
11
|
+
class EftFilterTest < Test::Unit::TestCase
|
12
|
+
include FunctionalBase
|
13
|
+
|
14
|
+
def assert_terminates(pdef, fields, result=nil)
|
15
|
+
|
16
|
+
wfid = @engine.launch(pdef, fields)
|
17
|
+
r = @engine.wait_for(wfid)
|
18
|
+
|
19
|
+
assert_equal 'terminated', r['action']
|
20
|
+
assert_equal(result, r['workitem']['fields']) if result
|
21
|
+
end
|
22
|
+
|
23
|
+
def assert_does_not_validate(pdef, fields={})
|
24
|
+
|
25
|
+
wfid = @engine.launch(pdef, fields)
|
26
|
+
r = @engine.wait_for(wfid)
|
27
|
+
|
28
|
+
err = @engine.errors.first
|
29
|
+
|
30
|
+
assert_equal 'error_intercepted', r['action']
|
31
|
+
assert_match /ValidationError/, err.message
|
32
|
+
assert_equal Array, err.deviations.class
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# the tests
|
37
|
+
|
38
|
+
def test_filter_single_rule_validation
|
39
|
+
|
40
|
+
pdef = Ruote.process_definition do
|
41
|
+
filter 'x', :type => 'string'
|
42
|
+
end
|
43
|
+
|
44
|
+
assert_terminates(pdef, 'x' => 'nada')
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_filter_single_rule__drop_if
|
48
|
+
|
49
|
+
pdef = Ruote.process_definition do
|
50
|
+
filter 'x', :type => 'string', :if => true
|
51
|
+
end
|
52
|
+
|
53
|
+
assert_terminates(pdef, 'x' => 'nada')
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_filter_single_rule_validation_failure
|
57
|
+
|
58
|
+
pdef = Ruote.process_definition do
|
59
|
+
filter 'x', :type => 'string'
|
60
|
+
end
|
61
|
+
|
62
|
+
assert_does_not_validate(pdef, 'x' => 2)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_filter_single_rule_transformation
|
66
|
+
|
67
|
+
pdef = Ruote.process_definition do
|
68
|
+
filter 'x', :or => 'crimea'
|
69
|
+
end
|
70
|
+
|
71
|
+
assert_terminates(pdef, {}, { 'x' => 'crimea' })
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_filter_single_rule_in
|
75
|
+
|
76
|
+
pdef = Ruote.process_definition do
|
77
|
+
filter 'colour', :in => %w[ red green blue ]
|
78
|
+
end
|
79
|
+
|
80
|
+
assert_terminates(pdef, 'colour' => 'green')
|
81
|
+
end
|
82
|
+
|
83
|
+
PDEF1 = Ruote.process_definition do
|
84
|
+
filter :in => [
|
85
|
+
{ :field => 'x', :type => 'string' },
|
86
|
+
{ :field => 'y', :type => 'number' }
|
87
|
+
]
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_filter_multiple_rules_validation
|
91
|
+
|
92
|
+
assert_terminates(PDEF1, 'x' => 's', 'y' => 2)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_filter_multiple_rules_validation_failure
|
96
|
+
|
97
|
+
assert_does_not_validate(PDEF1, 'x' => 's', 'y' => 's')
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_filter_multiple_rules_transformation
|
101
|
+
|
102
|
+
pdef = Ruote.process_definition do
|
103
|
+
filter :in => [
|
104
|
+
{ :field => 'x', :or => 'alpha' },
|
105
|
+
{ :field => 'y', :or => 'bravo' }
|
106
|
+
]
|
107
|
+
end
|
108
|
+
|
109
|
+
assert_terminates(pdef, {}, { 'x' => 'alpha', 'y' => 'bravo' })
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_filter_in_variable
|
113
|
+
|
114
|
+
pdef = Ruote.process_definition do
|
115
|
+
set 'v:toto' => [
|
116
|
+
{ :field => 'a', :set => 'A' },
|
117
|
+
{ :field => 'b', :or => 'B' },
|
118
|
+
]
|
119
|
+
filter 'v:toto'
|
120
|
+
end
|
121
|
+
|
122
|
+
assert_terminates(pdef, {}, { 'a' => 'A', 'b' => 'B' })
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_in_filter_in_variable
|
126
|
+
|
127
|
+
# compatibility with the :filter attribute
|
128
|
+
|
129
|
+
pdef = Ruote.process_definition do
|
130
|
+
set 'v:toto' => { :in => [
|
131
|
+
{ :field => 'a', :set => 'A' },
|
132
|
+
{ :field => 'b', :or => 'B' },
|
133
|
+
] }
|
134
|
+
filter 'v:toto'
|
135
|
+
end
|
136
|
+
|
137
|
+
assert_terminates(pdef, {}, { 'a' => 'A', 'b' => 'B' })
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_filter_in_field
|
141
|
+
|
142
|
+
pdef = Ruote.process_definition do
|
143
|
+
set 'f:toto' => [
|
144
|
+
{ :field => 'a', :set => 'A' },
|
145
|
+
{ :field => 'b', :or => 'B' },
|
146
|
+
]
|
147
|
+
filter 'f:toto'
|
148
|
+
unset 'f:toto'
|
149
|
+
end
|
150
|
+
|
151
|
+
assert_terminates(pdef, {}, { 'a' => 'A', 'b' => 'B' })
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_in_filter_in_field
|
155
|
+
|
156
|
+
pdef = Ruote.process_definition do
|
157
|
+
set 'f:toto' => { :in => [
|
158
|
+
{ :field => 'a', :set => 'A' },
|
159
|
+
{ :field => 'b', :or => 'B' },
|
160
|
+
] }
|
161
|
+
filter 'f:toto'
|
162
|
+
unset 'f:toto'
|
163
|
+
end
|
164
|
+
|
165
|
+
assert_terminates(pdef, {}, { 'a' => 'A', 'b' => 'B' })
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_tilde
|
169
|
+
|
170
|
+
# the ~ points to the hash as it was right before the filtering began
|
171
|
+
|
172
|
+
pdef = Ruote.process_definition do
|
173
|
+
filter :in => [
|
174
|
+
{ :field => 'x', :set => 'X' },
|
175
|
+
{ :field => 'x', :copy_from => '~.x' },
|
176
|
+
]
|
177
|
+
end
|
178
|
+
|
179
|
+
assert_terminates(pdef, { 'x' => 1 }, { 'x' => 1 })
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_double_tilde
|
183
|
+
|
184
|
+
# the ~~ points to the workitem fields as they are in the parent expression
|
185
|
+
|
186
|
+
pdef = Ruote.process_definition do
|
187
|
+
filter 'x', :set => 'X'
|
188
|
+
filter 'x', :copy_from => '~~.x'
|
189
|
+
end
|
190
|
+
|
191
|
+
assert_terminates(pdef, { 'x' => 1 }, { 'x' => 1 })
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_record
|
195
|
+
|
196
|
+
pdef = Ruote.process_definition do
|
197
|
+
filter 'x', :type => 'string', :record => true
|
198
|
+
end
|
199
|
+
|
200
|
+
assert_terminates(
|
201
|
+
pdef,
|
202
|
+
{ 'x' => 1 },
|
203
|
+
{ '__validation_errors__' => [
|
204
|
+
[ { 'type' => 'string', 'field' => 'x' }, 'x', 1 ]
|
205
|
+
],
|
206
|
+
'x' => 1
|
207
|
+
})
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_record__complex
|
211
|
+
|
212
|
+
pdef = Ruote.process_definition do
|
213
|
+
filter :in => [
|
214
|
+
{ :field => 'x', :type => 'string', :record => true },
|
215
|
+
{ :field => 'y', :type => 'number' }
|
216
|
+
]
|
217
|
+
end
|
218
|
+
|
219
|
+
assert_terminates(
|
220
|
+
pdef,
|
221
|
+
{ 'x' => 1 },
|
222
|
+
{ '__validation_errors__' => [
|
223
|
+
[ { 'type' => 'string', 'field' => 'x' }, 'x', 1 ],
|
224
|
+
[ { 'type' => 'number', 'field' => 'y' }, 'y', nil ]
|
225
|
+
],
|
226
|
+
'x' => 1
|
227
|
+
})
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_record_in_designated_field
|
231
|
+
|
232
|
+
pdef = Ruote.process_definition do
|
233
|
+
filter 'x', :type => 'string', :record => 'verrors'
|
234
|
+
end
|
235
|
+
|
236
|
+
assert_terminates(
|
237
|
+
pdef,
|
238
|
+
{ 'x' => 1 },
|
239
|
+
{ 'verrors' => [
|
240
|
+
[ { 'type' => 'string', 'field' => 'x' }, 'x', 1 ]
|
241
|
+
],
|
242
|
+
'x' => 1
|
243
|
+
})
|
244
|
+
end
|
245
|
+
|
246
|
+
def test_record_accumulates
|
247
|
+
|
248
|
+
pdef = Ruote.process_definition do
|
249
|
+
filter 'x', :type => 'string', :record => true
|
250
|
+
filter 'y', :type => 'number', :record => true
|
251
|
+
end
|
252
|
+
|
253
|
+
assert_terminates(
|
254
|
+
pdef,
|
255
|
+
{ 'x' => 1 },
|
256
|
+
{ '__validation_errors__' => [
|
257
|
+
[ { 'type' => 'string', 'field' => 'x' }, 'x', 1 ],
|
258
|
+
[ { 'type' => 'number', 'field' => 'y' }, 'y', nil ]
|
259
|
+
],
|
260
|
+
'x' => 1
|
261
|
+
})
|
262
|
+
end
|
263
|
+
|
264
|
+
def test_record_flushes_and_accumulates
|
265
|
+
|
266
|
+
pdef = Ruote.process_definition do
|
267
|
+
filter 'x', :type => 'string', :record => true
|
268
|
+
filter 'y', :type => 'number', :record => true, :flush => true
|
269
|
+
end
|
270
|
+
|
271
|
+
assert_terminates(
|
272
|
+
pdef,
|
273
|
+
{ 'x' => 1 },
|
274
|
+
{ '__validation_errors__' => [
|
275
|
+
[ { 'type' => 'number', 'field' => 'y' }, 'y', nil ]
|
276
|
+
],
|
277
|
+
'x' => 1
|
278
|
+
})
|
279
|
+
end
|
280
|
+
|
281
|
+
def test_filter_and_block
|
282
|
+
|
283
|
+
pdef = Ruote.process_definition do
|
284
|
+
filter do
|
285
|
+
field 'x', :type => 'string'
|
286
|
+
field 'y', :type => 'number'
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
#@engine.noisy = true
|
291
|
+
|
292
|
+
assert_terminates(pdef, 'x' => 's', 'y' => 2)
|
293
|
+
assert_does_not_validate(pdef, 'x' => 's', 'y' => 's')
|
294
|
+
end
|
295
|
+
|
296
|
+
def test_filter_and_block__radial
|
297
|
+
|
298
|
+
pdef = %{
|
299
|
+
define
|
300
|
+
filter
|
301
|
+
f x, type: 'string'
|
302
|
+
f y, type: 'number'
|
303
|
+
}
|
304
|
+
|
305
|
+
#@engine.noisy = true
|
306
|
+
|
307
|
+
assert_terminates(pdef, 'x' => 's', 'y' => 2)
|
308
|
+
assert_does_not_validate(pdef, 'x' => 's', 'y' => 's')
|
309
|
+
end
|
310
|
+
|
311
|
+
def test_filter_and_block__field_name_is_expname
|
312
|
+
|
313
|
+
pdef = %{
|
314
|
+
define
|
315
|
+
filter
|
316
|
+
x type: 'string'
|
317
|
+
y type: 'number'
|
318
|
+
}
|
319
|
+
|
320
|
+
#@engine.noisy = true
|
321
|
+
|
322
|
+
assert_terminates(pdef, 'x' => 's', 'y' => 2)
|
323
|
+
assert_does_not_validate(pdef, 'x' => 's', 'y' => 's')
|
324
|
+
end
|
325
|
+
|
326
|
+
def test_filter_and_block__collision_with_if
|
327
|
+
|
328
|
+
pdef = %{
|
329
|
+
define
|
330
|
+
filter if: true
|
331
|
+
x type: 'string'
|
332
|
+
y type: 'number'
|
333
|
+
}
|
334
|
+
|
335
|
+
#@engine.noisy = true
|
336
|
+
|
337
|
+
assert_terminates(pdef, 'x' => 's', 'y' => 2)
|
338
|
+
assert_does_not_validate(pdef, 'x' => 's', 'y' => 's')
|
339
|
+
end
|
340
|
+
|
341
|
+
def test_filter_block_and_or
|
342
|
+
|
343
|
+
pdef = Ruote.process_definition do
|
344
|
+
filter do
|
345
|
+
field 'x', :type => 'string'
|
346
|
+
_or
|
347
|
+
field 'x', :type => 'number'
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
#@engine.noisy = true
|
352
|
+
|
353
|
+
assert_terminates(pdef, 'x' => 's')
|
354
|
+
assert_terminates(pdef, 'x' => 5)
|
355
|
+
assert_does_not_validate(pdef, 'x' => true)
|
356
|
+
end
|
357
|
+
|
358
|
+
def test_filter_block_and_or__radial
|
359
|
+
|
360
|
+
pdef = %{
|
361
|
+
define
|
362
|
+
filter
|
363
|
+
x type: 'string'
|
364
|
+
or
|
365
|
+
x type: 'number'
|
366
|
+
}
|
367
|
+
|
368
|
+
#@engine.noisy = true
|
369
|
+
|
370
|
+
assert_terminates(pdef, 'x' => 's')
|
371
|
+
assert_terminates(pdef, 'x' => 5)
|
372
|
+
assert_does_not_validate(pdef, 'x' => true)
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|