_workflow__workflow_automatic_action (private)

 _workflow__workflow_automatic_action

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

Partial Call Graph (max 5 caller/called nodes):
%3 aa_equals aa_equals (public) aa_false aa_false (public) aa_log aa_log (public) aa_log_result aa_log_result (public) aa_true aa_true (public) _workflow__workflow_automatic_action _workflow__workflow_automatic_action _workflow__workflow_automatic_action->aa_equals _workflow__workflow_automatic_action->aa_false _workflow__workflow_automatic_action->aa_log _workflow__workflow_automatic_action->aa_log_result _workflow__workflow_automatic_action->aa_true

Testcases:
No testcase defined.
Source code:
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{
    workflow::test::run_with_teardown {
        # Define workflow
        
        set workflow_id [workflow::new  -short_name "test_automatic_ations"  -pretty_name "Testing Automatic Actions"  -package_key "acs-automated-testing"]

        # [open] -> (open) -> [auto] -> (closed)

        workflow::state::fsm::new  -workflow_id $workflow_id  -short_name "open"  -pretty_name "Open"

        workflow::state::fsm::new -workflow_id $workflow_id  -short_name "closed"  -pretty_name "Closed"

        workflow::action::fsm::new  -trigger_type init  -workflow_id $workflow_id  -short_name [ad_generate_random_string]  -pretty_name "Open"  -new_state "open"                              

        set auto_action_id [workflow::action::fsm::new  -workflow_id $workflow_id  -short_name "auto"  -pretty_name "Auto"  -enabled_states "open"  -new_state "closed"  -trigger_type auto]

        # Start a 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]]

        # Check that it's now in 'closed' state
        set current_state [workflow::case::fsm::get_current_state -case_id $case_id]
        set current_state_short [workflow::state::fsm::get_element -state_id $current_state -element short_name]

        aa_equals "Case is closed" $current_state_short "closed"

        # Change the action to be timed

        set update_cols(timeout_seconds) 1
        set update_cols(trigger_type) "time"
        workflow::action::fsm::edit  -action_id $auto_action_id  -array update_cols
        
        set case_id [workflow::case::new  -workflow_id $workflow_id  -object_id [db_string objid { select max(object_id) from acs_objects } ]  -user_id [workflow::test::admin_owner_id]]

        # Check that it's now in 'open' state
        set current_state [workflow::case::fsm::get_current_state -case_id $case_id]
        set current_state_short [workflow::state::fsm::get_element -state_id $current_state -element short_name]

        aa_equals "Case is open" $current_state_short "open"
        
        # Run sweeper
        ns_sleep 1
        workflow::case::timed_actions_sweeper

        # Check that it's now in 'closed' state
        set current_state [workflow::case::fsm::get_current_state -case_id $case_id]
        set current_state_short [workflow::state::fsm::get_element -state_id $current_state -element short_name]

        aa_equals "Case is closed" $current_state_short "closed"

        # Add another action

        # Old process: [open] -> (open) -> [auto] -> (closed)
        # New process: [open] -> (open) -> [auto] -> (closed) -> [reopen] -> (open)

        set reopen_action_id [workflow::action::fsm::new  -workflow_id $workflow_id  -short_name "reopen"  -pretty_name "Reopen"  -enabled_states "closed"  -new_state "open"]

        # The new action should now be anabled
        aa_true "New 'reopen' action is enabled" [workflow::case::action::enabled_p  -case_id $case_id  -action_id $reopen_action_id]

        # Execute it
        workflow::case::action::execute  -no_perm_check  -case_id $case_id  -action_id $reopen_action_id

        # The new action should now be anabled
        aa_false "New 'reopen' action is not enabled" [workflow::case::action::enabled_p  -case_id $case_id  -action_id $reopen_action_id]

        # Case should be open
        set current_state [workflow::case::fsm::get_current_state -case_id $case_id]
        set current_state_short [workflow::state::fsm::get_element -state_id $current_state -element short_name]
        aa_equals "Case is open" $current_state_short "open"
        
        # The new action should now be anabled again
        aa_true "Timed 'close' action is enabled" [workflow::case::action::enabled_p  -case_id $case_id  -action_id $auto_action_id]
        # Run sweeper
        ns_sleep 1
        workflow::case::timed_actions_sweeper

        # Check that it's now in 'closed' state
        set current_state [workflow::case::fsm::get_current_state -case_id $case_id]
        set current_state_short [workflow::state::fsm::get_element -state_id $current_state -element short_name]

        aa_equals "Case is closed" $current_state_short "closed"

        # The new action should now be anabled again
        aa_true "New 'reopen' action is enabled" [workflow::case::action::enabled_p  -case_id $case_id  -action_id $reopen_action_id]

    } {
        set workflow_id [workflow::get_id -package_key "acs-automated-testing" -short_name "test_automatic_ations"]
        workflow::delete -workflow_id $workflow_id
    }
}} {
          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" "workflow_automatic_action (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: