_workflow__hierarchical_workflow (private)
_workflow__hierarchical_workflow
Defined in packages/workflow/tcl/test/workflow-test-procs.tcl
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set _aa_export {} set body_count 1 foreach testcase_body {{ aa_run_with_teardown -rollback -test_code { #---------------------------------------------------------------------- # Create hierarchical workflow #---------------------------------------------------------------------- # action_id | trigger |ask_cl|ask_lwr|lac-ask|lac-give|cal-ask|cal-give # ---------------------------+----------+------+-------+-------+--------+-------+--------- # open | init | | | | | | # lawyer_asks_client | workflow | X | | | | | # lawyer_asks_client_init | init | | | | | | # lawyer_asks_client_ask | user | | | X | | | # lawyer_asks_client_give | user | | | | X | | # client_asks_lawyer | workflow | | X | | | | # client_asks_lawyer_init | init | | | | | | # client_asks_lawyer_ask | user | | | | | X | # client_asks_lawyer_give | user | | | | | | X set workflow_id [workflow::fsm::new_from_spec -package_key "acs-automated-testing" -spec { hierarchical_workflow { pretty_name "Hierarchical Workflow" states { asking_client { pretty_name "Asking Client" enabled_actions { lawyer_asks_client } } asking_lawyer { pretty_name "Asking Lawyer" enabled_actions { client_asks_lawyer } } done { pretty_name "Done" } lawyer_asks_client_asking { pretty_name "AC-Asking" parent_action "lawyer_asks_client" enabled_actions { lawyer_asks_client_ask } } lawyer_asks_client_giving { pretty_name "AC-Giving" parent_action "lawyer_asks_client" enabled_actions { lawyer_asks_client_give } } lawyer_asks_client_done { pretty_name "AC-Done" parent_action "lawyer_asks_client" } client_asks_lawyer_asking { pretty_name "AL-Asking" parent_action "client_asks_lawyer" enabled_actions { client_asks_lawyer_ask } } client_asks_lawyer_giving { pretty_name "AL-Giving" parent_action "client_asks_lawyer" enabled_actions { client_asks_lawyer_give } } client_asks_lawyer_done { pretty_name "AL-Done" parent_action "client_asks_lawyer" } } roles { lawyer { pretty_name "Lawyer" } client { pretty_name "Client" } } actions { open { pretty_name "Open" pretty_past_tense "Opened" new_state "asking_client" trigger_type init } lawyer_asks_client { pretty_name "Lawyer asks client" pretty_past_tense "Lawyer asked client" new_state "asking_lawyer" trigger_type workflow } lawyer_asks_client_init { pretty_name "Lawyer asks client-Init" pretty_past_tense "Lawyer asked client-Init" trigger_type init parent_action "lawyer_asks_client" new_state "lawyer_asks_client_asking" } lawyer_asks_client_ask { pretty_name "Ask client" pretty_past_tense "Asked client" parent_action "lawyer_asks_client" new_state "lawyer_asks_client_giving" assigned_role "lawyer" } lawyer_asks_client_give { pretty_name "Respond to lawyer" pretty_past_tense "Responded to lawyer" parent_action "lawyer_asks_client" new_state "lawyer_asks_client_done" assigned_role "client" } client_asks_lawyer { pretty_name "Client asks lawyer" pretty_past_tense "Client asked lawyer" enabled_states { asking_lawyer } new_state "done" trigger_type workflow } client_asks_lawyer_init { pretty_name "Client asks lawyer-Init" pretty_past_tense "Client asked lawyer-Init" trigger_type init parent_action "client_asks_lawyer" new_state "client_asks_lawyer_asking" } client_asks_lawyer_ask { pretty_name "Ask lawyer" pretty_past_tense "Asked lawyer" parent_action "client_asks_lawyer" enabled_states { client_asks_lawyer_asking } new_state "client_asks_lawyer_giving" assigned_role "client" } client_asks_lawyer_give { pretty_name "Respond to client" pretty_past_tense "Responded to client" parent_action "client_asks_lawyer" enabled_states { client_asks_lawyer_giving } new_state "client_asks_lawyer_done" assigned_role "lawyer" } } } }] #---------------------------------------------------------------------- # Test the state-action map #---------------------------------------------------------------------- array set state_action_map { asking_client { lawyer_asks_client } asking_lawyer { client_asks_lawyer } done {} lawyer_asks_client_asking { lawyer_asks_client_ask } lawyer_asks_client_giving { lawyer_asks_client_give } lawyer_asks_client_done {} client_asks_lawyer_asking { client_asks_lawyer_ask } client_asks_lawyer_giving { client_asks_lawyer_give } client_asks_lawyer_done {} } foreach state [array names state_action_map] { set state_id [workflow::state::fsm::get_id -workflow_id $workflow_id -short_name $state] set enabled_actions [workflow::state::fsm::get_element -state_id $state_id -element enabled_actions] #aa_true "Enabled actions in state $state are $enabled_actions, should be $state_action_map($state)" [util_sets_equal_p $state_action_map($state) $enabled_actions] } #---------------------------------------------------------------------- # Start a case of the workflow #---------------------------------------------------------------------- aa_log "Starting case." set case_id [workflow::case::new -workflow_id $workflow_id -object_id [workflow::test::workflow_object_id] -user_id [workflow::test::admin_owner_id]] #---------------------------------------------------------------------- # 'lawyer_asks_client_ask' should now be available #---------------------------------------------------------------------- workflow::test::assert_case_state -workflow_id $workflow_id -case_id $case_id -expect_current_state { "asking_client" "lawyer_asks_client_asking" } -expect_enabled_actions "lawyer_asks_client_ask" #---------------------------------------------------------------------- # Execute 'lawyer_asks_client_ask' #---------------------------------------------------------------------- aa_log "Executing: lawyer_asks_client_ask" workflow::case::action::execute -case_id $case_id -action_id [workflow::action::get_id -workflow_id $workflow_id -short_name "lawyer_asks_client_ask"] -comment "Lawyer asks" -comment_mime_type "text/plain" -user_id [workflow::test::admin_owner_id] #---------------------------------------------------------------------- # Enabled action: 'lawyer_asks_client_give' #---------------------------------------------------------------------- workflow::test::assert_case_state -workflow_id $workflow_id -case_id $case_id -expect_current_state { "asking_client" "lawyer_asks_client_giving" } -expect_enabled_actions "lawyer_asks_client_give" #---------------------------------------------------------------------- # Execute 'lawyer_asks_client_give' #---------------------------------------------------------------------- aa_log "Executing: lawyer_asks_client_give" workflow::case::action::execute -case_id $case_id -action_id [workflow::action::get_id -workflow_id $workflow_id -short_name "lawyer_asks_client_give"] -comment "Client responds" -comment_mime_type "text/plain" -user_id [workflow::test::admin_owner_id] #---------------------------------------------------------------------- # 'client_asks_lawyer_ask' should now be available #---------------------------------------------------------------------- workflow::test::assert_case_state -workflow_id $workflow_id -case_id $case_id -expect_current_state { "asking_lawyer" "client_asks_lawyer_asking" } -expect_enabled_actions "client_asks_lawyer_ask" #---------------------------------------------------------------------- # Execute 'client_asks_lawyer_ask' #---------------------------------------------------------------------- aa_log "Executing: client_asks_lawyer_ask" workflow::case::action::execute -case_id $case_id -action_id [workflow::action::get_id -workflow_id $workflow_id -short_name "client_asks_lawyer_ask"] -comment "Client asks" -comment_mime_type "text/plain" -user_id [workflow::test::admin_owner_id] #---------------------------------------------------------------------- # Enabled action: 'client_asks_lawyer_give' #---------------------------------------------------------------------- workflow::test::assert_case_state -workflow_id $workflow_id -case_id $case_id -expect_current_state { "asking_lawyer" "client_asks_lawyer_giving" } -expect_enabled_actions "client_asks_lawyer_give" #---------------------------------------------------------------------- # Execute 'client_asks_lawyer_give' #---------------------------------------------------------------------- aa_log "Executing: client_asks_lawyer_give" workflow::case::action::execute -case_id $case_id -action_id [workflow::action::get_id -workflow_id $workflow_id -short_name "client_asks_lawyer_give"] -comment "Lawyer responds" -comment_mime_type "text/plain" -user_id [workflow::test::admin_owner_id] #---------------------------------------------------------------------- # 'done', Nothing enabled #---------------------------------------------------------------------- workflow::test::assert_case_state -workflow_id $workflow_id -case_id $case_id -expect_current_state { "done" } -expect_enabled_actions [list] } }} { aa_log "Running testcase body $body_count" set ::__aa_test_indent [info level] set catch_val [catch $testcase_body msg] if {$catch_val != 0 && $catch_val != 2} { aa_log_result "fail" "hierarchical_workflow (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo" } incr body_count }XQL Not present: Generic, PostgreSQL, Oracle