_workflow__dynamic_simple_workflow (private)

 _workflow__dynamic_simple_workflow

Defined in packages/workflow/tcl/test/workflow-test-procs.tcl

Partial Call Graph (max 5 caller/called nodes):
%3 aa_log aa_log (public) aa_log_result aa_log_result (public) aa_run_with_teardown aa_run_with_teardown (public) aa_true aa_true (public) ad_generate_random_string ad_generate_random_string (public) _workflow__dynamic_simple_workflow _workflow__dynamic_simple_workflow _workflow__dynamic_simple_workflow->aa_log _workflow__dynamic_simple_workflow->aa_log_result _workflow__dynamic_simple_workflow->aa_run_with_teardown _workflow__dynamic_simple_workflow->aa_true _workflow__dynamic_simple_workflow->ad_generate_random_string

Testcases:
No testcase defined.
Source code:
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{
    aa_run_with_teardown -rollback -test_code {

        #----------------------------------------------------------------------
        # Create dynamic workflow
        #----------------------------------------------------------------------
        #  action_id                 | trigger  |  s1  |  s2  | done  |
        # ---------------------------+----------+------+------+-------+
        #  inti                      | init     |      |      |       |
        #  task_one                  | dynamic  |  X   |      |       |
        #    dyn                     | user     |      |      |       |
        #  task_two                  | user     |      |  X   |       |

        set workflow_id [workflow::fsm::new_from_spec -package_key "acs-automated-testing" -spec {
            dynamic_simple {
                pretty_name "Simple Dynamic Test Workflow"
                states {
                    s1 {
                        pretty_name "S1"
                        assigned_actions { task_one } 
                    }
                    s2 { 
                        pretty_name "S2" 
                        assigned_actions { task_two }
                    }
                    done { 
                        pretty_name "Done" 
                    }
                }
                roles {
                    role1 {
                        pretty_name "Role1"
                    }
                    role2 {
                        pretty_name "Role2"
                    }
                }
                actions {
                    init {
                        pretty_name "Open"
                        new_state "s1"
                        trigger_type init
                    }
                    task_one {
                        pretty_name "Task 1 (dynamic)"
                        new_state "s2"
                        trigger_type dynamic
                    }
                    dyn {
                        pretty_name "Dynamic (user)"
                        parent_action "task_one"
                        assigned_role role1
                    }
                    task_two {
                        pretty_name "Task 2 (user)"
                        new_state "done"
                        assigned_role role2
                    }
                }
            }
        }]
        
        #----------------------------------------------------------------------
        # Test the state-action map
        #----------------------------------------------------------------------

        array set state_action_map {
            s1 { task_one } 
            s2 { task_two }
            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]
        }

        #----------------------------------------------------------------------
        # Create the required users
        #----------------------------------------------------------------------
        
        array set r1u1_array [auth::create_user -username [ad_generate_random_string] -email "[ad_generate_random_string]@test.test"  -first_names [ad_generate_random_string] -last_name [ad_generate_random_string]]
        set r1u1 $r1u1_array(user_id)

        array set r1u2_array [auth::create_user -username [ad_generate_random_string] -email "[ad_generate_random_string]@test.test"  -first_names [ad_generate_random_string] -last_name [ad_generate_random_string]]
        set r1u2 $r1u2_array(user_id)

        array set r2u1_array [auth::create_user -username [ad_generate_random_string] -email "[ad_generate_random_string]@test.test"  -first_names [ad_generate_random_string] -last_name [ad_generate_random_string]]
        set r2u1 $r2u1_array(user_id)

        #----------------------------------------------------------------------
        # 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]  -assignment [list role1 [list $r1u1 $r1u2] role2 [list $r2u1]]]
    
        workflow::test::assert_case_state  -workflow_id $workflow_id  -case_id $case_id  -expect_current_state { s1 }  -expect_enabled_actions { dyn dyn }

        workflow::test::assert_user_actions  -workflow_id $workflow_id  -case_id $case_id  -user_id $r1u1  -expect_user_actions { dyn }

        workflow::test::assert_user_actions  -workflow_id $workflow_id  -case_id $case_id  -user_id $r1u2  -expect_user_actions { dyn }

        workflow::test::assert_user_actions  -workflow_id $workflow_id  -case_id $case_id  -user_id $r2u1  -expect_user_actions { }

        #----------------------------------------------------------------------
        # Execute 'sub' as r1u2
        #----------------------------------------------------------------------

        set enabled_action_id [workflow::case::get_available_enabled_action_ids  -case_id $case_id  -user_id $r1u2]
        
        workflow::case::action::execute  -case_id $case_id  -enabled_action_id $enabled_action_id  -user_id $r1u2

        #----------------------------------------------------------------------
        # Available should now be 'sub' as r1u1
        #----------------------------------------------------------------------

        workflow::test::assert_case_state  -workflow_id $workflow_id  -case_id $case_id  -expect_current_state { s1 }  -expect_enabled_actions { dyn }

        workflow::test::assert_user_actions  -workflow_id $workflow_id  -case_id $case_id  -user_id $r1u1  -expect_user_actions { dyn }

        workflow::test::assert_user_actions  -workflow_id $workflow_id  -case_id $case_id  -user_id $r1u2  -expect_user_actions { }

        workflow::test::assert_user_actions  -workflow_id $workflow_id  -case_id $case_id  -user_id $r2u1  -expect_user_actions { }

        #----------------------------------------------------------------------
        # Execute 'sub' as r1u1
        #----------------------------------------------------------------------

        set enabled_action_id [workflow::case::get_available_enabled_action_ids  -case_id $case_id  -user_id $r1u1]
        
        workflow::case::action::execute  -case_id $case_id  -enabled_action_id $enabled_action_id  -user_id $r1u1

        #----------------------------------------------------------------------
        # Available should now be 'task_two' as r2u1
        #----------------------------------------------------------------------

        workflow::test::assert_case_state  -workflow_id $workflow_id  -case_id $case_id  -expect_current_state { s2 }  -expect_enabled_actions { task_two }

        workflow::test::assert_user_actions  -workflow_id $workflow_id  -case_id $case_id  -user_id $r1u1  -expect_user_actions { }

        workflow::test::assert_user_actions  -workflow_id $workflow_id  -case_id $case_id  -user_id $r1u2  -expect_user_actions { }

        workflow::test::assert_user_actions  -workflow_id $workflow_id  -case_id $case_id  -user_id $r2u1  -expect_user_actions { task_two }

        #----------------------------------------------------------------------
        # Execute 'task_two'
        #----------------------------------------------------------------------

        set enabled_action_id [workflow::case::get_available_enabled_action_ids  -case_id $case_id  -user_id $r2u1]
        
        workflow::case::action::execute  -case_id $case_id  -enabled_action_id $enabled_action_id  -user_id $r2u1

        #----------------------------------------------------------------------
        # 'done', Nothing enabled
        #----------------------------------------------------------------------
        
        workflow::test::assert_case_state  -workflow_id $workflow_id  -case_id $case_id  -expect_current_state { done }  -expect_enabled_actions { }  -expect_user_actions { }
    }
        
}} {
          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" "dynamic_simple_workflow (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo"
          }
          incr body_count
        }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: