All files / src/objects/core zcl_abapgit_objects_activation.clas.testclasses.abap

28.75% Statements 44/153
100% Branches 4/4
66.66% Functions 4/6
28.75% Lines 44/153

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 1541x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 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_tests DEFINITION DEFERRED.
CLASS zcl_abapgit_objects_activation DEFINITION LOCAL FRIENDS ltcl_tests.
 
CLASS ltcl_tests DEFINITION FOR TESTING RISK LEVEL HARMLESS
  DURATION SHORT FINAL.
 
  PRIVATE SECTION.
    DATA mo_cut TYPE REF TO zcl_abapgit_objects_activation.
 
    METHODS:
      setup,
      is_active FOR TESTING RAISING zcx_abapgit_exception,
      is_ddic_type FOR TESTING,
      get_ddic_type FOR TESTING RAISING zcx_abapgit_exception.
 
ENDCLASS.
 
CLASS ltcl_tests IMPLEMENTATION.
 
  METHOD setup.
    CREATE OBJECT mo_cut.
  ENDMETHOD.
 
  METHOD is_active.

    DATA ls_item TYPE zif_abapgit_definitions=>ty_item.

    " DDIC, exists
    ls_item-obj_type = 'TABL'.
    ls_item-obj_name = 'T000'.

    cl_abap_unit_assert=>assert_equals(
      act = mo_cut->is_active( ls_item )
      exp = abap_true ).

    " DDIC, does not exist
    ls_item-obj_type = 'TABL'.
    ls_item-obj_name = 'TABL_ABAPGIT'.

    cl_abap_unit_assert=>assert_equals(
      act = mo_cut->is_active( ls_item )
      exp = abap_true ).

    " non-DDIC, exists
    ls_item-obj_type = 'PROG'.
    ls_item-obj_name = 'SAPMSYST'.

    cl_abap_unit_assert=>assert_equals(
      act = mo_cut->is_active( ls_item )
      exp = abap_true ).

    ls_item-obj_type = 'SFSW'.
    ls_item-obj_name = 'SRIS_SWITCH_SOURCE_SEARCH'.

    cl_abap_unit_assert=>assert_equals(
      act = mo_cut->is_active( ls_item )
      exp = abap_true ).

    " non-DDIC, does not exist
    ls_item-obj_type = 'FUGR'.
    ls_item-obj_name = 'FUGR_ABAPGIT'.

    cl_abap_unit_assert=>assert_equals(
      act = mo_cut->is_active( ls_item )
      exp = abap_true ).

  ENDMETHOD.
 
  METHOD is_ddic_type.
 
    cl_abap_unit_assert=>assert_equals(
      act = mo_cut->is_ddic_type( 'TABL' )
      exp = abap_true ).
 
    cl_abap_unit_assert=>assert_equals(
      act = mo_cut->is_ddic_type( 'PROG' )
      exp = abap_false ).
 
    cl_abap_unit_assert=>assert_equals(
      act = mo_cut->is_ddic_type( 'DESD' )
      exp = abap_true ).
 
  ENDMETHOD.
 
  METHOD get_ddic_type.

    DATA:
      lv_type TYPE ddobjtyp,
      lv_name TYPE ddobjname,
      lv_id   TYPE ddobjectid.

    mo_cut->get_ddic_type(
      EXPORTING
        iv_obj_type = 'TABL'
        iv_obj_name = 'T005'
      IMPORTING
        ev_type     = lv_type
        ev_name     = lv_name
        ev_id       = lv_id ).

    cl_abap_unit_assert=>assert_equals(
      act = lv_type
      exp = 'TABL' ).
    cl_abap_unit_assert=>assert_equals(
      act = lv_name
      exp = 'T005' ).
    cl_abap_unit_assert=>assert_equals(
      act = lv_id
      exp = '' ).

    " index id at +10
    mo_cut->get_ddic_type(
      EXPORTING
        iv_obj_type = 'XINX'
        iv_obj_name = 'T005      Z00'
      IMPORTING
        ev_type     = lv_type
        ev_name     = lv_name
        ev_id       = lv_id ).

    cl_abap_unit_assert=>assert_equals(
      act = lv_type
      exp = 'XINX' ).
    cl_abap_unit_assert=>assert_equals(
      act = lv_name
      exp = 'T005' ).
    cl_abap_unit_assert=>assert_equals(
      act = lv_id
      exp = 'Z00' ).

    " index id at +30
    mo_cut->get_ddic_type(
      EXPORTING
        iv_obj_type = 'XINX'
        iv_obj_name = 'ZLONG_TABLE_NAME              Z99'
      IMPORTING
        ev_type     = lv_type
        ev_name     = lv_name
        ev_id       = lv_id ).

    cl_abap_unit_assert=>assert_equals(
      act = lv_type
      exp = 'XINX' ).
    cl_abap_unit_assert=>assert_equals(
      act = lv_name
      exp = 'ZLONG_TABLE_NAME' ).
    cl_abap_unit_assert=>assert_equals(
      act = lv_id
      exp = 'Z99' ).

  ENDMETHOD.
 
ENDCLASS.