Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 1x 1x 1x 3x 3x 3x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 1x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 1x 5x 1x 1x 1x 1x 1x 1x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 6x 6x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 2x 2x 8x 8x 10x 10x 1x 1x 1x 1x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 1x 1x 6x 6x 6x 6x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | CLASS ltcl_get_patch_data DEFINITION FINAL FOR TESTING
DURATION SHORT
RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS:
get_patch_data_add FOR TESTING RAISING cx_static_check,
get_patch_data_remove FOR TESTING RAISING cx_static_check,
invalid_patch_missing_file FOR TESTING RAISING cx_static_check,
invalid_patch_missing_index FOR TESTING RAISING cx_static_check.
ENDCLASS.
CLASS ltcl_is_patch_line_possible DEFINITION FINAL FOR TESTING
DURATION SHORT
RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA:
mv_is_patch_line_possible TYPE abap_bool,
ms_diff_line TYPE zif_abapgit_definitions=>ty_diff.
METHODS:
initial_diff_line FOR TESTING RAISING cx_static_check,
for_update_patch_shd_be_possbl FOR TESTING RAISING cx_static_check,
for_insert_patch_shd_be_possbl FOR TESTING RAISING cx_static_check,
for_delete_patch_shd_be_possbl FOR TESTING RAISING cx_static_check,
given_diff_line
IMPORTING
is_diff_line TYPE zif_abapgit_definitions=>ty_diff OPTIONAL,
when_is_patch_line_possible,
then_patch_shd_be_possible,
then_patch_shd_not_be_possible.
ENDCLASS.
CLASS zcl_abapgit_gui_page_patch DEFINITION LOCAL FRIENDS ltcl_is_patch_line_possible.
CLASS ltcl_get_patch_data IMPLEMENTATION.
METHOD get_patch_data_add.
DATA: lv_file_name TYPE string,
lv_line_index TYPE string.
zcl_abapgit_gui_page_patch=>get_patch_data(
EXPORTING
iv_patch = |patch_line_zcl_test_git_add_p.clas.abap_0_19|
IMPORTING
ev_filename = lv_file_name
ev_line_index = lv_line_index ).
cl_abap_unit_assert=>assert_equals(
exp = |zcl_test_git_add_p.clas.abap|
act = lv_file_name ).
cl_abap_unit_assert=>assert_equals(
exp = |19|
act = lv_line_index ).
ENDMETHOD.
METHOD get_patch_data_remove.
DATA: lv_file_name TYPE string,
lv_line_index TYPE string.
zcl_abapgit_gui_page_patch=>get_patch_data(
EXPORTING
iv_patch = |patch_line_ztest_patch.prog.abap_0_39|
IMPORTING
ev_filename = lv_file_name
ev_line_index = lv_line_index ).
cl_abap_unit_assert=>assert_equals(
exp = |ztest_patch.prog.abap|
act = lv_file_name ).
cl_abap_unit_assert=>assert_equals(
exp = |39|
act = lv_line_index ).
ENDMETHOD.
METHOD invalid_patch_missing_file.
DATA: lv_file_name TYPE string,
lv_line_index TYPE string,
lx_error TYPE REF TO zcx_abapgit_exception.
TRY.
zcl_abapgit_gui_page_patch=>get_patch_data(
EXPORTING
iv_patch = |patch_39|
IMPORTING
ev_filename = lv_file_name
ev_line_index = lv_line_index ).
cl_abap_unit_assert=>fail( ).
CATCH zcx_abapgit_exception INTO lx_error.
cl_abap_unit_assert=>assert_equals(
exp = |Invalid patch|
act = lx_error->get_text( ) ).
ENDTRY.
ENDMETHOD.
METHOD invalid_patch_missing_index.
DATA: lv_file_name TYPE string,
lv_line_index TYPE string,
lx_error TYPE REF TO zcx_abapgit_exception.
TRY.
zcl_abapgit_gui_page_patch=>get_patch_data(
EXPORTING
iv_patch = |patch_ztest_patch.prog.abap|
IMPORTING
ev_filename = lv_file_name
ev_line_index = lv_line_index ).
cl_abap_unit_assert=>fail( ).
CATCH zcx_abapgit_exception INTO lx_error.
cl_abap_unit_assert=>assert_equals(
exp = |Invalid patch|
act = lx_error->get_text( ) ).
ENDTRY.
ENDMETHOD.
ENDCLASS.
CLASS ltcl_is_patch_line_possible IMPLEMENTATION.
METHOD initial_diff_line.
given_diff_line( ).
when_is_patch_line_possible( ).
then_patch_shd_not_be_possible( ).
ENDMETHOD.
METHOD for_update_patch_shd_be_possbl.
DATA: ls_diff_line TYPE zif_abapgit_definitions=>ty_diff.
ls_diff_line-result = zif_abapgit_definitions=>c_diff-update.
given_diff_line( ls_diff_line ).
when_is_patch_line_possible( ).
then_patch_shd_be_possible( ).
ENDMETHOD.
METHOD for_insert_patch_shd_be_possbl.
DATA: ls_diff_line TYPE zif_abapgit_definitions=>ty_diff.
ls_diff_line-result = zif_abapgit_definitions=>c_diff-insert.
given_diff_line( ls_diff_line ).
when_is_patch_line_possible( ).
then_patch_shd_be_possible( ).
ENDMETHOD.
METHOD for_delete_patch_shd_be_possbl.
DATA: ls_diff_line TYPE zif_abapgit_definitions=>ty_diff.
ls_diff_line-result = zif_abapgit_definitions=>c_diff-delete.
given_diff_line( ls_diff_line ).
when_is_patch_line_possible( ).
then_patch_shd_be_possible( ).
ENDMETHOD.
METHOD when_is_patch_line_possible.
mv_is_patch_line_possible = zcl_abapgit_gui_page_patch=>is_patch_line_possible( ms_diff_line ).
ENDMETHOD.
METHOD then_patch_shd_be_possible.
cl_abap_unit_assert=>assert_not_initial(
act = mv_is_patch_line_possible
msg = |Patch should be possible| ).
ENDMETHOD.
METHOD then_patch_shd_not_be_possible.
cl_abap_unit_assert=>assert_initial(
act = mv_is_patch_line_possible
msg = |Patch should not be possible| ).
ENDMETHOD.
METHOD given_diff_line.
ms_diff_line = is_diff_line.
ENDMETHOD.
ENDCLASS.
CLASS lcl_continue_repo DEFINITION FINAL INHERITING FROM zcl_abapgit_repo.
PUBLIC SECTION.
DATA mv_pushes TYPE i.
INTERFACES zif_abapgit_repo_online.
METHODS zif_abapgit_repo~get_files_local REDEFINITION.
METHODS zif_abapgit_repo~get_files_remote REDEFINITION.
METHODS zif_abapgit_repo~find_remote_dot_abapgit REDEFINITION.
ENDCLASS.
CLASS lcl_continue_user DEFINITION FINAL.
PUBLIC SECTION.
INTERFACES zif_abapgit_persist_user.
ENDCLASS.
CLASS lcl_continue_settings DEFINITION FINAL.
PUBLIC SECTION.
INTERFACES zif_abapgit_persist_settings.
ENDCLASS.
CLASS lcl_continue_repo_srv DEFINITION FINAL.
PUBLIC SECTION.
INTERFACES zif_abapgit_repo_srv.
DATA mi_repo TYPE REF TO zif_abapgit_repo.
ENDCLASS.
CLASS lcl_continue_patch DEFINITION FINAL INHERITING FROM zcl_abapgit_gui_page_patch.
PUBLIC SECTION.
DATA mv_refreshes TYPE i.
DATA mv_fail_refresh TYPE abap_bool.
METHODS get_diffs
RETURNING
VALUE(rt_diffs) TYPE zif_abapgit_gui_diff=>ty_file_diffs.
PROTECTED SECTION.
METHODS get_files_and_status REDEFINITION.
METHODS refresh_full REDEFINITION.
ENDCLASS.
CLASS ltcl_continue_patching DEFINITION FINAL FOR TESTING
DURATION SHORT
RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mi_previous_srv TYPE REF TO zif_abapgit_repo_srv.
DATA mi_previous_user TYPE REF TO zif_abapgit_persist_user.
DATA mi_previous_settings TYPE REF TO zif_abapgit_persist_settings.
DATA mo_repo TYPE REF TO lcl_continue_repo.
DATA mo_patch TYPE REF TO zcl_abapgit_gui_page_patch.
DATA mo_fixture TYPE REF TO lcl_continue_patch.
METHODS setup RAISING cx_static_check.
METHODS teardown.
METHODS successive_patches FOR TESTING RAISING cx_static_check.
METHODS invalid_commit_keeps_patch FOR TESTING RAISING cx_static_check.
METHODS reject_continue_without_patch FOR TESTING RAISING cx_static_check.
METHODS commit_with_remaining_changes FOR TESTING RAISING cx_static_check.
METHODS commit_without_remaining FOR TESTING RAISING cx_static_check.
METHODS commit_refresh_failure FOR TESTING RAISING cx_static_check.
METHODS commit_refresh_warning FOR TESTING RAISING cx_static_check.
METHODS commit_patch
RETURNING VALUE(rs_handled) TYPE zif_abapgit_gui_event_handler=>ty_handling_result
RAISING cx_static_check.
ENDCLASS.
CLASS lcl_continue_repo_srv IMPLEMENTATION.
METHOD zif_abapgit_repo_srv~get.
ri_repo = mi_repo.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~init.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~delete.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~is_repo_installed.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~list.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~list_favorites.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~new_offline.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~new_online.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~purge.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~validate_package.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~validate_url.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~get_repo_from_package.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~get_repo_from_url.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~get_label_list.
ENDMETHOD.
METHOD zif_abapgit_repo_srv~reload.
ENDMETHOD.
ENDCLASS.
CLASS lcl_continue_repo IMPLEMENTATION.
METHOD zif_abapgit_repo_online~get_url.
rv_url = ms_data-url.
ENDMETHOD.
METHOD zif_abapgit_repo_online~get_selected_branch.
rv_name = ms_data-branch_name.
ENDMETHOD.
METHOD zif_abapgit_repo_online~set_url.
ENDMETHOD.
METHOD zif_abapgit_repo_online~select_branch.
ENDMETHOD.
METHOD zif_abapgit_repo_online~get_selected_commit.
ENDMETHOD.
METHOD zif_abapgit_repo_online~get_current_remote.
ENDMETHOD.
METHOD zif_abapgit_repo_online~select_commit.
ENDMETHOD.
METHOD zif_abapgit_repo_online~switch_origin.
ENDMETHOD.
METHOD zif_abapgit_repo_online~get_switched_origin.
ENDMETHOD.
METHOD zif_abapgit_repo_online~push.
mv_pushes = mv_pushes + 1.
ENDMETHOD.
METHOD zif_abapgit_repo_online~create_branch.
ENDMETHOD.
METHOD zif_abapgit_repo_online~check_for_valid_branch.
ENDMETHOD.
METHOD zif_abapgit_repo_online~get_remote_settings.
ENDMETHOD.
METHOD zif_abapgit_repo~get_files_local.
DATA ls_file LIKE LINE OF rt_files.
ls_file-file-path = '/'.
ls_file-file-filename = 'test.abap'.
ls_file-file-data = zcl_abapgit_convert=>string_to_xstring_utf8(
|unchanged\nfirst new\nsecond new\n| ).
ls_file-file-sha1 = zcl_abapgit_hash=>sha1_blob( ls_file-file-data ).
APPEND ls_file TO rt_files.
ENDMETHOD.
METHOD zif_abapgit_repo~get_files_remote.
DATA ls_file LIKE LINE OF rt_files.
ls_file-path = '/'.
ls_file-filename = 'test.abap'.
ls_file-data = zcl_abapgit_convert=>string_to_xstring_utf8(
|unchanged\nfirst old\nsecond old\n| ).
ls_file-sha1 = zcl_abapgit_hash=>sha1_blob( ls_file-data ).
INSERT ls_file INTO TABLE rt_files.
ENDMETHOD.
METHOD zif_abapgit_repo~find_remote_dot_abapgit.
ENDMETHOD.
ENDCLASS.
CLASS lcl_continue_user IMPLEMENTATION.
METHOD zif_abapgit_persist_user~get_changes_only.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_default_git_user_email.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_default_git_user_name.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_diff_unified.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_favorites.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_hide_files.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_show_folders.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_repo_git_user_email.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_repo_git_user_name.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_repo_last_change_seen.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_repo_login.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_repo_show.
ENDMETHOD.
METHOD zif_abapgit_persist_user~is_favorite_repo.
ENDMETHOD.
METHOD zif_abapgit_persist_user~set_default_git_user_email.
ENDMETHOD.
METHOD zif_abapgit_persist_user~set_default_git_user_name.
ENDMETHOD.
METHOD zif_abapgit_persist_user~set_repo_git_user_email.
ENDMETHOD.
METHOD zif_abapgit_persist_user~set_repo_git_user_name.
ENDMETHOD.
METHOD zif_abapgit_persist_user~set_repo_last_change_seen.
ENDMETHOD.
METHOD zif_abapgit_persist_user~set_repo_login.
ENDMETHOD.
METHOD zif_abapgit_persist_user~set_repo_show.
ENDMETHOD.
METHOD zif_abapgit_persist_user~toggle_changes_only.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_order_by.
ENDMETHOD.
METHOD zif_abapgit_persist_user~set_order_by.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_order_descending.
ENDMETHOD.
METHOD zif_abapgit_persist_user~set_order_descending.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_diff_first.
ENDMETHOD.
METHOD zif_abapgit_persist_user~set_diff_first.
ENDMETHOD.
METHOD zif_abapgit_persist_user~toggle_diff_unified.
ENDMETHOD.
METHOD zif_abapgit_persist_user~toggle_favorite.
ENDMETHOD.
METHOD zif_abapgit_persist_user~toggle_hide_files.
ENDMETHOD.
METHOD zif_abapgit_persist_user~toggle_show_folders.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_settings.
ENDMETHOD.
METHOD zif_abapgit_persist_user~set_settings.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_list_settings.
ENDMETHOD.
METHOD zif_abapgit_persist_user~set_list_settings.
ENDMETHOD.
METHOD zif_abapgit_persist_user~get_flow_settings.
ENDMETHOD.
METHOD zif_abapgit_persist_user~set_flow_settings.
ENDMETHOD.
ENDCLASS.
CLASS lcl_continue_settings IMPLEMENTATION.
METHOD zif_abapgit_persist_settings~read.
CREATE OBJECT ro_settings.
ro_settings->set_defaults( ).
ENDMETHOD.
METHOD zif_abapgit_persist_settings~modify.
ENDMETHOD.
ENDCLASS.
CLASS lcl_continue_patch IMPLEMENTATION.
METHOD refresh_full.
" Simulate a successful push changing the remote, without network access
mv_refreshes = mv_refreshes + 1.
IF mv_fail_refresh = abap_true.
zcx_abapgit_exception=>raise( 'Test refresh failure' ).
ENDIF.
ENDMETHOD.
METHOD get_diffs.
rt_diffs = mt_diff_files.
ENDMETHOD.
METHOD get_files_and_status.
DATA ls_local LIKE LINE OF et_local.
DATA ls_remote LIKE LINE OF et_remote.
DATA ls_status LIKE LINE OF et_status.
DATA lv_remote TYPE string.
DATA lv_local TYPE string.
CLEAR: et_local, et_remote, et_status.
lv_local = |unchanged\nfirst new\nsecond new\n|.
CASE mv_refreshes.
WHEN 0.
lv_remote = |unchanged\nfirst old\nsecond old\n|.
WHEN 1.
lv_remote = |unchanged\nfirst new\nsecond old\n|.
WHEN OTHERS.
lv_remote = lv_local.
ENDCASE.
ls_local-file-path = '/'.
ls_local-file-filename = 'test.abap'.
ls_local-file-data = zcl_abapgit_convert=>string_to_xstring_utf8( lv_local ).
APPEND ls_local TO et_local.
ls_remote-path = '/'.
ls_remote-filename = 'test.abap'.
ls_remote-data = zcl_abapgit_convert=>string_to_xstring_utf8( lv_remote ).
INSERT ls_remote INTO TABLE et_remote.
ls_status-path = '/'.
ls_status-filename = 'test.abap'.
IF lv_local = lv_remote.
ls_status-match = abap_true.
ELSE.
ls_status-lstate = zif_abapgit_definitions=>c_state-modified.
ENDIF.
APPEND ls_status TO et_status.
ENDMETHOD.
ENDCLASS.
CLASS ltcl_continue_patching IMPLEMENTATION.
METHOD setup.
DATA lo_srv TYPE REF TO lcl_continue_repo_srv.
DATA ls_repo TYPE zif_abapgit_persistence=>ty_repo.
DATA ls_file TYPE zif_abapgit_git_definitions=>ty_file.
DATA lo_user TYPE REF TO lcl_continue_user.
DATA lo_settings TYPE REF TO lcl_continue_settings.
mi_previous_srv = zcl_abapgit_repo_srv=>get_instance( ).
mi_previous_user = zcl_abapgit_persist_factory=>get_user( ).
mi_previous_settings = zcl_abapgit_persist_factory=>get_settings( ).
CREATE OBJECT lo_settings.
zcl_abapgit_persist_injector=>set_settings( lo_settings ).
CREATE OBJECT lo_user.
zcl_abapgit_persist_injector=>set_current_user( lo_user ).
CREATE OBJECT lo_srv.
ls_repo-key = '1'.
ls_repo-url = 'https://github.com/abapGit/abapGit.git'.
ls_repo-branch_name = 'refs/heads/main'.
ls_repo-package = '$TMP'.
ls_repo-dot_abapgit = zcl_abapgit_dot_abapgit=>build_default( )->get_data( ).
ls_repo-dot_abapgit-folder_logic = zif_abapgit_dot_abapgit=>c_folder_logic-full.
CREATE OBJECT lo_srv->mi_repo TYPE lcl_continue_repo
EXPORTING
is_data = ls_repo.
mo_repo ?= lo_srv->mi_repo.
zcl_abapgit_repo_srv=>inject_instance( lo_srv ).
ls_file-path = '/'.
ls_file-filename = 'test.abap'.
CREATE OBJECT mo_fixture
EXPORTING
iv_key = ls_repo-key
is_file = ls_file.
mo_patch = mo_fixture.
ENDMETHOD.
METHOD teardown.
zcl_abapgit_repo_srv=>inject_instance( mi_previous_srv ).
zcl_abapgit_persist_injector=>set_current_user( mi_previous_user ).
zcl_abapgit_persist_injector=>set_settings( mi_previous_settings ).
ENDMETHOD.
METHOD commit_patch.
DATA lo_page TYPE REF TO zcl_abapgit_gui_page_hoc.
DATA lo_commit TYPE REF TO zcl_abapgit_gui_page_commit.
DATA lo_stage TYPE REF TO zcl_abapgit_stage.
DATA lt_postdata TYPE zif_abapgit_html_viewer=>ty_post_data.
CREATE OBJECT lo_stage.
lo_page ?= zcl_abapgit_gui_page_commit=>create(
ii_repo_online = mo_repo
io_stage = lo_stage
io_patch = mo_patch ).
lo_commit ?= lo_page->get_child( ).
APPEND 'comment=Test&committer_name=Committer&committer_email=test@example.org' TO lt_postdata.
rs_handled = lo_commit->zif_abapgit_gui_event_handler~on_event(
zcl_abapgit_gui_event=>new( iv_action = 'commit_patch'
it_postdata = lt_postdata ) ).
ENDMETHOD.
METHOD commit_with_remaining_changes.
DATA ls_handled TYPE zif_abapgit_gui_event_handler=>ty_handling_result.
ls_handled = commit_patch( ).
cl_abap_unit_assert=>assert_equals(
act = ls_handled-state
exp = zcl_abapgit_gui=>c_event_state-go_back ).
cl_abap_unit_assert=>assert_equals(
act = mo_repo->mv_pushes
exp = 1 ).
cl_abap_unit_assert=>assert_equals(
act = mo_fixture->mv_refreshes
exp = 1 ).
ENDMETHOD.
METHOD commit_without_remaining.
DATA ls_handled TYPE zif_abapgit_gui_event_handler=>ty_handling_result.
mo_fixture->mv_refreshes = 1.
ls_handled = commit_patch( ).
cl_abap_unit_assert=>assert_equals(
act = ls_handled-state
exp = zcl_abapgit_gui=>c_event_state-go_back_to_bookmark ).
cl_abap_unit_assert=>assert_equals(
act = mo_repo->mv_pushes
exp = 1 ).
cl_abap_unit_assert=>assert_initial( mo_fixture->get_diffs( ) ).
ENDMETHOD.
METHOD commit_refresh_failure.
DATA ls_handled TYPE zif_abapgit_gui_event_handler=>ty_handling_result.
mo_fixture->mv_fail_refresh = abap_true.
ls_handled = commit_patch( ).
cl_abap_unit_assert=>assert_equals(
act = ls_handled-state
exp = zcl_abapgit_gui=>c_event_state-go_back_to_bookmark ).
cl_abap_unit_assert=>assert_equals(
act = mo_repo->mv_pushes
exp = 1 ).
cl_abap_unit_assert=>assert_equals(
act = mo_fixture->mv_refreshes
exp = 1 ).
ENDMETHOD.
METHOD commit_refresh_warning.
DATA ls_handled TYPE zif_abapgit_gui_event_handler=>ty_handling_result.
DATA lv_message TYPE string.
DATA lv_act TYPE abap_bool.
mo_fixture->mv_fail_refresh = abap_true.
ls_handled = commit_patch( ).
" MESSAGE with a free text fills these fields on SAP, but not in open-abap
CONCATENATE sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lv_message.
lv_act = boolc( lv_message CS 'Commit was successful, but continuing patching failed' ).
cl_abap_unit_assert=>assert_equals(
act = lv_act
exp = abap_true ).
ENDMETHOD.
METHOD successive_patches.
DATA lt_files TYPE zif_abapgit_gui_diff=>ty_file_diffs.
DATA ls_file LIKE LINE OF lt_files.
DATA lt_diff TYPE zif_abapgit_definitions=>ty_diffs_tt.
DATA ls_line LIKE LINE OF lt_diff.
DATA ls_commit TYPE zif_abapgit_services_git=>ty_commit_fields.
DATA lv_updates TYPE i.
lt_files = mo_fixture->get_diffs( ).
READ TABLE lt_files INTO ls_file INDEX 1.
cl_abap_unit_assert=>assert_subrc( ).
ls_file-o_diff->set_patch_new(
iv_line_new = 2
iv_patch_flag = abap_true ).
ls_commit-committer_name = 'Committer'.
ls_commit-committer_email = 'committer@example.org'.
ls_commit-author_name = 'Author'.
ls_commit-author_email = 'author@example.org'.
ls_commit-comment = 'First patch'.
ls_commit-body = 'First description'.
cl_abap_unit_assert=>assert_equals(
act = mo_patch->continue_patching( ls_commit )
exp = abap_true ).
lt_files = mo_fixture->get_diffs( ).
READ TABLE lt_files INTO ls_file INDEX 1.
cl_abap_unit_assert=>assert_subrc( ).
lt_diff = ls_file-o_diff->get( ).
LOOP AT lt_diff INTO ls_line.
cl_abap_unit_assert=>assert_initial( ls_line-patch_flag ).
IF ls_line-result = zif_abapgit_definitions=>c_diff-update.
lv_updates = lv_updates + 1.
cl_abap_unit_assert=>assert_equals(
act = ls_line-old
exp = 'second old' ).
cl_abap_unit_assert=>assert_equals(
act = ls_line-new
exp = 'second new' ).
ENDIF.
ENDLOOP.
cl_abap_unit_assert=>assert_equals(
act = lv_updates
exp = 1 ).
" Completing the single-file scope must return to the repository
cl_abap_unit_assert=>assert_equals(
act = mo_patch->continue_patching( ls_commit )
exp = abap_false ).
lt_files = mo_fixture->get_diffs( ).
cl_abap_unit_assert=>assert_initial( lt_files ).
cl_abap_unit_assert=>assert_equals(
act = mo_fixture->mv_refreshes
exp = 2 ).
ENDMETHOD.
METHOD invalid_commit_keeps_patch.
DATA lo_commit TYPE REF TO zcl_abapgit_gui_page_commit.
DATA lo_page TYPE REF TO zcl_abapgit_gui_page_hoc.
DATA li_repo TYPE REF TO zif_abapgit_repo_online.
DATA lo_stage TYPE REF TO zcl_abapgit_stage.
DATA ls_handled TYPE zif_abapgit_gui_event_handler=>ty_handling_result.
li_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( '1' ).
CREATE OBJECT lo_stage.
lo_page ?= zcl_abapgit_gui_page_commit=>create(
ii_repo_online = li_repo
io_stage = lo_stage
io_patch = mo_patch
iv_sci_result = zif_abapgit_definitions=>c_sci_result-no_run ).
lo_commit ?= lo_page->get_child( ).
" Missing required fields: no push or patch reset may happen
ls_handled = lo_commit->zif_abapgit_gui_event_handler~on_event(
zcl_abapgit_gui_event=>new( iv_action = 'commit_patch' ) ).
cl_abap_unit_assert=>assert_equals(
act = ls_handled-state
exp = zcl_abapgit_gui=>c_event_state-re_render ).
cl_abap_unit_assert=>assert_initial( mo_fixture->mv_refreshes ).
ENDMETHOD.
METHOD reject_continue_without_patch.
DATA lo_commit TYPE REF TO zcl_abapgit_gui_page_commit.
DATA lo_page TYPE REF TO zcl_abapgit_gui_page_hoc.
DATA li_repo TYPE REF TO zif_abapgit_repo_online.
DATA lo_stage TYPE REF TO zcl_abapgit_stage.
DATA lx_error TYPE REF TO zcx_abapgit_exception.
li_repo ?= zcl_abapgit_repo_srv=>get_instance( )->get( '1' ).
CREATE OBJECT lo_stage.
lo_page ?= zcl_abapgit_gui_page_commit=>create(
ii_repo_online = li_repo
io_stage = lo_stage
iv_sci_result = zif_abapgit_definitions=>c_sci_result-no_run ).
lo_commit ?= lo_page->get_child( ).
TRY.
lo_commit->zif_abapgit_gui_event_handler~on_event(
zcl_abapgit_gui_event=>new( iv_action = 'commit_patch' ) ).
cl_abap_unit_assert=>fail( 'A normal commit must not accept the patch continuation action' ).
CATCH zcx_abapgit_exception INTO lx_error.
cl_abap_unit_assert=>assert_equals(
act = lx_error->get_text( )
exp = 'Continue patching is only available when committing a patch' ).
ENDTRY.
ENDMETHOD.
ENDCLASS.
|