ADT fallback: Accept headers for FUNC; G0189 accepted; regen2 results
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
@@ -1,302 +0,0 @@
|
||||
CLASS {{p}}t31_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES ty_stations TYPE STANDARD TABLE OF {{p}}station.
|
||||
TYPES ty_moves TYPE STANDARD TABLE OF {{p}}move.
|
||||
TYPES ty_id TYPE {{p}}station-station_id.
|
||||
TYPES ty_name TYPE {{p}}station-station_name.
|
||||
|
||||
METHODS given
|
||||
IMPORTING it_stations TYPE ty_stations
|
||||
it_moves TYPE ty_moves.
|
||||
|
||||
METHODS rebalance
|
||||
IMPORTING iv_dry_run TYPE abap_bool DEFAULT abap_false
|
||||
EXPORTING ev_applied TYPE i
|
||||
ev_rejected TYPE i.
|
||||
|
||||
METHODS bikes_of
|
||||
IMPORTING iv_id TYPE ty_id
|
||||
RETURNING VALUE(rv_bikes) TYPE i.
|
||||
|
||||
METHODS name_of
|
||||
IMPORTING iv_id TYPE ty_id
|
||||
RETURNING VALUE(rv_name) TYPE ty_name.
|
||||
|
||||
METHODS applies_one_move FOR TESTING.
|
||||
METHODS applies_in_move_order FOR TESTING.
|
||||
METHODS rejects_unknown_station FOR TESTING.
|
||||
METHODS rejects_insufficient_bikes FOR TESTING.
|
||||
METHODS rejects_full_target FOR TESTING.
|
||||
METHODS rejects_non_positive_qty FOR TESTING.
|
||||
METHODS rejects_same_station FOR TESTING.
|
||||
METHODS counts_rejections FOR TESTING.
|
||||
METHODS keeps_untouched_stations FOR TESTING.
|
||||
METHODS dry_run_keeps_state FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t31_hidden IMPLEMENTATION.
|
||||
|
||||
METHOD given.
|
||||
DATA(lt_stations) = it_stations.
|
||||
DATA(lt_moves) = it_moves.
|
||||
|
||||
LOOP AT lt_stations ASSIGNING FIELD-SYMBOL(<ls_station>).
|
||||
<ls_station>-client = sy-mandt.
|
||||
ENDLOOP.
|
||||
|
||||
LOOP AT lt_moves ASSIGNING FIELD-SYMBOL(<ls_move>).
|
||||
<ls_move>-client = sy-mandt.
|
||||
ENDLOOP.
|
||||
|
||||
DELETE FROM {{p}}station.
|
||||
DELETE FROM {{p}}move.
|
||||
INSERT {{p}}station FROM TABLE @lt_stations.
|
||||
INSERT {{p}}move FROM TABLE @lt_moves.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rebalance.
|
||||
CALL FUNCTION '{{P}}BIKE_REBALANCE'
|
||||
EXPORTING
|
||||
iv_dry_run = iv_dry_run
|
||||
IMPORTING
|
||||
ev_applied = ev_applied
|
||||
ev_rejected = ev_rejected
|
||||
EXCEPTIONS
|
||||
OTHERS = 1.
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD bikes_of.
|
||||
SELECT SINGLE bikes FROM {{p}}station
|
||||
INTO @rv_bikes
|
||||
WHERE station_id = @iv_id.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD name_of.
|
||||
SELECT SINGLE station_name FROM {{p}}station
|
||||
INTO @rv_name
|
||||
WHERE station_id = @iv_id.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD applies_one_move.
|
||||
DATA lt_stations TYPE ty_stations.
|
||||
DATA lt_moves TYPE ty_moves.
|
||||
DATA lv_applied TYPE i.
|
||||
DATA lv_rejected TYPE i.
|
||||
|
||||
lt_stations = VALUE #(
|
||||
( station_id = 'S001' station_name = 'Alpha' capacity = 10 bikes = 6 )
|
||||
( station_id = 'S002' station_name = 'Beta' capacity = 10 bikes = 1 ) ).
|
||||
lt_moves = VALUE #(
|
||||
( move_no = 1 source_id = 'S001' target_id = 'S002' quantity = 4 ) ).
|
||||
|
||||
given( it_stations = lt_stations it_moves = lt_moves ).
|
||||
rebalance( IMPORTING ev_applied = lv_applied ev_rejected = lv_rejected ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_applied exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_rejected exp = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S001' ) exp = 2 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S002' ) exp = 5 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD applies_in_move_order.
|
||||
DATA lt_stations TYPE ty_stations.
|
||||
DATA lt_moves TYPE ty_moves.
|
||||
DATA lv_applied TYPE i.
|
||||
DATA lv_rejected TYPE i.
|
||||
|
||||
lt_stations = VALUE #(
|
||||
( station_id = 'S001' station_name = 'Alpha' capacity = 10 bikes = 5 )
|
||||
( station_id = 'S002' station_name = 'Beta' capacity = 10 bikes = 0 )
|
||||
( station_id = 'S003' station_name = 'Gamma' capacity = 10 bikes = 0 ) ).
|
||||
lt_moves = VALUE #(
|
||||
( move_no = 2 source_id = 'S001' target_id = 'S002' quantity = 5 )
|
||||
( move_no = 1 source_id = 'S002' target_id = 'S003' quantity = 5 ) ).
|
||||
|
||||
given( it_stations = lt_stations it_moves = lt_moves ).
|
||||
rebalance( IMPORTING ev_applied = lv_applied ev_rejected = lv_rejected ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_applied exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_rejected exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S001' ) exp = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S002' ) exp = 5 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S003' ) exp = 0 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_unknown_station.
|
||||
DATA lt_stations TYPE ty_stations.
|
||||
DATA lt_moves TYPE ty_moves.
|
||||
DATA lv_applied TYPE i.
|
||||
DATA lv_rejected TYPE i.
|
||||
|
||||
lt_stations = VALUE #(
|
||||
( station_id = 'S001' station_name = 'Alpha' capacity = 10 bikes = 6 ) ).
|
||||
lt_moves = VALUE #(
|
||||
( move_no = 1 source_id = 'S009' target_id = 'S001' quantity = 2 ) ).
|
||||
|
||||
given( it_stations = lt_stations it_moves = lt_moves ).
|
||||
rebalance( IMPORTING ev_applied = lv_applied ev_rejected = lv_rejected ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_applied exp = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_rejected exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S001' ) exp = 6 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_insufficient_bikes.
|
||||
DATA lt_stations TYPE ty_stations.
|
||||
DATA lt_moves TYPE ty_moves.
|
||||
DATA lv_applied TYPE i.
|
||||
DATA lv_rejected TYPE i.
|
||||
|
||||
lt_stations = VALUE #(
|
||||
( station_id = 'S001' station_name = 'Alpha' capacity = 10 bikes = 2 )
|
||||
( station_id = 'S002' station_name = 'Beta' capacity = 10 bikes = 0 ) ).
|
||||
lt_moves = VALUE #(
|
||||
( move_no = 1 source_id = 'S001' target_id = 'S002' quantity = 5 ) ).
|
||||
|
||||
given( it_stations = lt_stations it_moves = lt_moves ).
|
||||
rebalance( IMPORTING ev_applied = lv_applied ev_rejected = lv_rejected ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_applied exp = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_rejected exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S001' ) exp = 2 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S002' ) exp = 0 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_full_target.
|
||||
DATA lt_stations TYPE ty_stations.
|
||||
DATA lt_moves TYPE ty_moves.
|
||||
DATA lv_applied TYPE i.
|
||||
DATA lv_rejected TYPE i.
|
||||
|
||||
lt_stations = VALUE #(
|
||||
( station_id = 'S001' station_name = 'Alpha' capacity = 10 bikes = 5 )
|
||||
( station_id = 'S002' station_name = 'Beta' capacity = 4 bikes = 4 ) ).
|
||||
lt_moves = VALUE #(
|
||||
( move_no = 1 source_id = 'S001' target_id = 'S002' quantity = 1 ) ).
|
||||
|
||||
given( it_stations = lt_stations it_moves = lt_moves ).
|
||||
rebalance( IMPORTING ev_applied = lv_applied ev_rejected = lv_rejected ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_applied exp = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_rejected exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S001' ) exp = 5 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S002' ) exp = 4 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_non_positive_qty.
|
||||
DATA lt_stations TYPE ty_stations.
|
||||
DATA lt_moves TYPE ty_moves.
|
||||
DATA lv_applied TYPE i.
|
||||
DATA lv_rejected TYPE i.
|
||||
|
||||
lt_stations = VALUE #(
|
||||
( station_id = 'S001' station_name = 'Alpha' capacity = 10 bikes = 5 )
|
||||
( station_id = 'S002' station_name = 'Beta' capacity = 10 bikes = 0 ) ).
|
||||
lt_moves = VALUE #(
|
||||
( move_no = 1 source_id = 'S001' target_id = 'S002' quantity = 0 )
|
||||
( move_no = 2 source_id = 'S001' target_id = 'S002' quantity = -3 ) ).
|
||||
|
||||
given( it_stations = lt_stations it_moves = lt_moves ).
|
||||
rebalance( IMPORTING ev_applied = lv_applied ev_rejected = lv_rejected ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_applied exp = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_rejected exp = 2 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S001' ) exp = 5 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S002' ) exp = 0 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_same_station.
|
||||
DATA lt_stations TYPE ty_stations.
|
||||
DATA lt_moves TYPE ty_moves.
|
||||
DATA lv_applied TYPE i.
|
||||
DATA lv_rejected TYPE i.
|
||||
|
||||
lt_stations = VALUE #(
|
||||
( station_id = 'S001' station_name = 'Alpha' capacity = 10 bikes = 5 ) ).
|
||||
lt_moves = VALUE #(
|
||||
( move_no = 1 source_id = 'S001' target_id = 'S001' quantity = 2 ) ).
|
||||
|
||||
given( it_stations = lt_stations it_moves = lt_moves ).
|
||||
rebalance( IMPORTING ev_applied = lv_applied ev_rejected = lv_rejected ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_applied exp = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_rejected exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S001' ) exp = 5 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD counts_rejections.
|
||||
DATA lt_stations TYPE ty_stations.
|
||||
DATA lt_moves TYPE ty_moves.
|
||||
DATA lv_applied TYPE i.
|
||||
DATA lv_rejected TYPE i.
|
||||
|
||||
lt_stations = VALUE #(
|
||||
( station_id = 'S001' station_name = 'Alpha' capacity = 10 bikes = 5 )
|
||||
( station_id = 'S002' station_name = 'Beta' capacity = 10 bikes = 0 ) ).
|
||||
lt_moves = VALUE #(
|
||||
( move_no = 1 source_id = 'S001' target_id = 'S002' quantity = 2 )
|
||||
( move_no = 2 source_id = 'S001' target_id = 'S999' quantity = 1 )
|
||||
( move_no = 3 source_id = 'S001' target_id = 'S002' quantity = 0 )
|
||||
( move_no = 4 source_id = 'S001' target_id = 'S002' quantity = 100 )
|
||||
( move_no = 5 source_id = 'S002' target_id = 'S001' quantity = 1 ) ).
|
||||
|
||||
given( it_stations = lt_stations it_moves = lt_moves ).
|
||||
rebalance( IMPORTING ev_applied = lv_applied ev_rejected = lv_rejected ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_applied exp = 2 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_rejected exp = 3 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S001' ) exp = 4 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S002' ) exp = 1 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD keeps_untouched_stations.
|
||||
DATA lt_stations TYPE ty_stations.
|
||||
DATA lt_moves TYPE ty_moves.
|
||||
DATA lv_applied TYPE i.
|
||||
DATA lv_rejected TYPE i.
|
||||
|
||||
lt_stations = VALUE #(
|
||||
( station_id = 'S001' station_name = 'Alpha' capacity = 10 bikes = 4 )
|
||||
( station_id = 'S002' station_name = 'Beta' capacity = 10 bikes = 4 )
|
||||
( station_id = 'S003' station_name = 'Gamma' capacity = 12 bikes = 7 ) ).
|
||||
lt_moves = VALUE #(
|
||||
( move_no = 1 source_id = 'S001' target_id = 'S002' quantity = 1 ) ).
|
||||
|
||||
given( it_stations = lt_stations it_moves = lt_moves ).
|
||||
rebalance( IMPORTING ev_applied = lv_applied ev_rejected = lv_rejected ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_applied exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_rejected exp = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S001' ) exp = 3 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S002' ) exp = 5 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S003' ) exp = 7 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = name_of( 'S003' ) exp = CONV ty_name( 'Gamma' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD dry_run_keeps_state.
|
||||
DATA lt_stations TYPE ty_stations.
|
||||
DATA lt_moves TYPE ty_moves.
|
||||
DATA lv_applied TYPE i.
|
||||
DATA lv_rejected TYPE i.
|
||||
|
||||
lt_stations = VALUE #(
|
||||
( station_id = 'S001' station_name = 'Alpha' capacity = 10 bikes = 5 )
|
||||
( station_id = 'S002' station_name = 'Beta' capacity = 10 bikes = 0 ) ).
|
||||
lt_moves = VALUE #(
|
||||
( move_no = 1 source_id = 'S001' target_id = 'S002' quantity = 3 ) ).
|
||||
|
||||
given( it_stations = lt_stations it_moves = lt_moves ).
|
||||
rebalance( EXPORTING iv_dry_run = abap_true
|
||||
IMPORTING ev_applied = lv_applied ev_rejected = lv_rejected ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_applied exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lv_rejected exp = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S001' ) exp = 5 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = bikes_of( 'S002' ) exp = 0 ).
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
129
tasks_gen/eval/G0122/hidden/track_hidden.clas.abap
Normal file
129
tasks_gen/eval/G0122/hidden/track_hidden.clas.abap
Normal file
@@ -0,0 +1,129 @@
|
||||
CLASS {{p}}track_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES ty_paths TYPE {{P}}TRACK_TYPES=>tt_path.
|
||||
TYPES ty_fees TYPE {{P}}TRACK_TYPES=>tt_fee.
|
||||
TYPES ty_km TYPE {{P}}TRACK_TYPES=>ty_km.
|
||||
TYPES ty_money TYPE {{P}}TRACK_TYPES=>ty_money.
|
||||
|
||||
METHODS call_fm
|
||||
IMPORTING it_paths TYPE ty_paths
|
||||
EXPORTING et_fees TYPE ty_fees
|
||||
ev_subrc TYPE sysubrc.
|
||||
|
||||
METHODS one_path_one_row FOR TESTING.
|
||||
METHODS groups_and_sorts FOR TESTING.
|
||||
METHODS night_surcharge FOR TESTING.
|
||||
METHODS minimum_fee FOR TESTING.
|
||||
METHODS rounds_up FOR TESTING.
|
||||
METHODS invalid_distance FOR TESTING.
|
||||
METHODS invalid_category FOR TESTING.
|
||||
METHODS empty_input FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}track_hidden IMPLEMENTATION.
|
||||
|
||||
METHOD call_fm.
|
||||
CALL FUNCTION '{{P}}TRACK_FEE'
|
||||
EXPORTING
|
||||
it_paths = it_paths
|
||||
IMPORTING
|
||||
et_fees = et_fees
|
||||
EXCEPTIONS
|
||||
invalid_distance = 1
|
||||
invalid_category = 2
|
||||
OTHERS = 3.
|
||||
ev_subrc = sy-subrc.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD one_path_one_row.
|
||||
DATA lt_paths TYPE ty_paths.
|
||||
lt_paths = VALUE #( ( path_id = '00000001' train_cat = 'IC' distance_km = '100.00' night_flag = '' ) ).
|
||||
call_fm( EXPORTING it_paths = lt_paths
|
||||
IMPORTING et_fees = DATA(lt_fees) ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_fees ) ).
|
||||
DATA(ls_fee) = lt_fees[ 1 ].
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'IC' act = ls_fee-train_cat ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = ls_fee-path_count ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV ty_km( '100.00' ) act = ls_fee-total_km ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV ty_money( '120.00' ) act = ls_fee-total_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD groups_and_sorts.
|
||||
DATA lt_paths TYPE ty_paths.
|
||||
lt_paths = VALUE #( ( path_id = '00000001' train_cat = 'IC' distance_km = '100.00' night_flag = '' )
|
||||
( path_id = '00000002' train_cat = 'FR' distance_km = '100.00' night_flag = '' )
|
||||
( path_id = '00000003' train_cat = 'IC' distance_km = '50.00' night_flag = '' ) ).
|
||||
call_fm( EXPORTING it_paths = lt_paths
|
||||
IMPORTING et_fees = DATA(lt_fees) ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_fees ) ).
|
||||
DATA(ls_first) = lt_fees[ 1 ].
|
||||
DATA(ls_last) = lt_fees[ 2 ].
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'FR' act = ls_first-train_cat ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = ls_first-path_count ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV ty_money( '60.00' ) act = ls_first-total_fee ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'IC' act = ls_last-train_cat ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = ls_last-path_count ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV ty_km( '150.00' ) act = ls_last-total_km ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV ty_money( '180.00' ) act = ls_last-total_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD night_surcharge.
|
||||
DATA lt_paths TYPE ty_paths.
|
||||
lt_paths = VALUE #( ( path_id = '00000001' train_cat = 'RG' distance_km = '100.00' night_flag = 'X' ) ).
|
||||
call_fm( EXPORTING it_paths = lt_paths
|
||||
IMPORTING et_fees = DATA(lt_fees) ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
|
||||
DATA(ls_fee) = lt_fees[ 1 ].
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV ty_money( '108.00' ) act = ls_fee-total_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD minimum_fee.
|
||||
DATA lt_paths TYPE ty_paths.
|
||||
lt_paths = VALUE #( ( path_id = '00000001' train_cat = 'FR' distance_km = '2.00' night_flag = '' ) ).
|
||||
call_fm( EXPORTING it_paths = lt_paths
|
||||
IMPORTING et_fees = DATA(lt_fees) ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
|
||||
DATA(ls_fee) = lt_fees[ 1 ].
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV ty_money( '5.00' ) act = ls_fee-total_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rounds_up.
|
||||
DATA lt_paths TYPE ty_paths.
|
||||
lt_paths = VALUE #( ( path_id = '00000001' train_cat = 'FR' distance_km = '10.01' night_flag = '' ) ).
|
||||
call_fm( EXPORTING it_paths = lt_paths
|
||||
IMPORTING et_fees = DATA(lt_fees) ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
|
||||
DATA(ls_fee) = lt_fees[ 1 ].
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV ty_money( '6.01' ) act = ls_fee-total_fee ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_distance.
|
||||
DATA lt_paths TYPE ty_paths.
|
||||
lt_paths = VALUE #( ( path_id = '00000001' train_cat = 'IC' distance_km = '0.00' night_flag = '' ) ).
|
||||
call_fm( EXPORTING it_paths = lt_paths
|
||||
IMPORTING et_fees = DATA(lt_fees) ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_category.
|
||||
DATA lt_paths TYPE ty_paths.
|
||||
lt_paths = VALUE #( ( path_id = '00000001' train_cat = 'XX' distance_km = '10.00' night_flag = '' ) ).
|
||||
call_fm( EXPORTING it_paths = lt_paths
|
||||
IMPORTING et_fees = DATA(lt_fees) ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rc ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_input.
|
||||
DATA lt_paths TYPE ty_paths.
|
||||
call_fm( EXPORTING it_paths = lt_paths
|
||||
IMPORTING et_fees = DATA(lt_fees) ev_subrc = DATA(lv_rc) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_fees ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user