All files / src/http zcl_abapgit_url.clas.testclasses.abap

100% Statements 220/220
100% Branches 16/16
100% Functions 16/16
100% Lines 220/220

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 2211x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 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_test DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
 
  PRIVATE SECTION.
 
    METHODS:
      repo_host FOR TESTING RAISING zcx_abapgit_exception,
      repo_name1 FOR TESTING RAISING zcx_abapgit_exception,
      repo_name2 FOR TESTING RAISING zcx_abapgit_exception,
      repo_name3 FOR TESTING RAISING zcx_abapgit_exception,
      repo_name4 FOR TESTING RAISING zcx_abapgit_exception,
      repo_name5 FOR TESTING RAISING zcx_abapgit_exception,
      repo_address1 FOR TESTING RAISING zcx_abapgit_exception,
      repo_address2 FOR TESTING RAISING zcx_abapgit_exception,
      repo_address3 FOR TESTING RAISING zcx_abapgit_exception,
      repo_address4 FOR TESTING RAISING zcx_abapgit_exception,
      repo_address5_dots FOR TESTING RAISING zcx_abapgit_exception,
      repo_address6_dots_and_git FOR TESTING RAISING zcx_abapgit_exception,
      repo_error FOR TESTING,
      url_validate1 FOR TESTING,
      url_validate2 FOR TESTING,
      url_validate3 FOR TESTING.
 
ENDCLASS.
 
 
CLASS ltcl_test IMPLEMENTATION.
 
  METHOD repo_error.
 
    TRY.
        zcl_abapgit_url=>host( 'not a real url' ).
        cl_abap_unit_assert=>fail( ).
      CATCH zcx_abapgit_exception.                      "#EC NO_HANDLER
    ENDTRY.
 
  ENDMETHOD.
 
  METHOD repo_host.
 
    DATA: lv_host TYPE string.
 
    lv_host = zcl_abapgit_url=>host( 'https://github.com/larshp/Foobar.git' ).
 
    cl_abap_unit_assert=>assert_equals(
        exp = 'https://github.com'
        act = lv_host ).
 
  ENDMETHOD.
 
  METHOD repo_name1.
 
    DATA: lv_name TYPE string.
 
    lv_name = zcl_abapgit_url=>name( 'https://github.com/larshp/Foobar.git' ).
 
    cl_abap_unit_assert=>assert_equals(
        exp = 'Foobar'
        act = lv_name ).
 
  ENDMETHOD.
 
  METHOD repo_name2.
 
    DATA: lv_name TYPE string.
 
    lv_name = zcl_abapgit_url=>name( 'https://git.hanatrial.ondemand.com/p12345trial/yay' ).
 
    cl_abap_unit_assert=>assert_equals(
        exp = 'yay'
        act = lv_name ).
 
  ENDMETHOD.
 
  METHOD repo_name3.
 
    DATA: lv_name TYPE string.
 
    lv_name = zcl_abapgit_url=>name( 'https://github.com/larshp/Foobar/' ).
 
    cl_abap_unit_assert=>assert_equals(
        exp = 'Foobar'
        act = lv_name ).
 
  ENDMETHOD.
 
  METHOD repo_name4.
 
    DATA: lv_name TYPE string.
 
    lv_name = zcl_abapgit_url=>name( 'https://github.com/larshp/foo-bar/' ).
 
    cl_abap_unit_assert=>assert_equals(
        exp = 'foo-bar'
        act = lv_name ).
 
  ENDMETHOD.
 
  METHOD repo_name5.
 
    DATA: lv_name TYPE string.
 
    lv_name = zcl_abapgit_url=>name( 'https://github.com/larshp/foo_bar/' ).
 
    cl_abap_unit_assert=>assert_equals(
        exp = 'foo_bar'
        act = lv_name ).
 
  ENDMETHOD.
 
  METHOD repo_address1.
 
    DATA:
      lv_url_address TYPE string.
 
    lv_url_address = zcl_abapgit_url=>url_address( 'https://github.com/abapGit/abapGit.git' ).
 
    cl_abap_unit_assert=>assert_equals(
        exp = 'https://github.com/abapGit/abapGit'
        act = lv_url_address ).
 
  ENDMETHOD.
 
  METHOD repo_address2.
 
    DATA:
      lv_url_address TYPE string.
 
    lv_url_address = zcl_abapgit_url=>url_address( 'https://git.hanatrial.ondemand.com/abapGit/abapGit.git' ).
 
    cl_abap_unit_assert=>assert_equals(
        exp = 'https://git.hanatrial.ondemand.com/abapGit/abapGit'
        act = lv_url_address ).
 
  ENDMETHOD.
 
  METHOD repo_address3.
 
    DATA:
      lv_url_address TYPE string.
 
    lv_url_address = zcl_abapgit_url=>url_address( 'https://github.com/abapGit/abapGit/' ).
 
    cl_abap_unit_assert=>assert_equals(
        exp = 'https://github.com/abapGit/abapGit'
        act = lv_url_address ).
 
  ENDMETHOD.
 
  METHOD repo_address4.
 
    DATA:
      lv_url_address TYPE string.
 
    lv_url_address = zcl_abapgit_url=>url_address( 'https://github.com/abapGit/abapGit' ).
 
    cl_abap_unit_assert=>assert_equals(
        exp = 'https://github.com/abapGit/abapGit'
        act = lv_url_address ).
 
  ENDMETHOD.
 
  METHOD repo_address5_dots.
 
    DATA:
      lv_url_address TYPE string.
 
    lv_url_address = zcl_abapgit_url=>url_address( 'https://github.com/jfilak/abap.awesome.app1' ).
 
    cl_abap_unit_assert=>assert_equals(
        exp = 'https://github.com/jfilak/abap.awesome.app1'
        act = lv_url_address ).
 
  ENDMETHOD.
 
  METHOD repo_address6_dots_and_git.
 
    DATA:
      lv_url_address TYPE string.
 
    lv_url_address = zcl_abapgit_url=>url_address( 'https://github.com/jfilak/abap.awesome.app1.git' ).
 
    cl_abap_unit_assert=>assert_equals(
        exp = 'https://github.com/jfilak/abap.awesome.app1'
        act = lv_url_address ).
 
  ENDMETHOD.
 
 
  METHOD url_validate1.
 
    TRY.
        zcl_abapgit_url=>validate( 'http://github.com/larshp/Foobar.git' ).
      CATCH zcx_abapgit_exception.
        cl_abap_unit_assert=>fail( ).
    ENDTRY.
 
  ENDMETHOD.
 
  METHOD url_validate2.
 
    TRY.
        zcl_abapgit_url=>validate( 'https://github.com/larshp/Foobar.git' ).
      CATCH zcx_abapgit_exception.
        cl_abap_unit_assert=>fail( ).
    ENDTRY.
 
  ENDMETHOD.
 
  METHOD url_validate3.
 
    TRY.
        zcl_abapgit_url=>validate( 'XYZ://github.com/larshp/Foobar.git' ).
        cl_abap_unit_assert=>fail( ).
      CATCH zcx_abapgit_exception.                      "#EC NO_HANDLER
    ENDTRY.
 
  ENDMETHOD.
 
 
ENDCLASS.