All files / src/git zcl_abapgit_git_porcelain.clas.testclasses.abap

100% Statements 153/153
100% Branches 8/8
100% Functions 8/8
100% Lines 153/153

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 1541x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 6x 6x 6x 1x 1x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 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_git_porcelain DEFINITION DEFERRED.
CLASS zcl_abapgit_git_porcelain DEFINITION LOCAL FRIENDS ltcl_git_porcelain.
 
CLASS ltcl_git_porcelain DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL.
 
  PRIVATE SECTION.
    METHODS:
      setup,
      append
        IMPORTING iv_path TYPE string
                  iv_name TYPE string,
      single_file FOR TESTING
        RAISING zcx_abapgit_exception,
      two_files_same_path FOR TESTING
        RAISING zcx_abapgit_exception,
      root_empty FOR TESTING
        RAISING zcx_abapgit_exception,
      namespaces FOR TESTING
        RAISING zcx_abapgit_exception,
      more_sub FOR TESTING
        RAISING zcx_abapgit_exception,
      sub FOR TESTING
        RAISING zcx_abapgit_exception.
 
    DATA: mt_expanded TYPE zif_abapgit_git_definitions=>ty_expanded_tt,
          mt_trees    TYPE zcl_abapgit_git_porcelain=>ty_trees_tt.
 
ENDCLASS.
 
CLASS ltcl_git_porcelain IMPLEMENTATION.
 
  METHOD setup.
    CLEAR mt_expanded.
    CLEAR mt_trees.
  ENDMETHOD.
 
  METHOD append.
 
    FIELD-SYMBOLS: <ls_expanded> LIKE LINE OF mt_expanded.
 
 
    APPEND INITIAL LINE TO mt_expanded ASSIGNING <ls_expanded>.
    <ls_expanded>-path  = iv_path.
    <ls_expanded>-name  = iv_name.
    <ls_expanded>-sha1  = 'a'.
    <ls_expanded>-chmod = zif_abapgit_git_definitions=>c_chmod-file.
 
  ENDMETHOD.
 
  METHOD single_file.
 
    append( iv_path = '/'
            iv_name = 'foobar.txt' ).
 
    mt_trees = zcl_abapgit_git_porcelain=>build_trees( mt_expanded ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lines( mt_trees )
      exp = 1 ).
 
  ENDMETHOD.
 
  METHOD two_files_same_path.
 
    append( iv_path = '/'
            iv_name = 'foo.txt' ).
 
    append( iv_path = '/'
            iv_name = 'bar.txt' ).
 
    mt_trees = zcl_abapgit_git_porcelain=>build_trees( mt_expanded ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lines( mt_trees )
      exp = 1 ).
 
  ENDMETHOD.
 
  METHOD sub.
 
    append( iv_path = '/'
            iv_name = 'foo.txt' ).
 
    append( iv_path = '/sub/'
            iv_name = 'bar.txt' ).
 
    mt_trees = zcl_abapgit_git_porcelain=>build_trees( mt_expanded ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lines( mt_trees )
      exp = 2 ).
 
  ENDMETHOD.
 
  METHOD more_sub.
 
    FIELD-SYMBOLS: <ls_tree> LIKE LINE OF mt_trees.
 
    append( iv_path = '/src/foo_a/foo_a1/'
            iv_name = 'a1.txt' ).
 
    append( iv_path = '/src/foo_a/foo_a2/'
            iv_name = 'a2.txt' ).
 
    mt_trees = zcl_abapgit_git_porcelain=>build_trees( mt_expanded ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lines( mt_trees )
      exp = 5 ).
 
    LOOP AT mt_trees ASSIGNING <ls_tree>.
      cl_abap_unit_assert=>assert_not_initial( <ls_tree>-data ).
    ENDLOOP.
 
  ENDMETHOD.
 
  METHOD namespaces.
 
    FIELD-SYMBOLS: <ls_tree> LIKE LINE OF mt_trees.
 
    append( iv_path = '/src/#foo#a/#foo#a1/'
            iv_name = 'a1.txt' ).
 
    append( iv_path = '/src/#foo#a/#foo#a2/'
            iv_name = 'a2.txt' ).
 
    mt_trees = zcl_abapgit_git_porcelain=>build_trees( mt_expanded ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lines( mt_trees )
      exp = 5 ).
 
    LOOP AT mt_trees ASSIGNING <ls_tree>.
      cl_abap_unit_assert=>assert_not_initial( <ls_tree>-data ).
    ENDLOOP.
 
  ENDMETHOD.
 
  METHOD root_empty.
 
    append( iv_path = '/sub/'
            iv_name = 'bar.txt' ).
 
    mt_trees = zcl_abapgit_git_porcelain=>build_trees( mt_expanded ).
 
* so 2 total trees are expected: '/' and '/sub/'
    cl_abap_unit_assert=>assert_equals(
      act = lines( mt_trees )
      exp = 2 ).
 
  ENDMETHOD.
 
ENDCLASS.