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

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

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 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 1751x 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 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 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_i18n_params_test DEFINITION FINAL
  FOR TESTING
  RISK LEVEL HARMLESS
  DURATION SHORT.
 
  PUBLIC SECTION.
 
    METHODS iso_langs_to_lang_filter FOR TESTING.
    METHODS filter_sap_langs FOR TESTING RAISING zcx_abapgit_exception.
    METHODS filter_sap_langs_tab FOR TESTING RAISING zcx_abapgit_exception.
 
ENDCLASS.
 
CLASS zcl_abapgit_i18n_params DEFINITION LOCAL FRIENDS ltcl_i18n_params_test.
 
CLASS ltcl_i18n_params_test IMPLEMENTATION.
 
  METHOD iso_langs_to_lang_filter.
 
    DATA lt_filter TYPE zif_abapgit_definitions=>ty_languages.
    DATA lt_act TYPE zif_abapgit_environment=>ty_system_language_filter.
    DATA lt_exp TYPE zif_abapgit_environment=>ty_system_language_filter.
    DATA ls_range LIKE LINE OF lt_act.
 
    APPEND 'EN' TO lt_filter.
    APPEND 'DE' TO lt_filter.
 
    ls_range-sign   = 'I'.
    ls_range-option = 'EQ'.
    ls_range-low    = 'E'.
    APPEND ls_range TO lt_exp.
    ls_range-low    = 'D'.
    APPEND ls_range TO lt_exp.
 
    lt_act = zcl_abapgit_i18n_params=>iso_langs_to_lang_filter( lt_filter ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lt_act
      exp = lt_exp ).
 
  ENDMETHOD.
 
  METHOD filter_sap_langs.
 
    DATA lt_act TYPE zif_abapgit_definitions=>ty_sap_langu_tab.
    DATA lt_exp TYPE zif_abapgit_definitions=>ty_sap_langu_tab.
    DATA lt_filter TYPE zif_abapgit_definitions=>ty_languages.
    DATA lo_p TYPE REF TO zcl_abapgit_i18n_params.
 
    APPEND 'DE' TO lt_filter.
    APPEND 'EN' TO lt_filter.
 
    APPEND 'E' TO lt_act.
    APPEND 'D' TO lt_act.
    APPEND 'S' TO lt_act.
 
    APPEND 'E' TO lt_exp.
    APPEND 'D' TO lt_exp.
 
    lo_p = zcl_abapgit_i18n_params=>new(
      iv_main_language = '?'
      it_translation_langs = lt_filter ).
    lo_p->trim_saplang_list( CHANGING ct_sap_langs = lt_act ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lt_act
      exp = lt_exp ).
 
    " Empty filter
    CLEAR: lt_act, lt_exp, lt_filter.
    APPEND 'E' TO lt_act.
    APPEND 'D' TO lt_act.
 
    APPEND 'E' TO lt_exp.
    APPEND 'D' TO lt_exp.
 
    lo_p = zcl_abapgit_i18n_params=>new(
      iv_main_language = '?'
      it_translation_langs = lt_filter ).
    lo_p->trim_saplang_list( CHANGING ct_sap_langs = lt_act ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lt_act
      exp = lt_exp ).
 
  ENDMETHOD.
 
  METHOD filter_sap_langs_tab.
 
    DATA:
      BEGIN OF ls_i,
        spras TYPE sy-langu,
        stuff TYPE string,
      END OF ls_i.
 
    DATA lt_act LIKE TABLE OF ls_i.
    DATA lt_exp LIKE TABLE OF ls_i.
    DATA lt_filter TYPE zif_abapgit_definitions=>ty_languages.
    DATA lo_p TYPE REF TO zcl_abapgit_i18n_params.
 
    APPEND 'DE' TO lt_filter.
    APPEND 'EN' TO lt_filter.
 
    ls_i-spras = 'E'.
    APPEND ls_i TO lt_act.
    ls_i-spras = 'D'.
    APPEND ls_i TO lt_act.
    ls_i-spras = 'S'.
    APPEND ls_i TO lt_act.
 
    ls_i-spras = 'E'.
    APPEND ls_i TO lt_exp.
    ls_i-spras = 'D'.
    APPEND ls_i TO lt_exp.
 
    lo_p = zcl_abapgit_i18n_params=>new(
      iv_main_language = '?'
      it_translation_langs = lt_filter ).
    lo_p->trim_saplang_keyed_table(
      EXPORTING
        iv_lang_field_name = 'SPRAS'
      CHANGING
        ct_tab = lt_act ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lt_act
      exp = lt_exp ).
 
    " Keep master lang
    CLEAR lt_filter.
    APPEND 'DE' TO lt_filter.
 
    lo_p = zcl_abapgit_i18n_params=>new(
      iv_main_language = 'E'
      it_translation_langs = lt_filter ).
    lo_p->trim_saplang_keyed_table(
      EXPORTING
        iv_lang_field_name  = 'SPRAS'
        iv_keep_master_lang = abap_true
      CHANGING
        ct_tab = lt_act ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lt_act
      exp = lt_exp ).
 
    " Empty filter
    CLEAR: lt_act, lt_exp, lt_filter.
    ls_i-spras = 'E'.
    APPEND ls_i TO lt_act.
    ls_i-spras = 'D'.
    APPEND ls_i TO lt_act.
 
    ls_i-spras = 'E'.
    APPEND ls_i TO lt_exp.
    ls_i-spras = 'D'.
    APPEND ls_i TO lt_exp.
 
    lo_p = zcl_abapgit_i18n_params=>new(
      iv_main_language = '?'
      it_translation_langs = lt_filter ).
    lo_p->trim_saplang_keyed_table(
      EXPORTING
        iv_lang_field_name = 'SPRAS'
      CHANGING
        ct_tab = lt_act ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lt_act
      exp = lt_exp ).
 
  ENDMETHOD.
 
ENDCLASS.