1# -- 2# Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ 3# -- 4# This software comes with ABSOLUTELY NO WARRANTY. For details, see 5# the enclosed file COPYING for license information (GPL). If you 6# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt. 7# -- 8 9use strict; 10use warnings; 11use utf8; 12 13use vars (qw($Self)); 14 15use Kernel::System::VariableCheck qw(:all); 16 17# get needed objects 18my $ConfigObject = $Kernel::OM->Get('Kernel::Config'); 19my $QueueObject = $Kernel::OM->Get('Kernel::System::Queue'); 20my $ProcessObject = $Kernel::OM->Get('Kernel::System::ProcessManagement::Process'); 21 22# get helper object 23$Kernel::OM->ObjectParamAdd( 24 'Kernel::System::UnitTest::Helper' => { 25 RestoreDatabase => 1, 26 UseTmpArticleDir => 1, 27 }, 28); 29my $Helper = $Kernel::OM->Get('Kernel::System::UnitTest::Helper'); 30 31# create common objects to be used in ActivityDialog object creation 32my %CommonObject; 33$CommonObject{ActivityObject} = $Kernel::OM->Get('Kernel::System::ProcessManagement::Activity'); 34$CommonObject{ActivityDialogObject} = $Kernel::OM->Get('Kernel::System::ProcessManagement::ActivityDialog'); 35$CommonObject{TransitionObject} = $Kernel::OM->Get('Kernel::System::ProcessManagement::Transition'); 36$CommonObject{TransitionActionObject} = $Kernel::OM->Get('Kernel::System::ProcessManagement::TransitionAction'); 37$CommonObject{TicketObject} = $Kernel::OM->Get('Kernel::System::Ticket'); 38 39# define needed variables 40my $RandomID = $Helper->GetRandomID(); 41 42# create some queues in the system 43my %QueueData1 = ( 44 Name => 'Queue1' . $RandomID, 45 ValidID => 1, 46 GroupID => 1, 47 SystemAddressID => 1, 48 SalutationID => 1, 49 SignatureID => 1, 50 Comment => 'Some comment', 51 UserID => 1, 52); 53 54my %QueueData2 = ( 55 Name => 'Queue2' . $RandomID, 56 ValidID => 1, 57 GroupID => 1, 58 SystemAddressID => 1, 59 SalutationID => 1, 60 SignatureID => 1, 61 Comment => 'Some comment', 62 UserID => 1, 63); 64 65my %QueueData3 = ( 66 Name => 'Queue3' . $RandomID, 67 ValidID => 1, 68 GroupID => 1, 69 SystemAddressID => 1, 70 SalutationID => 1, 71 SignatureID => 1, 72 Comment => 'Some comment', 73 UserID => 1, 74); 75 76my $QueueID1 = $QueueObject->QueueAdd(%QueueData1); 77 78# sanity check 79$Self->IsNot( 80 $QueueID1, 81 undef, 82 "QueueAdd() - Added queue '$QueueData1{Name}' for ACL check - should not be undef" 83); 84 85my $QueueID2 = $QueueObject->QueueAdd(%QueueData2); 86 87# sanity check 88$Self->IsNot( 89 $QueueID2, 90 undef, 91 "QueueAdd() - Added queue '$QueueData2{Name}' for ACL check - should not be undef" 92); 93 94my $QueueID3 = $QueueObject->QueueAdd(%QueueData3); 95 96# sanity check 97$Self->IsNot( 98 $QueueID3, 99 undef, 100 "QueueAdd() - Added queue '$QueueData3{Name}' for ACL check - should not be undef" 101); 102 103my $TestCustomerUserLogin = $Helper->TestCustomerUserCreate(); 104 105# Get ServiceObject. 106my $ServiceObject = $Kernel::OM->Get('Kernel::System::Service'); 107 108my $ServiceID = $ServiceObject->ServiceAdd( 109 Name => $RandomID, 110 ValidID => 1, 111 UserID => 1, 112); 113 114$ServiceObject->CustomerUserServiceMemberAdd( 115 CustomerUserLogin => $TestCustomerUserLogin, 116 ServiceID => $ServiceID, 117 Active => 1, 118 UserID => 1, 119); 120 121my $SLAID = $Kernel::OM->Get('Kernel::System::SLA')->SLAAdd( 122 ServiceIDs => [$ServiceID], 123 Name => $RandomID, 124 ValidID => 1, 125 UserID => 1, 126); 127 128my $TicketID = $CommonObject{TicketObject}->TicketCreate( 129 Title => 'Process Unittest Testticket', 130 Queue => $QueueData3{Name}, 131 Lock => 'unlock', 132 Priority => '3 normal', 133 State => 'new', 134 OwnerID => 1, 135 CustomerUser => $TestCustomerUserLogin, 136 UserID => 1, 137); 138$Self->True( 139 $TicketID || 0, 140 "TicketCreate() Testticket for Unittests created", 141); 142 143my @Tests = ( 144 145 # Get on no config 146 { 147 ProcessGet => { 148 Config => {}, 149 ProcessEntityID => 'unknown123', 150 Message => 'ProcessGet() (No Config)', 151 TestType => 'False', 152 } 153 }, 154 155 # Get on no ProcessEntityID 156 { 157 ProcessGet => { 158 Config => { 159 'Process' => { 160 'P1' => { 161 Name => 'Book Orders', 162 CreateTime => '16-02-2012 13:37:00', 163 CreateBy => '1', 164 ChangeTime => '17-02-2012 13:37:00', 165 ChangeBy => '1', 166 State => 'Active', 167 StartActivity => 'A1', 168 StartActivityDialog => 'AD1', 169 Path => { 170 'A1' => { 171 'T1' => { 172 ActivityEntityID => 'A2', 173 }, 174 'T2' => { 175 ActivityEntityID => 'A3', 176 }, 177 }, 178 'A2' => { 179 'T3' => { 180 ActivityEntityID => 'A4', 181 }, 182 }, 183 }, 184 }, 185 }, 186 }, 187 ProcessEntityID => 'unknown' . $RandomID, 188 Message => 'ProcessGet() (unknown ProcessEntityID)', 189 TestType => 'False', 190 } 191 }, 192 193 { 194 ProcessGet => { 195 Config => { 196 'Process' => { 197 'P1' => { 198 Name => 'Book Orders', 199 CreateTime => '16-02-2012 13:37:00', 200 CreateBy => '1', 201 ChangeTime => '17-02-2012 13:37:00', 202 ChangeBy => '1', 203 State => 'Active', 204 StartActivity => 'A1', 205 StartActivityDialog => 'AD1', 206 Path => { 207 'A1' => { 208 'T1' => { 209 ActivityEntityID => 'A2', 210 }, 211 'T2' => { 212 ActivityEntityID => 'A3', 213 }, 214 }, 215 'A2' => { 216 'T3' => { 217 ActivityEntityID => 'A4', 218 }, 219 }, 220 }, 221 }, 222 }, 223 }, 224 Message => 'ProcessGet() (No ProcessEntityID)', 225 TestType => 'False', 226 } 227 }, 228 229 # Get on invalid ProcessEntityID 230 { 231 ProcessGet => { 232 Config => { 233 'Process' => { 234 'P1' => { 235 Name => 'Book Orders', 236 CreateTime => '16-02-2012 13:37:00', 237 CreateBy => '1', 238 ChangeTime => '17-02-2012 13:37:00', 239 ChangeBy => '1', 240 State => 'Active', 241 StartActivity => 'A1', 242 StartActivityDialog => 'AD1', 243 Path => { 244 'A1' => { 245 'T1' => { 246 ActivityEntityID => 'A2', 247 }, 248 'T2' => { 249 ActivityEntityID => 'A3', 250 }, 251 }, 252 'A2' => { 253 'T3' => { 254 ActivityEntityID => 'A4', 255 }, 256 }, 257 }, 258 }, 259 }, 260 }, 261 ProcessEntityID => 'unknown123', 262 Message => 'ProcessGet() (unknown ProcessEntityID)', 263 TestType => 'False', 264 } 265 }, 266 267 # Get on valid ProcessEntityID 268 { 269 ProcessGet => { 270 Config => { 271 'Process' => { 272 'P1' => { 273 Name => 'Book Orders', 274 CreateTime => '16-02-2012 13:37:00', 275 CreateBy => '1', 276 ChangeTime => '17-02-2012 13:37:00', 277 ChangeBy => '1', 278 State => 'Active', 279 StartActivity => 'A1', 280 StartActivityDialog => 'AD1', 281 Path => { 282 'A1' => { 283 'T1' => { 284 ActivityEntityID => 'A2', 285 }, 286 'T2' => { 287 ActivityEntityID => 'A3', 288 }, 289 }, 290 'A2' => { 291 'T3' => { 292 ActivityEntityID => 'A4', 293 }, 294 }, 295 }, 296 }, 297 }, 298 }, 299 ProcessEntityID => 'P1', 300 Message => 'ProcessGet() (known ProcessEntityID)', 301 TestType => 'Result', 302 Result => { 303 Name => 'Book Orders', 304 CreateTime => '16-02-2012 13:37:00', 305 CreateBy => '1', 306 ChangeTime => '17-02-2012 13:37:00', 307 ChangeBy => '1', 308 State => 'Active', 309 StartActivity => 'A1', 310 StartActivityDialog => 'AD1', 311 Path => { 312 'A1' => { 313 'T1' => { 314 ActivityEntityID => 'A2', 315 }, 316 'T2' => { 317 ActivityEntityID => 'A3', 318 }, 319 }, 320 'A2' => { 321 'T3' => { 322 ActivityEntityID => 'A4', 323 }, 324 }, 325 }, 326 }, 327 }, 328 }, 329 330 # Get on valid ProcessEntityID UTF8 331 { 332 ProcessGet => { 333 Config => { 334 'Process' => { 335 'P1' => { 336 Name => 337 'äöüßÄÖÜ€исáéíúóúÁÉÍÓÚñÑ-カスタ-用迎使用-Язык', 338 CreateTime => '16-02-2012 13:37:00', 339 CreateBy => '1', 340 ChangeTime => '17-02-2012 13:37:00', 341 ChangeBy => '1', 342 State => 'Active', 343 StartActivity => 'A1', 344 StartActivityDialog => 'AD1', 345 Path => { 346 'A1' => { 347 'T1' => { 348 ActivityEntityID => 'A2', 349 }, 350 'T2' => { 351 ActivityEntityID => 'A3', 352 }, 353 }, 354 'A2' => { 355 'T3' => { 356 ActivityEntityID => 'A4', 357 }, 358 }, 359 }, 360 }, 361 }, 362 }, 363 ProcessEntityID => 'P1', 364 Message => 'ProcessGet() (known ProcessEntityID UTF8)', 365 TestType => 'Result', 366 Result => { 367 Name => 368 'äöüßÄÖÜ€исáéíúóúÁÉÍÓÚñÑ-カスタ-用迎使用-Язык', 369 CreateTime => '16-02-2012 13:37:00', 370 CreateBy => '1', 371 ChangeTime => '17-02-2012 13:37:00', 372 ChangeBy => '1', 373 State => 'Active', 374 StartActivity => 'A1', 375 StartActivityDialog => 'AD1', 376 Path => { 377 'A1' => { 378 'T1' => { 379 ActivityEntityID => 'A2', 380 }, 381 'T2' => { 382 ActivityEntityID => 'A3', 383 }, 384 }, 385 'A2' => { 386 'T3' => { 387 ActivityEntityID => 'A4', 388 }, 389 }, 390 }, 391 }, 392 }, 393 }, 394 395 # List on invalid Config 396 { 397 ProcessList => { 398 Config => { 399 'Process' => { 400 }, 401 }, 402 ProcessEntityID => 'P1', 403 ProcessState => [ 'Active', 'FadeAway', 'Inactive' ], 404 Message => 'ProcessList() (invalid Config)', 405 TestType => 'False', 406 } 407 }, 408 409 # List on valid Config, missing ProcessState 410 { 411 ProcessList => { 412 Config => { 413 'Process' => { 414 'P1' => { 415 Name => 'Book Orders', 416 CreateTime => '16-02-2012 13:37:00', 417 CreateBy => '1', 418 ChangeTime => '17-02-2012 13:37:00', 419 ChangeBy => '1', 420 State => 'Active', 421 StartActivity => 'A1', 422 StartActivityDialog => 'AD1', 423 Path => { 424 'A1' => { 425 'T1' => { 426 ActivityEntityID => 'A2', 427 }, 428 'T2' => { 429 ActivityEntityID => 'A3', 430 }, 431 }, 432 'A2' => { 433 'T3' => { 434 ActivityEntityID => 'A4', 435 }, 436 }, 437 }, 438 }, 439 }, 440 }, 441 ProcessEntityID => 'P1', 442 ProcessState => [], 443 Message => 'ProcessList() (valid Config, missing ProcessState)', 444 TestType => 'False', 445 }, 446 }, 447 448 # List on valid Config, right ProcessState 449 { 450 ProcessList => { 451 Config => { 452 'Process' => { 453 'P1' => { 454 Name => 'Book Orders', 455 CreateTime => '16-02-2012 13:37:00', 456 CreateBy => '1', 457 ChangeTime => '17-02-2012 13:37:00', 458 ChangeBy => '1', 459 State => 'Active', 460 StartActivity => 'A1', 461 StartActivityDialog => 'AD1', 462 Path => { 463 'A1' => { 464 'T1' => { 465 ActivityEntityID => 'A2', 466 }, 467 'T2' => { 468 ActivityEntityID => 'A3', 469 }, 470 }, 471 'A2' => { 472 'T3' => { 473 ActivityEntityID => 'A4', 474 }, 475 }, 476 }, 477 }, 478 }, 479 }, 480 ProcessEntityID => 'P1', 481 ProcessState => [ 'Active', 'FadeAway', 'Inactive' ], 482 Message => 'ProcessList() (valid Config, right ProcessState)', 483 TestType => 'Result', 484 Result => { 485 'P1' => 'Book Orders' 486 }, 487 }, 488 }, 489 490 # List on valid Config, wrong ProcessState 491 { 492 ProcessList => { 493 Config => { 494 'Process' => { 495 'P1' => { 496 Name => 'Book Orders', 497 CreateTime => '16-02-2012 13:37:00', 498 CreateBy => '1', 499 ChangeTime => '17-02-2012 13:37:00', 500 ChangeBy => '1', 501 State => 'Active', 502 StartActivity => 'A1', 503 StartActivityDialog => 'AD1', 504 Path => { 505 'A1' => { 506 'T1' => { 507 ActivityEntityID => 'A2', 508 }, 509 'T2' => { 510 ActivityEntityID => 'A3', 511 }, 512 }, 513 'A2' => { 514 'T3' => { 515 ActivityEntityID => 'A4', 516 }, 517 }, 518 }, 519 }, 520 }, 521 }, 522 ProcessEntityID => 'P1', 523 ProcessState => [ 'FadeAway', 'Inactive' ], 524 Message => 'ProcessList() (valid Config, wrong ProcessState)', 525 TestType => 'Result', 526 Result => {}, 527 }, 528 }, 529 530 # List on valid Config, wrong interface 531 { 532 ProcessList => { 533 Config => { 534 'Process' => { 535 'P1' => { 536 Name => 'Book Orders', 537 CreateTime => '16-02-2012 13:37:00', 538 CreateBy => '1', 539 ChangeTime => '17-02-2012 13:37:00', 540 ChangeBy => '1', 541 State => 'Active', 542 StartActivity => 'A1', 543 StartActivityDialog => 'AD1', 544 Path => { 545 'A1' => { 546 'T1' => { 547 ActivityEntityID => 'A2', 548 }, 549 'T2' => { 550 ActivityEntityID => 'A3', 551 }, 552 }, 553 'A2' => { 554 'T3' => { 555 ActivityEntityID => 'A4', 556 }, 557 }, 558 }, 559 }, 560 }, 561 'Process::ActivityDialog' => { 562 'AD1' => { 563 Interface => ['CustomerInterface'], 564 Name => 'Activity Dialog 1', 565 DescriptionShort => 'AD1 Process Short', 566 DescriptionLong => 'AD1 Process Long description', 567 CreateTime => '07-02-2012 13:37:00', 568 CreateBy => '2', 569 ChangeTime => '08-02-2012 13:37:00', 570 ChangeBy => '3', 571 Fields => { 572 DynamicField_Make => { 573 Display => 2, 574 DescriptionLong => 'Make Long', 575 DescriptionShort => 'Make Short', 576 }, 577 }, 578 FieldOrder => [ 579 'DynamicField_Make', 580 ], 581 SubmitAdviceText => 'NOTE: If you submit the form ...', 582 SubmitButtonText => 'Make an inquiry', 583 }, 584 } 585 }, 586 ProcessEntityID => 'P1', 587 ProcessState => ['Active'], 588 Interface => ['AgentInterface'], 589 Message => 'ProcessList() (valid Config, wrong Interface)', 590 TestType => 'Result', 591 Result => {}, 592 }, 593 }, 594 595 # List on valid Config, right interface 596 { 597 ProcessList => { 598 Config => { 599 'Process' => { 600 'P1' => { 601 Name => 'Book Orders', 602 CreateTime => '16-02-2012 13:37:00', 603 CreateBy => '1', 604 ChangeTime => '17-02-2012 13:37:00', 605 ChangeBy => '1', 606 State => 'Active', 607 StartActivity => 'A1', 608 StartActivityDialog => 'AD1', 609 Path => { 610 'A1' => { 611 'T1' => { 612 ActivityEntityID => 'A2', 613 }, 614 'T2' => { 615 ActivityEntityID => 'A3', 616 }, 617 }, 618 'A2' => { 619 'T3' => { 620 ActivityEntityID => 'A4', 621 }, 622 }, 623 }, 624 }, 625 }, 626 'Process::ActivityDialog' => { 627 'AD1' => { 628 Interface => ['AgentInterface'], 629 Name => 'Activity Dialog 1', 630 DescriptionShort => 'AD1 Process Short', 631 DescriptionLong => 'AD1 Process Long description', 632 CreateTime => '07-02-2012 13:37:00', 633 CreateBy => '2', 634 ChangeTime => '08-02-2012 13:37:00', 635 ChangeBy => '3', 636 Fields => { 637 DynamicField_Make => { 638 Display => 2, 639 DescriptionLong => 'Make Long', 640 DescriptionShort => 'Make Short', 641 }, 642 }, 643 FieldOrder => [ 644 'DynamicField_Make', 645 ], 646 SubmitAdviceText => 'NOTE: If you submit the form ...', 647 SubmitButtonText => 'Make an inquiry', 648 }, 649 } 650 }, 651 ProcessEntityID => 'P1', 652 ProcessState => ['Active'], 653 Interface => ['AgentInterface'], 654 Message => 'ProcessList() (valid Config, right Interface)', 655 TestType => 'Result', 656 Result => { 'P1' => 'Book Orders' }, 657 }, 658 }, 659 660 # ProcessStartpointGet on invalid Config 661 { 662 ProcessStartpointGet => { 663 Config => { 664 'Process' => { 665 'P1' => { 666 Name => 'Book Orders', 667 CreateTime => '16-02-2012 13:37:00', 668 CreateBy => '1', 669 ChangeTime => '17-02-2012 13:37:00', 670 ChangeBy => '1', 671 State => 'Active', 672 Path => { 673 'A1' => { 674 'T1' => { 675 ActivityEntityID => 'A2', 676 }, 677 'T2' => { 678 ActivityEntityID => 'A3', 679 }, 680 }, 681 'A2' => { 682 'T3' => { 683 ActivityEntityID => 'A4', 684 }, 685 }, 686 }, 687 }, 688 }, 689 }, 690 ProcessEntityID => 'P1', 691 Message => 'ProcessStartpointGet() (invalid Start)', 692 TestType => 'False', 693 }, 694 }, 695 696 # ProcessStartpointGet on valid Config 697 { 698 ProcessStartpointGet => { 699 Config => { 700 'Process' => { 701 'P1' => { 702 Name => 'Book Orders', 703 CreateTime => '16-02-2012 13:37:00', 704 CreateBy => '1', 705 ChangeTime => '17-02-2012 13:37:00', 706 ChangeBy => '1', 707 State => 'Active', 708 StartActivity => 'A1', 709 StartActivityDialog => 'AD1', 710 Path => { 711 'A1' => { 712 'T1' => { 713 ActivityEntityID => 'A2', 714 }, 715 'T2' => { 716 ActivityEntityID => 'A3', 717 }, 718 }, 719 'A2' => { 720 'T3' => { 721 ActivityEntityID => 'A4', 722 }, 723 }, 724 }, 725 }, 726 }, 727 }, 728 ProcessEntityID => 'P1', 729 Message => 'ProcessStartpointGet() (valid Start)', 730 TestType => 'Result', 731 Result => { 732 Activityset => 'A1', 733 ActivityDialog => 'AD1', 734 }, 735 }, 736 }, 737 738 # Transition on missing ProcessEntityID 739 { 740 ProcessTransition => { 741 Config => { 742 'Process' => { 743 }, 744 }, 745 ProcessEntityID => undef, 746 ActivityEntityID => 'A1', 747 TicketID => $TicketID, 748 UserID => 1, 749 Message => 'ProcessTransition() (missing ProcessEntityID)', 750 TestType => 'False', 751 } 752 }, 753 754 # Transition on missing ActivityEntityID 755 { 756 ProcessTransition => { 757 Config => { 758 'Process' => { 759 }, 760 }, 761 ProcessEntityID => 'P1', 762 ActivityEntityID => undef, 763 TicketID => $TicketID, 764 UserID => 1, 765 Message => 'ProcessTransition() (missing ActivityDialogEntityID)', 766 TestType => 'False', 767 } 768 }, 769 770 # Transition on missing TicketID 771 { 772 ProcessTransition => { 773 Config => { 774 'Process' => { 775 }, 776 }, 777 ProcessEntityID => 'P1', 778 ActivityEntityID => 'A1', 779 TicketID => undef, 780 UserID => 1, 781 Message => 'ProcessTransition() (missing TicketID)', 782 TestType => 'False', 783 } 784 }, 785 786 # Transition on missing UserID 787 { 788 ProcessTransition => { 789 Config => { 790 'Process' => { 791 }, 792 }, 793 ProcessEntityID => 'P1', 794 ActivityEntityID => 'A1', 795 TicketID => $TicketID, 796 UserID => undef, 797 Message => 'ProcessTransition() (missing UserID)', 798 TestType => 'False', 799 } 800 }, 801 802 # Transition on invalid TicketID 803 { 804 ProcessTransition => { 805 Config => { 806 'Process' => { 807 }, 808 }, 809 ProcessEntityID => 'P1', 810 ActivityEntityID => 'A1', 811 TicketID => 0, 812 UserID => 1, 813 Message => 'ProcessTransition() (invalid TicketID)', 814 TestType => 'False', 815 } 816 }, 817 818 # Transition on invalid Process Configuration 819 { 820 ProcessTransition => { 821 Config => { 822 'Process' => { 823 'P1' => { 824 Name => 'Book Orders', 825 CreateTime => '16-02-2012 13:37:00', 826 CreateBy => '1', 827 ChangeTime => '17-02-2012 13:37:00', 828 ChangeBy => '1', 829 State => 'Active', 830 StartActivity => 'A1', 831 StartActivityDialog => 'AD1', 832 Path => { 833 }, 834 } 835 }, 836 }, 837 ProcessEntityID => 'P1', 838 ActivityEntityID => 'A1', 839 TicketID => $TicketID, 840 UserID => 1, 841 Message => 'ProcessTransition() (invalid Process Configuration)', 842 TestType => 'False', 843 } 844 }, 845 846 # Transition on missing Activitsets in Process->Path 847 { 848 ProcessTransition => { 849 Config => { 850 'Process' => { 851 'P1' => { 852 Name => 'Book Orders', 853 CreateTime => '16-02-2012 13:37:00', 854 CreateBy => '1', 855 ChangeTime => '16-02-2012 13:37:00', 856 ChangeBy => '1', 857 State => 'Active', 858 StartActivity => 'A1', 859 StartActivityDialog => 'AD1', 860 Path => { 861 'A2' => { 862 'T3' => { 863 ActivityEntityID => 'A4', 864 }, 865 }, 866 }, 867 }, 868 }, 869 }, 870 ProcessEntityID => 'P1', 871 ActivityEntityID => 'A1', 872 TicketID => $TicketID, 873 UserID => 1, 874 Message => 'ProcessTransition() (missing required Activity in Path Config)', 875 TestType => 'False', 876 Debug => 1, 877 } 878 }, 879 880 # Transition on no matching Transition 881 { 882 ProcessTransition => { 883 Config => { 884 'Process::Transition' => { 885 'T1' => { 886 Name => 'Transition 1', 887 Condition => { 888 Cond1 => { 889 Fields => { 890 TicketID => '99999999999999999999', 891 Title => 'Process Unittest Testticket', 892 TypeID => '1', 893 }, 894 }, 895 }, 896 }, 897 'T2' => { 898 Name => 'Transition 2', 899 Condition => { 900 Cond1 => { 901 Fields => { 902 TicketID => '99999999999999999999', 903 Title => 'Process Unittest Testticket', 904 TypeID => '1', 905 }, 906 }, 907 }, 908 }, 909 }, 910 'Process' => { 911 'P1' => { 912 Name => 'Book Orders', 913 CreateTime => '16-02-2012 13:37:00', 914 CreateBy => '1', 915 ChangeTime => '17-02-2012 13:37:00', 916 ChangeBy => '1', 917 State => 'Active', 918 StartActivity => 'A1', 919 StartActivityDialog => 'AD1', 920 Path => { 921 'A1' => { 922 'T1' => { 923 ActivityEntityID => 'A2', 924 }, 925 'T2' => { 926 ActivityEntityID => 'A3', 927 }, 928 }, 929 'A2' => { 930 'T3' => { 931 ActivityEntityID => 'A4', 932 }, 933 }, 934 }, 935 }, 936 }, 937 }, 938 ProcessEntityID => 'P1', 939 ActivityEntityID => 'A1', 940 TicketID => $TicketID, 941 UserID => 1, 942 Message => 'ProcessTransition() (no matching Transition)', 943 TestType => 'False', 944 Debug => 1, 945 } 946 }, 947 948 # Transition on matching Transition Check Only 949 { 950 ProcessTransition => { 951 Config => { 952 'Process::Transition' => { 953 'T1' => { 954 Name => 'Transition 1', 955 Condition => { 956 Cond1 => { 957 Fields => { 958 TicketID => '99999999999999999999', 959 Title => 'Process Unittest Testticket', 960 TypeID => '1', 961 }, 962 }, 963 }, 964 }, 965 'T2' => { 966 Name => 'Transition 2', 967 Condition => { 968 Cond1 => { 969 Fields => { 970 TicketID => $TicketID, 971 Title => 'Process Unittest Testticket', 972 TypeID => '1', 973 }, 974 }, 975 }, 976 }, 977 }, 978 'Process' => { 979 'P1' => { 980 Name => 'Book Orders', 981 CreateTime => '16-02-2012 13:37:00', 982 CreateBy => '1', 983 ChangeTime => '17-02-2012 13:37:00', 984 ChangeBy => '1', 985 State => 'Active', 986 StartActivity => 'A1', 987 StartActivityDialog => 'AD1', 988 Path => { 989 'A1' => { 990 'T1' => { 991 ActivityEntityID => 'A2', 992 }, 993 'T2' => { 994 ActivityEntityID => 'A3', 995 }, 996 }, 997 'A2' => { 998 'T3' => { 999 ActivityEntityID => 'A4', 1000 }, 1001 }, 1002 }, 1003 }, 1004 }, 1005 'Process::Activity' => { 1006 'A1' => { 1007 Name => 'Activity 1 optional', 1008 CreateTime => '16-02-2012 13:37:00', 1009 CreateBy => '1', 1010 ChangeTime => '17-02-2012 13:37:00', 1011 ChangeBy => '1', 1012 ActivityDialog => [ 1013 'AD1', 1014 'AD2', 1015 ], 1016 }, 1017 'A2' => { 1018 Name => 'Activity 2 optional', 1019 CreateTime => '16-02-2012 13:37:00', 1020 CreateBy => '1', 1021 ChangeTime => '17-02-2012 13:37:00', 1022 ChangeBy => '1', 1023 ActivityDialog => [ 1024 'AD1', 1025 'AD2', 1026 ], 1027 }, 1028 'A3' => { 1029 Name => 'Activity 3 optional', 1030 CreateTime => '16-02-2012 13:37:00', 1031 CreateBy => '1', 1032 ChangeTime => '17-02-2012 13:37:00', 1033 ChangeBy => '1', 1034 ActivityDialog => [ 1035 'AD1', 1036 'AD2', 1037 ], 1038 }, 1039 'A4' => { 1040 Name => 'Activity 4 optional', 1041 CreateTime => '16-02-2012 13:37:00', 1042 CreateBy => '1', 1043 ChangeTime => '17-02-2012 13:37:00', 1044 ChangeBy => '1', 1045 ActivityDialog => [ 1046 'AD1', 1047 'AD2', 1048 ], 1049 }, 1050 }, 1051 }, 1052 ProcessEntityID => 'P1', 1053 ActivityEntityID => 'A1', 1054 TicketID => $TicketID, 1055 UserID => 1, 1056 CheckOnly => 1, 1057 Message => 'ProcessTransition() (matching Transition Check Only)', 1058 TestType => 'Result', 1059 Result => { 1060 'T2' => { 1061 ActivityEntityID => 'A3', 1062 }, 1063 }, 1064 }, 1065 }, 1066 1067 # Transition on matching Transition change ActivityEntityID on Ticket 1068 { 1069 ProcessTransition => { 1070 Config => { 1071 'Process::Transition' => { 1072 'T1' => { 1073 Name => 'Transition 1', 1074 Condition => { 1075 Cond1 => { 1076 Fields => { 1077 TicketID => '99999999999999999999', 1078 Title => 'Process Unittest Testticket', 1079 TypeID => '1', 1080 }, 1081 }, 1082 }, 1083 }, 1084 'T2' => { 1085 Name => 'Transition 2', 1086 Condition => { 1087 Cond1 => { 1088 Fields => { 1089 TicketID => $TicketID, 1090 Title => 'Process Unittest Testticket', 1091 TypeID => '1', 1092 }, 1093 }, 1094 }, 1095 }, 1096 }, 1097 'Process' => { 1098 'P1' => { 1099 Name => 'Book Orders', 1100 CreateTime => '16-02-2012 13:37:00', 1101 CreateBy => '1', 1102 ChangeTime => '17-02-2012 13:37:00', 1103 ChangeBy => '1', 1104 State => 'Active', 1105 StartActivity => 'A1', 1106 StartActivityDialog => 'AD1', 1107 Path => { 1108 'A1' => { 1109 'T1' => { 1110 ActivityEntityID => 'A2', 1111 }, 1112 'T2' => { 1113 ActivityEntityID => 'A3', 1114 }, 1115 }, 1116 'A2' => { 1117 'T3' => { 1118 ActivityEntityID => 'A4', 1119 }, 1120 }, 1121 }, 1122 }, 1123 }, 1124 'Process::Activity' => { 1125 'A1' => { 1126 Name => 'Activity 1 optional', 1127 CreateTime => '16-02-2012 13:37:00', 1128 CreateBy => '1', 1129 ChangeTime => '17-02-2012 13:37:00', 1130 ChangeBy => '1', 1131 ActivityDialog => [ 1132 'AD1', 1133 'AD2', 1134 ], 1135 }, 1136 'A2' => { 1137 Name => 'Activity 2 optional', 1138 CreateTime => '16-02-2012 13:37:00', 1139 CreateBy => '1', 1140 ChangeTime => '17-02-2012 13:37:00', 1141 ChangeBy => '1', 1142 ActivityDialog => [ 1143 'AD1', 1144 'AD2', 1145 ], 1146 }, 1147 'A3' => { 1148 Name => 'Activity 3 optional', 1149 CreateTime => '16-02-2012 13:37:00', 1150 CreateBy => '1', 1151 ChangeTime => '17-02-2012 13:37:00', 1152 ChangeBy => '1', 1153 ActivityDialog => [ 1154 'AD1', 1155 'AD2', 1156 ], 1157 }, 1158 'A4' => { 1159 Name => 'Activity 4 optional', 1160 CreateTime => '16-02-2012 13:37:00', 1161 CreateBy => '1', 1162 ChangeTime => '17-02-2012 13:37:00', 1163 ChangeBy => '1', 1164 ActivityDialog => [ 1165 'AD1', 1166 'AD2', 1167 ], 1168 }, 1169 }, 1170 }, 1171 ProcessEntityID => 'P1', 1172 ActivityEntityID => 'A1', 1173 TicketID => $TicketID, 1174 UserID => 1, 1175 CheckOnly => 0, 1176 Message => 'ProcessTransition() (matching Transition change ActivityEntityID)', 1177 TestType => 'True', 1178 } 1179 }, 1180 1181 # ProcessTicketActivitySet on no ActivityEntityID 1182 { 1183 ProcessTicketActivitySet => { 1184 Config => { 1185 'Process' => { 1186 'P1' => { 1187 Name => 'Book Orders', 1188 CreateTime => '16-02-2012 13:37:00', 1189 CreateBy => '1', 1190 ChangeTime => '17-02-2012 13:37:00', 1191 ChangeBy => '1', 1192 State => 'Active', 1193 StartActivity => 'A1', 1194 StartActivityDialog => 'AD1', 1195 Path => { 1196 'A1' => { 1197 'T1' => 'A2', 1198 'T2' => 'A3', 1199 }, 1200 'A2' => { 1201 'T3' => 'A4', 1202 }, 1203 }, 1204 } 1205 }, 1206 'Process::Activity' => { 1207 'A1' => { 1208 Name => 'Activity 1 optional', 1209 CreateTime => '16-02-2012 13:37:00', 1210 CreateBy => '1', 1211 ChangeTime => '17-02-2012 13:37:00', 1212 ChangeBy => '1', 1213 ActivityDialog => [ 1214 'AD1', 1215 'AD2', 1216 ], 1217 }, 1218 }, 1219 }, 1220 ProcessEntityID => 'P1', 1221 ActivityEntityID => undef, 1222 TicketID => $TicketID, 1223 UserID => 1, 1224 Message => 1225 'ProcessTicketActivitySet() (Set ActivityEntityID on Ticket with no ActivityEntityID)', 1226 TestType => 'False', 1227 } 1228 }, 1229 1230 # ProcessTicketActivitySet on no ProcessEntityID 1231 { 1232 ProcessTicketActivitySet => { 1233 Config => { 1234 'Process' => { 1235 'P1' => { 1236 Name => 'Book Orders', 1237 CreateTime => '16-02-2012 13:37:00', 1238 CreateBy => '1', 1239 ChangeTime => '17-02-2012 13:37:00', 1240 ChangeBy => '1', 1241 State => 'Active', 1242 StartActivity => 'A1', 1243 StartActivityDialog => 'AD1', 1244 Path => { 1245 'A1' => { 1246 'T1' => 'A2', 1247 'T2' => 'A3', 1248 }, 1249 'A2' => { 1250 'T3' => 'A4', 1251 }, 1252 }, 1253 } 1254 }, 1255 'Process::Activity' => { 1256 'A1' => { 1257 Name => 'Activity 1 optional', 1258 CreateTime => '16-02-2012 13:37:00', 1259 CreateBy => '1', 1260 ChangeTime => '17-02-2012 13:37:00', 1261 ChangeBy => '1', 1262 ActivityDialog => [ 1263 'AD1', 1264 'AD2', 1265 ], 1266 }, 1267 }, 1268 }, 1269 ProcessEntityID => undef, 1270 ActivityEntityID => 'A3', 1271 TicketID => $TicketID, 1272 UserID => 1, 1273 Message => 1274 'ProcessTicketActivitySet() (Set ActivityEntityID on Ticket with no ProcessEntityID)', 1275 TestType => 'False', 1276 } 1277 }, 1278 1279 # ProcessTicketActivitySet on no TicketID 1280 { 1281 ProcessTicketActivitySet => { 1282 Config => { 1283 'Process' => { 1284 'P1' => { 1285 Name => 'Book Orders', 1286 CreateTime => '16-02-2012 13:37:00', 1287 CreateBy => '1', 1288 ChangeTime => '17-02-2012 13:37:00', 1289 ChangeBy => '1', 1290 State => 'Active', 1291 StartActivity => 'A1', 1292 StartActivityDialog => 'AD1', 1293 Path => { 1294 'A1' => { 1295 'T1' => 'A2', 1296 'T2' => 'A3', 1297 }, 1298 'A2' => { 1299 'T3' => 'A4', 1300 }, 1301 }, 1302 } 1303 }, 1304 'Process::Activity' => { 1305 'A1' => { 1306 Name => 'Activity 1 optional', 1307 CreateTime => '16-02-2012 13:37:00', 1308 CreateBy => '1', 1309 ChangeTime => '17-02-2012 13:37:00', 1310 ChangeBy => '1', 1311 ActivityDialog => [ 1312 'AD1', 1313 'AD2', 1314 ], 1315 }, 1316 }, 1317 }, 1318 ProcessEntityID => 'P1', 1319 ActivityEntityID => 'A3', 1320 TicketID => undef, 1321 UserID => 1, 1322 Message => 1323 'ProcessTicketActivitySet() (Set ActivityEntityID on Ticket with no TicketID)', 1324 TestType => 'False', 1325 } 1326 }, 1327 1328 # ProcessTicketActivitySet on invalid ActivityEntityID 1329 { 1330 ProcessTicketActivitySet => { 1331 Config => { 1332 'Process' => { 1333 'P1' => { 1334 Name => 'Book Orders', 1335 CreateTime => '16-02-2012 13:37:00', 1336 CreateBy => '1', 1337 ChangeTime => '17-02-2012 13:37:00', 1338 ChangeBy => '1', 1339 State => 'Active', 1340 StartActivity => 'A1', 1341 StartActivityDialog => 'AD1', 1342 Path => { 1343 'A1' => { 1344 'T1' => 'A2', 1345 'T2' => 'A3', 1346 }, 1347 'A2' => { 1348 'T3' => 'A4', 1349 }, 1350 }, 1351 } 1352 }, 1353 'Process::Activity' => { 1354 'A1' => { 1355 Name => 'Activity 1 optional', 1356 CreateTime => '16-02-2012 13:37:00', 1357 CreateBy => '1', 1358 ChangeTime => '17-02-2012 13:37:00', 1359 ChangeBy => '1', 1360 ActivityDialog => [ 1361 'AD1', 1362 'AD2', 1363 ], 1364 }, 1365 }, 1366 }, 1367 ProcessEntityID => 'P1', 1368 ActivityEntityID => 'A3', 1369 TicketID => $TicketID, 1370 UserID => 1, 1371 Message => 1372 'ProcessTicketActivitySet() (Set ActivityEntityID on Ticket with invalid ActivityEntityID)', 1373 TestType => 'False', 1374 } 1375 }, 1376 1377 # ProcessTicketActivitySet on invalid ProcessEntityID 1378 { 1379 ProcessTicketActivitySet => { 1380 Config => { 1381 'Process' => { 1382 'P1' => { 1383 Name => 'Book Orders', 1384 CreateTime => '16-02-2012 13:37:00', 1385 CreateBy => '1', 1386 ChangeTime => '17-02-2012 13:37:00', 1387 ChangeBy => '1', 1388 State => 'Active', 1389 StartActivity => 'A1', 1390 StartActivityDialog => 'AD1', 1391 Path => { 1392 'A1' => { 1393 'T1' => { 1394 ActivityEntityID => 'A2', 1395 }, 1396 'T2' => { 1397 ActivityEntityID => 'A3', 1398 }, 1399 }, 1400 'A2' => { 1401 'T3' => { 1402 ActivityEntityID => 'A4', 1403 }, 1404 }, 1405 }, 1406 }, 1407 }, 1408 'Process::Activity' => { 1409 'A1' => { 1410 Name => 'Activity 1 optional', 1411 CreateTime => '16-02-2012 13:37:00', 1412 CreateBy => '1', 1413 ChangeTime => '17-02-2012 13:37:00', 1414 ChangeBy => '1', 1415 ActivityDialog => [ 1416 'AD1', 1417 'AD2', 1418 ], 1419 }, 1420 }, 1421 }, 1422 ProcessEntityID => 'P2', 1423 ActivityEntityID => 'A1', 1424 TicketID => $TicketID, 1425 UserID => 1, 1426 Message => 1427 'ProcessTicketActivitySet() (Set ActivityEntityID on Ticket with invalid ProcessEntityID)', 1428 TestType => 'False', 1429 } 1430 }, 1431 1432 # ProcessTicketActivitySet on valid Config 1433 { 1434 ProcessTicketActivitySet => { 1435 Config => { 1436 'Process' => { 1437 'P1' => { 1438 Name => 'Book Orders', 1439 CreateTime => '16-02-2012 13:37:00', 1440 CreateBy => '1', 1441 ChangeTime => '17-02-2012 13:37:00', 1442 ChangeBy => '1', 1443 State => 'Active', 1444 StartActivity => 'A1', 1445 StartActivityDialog => 'AD1', 1446 Path => { 1447 'A1' => { 1448 'T1' => { 1449 ActivityEntityID => 'A2', 1450 }, 1451 'T2' => { 1452 ActivityEntityID => 'A3', 1453 }, 1454 }, 1455 'A2' => { 1456 'T3' => { 1457 ActivityEntityID => 'A4', 1458 }, 1459 }, 1460 }, 1461 }, 1462 }, 1463 'Process::Activity' => { 1464 'A1' => { 1465 Name => 'Activity 1 optional', 1466 CreateTime => '16-02-2012 13:37:00', 1467 CreateBy => '1', 1468 ChangeTime => '17-02-2012 13:37:00', 1469 ChangeBy => '1', 1470 ActivityDialog => [ 1471 'AD1', 1472 'AD2', 1473 ], 1474 }, 1475 }, 1476 }, 1477 ProcessEntityID => 'P1', 1478 ActivityEntityID => 'A1', 1479 TicketID => $TicketID, 1480 UserID => 1, 1481 Message => 1482 'ProcessTicketActivitySet() (Set ActivityEntityID on Ticket with valid Config)', 1483 TestType => 'True', 1484 } 1485 }, 1486 1487 # ProcessTicketProcessSet on invalid Config 1488 { 1489 ProcessTicketProcessSet => { 1490 Config => { 1491 'Process' => { 1492 'P1' => { 1493 Name => 'Book Orders', 1494 CreateTime => '16-02-2012 13:37:00', 1495 CreateBy => '1', 1496 ChangeTime => '17-02-2012 13:37:00', 1497 ChangeBy => '1', 1498 State => 'Active', 1499 StartActivity => 'A1', 1500 StartActivityDialog => 'AD1', 1501 Path => { 1502 'A1' => { 1503 'T1' => { 1504 ActivityEntityID => 'A2', 1505 }, 1506 'T2' => { 1507 ActivityEntityID => 'A3', 1508 }, 1509 }, 1510 'A2' => { 1511 'T3' => { 1512 ActivityEntityID => 'A4', 1513 }, 1514 }, 1515 }, 1516 }, 1517 }, 1518 }, 1519 ProcessEntityID => 'P17', 1520 TicketID => $TicketID, 1521 UserID => 1, 1522 Message => 1523 'ProcessTicketProcessSet() (Set ProcessEntityID on Ticket with invalid ProcessEntityID)', 1524 TestType => 'False', 1525 }, 1526 }, 1527 1528 # ProcessTicketProcessSet on invalid TicketID 1529 { 1530 ProcessTicketProcessSet => { 1531 Config => { 1532 'Process' => { 1533 'P1' => { 1534 Name => 'Book Orders', 1535 CreateTime => '16-02-2012 13:37:00', 1536 CreateBy => '1', 1537 ChangeTime => '17-02-2012 13:37:00', 1538 ChangeBy => '1', 1539 State => 'Active', 1540 StartActivity => 'A1', 1541 StartActivityDialog => 'AD1', 1542 Path => { 1543 'A1' => { 1544 'T1' => { 1545 ActivityEntityID => 'A2', 1546 }, 1547 'T2' => { 1548 ActivityEntityID => 'A3', 1549 }, 1550 }, 1551 'A2' => { 1552 'T3' => { 1553 ActivityEntityID => 'A4', 1554 }, 1555 }, 1556 }, 1557 }, 1558 }, 1559 }, 1560 ProcessEntityID => 'P1', 1561 TicketID => undef, 1562 UserID => 1, 1563 Message => 1564 'ProcessTicketProcessSet() (Set ProcessEntityID on Ticket with invalid TicketID)', 1565 TestType => 'False', 1566 }, 1567 }, 1568 1569 # ProcessTicketProcessSet on valid Config 1570 { 1571 ProcessTicketProcessSet => { 1572 Config => { 1573 'Process' => { 1574 'P1' => { 1575 Name => 'Book Orders', 1576 CreateTime => '16-02-2012 13:37:00', 1577 CreateBy => '1', 1578 ChangeTime => '17-02-2012 13:37:00', 1579 ChangeBy => '1', 1580 State => 'Active', 1581 StartActivity => 'A1', 1582 StartActivityDialog => 'AD1', 1583 Path => { 1584 'A1' => { 1585 'T1' => { 1586 ActivityEntityID => 'A2', 1587 }, 1588 'T2' => { 1589 ActivityEntityID => 'A3', 1590 }, 1591 }, 1592 'A2' => { 1593 'T3' => { 1594 ActivityEntityID => 'A4', 1595 }, 1596 }, 1597 }, 1598 }, 1599 }, 1600 }, 1601 ProcessEntityID => 'P1', 1602 TicketID => $TicketID, 1603 UserID => 1, 1604 Message => 1605 'ProcessTicketProcessSet() (Set ProcessEntityID on Ticket with valid Config)', 1606 TestType => 'True', 1607 }, 1608 }, 1609 1610 # Transition + QueueMove TransitionAction on matching Transition change ActivityEntityID on Ticket 1611 # and move it to Queue1 1612 { 1613 ProcessTransition => { 1614 Config => { 1615 'Process::Transition' => { 1616 'T1' => { 1617 Name => 'Transition 1', 1618 Condition => { 1619 Cond1 => { 1620 Fields => { 1621 TicketID => '99999999999999999999', 1622 Title => 'Process Unittest Testticket', 1623 TypeID => '1', 1624 }, 1625 }, 1626 }, 1627 }, 1628 'T2' => { 1629 Name => 'Transition 2', 1630 Condition => { 1631 Cond1 => { 1632 Fields => { 1633 TicketID => $TicketID, 1634 Title => 'Process Unittest Testticket', 1635 TypeID => '1', 1636 }, 1637 }, 1638 }, 1639 }, 1640 }, 1641 'Process' => { 1642 'P1' => { 1643 Name => 'Book Orders', 1644 CreateTime => '16-02-2012 13:37:00', 1645 CreateBy => '1', 1646 ChangeTime => '17-02-2012 13:37:00', 1647 ChangeBy => '1', 1648 State => 'Active', 1649 StartActivity => 'A1', 1650 StartActivityDialog => 'AD1', 1651 Path => { 1652 'A1' => { 1653 'T1' => { 1654 ActivityEntityID => 'A2', 1655 }, 1656 'T2' => { 1657 ActivityEntityID => 'A3', 1658 TransitionAction => ['TA1'], 1659 }, 1660 }, 1661 'A2' => { 1662 'T3' => { 1663 ActivityEntityID => 'A4', 1664 }, 1665 }, 1666 }, 1667 }, 1668 }, 1669 'Process::Activity' => { 1670 'A1' => { 1671 Name => 'Activity 1 optional', 1672 CreateTime => '16-02-2012 13:37:00', 1673 CreateBy => '1', 1674 ChangeTime => '17-02-2012 13:37:00', 1675 ChangeBy => '1', 1676 ActivityDialog => [ 1677 'AD1', 1678 'AD2', 1679 ], 1680 }, 1681 'A2' => { 1682 Name => 'Activity 2 optional', 1683 CreateTime => '16-02-2012 13:37:00', 1684 CreateBy => '1', 1685 ChangeTime => '17-02-2012 13:37:00', 1686 ChangeBy => '1', 1687 ActivityDialog => [ 1688 'AD1', 1689 'AD2', 1690 ], 1691 }, 1692 'A3' => { 1693 Name => 'Activity 3 optional', 1694 CreateTime => '16-02-2012 13:37:00', 1695 CreateBy => '1', 1696 ChangeTime => '17-02-2012 13:37:00', 1697 ChangeBy => '1', 1698 ActivityDialog => [ 1699 'AD1', 1700 'AD2', 1701 ], 1702 }, 1703 'A4' => { 1704 Name => 'Activity 4 optional', 1705 CreateTime => '16-02-2012 13:37:00', 1706 CreateBy => '1', 1707 ChangeTime => '17-02-2012 13:37:00', 1708 ChangeBy => '1', 1709 ActivityDialog => [ 1710 'AD1', 1711 'AD2', 1712 ], 1713 }, 1714 }, 1715 'Process::TransitionAction' => { 1716 'TA1' => { 1717 Name => 'Queue Move', 1718 Module => 1719 'Kernel::System::ProcessManagement::TransitionAction::TicketQueueSet', 1720 Config => { 1721 Queue => $QueueData1{Name}, 1722 }, 1723 1724 }, 1725 'TA2' => { 1726 Name => 'Queue Move', 1727 Module => 1728 'Kernel::System::ProcessManagement::TransitionAction::TicketQueueSet', 1729 Config => { 1730 Queue => $QueueData2{Name}, 1731 }, 1732 1733 }, 1734 'TA3' => { 1735 Name => 'Queue Move', 1736 Module => 1737 'Kernel::System::ProcessManagement::TransitionAction::TicketQueueSet', 1738 Config => { 1739 Queue => $QueueData3{Name}, 1740 }, 1741 1742 }, 1743 }, 1744 }, 1745 ProcessEntityID => 'P1', 1746 ActivityEntityID => 'A1', 1747 TicketID => $TicketID, 1748 UserID => 1, 1749 CheckOnly => 0, 1750 Message => 1751 'ProcessTransition() (matching Transition change ActivityEntityID and Action Queue Move to Misc)', 1752 TestType => 'True', 1753 } 1754 }, 1755 1756 # Transition + QueueMove TransitionAction on matching Transition change ActivityEntityID on Ticket 1 1757 # back to A1 and move it back to Queue3 1758 { 1759 ProcessTransition => { 1760 Config => { 1761 'Process::Transition' => { 1762 'T1' => { 1763 Name => 'Transition 1', 1764 Condition => { 1765 Cond1 => { 1766 Fields => { 1767 TicketID => '99999999999999999999', 1768 Title => 'Process Unittest Testticket', 1769 TypeID => '1', 1770 }, 1771 }, 1772 }, 1773 }, 1774 'T2' => { 1775 Name => 'Transition 2', 1776 Condition => { 1777 Cond1 => { 1778 Fields => { 1779 TicketID => $TicketID, 1780 Title => 'Process Unittest Testticket', 1781 TypeID => '1', 1782 }, 1783 }, 1784 }, 1785 }, 1786 'T4' => { 1787 Name => 'Transition 4', 1788 Condition => { 1789 Cond1 => { 1790 Fields => { 1791 TicketID => $TicketID, 1792 Title => 'Process Unittest Testticket', 1793 TypeID => '1', 1794 }, 1795 }, 1796 }, 1797 }, 1798 }, 1799 'Process' => { 1800 'P1' => { 1801 Name => 'Book Orders', 1802 CreateTime => '16-02-2012 13:37:00', 1803 CreateBy => '1', 1804 ChangeTime => '17-02-2012 13:37:00', 1805 ChangeBy => '1', 1806 State => 'Active', 1807 StartActivity => 'A1', 1808 StartActivityDialog => 'AD1', 1809 Path => { 1810 'A1' => { 1811 'T1' => { 1812 ActivityEntityID => 'A2', 1813 }, 1814 'T2' => { 1815 ActivityEntityID => 'A3', 1816 TransitionAction => ['TA1'], 1817 }, 1818 }, 1819 'A2' => { 1820 'T3' => { 1821 ActivityEntityID => 'A4', 1822 }, 1823 }, 1824 'A3' => { 1825 'T4' => { 1826 ActivityEntityID => 'A1', 1827 TransitionAction => ['TA3'], 1828 } 1829 } 1830 }, 1831 }, 1832 }, 1833 'Process::Activity' => { 1834 'A1' => { 1835 Name => 'Activity 1 optional', 1836 CreateTime => '16-02-2012 13:37:00', 1837 CreateBy => '1', 1838 ChangeTime => '17-02-2012 13:37:00', 1839 ChangeBy => '1', 1840 ActivityDialog => [ 1841 'AD1', 1842 'AD2', 1843 ], 1844 }, 1845 'A2' => { 1846 Name => 'Activity 2 optional', 1847 CreateTime => '16-02-2012 13:37:00', 1848 CreateBy => '1', 1849 ChangeTime => '17-02-2012 13:37:00', 1850 ChangeBy => '1', 1851 ActivityDialog => [ 1852 'AD1', 1853 'AD2', 1854 ], 1855 }, 1856 'A3' => { 1857 Name => 'Activity 3 optional', 1858 CreateTime => '16-02-2012 13:37:00', 1859 CreateBy => '1', 1860 ChangeTime => '17-02-2012 13:37:00', 1861 ChangeBy => '1', 1862 ActivityDialog => [ 1863 'AD1', 1864 'AD2', 1865 ], 1866 }, 1867 'A4' => { 1868 Name => 'Activity 4 optional', 1869 CreateTime => '16-02-2012 13:37:00', 1870 CreateBy => '1', 1871 ChangeTime => '17-02-2012 13:37:00', 1872 ChangeBy => '1', 1873 ActivityDialog => [ 1874 'AD1', 1875 'AD2', 1876 ], 1877 }, 1878 }, 1879 'Process::TransitionAction' => { 1880 'TA1' => { 1881 Name => 'Queue Move', 1882 Module => 1883 'Kernel::System::ProcessManagement::TransitionAction::TicketQueueSet', 1884 Config => { 1885 Queue => $QueueData1{Name}, 1886 }, 1887 1888 }, 1889 'TA2' => { 1890 Name => 'Queue Move', 1891 Module => 1892 'Kernel::System::ProcessManagement::TransitionAction::TicketQueueSet', 1893 Config => { 1894 Queue => $QueueData2{Name}, 1895 }, 1896 1897 }, 1898 'TA3' => { 1899 Name => 'Queue Move', 1900 Module => 1901 'Kernel::System::ProcessManagement::TransitionAction::TicketQueueSet', 1902 Config => { 1903 Queue => $QueueData3{Name}, 1904 }, 1905 1906 }, 1907 }, 1908 }, 1909 ProcessEntityID => 'P1', 1910 ActivityEntityID => 'A3', 1911 TicketID => $TicketID, 1912 UserID => 1, 1913 CheckOnly => 0, 1914 Message => 1915 'ProcessTransition() (matching Transition change ActivityEntityID and TransitionAction Queue Move to Raw)', 1916 TestType => 'True', 1917 } 1918 }, 1919 1920 # Transition + TicketServiceSet + TicketSLASet TransitionAction on matching Transition change Service and SLA on Ticket 1921 { 1922 ProcessTransition => { 1923 Config => { 1924 'Process::Transition' => { 1925 'T1' => { 1926 Name => 'Transition 1', 1927 Condition => { 1928 Cond1 => { 1929 Fields => { 1930 TicketID => $TicketID, 1931 Title => 'Process Unittest Testticket', 1932 TypeID => '1', 1933 }, 1934 }, 1935 }, 1936 }, 1937 }, 1938 'Process' => { 1939 'P1' => { 1940 Name => 'Book Orders', 1941 CreateTime => '16-02-2012 13:37:00', 1942 CreateBy => '1', 1943 ChangeTime => '17-02-2012 13:37:00', 1944 ChangeBy => '1', 1945 State => 'Active', 1946 StartActivity => 'A1', 1947 StartActivityDialog => 'AD1', 1948 Path => { 1949 'A1' => { 1950 'T1' => { 1951 ActivityEntityID => 'A2', 1952 TransitionAction => [ 'TA1', 'TA2' ], 1953 }, 1954 }, 1955 'A2' => {}, 1956 }, 1957 }, 1958 }, 1959 'Process::Activity' => { 1960 'A1' => { 1961 Name => 'Activity 1 optional', 1962 CreateTime => '16-02-2012 13:37:00', 1963 CreateBy => '1', 1964 ChangeTime => '17-02-2012 13:37:00', 1965 ChangeBy => '1', 1966 ActivityDialog => [ 1967 'AD1', 1968 'AD2', 1969 ], 1970 }, 1971 'A2' => { 1972 Name => 'Activity 2 optional', 1973 CreateTime => '16-02-2012 13:37:00', 1974 CreateBy => '1', 1975 ChangeTime => '17-02-2012 13:37:00', 1976 ChangeBy => '1', 1977 ActivityDialog => [ 1978 'AD1', 1979 'AD2', 1980 ], 1981 }, 1982 1983 }, 1984 'Process::TransitionAction' => { 1985 'TA1' => { 1986 Name => 'Service Set', 1987 Module => 1988 'Kernel::System::ProcessManagement::TransitionAction::TicketServiceSet', 1989 Config => { 1990 ServiceID => $ServiceID, 1991 }, 1992 1993 }, 1994 'TA2' => { 1995 Name => 'SLA Set', 1996 Module => 1997 'Kernel::System::ProcessManagement::TransitionAction::TicketSLASet', 1998 Config => { 1999 SLAID => $SLAID, 2000 }, 2001 }, 2002 }, 2003 }, 2004 ProcessEntityID => 'P1', 2005 ActivityEntityID => 'A1', 2006 TicketID => $TicketID, 2007 UserID => 1, 2008 CheckOnly => 0, 2009 Message => 2010 'ProcessTransition() (matching Transition Actions Service Set and SLA Set)', 2011 TestType => 'TicketValues', 2012 ExpectedResult => { 2013 ServiceID => $ServiceID, 2014 SLAID => $SLAID, 2015 }, 2016 }, 2017 }, 2018); 2019 2020for my $Test (@Tests) { 2021 if ( $Test->{ProcessTransition} ) { 2022 2023 # Set Config 2024 if ( IsHashRefWithData( $Test->{ProcessTransition}->{Config} ) ) { 2025 for my $Config ( sort keys %{ $Test->{ProcessTransition}->{Config} } ) { 2026 $ConfigObject->Set( 2027 Key => $Config, 2028 Value => {}, 2029 ); 2030 $ConfigObject->Set( 2031 Key => $Config, 2032 Value => $Test->{ProcessTransition}->{Config}->{$Config}, 2033 ); 2034 } 2035 } 2036 2037 # If we have a test with debug on, we need a new ProcessObject 2038 # with Debug turned on 2039 if ( $Test->{ProcessTransition}->{Debug} ) { 2040 $ProcessObject = undef; 2041 $ProcessObject = Kernel::System::ProcessManagement::Process->new( 2042 %{$Self}, 2043 %CommonObject, 2044 ConfigObject => $ConfigObject, 2045 Debug => $Test->{ProcessTransition}->{Debug}, 2046 ); 2047 } 2048 2049 # excuse process object call 2050 my $Result = $ProcessObject->ProcessTransition( %{ $Test->{ProcessTransition} } ); 2051 2052 if ( $Test->{ProcessTransition}->{TestType} eq 'False' ) { 2053 2054 # ProcessTransition - Check on False 2055 $Self->False( 2056 $Result, 2057 $Test->{ProcessTransition}->{Message}, 2058 ); 2059 } 2060 elsif ( $Test->{ProcessTransition}->{TestType} eq 'True' ) { 2061 2062 # ProcessTransition - Check on True 2063 $Self->True( 2064 $Result, 2065 $Test->{ProcessTransition}->{Message}, 2066 ); 2067 } 2068 elsif ( $Test->{ProcessTransition}->{TestType} eq 'Result' ) { 2069 my $ExpectedResult = $Test->{ProcessTransition}->{Result}; 2070 2071 # ProcessTransition - Check given and expected result 2072 $Self->IsDeeply( 2073 $Result, 2074 $ExpectedResult, 2075 $Test->{ProcessTransition}->{Message}, 2076 ); 2077 } 2078 elsif ( $Test->{ProcessTransition}->{TestType} eq 'TicketValues' ) { 2079 2080 # ProcessTrnsition - Check ticket values after all transition actions 2081 my %Ticket = $CommonObject{TicketObject}->TicketGet( 2082 TicketID => $TicketID, 2083 DynamicFields => 1, 2084 UserID => 1, 2085 ); 2086 2087 for my $Attribute ( sort keys %{ $Test->{ProcessTransition}->{ExpectedResult} } ) { 2088 $Self->Is( 2089 $Ticket{$Attribute} // '', 2090 $Test->{ProcessTransition}->{ExpectedResult}->{$Attribute}, 2091 "$Test->{ProcessTransition}->{Message} - Ticket $Attribute", 2092 ); 2093 } 2094 } 2095 2096 # If we had a test with debug on, restore ProcessObject to default 2097 if ( $Test->{ProcessTransition}->{Debug} ) { 2098 $ProcessObject = undef; 2099 $ProcessObject = Kernel::System::ProcessManagement::Process->new( 2100 %{$Self}, 2101 %CommonObject, 2102 ConfigObject => $ConfigObject, 2103 ); 2104 } 2105 } 2106 elsif ( $Test->{ProcessTicketProcessSet} ) { 2107 2108 # Set Config 2109 if ( IsHashRefWithData( $Test->{ProcessTicketProcessSet}->{Config} ) ) { 2110 for my $Config ( sort keys %{ $Test->{ProcessTicketProcessSet}->{Config} } ) { 2111 $ConfigObject->Set( 2112 Key => $Config, 2113 Value => {}, 2114 ); 2115 $ConfigObject->Set( 2116 Key => $Config, 2117 Value => $Test->{ProcessTicketProcessSet}->{Config}->{$Config}, 2118 ); 2119 } 2120 } 2121 2122 # If we have a test with debug on, we need a new ProcessObject 2123 # with Debug turned on 2124 if ( $Test->{ProcessTicketProcessSet}->{Debug} ) { 2125 $ProcessObject = undef; 2126 $ProcessObject = Kernel::System::ProcessManagement::Process->new( 2127 %{$Self}, 2128 %CommonObject, 2129 ConfigObject => $ConfigObject, 2130 Debug => $Test->{ProcessTicketProcessSet}->{Debug}, 2131 ); 2132 } 2133 2134 # execute process object call 2135 my $Result = $ProcessObject->ProcessTicketProcessSet( %{ $Test->{ProcessTicketProcessSet} } ); 2136 2137 if ( $Test->{ProcessTicketProcessSet}->{TestType} eq 'False' ) { 2138 2139 # ProcessTicketProcessSet - Check on False 2140 $Self->False( 2141 $Result, 2142 $Test->{ProcessTicketProcessSet}->{Message}, 2143 ); 2144 } 2145 elsif ( $Test->{ProcessTicketProcessSet}->{TestType} eq 'True' ) { 2146 2147 # ProcessTicketProcessSet - Check on True 2148 $Self->True( 2149 $Result, 2150 $Test->{ProcessTicketProcessSet}->{Message}, 2151 ); 2152 } 2153 2154 # If we had a test with debug on, restore ProcessObject to default 2155 if ( $Test->{ProcessTicketProcessSet}->{Debug} ) { 2156 $ProcessObject = undef; 2157 $ProcessObject = Kernel::System::ProcessManagement::Process->new( 2158 %{$Self}, 2159 %CommonObject, 2160 ConfigObject => $ConfigObject, 2161 ); 2162 } 2163 } 2164 elsif ( $Test->{ProcessTicketActivitySet} ) { 2165 2166 # Set Config 2167 if ( IsHashRefWithData( $Test->{ProcessTicketActivitySet}->{Config} ) ) { 2168 for my $Config ( sort keys %{ $Test->{ProcessTicketActivitySet}->{Config} } ) { 2169 $ConfigObject->Set( 2170 Key => $Config, 2171 Value => {}, 2172 ); 2173 $ConfigObject->Set( 2174 Key => $Config, 2175 Value => $Test->{ProcessTicketActivitySet}->{Config}->{$Config}, 2176 ); 2177 } 2178 } 2179 2180 # If we have a test with debug on, we need a new ProcessObject 2181 # with Debug turned on 2182 if ( $Test->{ProcessTicketActivitySet}->{Debug} ) { 2183 $ProcessObject = undef; 2184 $ProcessObject = Kernel::System::ProcessManagement::Process->new( 2185 %{$Self}, 2186 %CommonObject, 2187 ConfigObject => $ConfigObject, 2188 Debug => $Test->{ProcessTicketActivitySet}->{Debug}, 2189 ); 2190 } 2191 2192 # execute process object call 2193 my $Result = $ProcessObject->ProcessTicketActivitySet( %{ $Test->{ProcessTicketActivitySet} } ); 2194 2195 if ( $Test->{ProcessTicketActivitySet}->{TestType} eq 'False' ) { 2196 2197 # ProcessTicketActivitySet - Check on False 2198 $Self->False( 2199 $Result, 2200 $Test->{ProcessTicketActivitySet}->{Message}, 2201 ); 2202 } 2203 elsif ( $Test->{ProcessTicketActivitySet}->{TestType} eq 'True' ) { 2204 2205 # ProcessTicketActivitySet - Check on True 2206 $Self->True( 2207 $Result, 2208 $Test->{ProcessTicketActivitySet}->{Message}, 2209 ); 2210 } 2211 2212 # If we had a test with debug on, restore ProcessObject to default 2213 if ( $Test->{ProcessTicketActivitySet}->{Debug} ) { 2214 $ProcessObject = undef; 2215 $ProcessObject = Kernel::System::ProcessManagement::Process->new( 2216 %{$Self}, 2217 %CommonObject, 2218 ConfigObject => $ConfigObject, 2219 ); 2220 } 2221 } 2222 elsif ( $Test->{ProcessList} ) { 2223 2224 # Set Config 2225 if ( IsHashRefWithData( $Test->{ProcessList}->{Config} ) ) { 2226 for my $Config ( sort keys %{ $Test->{ProcessList}->{Config} } ) { 2227 $ConfigObject->Set( 2228 Key => $Config, 2229 Value => {}, 2230 ); 2231 $ConfigObject->Set( 2232 Key => $Config, 2233 Value => $Test->{ProcessList}->{Config}->{$Config}, 2234 ); 2235 } 2236 } 2237 2238 # If we have a test with debug on, we need a new ProcessObject 2239 # with Debug turned on 2240 if ( $Test->{ProcessList}->{Debug} ) { 2241 $ProcessObject = undef; 2242 $ProcessObject = Kernel::System::ProcessManagement::Process->new( 2243 %{$Self}, 2244 %CommonObject, 2245 ConfigObject => $ConfigObject, 2246 Debug => $Test->{ProcessList}->{Debug}, 2247 ); 2248 } 2249 2250 # execute process object call 2251 my $Result = $ProcessObject->ProcessList( %{ $Test->{ProcessList} } ); 2252 2253 if ( $Test->{ProcessList}->{TestType} eq 'False' ) { 2254 2255 # ProcessList - Check on False 2256 $Self->False( 2257 $Result, 2258 $Test->{ProcessList}->{Message}, 2259 ); 2260 } 2261 elsif ( $Test->{ProcessList}->{TestType} eq 'True' ) { 2262 2263 # ProcessList - Check on True 2264 $Self->True( 2265 $Result, 2266 $Test->{ProcessList}->{Message}, 2267 ); 2268 } 2269 elsif ( $Test->{ProcessList}->{TestType} eq 'Result' ) { 2270 my $ExpectedResult = $Test->{ProcessList}->{Result}; 2271 2272 # ProcessList - Check given and expected result 2273 $Self->IsDeeply( 2274 $Result, 2275 $ExpectedResult, 2276 $Test->{ProcessList}->{Message}, 2277 ); 2278 } 2279 2280 # If we had a test with debug on, restore ProcessObject to default 2281 if ( $Test->{ProcessList}->{Debug} ) { 2282 $ProcessObject = undef; 2283 $ProcessObject = Kernel::System::ProcessManagement::Process->new( 2284 %{$Self}, 2285 %CommonObject, 2286 ConfigObject => $ConfigObject, 2287 ); 2288 } 2289 } 2290 elsif ( $Test->{ProcessGet} ) { 2291 2292 # Set Config 2293 if ( IsHashRefWithData( $Test->{ProcessGet}->{Config} ) ) { 2294 for my $Config ( sort keys %{ $Test->{ProcessGet}->{Config} } ) { 2295 $ConfigObject->Set( 2296 Key => $Config, 2297 Value => {}, 2298 ); 2299 $ConfigObject->Set( 2300 Key => $Config, 2301 Value => $Test->{ProcessGet}->{Config}->{$Config}, 2302 ); 2303 } 2304 } 2305 2306 # If we have a test with debug on, we need a new ProcessObject 2307 # with Debug turned on 2308 if ( $Test->{ProcessGet}->{Debug} ) { 2309 $ProcessObject = undef; 2310 $ProcessObject = Kernel::System::ProcessManagement::Process->new( 2311 %{$Self}, 2312 %CommonObject, 2313 ConfigObject => $ConfigObject, 2314 Debug => $Test->{ProcessGet}->{Debug}, 2315 ); 2316 } 2317 2318 # execute process object call 2319 my $Result = $ProcessObject->ProcessGet( %{ $Test->{ProcessGet} } ); 2320 2321 if ( $Test->{ProcessGet}->{TestType} eq 'False' ) { 2322 2323 # ProcessGet - Check on False 2324 $Self->False( 2325 $Result, 2326 $Test->{ProcessGet}->{Message}, 2327 ); 2328 } 2329 elsif ( $Test->{ProcessGet}->{TestType} eq 'True' ) { 2330 2331 # ProcessGet - Check on True 2332 $Self->True( 2333 $Result, 2334 $Test->{ProcessGet}->{Message}, 2335 ); 2336 } 2337 elsif ( $Test->{ProcessGet}->{TestType} eq 'Result' ) { 2338 my $ExpectedResult = $Test->{ProcessGet}->{Result}; 2339 2340 # ProcessGet - Check given and expected result 2341 $Self->IsDeeply( 2342 $Result, 2343 $ExpectedResult, 2344 $Test->{ProcessGet}->{Message}, 2345 ); 2346 } 2347 2348 # If we had a test with debug on, restore ProcessObject to default 2349 if ( $Test->{ProcessList}->{Debug} ) { 2350 $ProcessObject = undef; 2351 $ProcessObject = Kernel::System::ProcessManagement::Process->new( 2352 %{$Self}, 2353 %CommonObject, 2354 ConfigObject => $ConfigObject, 2355 ); 2356 } 2357 } 2358 elsif ( $Test->{ProcessStartpointGet} ) { 2359 2360 # Set Config 2361 if ( IsHashRefWithData( $Test->{ProcessStartpointGet}->{Config} ) ) { 2362 for my $Config ( sort keys %{ $Test->{ProcessStartpointGet}->{Config} } ) { 2363 $ConfigObject->Set( 2364 Key => $Config, 2365 Value => {}, 2366 ); 2367 $ConfigObject->Set( 2368 Key => $Config, 2369 Value => $Test->{ProcessStartpointGet}->{Config}->{$Config}, 2370 ); 2371 } 2372 } 2373 2374 # If we have a test with debug on, we need a new ProcessObject 2375 # with Debug turned on 2376 if ( $Test->{ProcessStartpointGet}->{Debug} ) { 2377 $ProcessObject = undef; 2378 $ProcessObject = Kernel::System::ProcessManagement::Process->new( 2379 %{$Self}, 2380 %CommonObject, 2381 ConfigObject => $ConfigObject, 2382 Debug => $Test->{ProcessStartpointGet}->{Debug}, 2383 ); 2384 } 2385 2386 # execute process object call 2387 my $Result = $ProcessObject->ProcessStartpointGet( %{ $Test->{ProcessStartpointGet} } ); 2388 2389 if ( $Test->{ProcessStartpointGet}->{TestType} eq 'False' ) { 2390 2391 # ProcessStartpointGet - Check on False 2392 $Self->False( 2393 $Result, 2394 $Test->{ProcessStartpointGet}->{Message}, 2395 ); 2396 } 2397 elsif ( $Test->{ProcessStartpointGet}->{TestType} eq 'True' ) { 2398 2399 # ProcessStartpointGet - Check on True 2400 $Self->True( 2401 $Result, 2402 $Test->{ProcessStartpointGet}->{Message}, 2403 ); 2404 } 2405 2406 # If we had a test with debug on, restore ProcessObject to default 2407 if ( $Test->{ProcessStartpointGet}->{Debug} ) { 2408 $ProcessObject = undef; 2409 $ProcessObject = Kernel::System::ProcessManagement::Process->new( 2410 %{$Self}, 2411 %CommonObject, 2412 ConfigObject => $ConfigObject, 2413 ); 2414 } 2415 } 2416} 2417 2418# cleanup is done by RestoreDatabase 2419 24201; 2421