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

100% Statements 67/67
100% Branches 2/2
100% Functions 2/2
100% Lines 67/67

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 681x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 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 lcl_supporter_mock DEFINITION.
  PUBLIC SECTION.
    INTERFACES zif_abapgit_data_supporter.
ENDCLASS.
 
CLASS lcl_supporter_mock IMPLEMENTATION.
  METHOD zif_abapgit_data_supporter~is_object_supported.
 
    IF iv_type = zif_abapgit_data_config=>c_data_type-tabu AND iv_name = 'T005'.
      rv_supported = abap_true.
    ENDIF.
 
  ENDMETHOD.
 
ENDCLASS.
 
CLASS ltcl_supporter DEFINITION FOR TESTING RISK LEVEL HARMLESS
  DURATION SHORT FINAL.
 
  PRIVATE SECTION.
    METHODS:
      is_not_supported FOR TESTING,
      is_supported FOR TESTING.
 
ENDCLASS.
 
CLASS zcl_abapgit_data_supporter DEFINITION LOCAL FRIENDS ltcl_supporter.
 
CLASS ltcl_supporter IMPLEMENTATION.
 
  METHOD is_not_supported.
 
    DATA lv_act TYPE abap_bool.
 
    " By default, SAP tables are not supported
    lv_act = zcl_abapgit_data_factory=>get_supporter( )->is_object_supported(
      iv_type = zif_abapgit_data_config=>c_data_type-tabu
      iv_name = 'T005' ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lv_act
      exp = abap_false ).
 
  ENDMETHOD.
 
  METHOD is_supported.
 
    DATA lo_mock TYPE REF TO lcl_supporter_mock.
    DATA lo_inject TYPE REF TO zcl_abapgit_data_injector.
    DATA lv_act TYPE abap_bool.
 
    " Mock sets table T005 to be supported
    CREATE OBJECT lo_mock.
    CREATE OBJECT lo_inject.
    lo_inject->set_supporter( lo_mock ).
 
    lv_act = zcl_abapgit_data_factory=>get_supporter( )->is_object_supported(
      iv_type = zif_abapgit_data_config=>c_data_type-tabu
      iv_name = 'T005' ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lv_act
      exp = abap_true ).
 
  ENDMETHOD.
 
ENDCLASS.