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

135 lines
5.0 KiB
ABAP

CLASS {{p}}t42_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS call
IMPORTING
iv_type TYPE string
iv_area TYPE decfloat34
iv_stain TYPE abap_bool DEFAULT abap_false
EXPORTING
ev_fee TYPE decfloat34
ev_note TYPE string
ev_subrc TYPE sysubrc.
METHODS carpet_rate FOR TESTING.
METHODS upholstery_stain FOR TESTING.
METHODS rug_rate FOR TESTING.
METHODS minimum_fee_note FOR TESTING.
METHODS rounding_half_up FOR TESTING.
METHODS invalid_type FOR TESTING.
METHODS invalid_area FOR TESTING.
METHODS stain_not_allowed FOR TESTING.
METHODS area_too_large FOR TESTING.
METHODS type_checked_first FOR TESTING.
METHODS area_before_stain FOR TESTING.
ENDCLASS.
CLASS {{p}}t42_hidden IMPLEMENTATION.
METHOD call.
CALL FUNCTION '{{P}}CARPET_FEE'
EXPORTING
iv_clean_type = iv_type
iv_area_sqm = iv_area
iv_stain = iv_stain
IMPORTING
ev_fee = ev_fee
ev_note = ev_note
EXCEPTIONS
invalid_type = 1
invalid_area = 2
stain_not_allowed = 3
area_too_large = 4
OTHERS = 5.
ev_subrc = sy-subrc.
ENDMETHOD.
METHOD carpet_rate.
call( EXPORTING iv_type = `CP` iv_area = 20
IMPORTING ev_fee = DATA(lv_fee) ev_note = DATA(lv_note) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '70.00' ) act = lv_fee ).
cl_abap_unit_assert=>assert_initial( act = lv_note ).
call( EXPORTING iv_type = `CP` iv_area = 100
IMPORTING ev_fee = lv_fee ev_subrc = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '350.00' ) act = lv_fee ).
ENDMETHOD.
METHOD upholstery_stain.
call( EXPORTING iv_type = `UP` iv_area = 10 iv_stain = abap_true
IMPORTING ev_fee = DATA(lv_fee) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '75.00' ) act = lv_fee ).
ENDMETHOD.
METHOD rug_rate.
call( EXPORTING iv_type = `RU` iv_area = 25
IMPORTING ev_fee = DATA(lv_fee) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '50.00' ) act = lv_fee ).
call( EXPORTING iv_type = `RU` iv_area = 200
IMPORTING ev_fee = lv_fee ev_subrc = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '400.00' ) act = lv_fee ).
ENDMETHOD.
METHOD minimum_fee_note.
call( EXPORTING iv_type = `CP` iv_area = 5
IMPORTING ev_fee = DATA(lv_fee) ev_note = DATA(lv_note) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '40.00' ) act = lv_fee ).
cl_abap_unit_assert=>assert_equals( exp = `MINIMUM FEE APPLIED` act = lv_note ).
call( EXPORTING iv_type = `UP` iv_area = 8
IMPORTING ev_fee = lv_fee ev_note = lv_note ev_subrc = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '40.00' ) act = lv_fee ).
cl_abap_unit_assert=>assert_initial( act = lv_note ).
ENDMETHOD.
METHOD rounding_half_up.
call( EXPORTING iv_type = `CP` iv_area = '12.57'
IMPORTING ev_fee = DATA(lv_fee) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '44.00' ) act = lv_fee ).
ENDMETHOD.
METHOD invalid_type.
call( EXPORTING iv_type = `XX` iv_area = 10
IMPORTING ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
ENDMETHOD.
METHOD invalid_area.
call( EXPORTING iv_type = `CP` iv_area = 0
IMPORTING ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rc ).
ENDMETHOD.
METHOD stain_not_allowed.
call( EXPORTING iv_type = `RU` iv_area = 10 iv_stain = abap_true
IMPORTING ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 3 act = lv_rc ).
ENDMETHOD.
METHOD area_too_large.
call( EXPORTING iv_type = `CP` iv_area = '100.01'
IMPORTING ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 4 act = lv_rc ).
ENDMETHOD.
METHOD type_checked_first.
call( EXPORTING iv_type = `XX` iv_area = -5
IMPORTING ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
ENDMETHOD.
METHOD area_before_stain.
call( EXPORTING iv_type = `RU` iv_area = -5 iv_stain = abap_true
IMPORTING ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rc ).
ENDMETHOD.
ENDCLASS.