All files / src/objects/texts zcl_abapgit_sotr_handler.clas.testclasses.abap

35.45% Statements 39/110
100% Branches 0/0
0% Functions 0/4
35.45% Lines 39/110

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 1111x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 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_sotr_handler DEFINITION FOR TESTING
  DURATION SHORT
  RISK LEVEL HARMLESS.
  PRIVATE SECTION.
    METHODS is_wd_component_existing
      IMPORTING iv_component_name                  TYPE sobj_name
      RETURNING VALUE(rv_is_wd_component_existing) TYPE abap_bool.
    METHODS sotr_wda_0001 FOR TESTING.
    METHODS sotr_wda_0003_not_exist FOR TESTING.
    METHODS sotr_wda_0004 FOR TESTING.
    METHODS sotr_cx_0002 FOR TESTING.
ENDCLASS.
 
CLASS ltcl_sotr_handler IMPLEMENTATION.
  METHOD is_wd_component_existing.
    DATA ls_repository TYPE wdy_rr_cluster.
    DATA lv_component_name TYPE string.
 
    lv_component_name = iv_component_name.
    TRY.
        "need to regenerate for unit test to work
        CALL FUNCTION 'WDR_REPOSITORY_INFO'
          EXPORTING
            component_name = lv_component_name
            extended_read  = abap_true
          IMPORTING
            repository     = ls_repository.
        IF ls_repository IS NOT INITIAL.
          rv_is_wd_component_existing = abap_true.
        ENDIF.
      CATCH cx_wdr_rr_exception.
        "ignore and return false
    ENDTRY.
  ENDMETHOD.
  METHOD sotr_wda_0001.
    CONSTANTS lc_wd_component_name TYPE sobj_name VALUE 'SALV_WD_TEST_TABLE_SIMPLE'.
    DATA lt_sotr TYPE zcl_abapgit_sotr_handler=>ty_sotr_tt.
    IF is_wd_component_existing( lc_wd_component_name ) = abap_true.
      TRY.
          zcl_abapgit_sotr_handler=>read_sotr(
            EXPORTING
              iv_pgmid    = 'LIMU'
              iv_object   = 'WDYV'
              iv_obj_name = lc_wd_component_name
              io_i18n_params = zcl_abapgit_i18n_params=>new( )
            IMPORTING
              et_sotr     = lt_sotr ).
          cl_abap_unit_assert=>assert_not_initial( lt_sotr ).
        CATCH zcx_abapgit_exception.
          cl_abap_unit_assert=>fail( quit = if_aunit_constants=>method ).
      ENDTRY.
    ENDIF.
  ENDMETHOD.
  METHOD sotr_wda_0003_not_exist.
    CONSTANTS lc_wd_not_exist_component_name TYPE sobj_name VALUE '_NOT_EXISTING'.
    DATA lt_sotr TYPE zcl_abapgit_sotr_handler=>ty_sotr_tt.
    IF is_wd_component_existing( lc_wd_not_exist_component_name ) <> abap_true.
      TRY.
          zcl_abapgit_sotr_handler=>read_sotr(
            EXPORTING
              iv_pgmid    = 'LIMU'
              iv_object   = 'WDYV'
              iv_obj_name = lc_wd_not_exist_component_name
              io_i18n_params = zcl_abapgit_i18n_params=>new( )
            IMPORTING
              et_sotr     = lt_sotr ).
          cl_abap_unit_assert=>assert_initial( lt_sotr ).
        CATCH zcx_abapgit_exception.
          cl_abap_unit_assert=>fail( quit = if_aunit_constants=>method ).
      ENDTRY.
    ENDIF.
  ENDMETHOD.
  METHOD sotr_wda_0004.
    CONSTANTS lc_wd_component_name TYPE sobj_name VALUE 'SALV_WD_TEST_TABLE_SELECT'.
    DATA lt_sotr TYPE zcl_abapgit_sotr_handler=>ty_sotr_tt.
    IF is_wd_component_existing( lc_wd_component_name ) = abap_true.
      TRY.
          zcl_abapgit_sotr_handler=>read_sotr(
            EXPORTING
              iv_pgmid    = 'LIMU'
              iv_object   = 'WDYV'
              iv_obj_name = lc_wd_component_name
              io_i18n_params = zcl_abapgit_i18n_params=>new( )
            IMPORTING
              et_sotr     = lt_sotr ).
          IF lines( lt_sotr ) < 50.
            cl_abap_unit_assert=>fail( quit = if_aunit_constants=>method ).
          ENDIF.
        CATCH zcx_abapgit_exception.
          cl_abap_unit_assert=>fail( quit = if_aunit_constants=>method ).
      ENDTRY.
    ENDIF.
  ENDMETHOD.
  METHOD sotr_cx_0002.
    DATA lt_sotr TYPE zcl_abapgit_sotr_handler=>ty_sotr_tt.
    TRY.
        zcl_abapgit_sotr_handler=>read_sotr(
          EXPORTING
            iv_pgmid    = 'LIMU'
            iv_object   = 'CPUB'
            iv_obj_name = 'CX_ABAP_INVALID_NAME'
            io_i18n_params = zcl_abapgit_i18n_params=>new( )
          IMPORTING
            et_sotr     = lt_sotr ).
        cl_abap_unit_assert=>assert_not_initial( lt_sotr ).
      CATCH zcx_abapgit_exception.
        cl_abap_unit_assert=>fail( quit = if_aunit_constants=>method ).
    ENDTRY.
  ENDMETHOD.
ENDCLASS.