All files / src/data zcl_abapgit_data_utils.clas.testclasses.abap

100% Statements 71/71
100% Branches 3/3
100% Functions 3/3
100% Lines 71/71

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 721x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 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_data_utils_test DEFINITION FINAL FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.
 
  PRIVATE SECTION.
    METHODS build_data_filename FOR TESTING RAISING cx_static_check.
    METHODS build_config_filename FOR TESTING RAISING cx_static_check.
    METHODS build_table_itab FOR TESTING RAISING cx_static_check.
 
ENDCLASS.
 
CLASS ltcl_data_utils_test IMPLEMENTATION.
 
  METHOD build_data_filename.
 
    DATA ls_config TYPE zif_abapgit_data_config=>ty_config.
 
    ls_config-name = 'T100'.
    ls_config-type = 'TABU'.
 
    cl_abap_unit_assert=>assert_equals(
      act = zcl_abapgit_data_utils=>build_data_filename( ls_config )
      exp = 't100.tabu.json' ).
 
    ls_config-name = '/NSPC/T200'.
    ls_config-type = 'TABU'.
 
    cl_abap_unit_assert=>assert_equals(
      act = zcl_abapgit_data_utils=>build_data_filename( ls_config )
      exp = '#nspc#t200.tabu.json' ).
 
  ENDMETHOD.
 
  METHOD build_config_filename.
 
    DATA ls_config TYPE zif_abapgit_data_config=>ty_config.
 
    ls_config-name = 'T100'.
    ls_config-type = 'TABU'.
 
    cl_abap_unit_assert=>assert_equals(
      act = zcl_abapgit_data_utils=>build_config_filename( ls_config )
      exp = 't100.conf.json' ).
 
    ls_config-name = '/NSPC/T200'.
    ls_config-type = 'TABU'.
 
    cl_abap_unit_assert=>assert_equals(
      act = zcl_abapgit_data_utils=>build_config_filename( ls_config )
      exp = '#nspc#t200.conf.json' ).
 
  ENDMETHOD.
 
  METHOD build_table_itab.
 
    DATA lr_data TYPE REF TO data.
    DATA ls_row  TYPE t100.
    FIELD-SYMBOLS <lt_tab> TYPE ANY TABLE.
    FIELD-SYMBOLS <ls_row> TYPE any.
 
    lr_data = zcl_abapgit_data_utils=>build_table_itab( 'T100' ).
    ASSIGN lr_data->* TO <lt_tab>.
 
* test that the table works with basic itab operations,
    INSERT ls_row INTO TABLE <lt_tab>.
    cl_abap_unit_assert=>assert_subrc( ).
 
    READ TABLE <lt_tab> ASSIGNING <ls_row> FROM ls_row.
    cl_abap_unit_assert=>assert_subrc( ).
 
  ENDMETHOD.
 
ENDCLASS.