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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 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 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 10x 10x 10x 10x 10x 10x 1x 1x 12x 12x 12x 12x 12x 12x 12x 12x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 10x 10x 10x 10x 10x 10x 10x 7x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x | CLASS ltcl_transport_objects DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS. PRIVATE SECTION. METHODS: add_new_to_local_files FOR TESTING RAISING cx_static_check, modified_to_new_local_files FOR TESTING RAISING cx_static_check, transport_not_in_repository FOR TESTING RAISING cx_static_check, object_not_in_local_files FOR TESTING RAISING cx_static_check, cant_be_added_with_del_flag FOR TESTING RAISING cx_static_check, cant_be_modified_with_del_flag FOR TESTING RAISING cx_static_check, deleted_to_removed_files FOR TESTING RAISING cx_static_check, should_remove_no_delflag FOR TESTING RAISING cx_static_check, should_add_all_local_files FOR TESTING RAISING cx_static_check, should_delete_all_related FOR TESTING RAISING cx_static_check, setup, given_the_transport_object IMPORTING iv_obj_name TYPE string iv_obj_type TYPE string iv_delflag TYPE abap_bool OPTIONAL, given_the_object_status IMPORTING iv_obj_name TYPE string OPTIONAL iv_obj_type TYPE string OPTIONAL iv_filename TYPE string OPTIONAL iv_path TYPE string OPTIONAL iv_lstate TYPE char1, given_the_local_file IMPORTING iv_obj_name TYPE string iv_obj_type TYPE string iv_filename TYPE string iv_path TYPE string iv_data TYPE string RETURNING VALUE(rs_local_file) TYPE zif_abapgit_definitions=>ty_file_item, when_staging RAISING zcx_abapgit_exception, then_file_should_be_added IMPORTING is_local_file TYPE zif_abapgit_definitions=>ty_file_item, then_it_should_raise_exception IMPORTING iv_with_text TYPE string, then_it_should_remove_at_stage IMPORTING iv_filename TYPE string iv_path TYPE string, then_it_should_not_raise_excpt. DATA: mo_transport_objects TYPE REF TO zcl_abapgit_transport_objects, mt_transport_objects TYPE zif_abapgit_definitions=>ty_tadir_tt, mt_object_statuses TYPE zif_abapgit_definitions=>ty_results_tt, ms_stage_objects TYPE zif_abapgit_definitions=>ty_stage_files, mo_stage TYPE REF TO zcl_abapgit_stage. ENDCLASS. CLASS ltcl_transport_objects IMPLEMENTATION. METHOD setup. CREATE OBJECT mo_stage. ENDMETHOD. METHOD add_new_to_local_files. DATA ls_local_file TYPE zif_abapgit_definitions=>ty_file_item. given_the_transport_object( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' ). given_the_object_status( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_filename = 'cl_foo.clas.abap' iv_lstate = zif_abapgit_definitions=>c_state-added ). ls_local_file = given_the_local_file( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_filename = 'cl_foo.clas.abap' iv_path = '/path' iv_data = 'data' ). when_staging( ). then_file_should_be_added( ls_local_file ). ENDMETHOD. METHOD modified_to_new_local_files. DATA ls_local_file TYPE zif_abapgit_definitions=>ty_file_item. given_the_transport_object( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' ). given_the_object_status( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_filename = 'cl_foo.clas.abap' iv_lstate = zif_abapgit_definitions=>c_state-modified ). ls_local_file = given_the_local_file( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_filename = 'cl_foo.clas.abap' iv_path = '/path' iv_data = 'data' ). when_staging( ). then_file_should_be_added( ls_local_file ). ENDMETHOD. METHOD should_add_all_local_files. "Not only .abap, but also .xml and other includes DATA ls_abap_local_file TYPE zif_abapgit_definitions=>ty_file_item. DATA ls_xml_local_file TYPE zif_abapgit_definitions=>ty_file_item. given_the_transport_object( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' ). given_the_object_status( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_filename = 'cl_foo.clas.abap' iv_lstate = zif_abapgit_definitions=>c_state-modified ). given_the_object_status( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_filename = 'cl_foo.clas.xml' iv_lstate = zif_abapgit_definitions=>c_state-modified ). ls_abap_local_file = given_the_local_file( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_filename = 'cl_foo.clas.abap' iv_path = '/path' iv_data = 'data' ). ls_xml_local_file = given_the_local_file( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_filename = 'cl_foo.clas.xml' iv_path = '/path' iv_data = 'data' ). when_staging( ). then_file_should_be_added( ls_abap_local_file ). then_file_should_be_added( ls_xml_local_file ). ENDMETHOD. METHOD transport_not_in_repository. given_the_transport_object( iv_obj_name = 'CL_A_CLASS_NOT_IN_REPO' iv_obj_type = 'CLAS' ). given_the_object_status( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_lstate = zif_abapgit_definitions=>c_state-added ). then_it_should_not_raise_excpt( ). ENDMETHOD. METHOD object_not_in_local_files. given_the_transport_object( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' ). given_the_object_status( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_lstate = zif_abapgit_definitions=>c_state-added ). given_the_local_file( iv_obj_name = 'CL_ANOTHER_LOCAL_FILE' iv_obj_type = 'CLAS' iv_filename = 'cl_foo.clas.abap' iv_path = '/path' iv_data = 'data' ). then_it_should_raise_exception( 'Object CLAS CL_FOO not found in the local repository files' ). ENDMETHOD. METHOD cant_be_added_with_del_flag. given_the_transport_object( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_delflag = abap_true ). given_the_object_status( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_lstate = zif_abapgit_definitions=>c_state-added ). then_it_should_raise_exception( 'Object CLAS CL_FOO should be added/modified, but has deletion flag in transport' ). ENDMETHOD. METHOD cant_be_modified_with_del_flag. given_the_transport_object( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_delflag = abap_true ). given_the_object_status( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_lstate = zif_abapgit_definitions=>c_state-modified ). then_it_should_raise_exception( 'Object CLAS CL_FOO should be added/modified, but has deletion flag in transport' ). ENDMETHOD. METHOD deleted_to_removed_files. given_the_transport_object( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_delflag = abap_true ). given_the_object_status( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_filename = 'cl_foo.clas.abap' iv_path = '/a_path' iv_lstate = zif_abapgit_definitions=>c_state-deleted ). when_staging( ). then_it_should_remove_at_stage( iv_filename = 'cl_foo.clas.abap' iv_path = '/a_path' ). ENDMETHOD. METHOD should_delete_all_related. "i.e. Should also delete the XMLs related to the transport objects given_the_transport_object( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_delflag = abap_true ). given_the_object_status( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_filename = 'cl_foo.clas.abap' iv_path = '/a_path' iv_lstate = zif_abapgit_definitions=>c_state-deleted ). given_the_object_status( iv_obj_name = 'CL_FOO' iv_obj_type = 'CLAS' iv_filename = 'cl_foo.clas.xml' iv_path = '/a_path' iv_lstate = zif_abapgit_definitions=>c_state-deleted ). when_staging( ). then_it_should_remove_at_stage( iv_filename = 'cl_foo.clas.abap' iv_path = '/a_path' ). then_it_should_remove_at_stage( iv_filename = 'cl_foo.clas.xml' iv_path = '/a_path' ). ENDMETHOD. METHOD should_remove_no_delflag. given_the_transport_object( iv_obj_name = 'ZFOO' iv_obj_type = 'CLAS' iv_delflag = abap_false ). given_the_object_status( iv_obj_name = 'ZFOO' iv_obj_type = 'CLAS' iv_filename = 'zfoo.clas.xml' iv_path = '/a_path' iv_lstate = zif_abapgit_definitions=>c_state-deleted ). then_it_should_not_raise_excpt( ). ENDMETHOD. METHOD given_the_transport_object. DATA ls_transport_object TYPE zif_abapgit_definitions=>ty_tadir. ls_transport_object-obj_name = iv_obj_name. ls_transport_object-object = iv_obj_type. ls_transport_object-delflag = iv_delflag. APPEND ls_transport_object TO mt_transport_objects. ENDMETHOD. METHOD given_the_object_status. DATA ls_object_status TYPE zif_abapgit_definitions=>ty_result. ls_object_status-obj_name = iv_obj_name. ls_object_status-obj_type = iv_obj_type. ls_object_status-filename = iv_filename. ls_object_status-path = iv_path. ls_object_status-lstate = iv_lstate. APPEND ls_object_status TO mt_object_statuses. ENDMETHOD. METHOD given_the_local_file. rs_local_file-item-obj_name = iv_obj_name. rs_local_file-item-obj_type = iv_obj_type. rs_local_file-file-filename = iv_filename. rs_local_file-file-path = iv_path. rs_local_file-file-data = iv_data. APPEND rs_local_file TO ms_stage_objects-local. ENDMETHOD. METHOD when_staging. CREATE OBJECT mo_transport_objects EXPORTING it_transport_objects = mt_transport_objects. mo_transport_objects->to_stage( io_stage = mo_stage is_stage_objects = ms_stage_objects it_object_statuses = mt_object_statuses ). ENDMETHOD. METHOD then_file_should_be_added. DATA: lt_staged_objects TYPE zif_abapgit_definitions=>ty_stage_tt. lt_staged_objects = mo_stage->get_all( ). READ TABLE lt_staged_objects TRANSPORTING NO FIELDS WITH KEY file-filename = is_local_file-file-filename file-path = is_local_file-file-path file-data = is_local_file-file-data method = zif_abapgit_definitions=>c_method-add. IF sy-subrc <> 0. cl_abap_unit_assert=>fail( |Object { is_local_file-file-filename } not added to stage| ). ENDIF. ENDMETHOD. METHOD then_it_should_raise_exception. DATA: lx_exception TYPE REF TO zcx_abapgit_exception. TRY. when_staging( ). cl_abap_unit_assert=>fail( 'Should have raised exception' ). CATCH zcx_abapgit_exception INTO lx_exception. cl_abap_unit_assert=>assert_equals( act = lx_exception->get_text( ) exp = iv_with_text ). ENDTRY. ENDMETHOD. METHOD then_it_should_remove_at_stage. DATA: lt_staged_objects TYPE zif_abapgit_definitions=>ty_stage_tt. lt_staged_objects = mo_stage->get_all( ). READ TABLE lt_staged_objects TRANSPORTING NO FIELDS WITH KEY file-filename = iv_filename file-path = iv_path. IF sy-subrc <> 0. cl_abap_unit_assert=>fail( |Object { iv_filename } not removed in stage| ). ENDIF. ENDMETHOD. METHOD then_it_should_not_raise_excpt. DATA: lx_exception TYPE REF TO zcx_abapgit_exception. TRY. when_staging( ). CATCH zcx_abapgit_exception INTO lx_exception. cl_abap_unit_assert=>fail( 'Should not have raised exception' ). ENDTRY. ENDMETHOD. ENDCLASS. |