All files / src/repo zcl_abapgit_dot_abapgit.clas.testclasses.abap

85.71% Statements 102/119
100% Branches 2/2
66.66% Functions 2/3
85.71% Lines 102/119

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 1201x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                                   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 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_dot_abapgit DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
 
  PRIVATE SECTION.
    METHODS identity FOR TESTING RAISING zcx_abapgit_exception.
    METHODS ignore FOR TESTING RAISING zcx_abapgit_exception.
 
ENDCLASS.
 
CLASS ltcl_dot_abapgit IMPLEMENTATION.
 
  METHOD identity.

    DATA: lo_dot    TYPE REF TO zcl_abapgit_dot_abapgit,
          ls_before TYPE zif_abapgit_dot_abapgit=>ty_dot_abapgit,
          ls_after  TYPE zif_abapgit_dot_abapgit=>ty_dot_abapgit.


    lo_dot = zcl_abapgit_dot_abapgit=>build_default( ).
    ls_before = lo_dot->get_data( ).

    lo_dot = zcl_abapgit_dot_abapgit=>deserialize( lo_dot->serialize( ) ).
    ls_after = lo_dot->get_data( ).

    cl_abap_unit_assert=>assert_equals(
      act = ls_after
      exp = ls_before ).

  ENDMETHOD.
 
  METHOD ignore.
 
    CONSTANTS: lc_path     TYPE string VALUE '/src/',
               lc_root     TYPE string VALUE '/',
               lc_filename TYPE string VALUE 'foobar.txt'.
 
    DATA: lv_ignored TYPE abap_bool,
          lo_dot     TYPE REF TO zcl_abapgit_dot_abapgit.
 
 
    lo_dot = zcl_abapgit_dot_abapgit=>build_default( ).
 
    " Any file in default starting folder /src/ should not be ignored
    lv_ignored = lo_dot->is_ignored( iv_path = lc_path
                                     iv_filename = lc_filename ).
    cl_abap_unit_assert=>assert_equals(
      act = lv_ignored
      exp = abap_false ).
 
    " Add file to ignore list -> expect to be ignored
    lo_dot->add_ignore( iv_path = lc_path
                        iv_filename = lc_filename ).
 
    lv_ignored = lo_dot->is_ignored( iv_path = lc_path
                                     iv_filename = lc_filename ).
    cl_abap_unit_assert=>assert_equals(
      act = lv_ignored
      exp = abap_true ).
 
    " Remove file from ignore list -> expect to be allowed
    lo_dot->remove_ignore( iv_path = lc_path
                           iv_filename = lc_filename ).
 
    lv_ignored = lo_dot->is_ignored( iv_path = lc_path
                                     iv_filename = lc_filename ).
    cl_abap_unit_assert=>assert_equals(
      act = lv_ignored
      exp = abap_false ).
 
    " .abapgit.xml and .apack-manifest.xml must always be allowed
    lv_ignored = lo_dot->is_ignored( iv_path = lc_root
                                     iv_filename = zif_abapgit_definitions=>c_dot_abapgit ).
    cl_abap_unit_assert=>assert_equals(
      act = lv_ignored
      exp = abap_false ).
 
    lv_ignored = lo_dot->is_ignored( iv_path = lc_root
                                     iv_filename = zif_abapgit_apack_definitions=>c_dot_apack_manifest ).
    cl_abap_unit_assert=>assert_equals(
      act = lv_ignored
      exp = abap_false ).
 
    " File in root must be ignored since it's not under starting folder
    lv_ignored = lo_dot->is_ignored( iv_path = lc_root
                                     iv_filename = 'abaplint.json' ).
    cl_abap_unit_assert=>assert_equals(
      act = lv_ignored
      exp = abap_true ).
 
    " File under starting folder must not be ignored
    lv_ignored = lo_dot->is_ignored( iv_path = lc_path
                                     iv_filename = 'ztest.prog.abap' ).
    cl_abap_unit_assert=>assert_equals(
      act = lv_ignored
      exp = abap_false ).
 
    " Ignore everything in a namespace
    lo_dot->add_ignore( iv_path = lc_path
                        iv_filename = '#namespace#*' ).
 
    lv_ignored = lo_dot->is_ignored( iv_path = lc_path
                                     iv_filename = '#namespace#cl_test.clas.abap' ).
    cl_abap_unit_assert=>assert_equals(
      act = lv_ignored
      exp = abap_true ).
 
    " Don't ignore file
    lo_dot->add_ignore( iv_path = '!' && lc_root
                        iv_filename = 'abaplint.json' ).
 
    lv_ignored = lo_dot->is_ignored( iv_path = lc_root
                                     iv_filename = 'abaplint.json' ).
    cl_abap_unit_assert=>assert_equals(
      act = lv_ignored
      exp = abap_false ).
 
  ENDMETHOD.
 
ENDCLASS.