All files / src/persist zcl_abapgit_persist_packages.clas.testclasses.abap

35.29% Statements 24/68
100% Branches 0/0
0% Functions 0/2
35.29% Lines 24/68

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 691x 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_packages DEFINITION
  FOR TESTING
  RISK LEVEL CRITICAL
  DURATION SHORT FINAL.
 
  PRIVATE SECTION.
    CONSTANTS:
      c_package    TYPE tdevc-devclass VALUE '$TEST$ABAPGIT$',
      c_component  TYPE tdevc-component VALUE 'HLB0009083',  "BC-ABA
      c_comp_posid TYPE scompkdtln-comp_posid VALUE 'BC-ABA'.
 
    METHODS:
      test_package FOR TESTING,
      teardown.
 
ENDCLASS.
 
CLASS ltcl_packages IMPLEMENTATION.
 
  METHOD test_package.

    DATA lo_packages TYPE REF TO zcl_abapgit_persist_packages.
    DATA ls_package TYPE zcl_abapgit_persist_packages=>ty_package.
    DATA lx_error TYPE REF TO zcx_abapgit_exception.

    lo_packages = zcl_abapgit_persist_packages=>get_instance( ).

    TRY.
        lo_packages->modify(
          iv_package    = c_package
          iv_component  = c_component
          iv_comp_posid = c_comp_posid ).
      CATCH zcx_abapgit_exception INTO lx_error.
        cl_abap_unit_assert=>fail( msg = lx_error->get_text( ) ).
    ENDTRY.

    TRY.
        ls_package = lo_packages->read( c_package ).

        cl_abap_unit_assert=>assert_equals(
          act = ls_package-component
          exp = c_component ).

        cl_abap_unit_assert=>assert_equals(
          act = ls_package-comp_posid
          exp = c_comp_posid ).

      CATCH zcx_abapgit_exception INTO lx_error.
        cl_abap_unit_assert=>fail( msg = lx_error->get_text( ) ).
    ENDTRY.

  ENDMETHOD.
 
  METHOD teardown.

    DATA lo_packages TYPE REF TO zcl_abapgit_persist_packages.

    lo_packages = zcl_abapgit_persist_packages=>get_instance( ).

    " Remove test data
    TRY.
        lo_packages->modify( c_package ).
      CATCH zcx_abapgit_exception.
    ENDTRY.

  ENDMETHOD.
 
ENDCLASS.