CLASS {{p}}air_frt_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC FOR TESTING DURATION SHORT RISK LEVEL HARMLESS. PRIVATE SECTION. TYPES ty_expected TYPE c LENGTH 20. DATA mo_cut TYPE REF TO {{p}}if_air_freight. METHODS setup. METHODS assert_weight IMPORTING iv_expected TYPE ty_expected iv_actual TYPE {{p}}if_air_freight=>ty_weight. METHODS assert_amount IMPORTING iv_expected TYPE ty_expected iv_actual TYPE {{p}}if_air_freight=>ty_amount. METHODS general_shipment FOR TESTING. METHODS volumetric_weight FOR TESTING. METHODS rounds_up_to_kg FOR TESTING. METHODS rate_break_100 FOR TESTING. METHODS rate_break_101 FOR TESTING. METHODS rate_break_501 FOR TESTING. METHODS perishable_goods FOR TESTING. METHODS valuable_dangerous FOR TESTING. METHODS rejects_zero_weight FOR TESTING. METHODS rejects_zero_volume FOR TESTING. METHODS rejects_bad_category FOR TESTING. METHODS rejects_too_heavy FOR TESTING. ENDCLASS. CLASS {{p}}air_frt_hidden IMPLEMENTATION. METHOD setup. mo_cut = NEW {{p}}air_freight_pricer( ). ENDMETHOD. METHOD assert_weight. DATA lv_expected TYPE {{p}}if_air_freight=>ty_weight. lv_expected = iv_expected. cl_abap_unit_assert=>assert_equals( exp = lv_expected act = iv_actual ). ENDMETHOD. METHOD assert_amount. DATA lv_expected TYPE {{p}}if_air_freight=>ty_amount. lv_expected = iv_expected. cl_abap_unit_assert=>assert_equals( exp = lv_expected act = iv_actual ). ENDMETHOD. METHOD general_shipment. DATA(ls_result) = mo_cut->price( iv_weight = '12.000' iv_volume = '48000.000' iv_category = {{p}}if_air_freight=>c_category-general iv_dangerous = abap_false ). cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-ok act = ls_result-reason ). assert_weight( iv_expected = '12.000' iv_actual = ls_result-chargeable_weight ). assert_amount( iv_expected = '108.00' iv_actual = ls_result-freight ). assert_amount( iv_expected = '0.00' iv_actual = ls_result-dangerous_fee ). assert_amount( iv_expected = '12.96' iv_actual = ls_result-fuel_fee ). assert_amount( iv_expected = '15.00' iv_actual = ls_result-security_fee ). assert_amount( iv_expected = '135.96' iv_actual = ls_result-total_amount ). ENDMETHOD. METHOD volumetric_weight. DATA(ls_result) = mo_cut->price( iv_weight = '5.000' iv_volume = '120000.000' iv_category = {{p}}if_air_freight=>c_category-general iv_dangerous = abap_false ). cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-ok act = ls_result-reason ). assert_weight( iv_expected = '20.000' iv_actual = ls_result-chargeable_weight ). assert_amount( iv_expected = '180.00' iv_actual = ls_result-freight ). assert_amount( iv_expected = '21.60' iv_actual = ls_result-fuel_fee ). assert_amount( iv_expected = '216.60' iv_actual = ls_result-total_amount ). ENDMETHOD. METHOD rounds_up_to_kg. DATA(ls_result) = mo_cut->price( iv_weight = '12.400' iv_volume = '900.000' iv_category = {{p}}if_air_freight=>c_category-general iv_dangerous = abap_false ). assert_weight( iv_expected = '13.000' iv_actual = ls_result-chargeable_weight ). assert_amount( iv_expected = '117.00' iv_actual = ls_result-freight ). assert_amount( iv_expected = '146.04' iv_actual = ls_result-total_amount ). ENDMETHOD. METHOD rate_break_100. DATA(ls_result) = mo_cut->price( iv_weight = '100.000' iv_volume = '600.000' iv_category = {{p}}if_air_freight=>c_category-general iv_dangerous = abap_false ). assert_weight( iv_expected = '100.000' iv_actual = ls_result-chargeable_weight ). assert_amount( iv_expected = '720.00' iv_actual = ls_result-freight ). assert_amount( iv_expected = '821.40' iv_actual = ls_result-total_amount ). ENDMETHOD. METHOD rate_break_101. DATA(ls_result) = mo_cut->price( iv_weight = '100.500' iv_volume = '600.000' iv_category = {{p}}if_air_freight=>c_category-general iv_dangerous = abap_false ). assert_weight( iv_expected = '101.000' iv_actual = ls_result-chargeable_weight ). assert_amount( iv_expected = '565.60' iv_actual = ls_result-freight ). assert_amount( iv_expected = '648.47' iv_actual = ls_result-total_amount ). ENDMETHOD. METHOD rate_break_501. DATA(ls_result) = mo_cut->price( iv_weight = '500.400' iv_volume = '600.000' iv_category = {{p}}if_air_freight=>c_category-general iv_dangerous = abap_false ). assert_weight( iv_expected = '501.000' iv_actual = ls_result-chargeable_weight ). assert_amount( iv_expected = '2154.30' iv_actual = ls_result-freight ). assert_amount( iv_expected = '2427.82' iv_actual = ls_result-total_amount ). ENDMETHOD. METHOD perishable_goods. DATA(ls_result) = mo_cut->price( iv_weight = '10.000' iv_volume = '600.000' iv_category = {{p}}if_air_freight=>c_category-perishable iv_dangerous = abap_false ). assert_amount( iv_expected = '112.50' iv_actual = ls_result-freight ). assert_amount( iv_expected = '0.00' iv_actual = ls_result-dangerous_fee ). assert_amount( iv_expected = '141.00' iv_actual = ls_result-total_amount ). ENDMETHOD. METHOD valuable_dangerous. DATA(ls_result) = mo_cut->price( iv_weight = '10.000' iv_volume = '600.000' iv_category = {{p}}if_air_freight=>c_category-valuable iv_dangerous = abap_true ). assert_amount( iv_expected = '135.00' iv_actual = ls_result-freight ). assert_amount( iv_expected = '54.00' iv_actual = ls_result-dangerous_fee ). assert_amount( iv_expected = '22.68' iv_actual = ls_result-fuel_fee ). assert_amount( iv_expected = '226.68' iv_actual = ls_result-total_amount ). ENDMETHOD. METHOD rejects_zero_weight. DATA(ls_result) = mo_cut->price( iv_weight = '0.000' iv_volume = '600.000' iv_category = {{p}}if_air_freight=>c_category-general iv_dangerous = abap_false ). cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-bad_weight act = ls_result-reason ). assert_weight( iv_expected = '0.000' iv_actual = ls_result-chargeable_weight ). assert_amount( iv_expected = '0.00' iv_actual = ls_result-total_amount ). ENDMETHOD. METHOD rejects_zero_volume. DATA(ls_result) = mo_cut->price( iv_weight = '10.000' iv_volume = '0.000' iv_category = {{p}}if_air_freight=>c_category-general iv_dangerous = abap_false ). cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-bad_volume act = ls_result-reason ). assert_amount( iv_expected = '0.00' iv_actual = ls_result-total_amount ). ENDMETHOD. METHOD rejects_bad_category. DATA(ls_result) = mo_cut->price( iv_weight = '10.000' iv_volume = '600.000' iv_category = 'EXPRESS' iv_dangerous = abap_false ). cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-bad_category act = ls_result-reason ). assert_amount( iv_expected = '0.00' iv_actual = ls_result-total_amount ). ENDMETHOD. METHOD rejects_too_heavy. DATA(ls_result) = mo_cut->price( iv_weight = '3000.500' iv_volume = '600.000' iv_category = {{p}}if_air_freight=>c_category-general iv_dangerous = abap_false ). cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-too_heavy act = ls_result-reason ). assert_weight( iv_expected = '0.000' iv_actual = ls_result-chargeable_weight ). assert_amount( iv_expected = '0.00' iv_actual = ls_result-total_amount ). ENDMETHOD. ENDCLASS.