Files
abap-llm/tasks_gen/train/G1086/hidden/wood_hidden.clas.abap
2026-10-05 18:02:52 +02:00

133 lines
4.5 KiB
ABAP

CLASS {{p}}wood_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS fee_of
IMPORTING iv_type TYPE string
iv_volume TYPE decfloat34
iv_distance TYPE i DEFAULT 0
iv_fee TYPE decfloat34 DEFAULT 7
EXPORTING ev_skip TYPE abap_bool
ev_fee TYPE decfloat34
ev_subrc TYPE sysubrc.
METHODS beech_price FOR TESTING.
METHODS type_prices FOR TESTING.
METHODS delivery_charge FOR TESTING.
METHODS no_charge_at_20 FOR TESTING.
METHODS minimum_fee FOR TESTING.
METHODS rounding_half_up FOR TESTING.
METHODS unknown_type_minimum FOR TESTING.
METHODS mixed_skips FOR TESTING.
METHODS skip_false_for_beech FOR TESTING.
METHODS invalid_volume FOR TESTING.
METHODS invalid_distance FOR TESTING.
ENDCLASS.
CLASS {{p}}wood_hidden IMPLEMENTATION.
METHOD fee_of.
ev_fee = iv_fee.
CALL FUNCTION '{{P}}WOOD_FEE'
EXPORTING
iv_wood_type = iv_type
iv_volume = iv_volume
iv_distance = iv_distance
IMPORTING
ev_skip = ev_skip
CHANGING
cv_fee = ev_fee
EXCEPTIONS
invalid_volume = 1
invalid_distance = 2
OTHERS = 3.
ev_subrc = sy-subrc.
ENDMETHOD.
METHOD beech_price.
DATA lv_fee TYPE decfloat34.
DATA lv_exp TYPE decfloat34.
lv_exp = '240'.
fee_of( EXPORTING iv_type = 'BE' iv_volume = '2' IMPORTING ev_fee = lv_fee ).
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_fee ).
ENDMETHOD.
METHOD type_prices.
DATA lv_fee TYPE decfloat34.
DATA lv_exp TYPE decfloat34.
lv_exp = '150'.
fee_of( EXPORTING iv_type = 'OK' iv_volume = '1' IMPORTING ev_fee = lv_fee ).
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_fee ).
lv_exp = '180'.
fee_of( EXPORTING iv_type = 'SP' iv_volume = '2' IMPORTING ev_fee = lv_fee ).
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_fee ).
ENDMETHOD.
METHOD delivery_charge.
DATA lv_fee TYPE decfloat34.
DATA lv_exp TYPE decfloat34.
lv_exp = '244.50'.
fee_of( EXPORTING iv_type = 'BE' iv_volume = '2' iv_distance = 30 IMPORTING ev_fee = lv_fee ).
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_fee ).
ENDMETHOD.
METHOD no_charge_at_20.
DATA lv_fee TYPE decfloat34.
DATA lv_exp TYPE decfloat34.
lv_exp = '240'.
fee_of( EXPORTING iv_type = 'BE' iv_volume = '2' iv_distance = 20 IMPORTING ev_fee = lv_fee ).
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_fee ).
ENDMETHOD.
METHOD minimum_fee.
DATA lv_fee TYPE decfloat34.
DATA lv_exp TYPE decfloat34.
lv_exp = '80'.
fee_of( EXPORTING iv_type = 'SP' iv_volume = '0.5' IMPORTING ev_fee = lv_fee ).
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_fee ).
ENDMETHOD.
METHOD rounding_half_up.
DATA lv_fee TYPE decfloat34.
DATA lv_exp TYPE decfloat34.
lv_exp = '100.13'.
fee_of( EXPORTING iv_type = 'SP' iv_volume = '1.1125' IMPORTING ev_fee = lv_fee ).
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_fee ).
ENDMETHOD.
METHOD unknown_type_minimum.
DATA lv_fee TYPE decfloat34.
DATA lv_exp TYPE decfloat34.
lv_exp = '80'.
fee_of( EXPORTING iv_type = 'XX' iv_volume = '2' IMPORTING ev_fee = lv_fee ).
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_fee ).
ENDMETHOD.
METHOD mixed_skips.
DATA lv_skip TYPE abap_bool.
DATA lv_fee TYPE decfloat34.
DATA lv_exp TYPE decfloat34.
lv_exp = '7'.
fee_of( EXPORTING iv_type = 'MX' iv_volume = '2' iv_distance = 10 iv_fee = '7'
IMPORTING ev_skip = lv_skip ev_fee = lv_fee ).
cl_abap_unit_assert=>assert_equals( exp = abap_true act = lv_skip ).
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_fee ).
ENDMETHOD.
METHOD skip_false_for_beech.
DATA lv_skip TYPE abap_bool.
fee_of( EXPORTING iv_type = 'BE' iv_volume = '2' IMPORTING ev_skip = lv_skip ).
cl_abap_unit_assert=>assert_equals( exp = abap_false act = lv_skip ).
ENDMETHOD.
METHOD invalid_volume.
DATA lv_rc TYPE sysubrc.
fee_of( EXPORTING iv_type = 'BE' iv_volume = '0' IMPORTING ev_subrc = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
ENDMETHOD.
METHOD invalid_distance.
DATA lv_rc TYPE sysubrc.
fee_of( EXPORTING iv_type = 'BE' iv_volume = '2' iv_distance = -1 IMPORTING ev_subrc = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rc ).
ENDMETHOD.
ENDCLASS.