Stage 2 summary at 50 accepted trajectories
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
212
tasks_gen/train/G1101/hidden/t41_hidden.clas.abap
Normal file
212
tasks_gen/train/G1101/hidden/t41_hidden.clas.abap
Normal file
@@ -0,0 +1,212 @@
|
||||
CLASS {{p}}t41_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS setup.
|
||||
METHODS teardown.
|
||||
METHODS insert_dishes.
|
||||
METHODS insert_positions
|
||||
IMPORTING it_positions TYPE STANDARD TABLE OF {{p}}pos.
|
||||
METHODS call
|
||||
IMPORTING iv_order_id TYPE string
|
||||
EXPORTING ev_total TYPE decfloat34
|
||||
ev_portions TYPE i
|
||||
ev_dishes TYPE i
|
||||
ev_subrc TYPE sysubrc.
|
||||
|
||||
METHODS total_and_portions FOR TESTING.
|
||||
METHODS distinct_dishes FOR TESTING.
|
||||
METHODS ignores_other_orders FOR TESTING.
|
||||
METHODS empty_order FOR TESTING.
|
||||
METHODS zero_quantity FOR TESTING.
|
||||
METHODS unknown_dish FOR TESTING.
|
||||
METHODS quantity_before_dish FOR TESTING.
|
||||
METHODS discount_from_fifty FOR TESTING.
|
||||
METHODS no_discount_below_fifty FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t41_hidden IMPLEMENTATION.
|
||||
|
||||
METHOD setup.
|
||||
DELETE FROM {{p}}pos WHERE client = @sy-mandt.
|
||||
DELETE FROM {{p}}dish WHERE client = @sy-mandt.
|
||||
insert_dishes( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD teardown.
|
||||
DELETE FROM {{p}}pos WHERE client = @sy-mandt.
|
||||
DELETE FROM {{p}}dish WHERE client = @sy-mandt.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD insert_dishes.
|
||||
DATA lt_dishes TYPE STANDARD TABLE OF {{p}}dish.
|
||||
lt_dishes = VALUE #(
|
||||
( client = sy-mandt dish_id = 'D001' dish_name = 'Tomato soup' price = '4.50' )
|
||||
( client = sy-mandt dish_id = 'D002' dish_name = 'Roast beef' price = '18.00' )
|
||||
( client = sy-mandt dish_id = 'D003' dish_name = 'Apple pie' price = '5.25' )
|
||||
( client = sy-mandt dish_id = 'D004' dish_name = 'Sparkling water' price = '2.00' )
|
||||
( client = sy-mandt dish_id = 'D005' dish_name = 'Bread basket' price = '2.05' )
|
||||
).
|
||||
INSERT {{p}}dish FROM TABLE @lt_dishes.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD insert_positions.
|
||||
INSERT {{p}}pos FROM TABLE @it_positions.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD call.
|
||||
CLEAR: ev_total, ev_portions, ev_dishes.
|
||||
|
||||
CALL FUNCTION '{{P}}BANQUET_FEE'
|
||||
EXPORTING
|
||||
iv_order_id = iv_order_id
|
||||
IMPORTING
|
||||
ev_total = ev_total
|
||||
ev_portions = ev_portions
|
||||
ev_dishes = ev_dishes
|
||||
EXCEPTIONS
|
||||
no_positions = 1
|
||||
unknown_dish = 2
|
||||
invalid_quantity = 3
|
||||
OTHERS = 4.
|
||||
|
||||
ev_subrc = sy-subrc.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD total_and_portions.
|
||||
DATA lt_positions TYPE STANDARD TABLE OF {{p}}pos.
|
||||
lt_positions = VALUE #(
|
||||
( client = sy-mandt order_id = 'T41A' pos_no = 1 dish_id = 'D001' qty = 2 )
|
||||
( client = sy-mandt order_id = 'T41A' pos_no = 2 dish_id = 'D002' qty = 1 ) ).
|
||||
insert_positions( lt_positions ).
|
||||
|
||||
call( EXPORTING iv_order_id = 'T41A'
|
||||
IMPORTING ev_total = DATA(lv_total)
|
||||
ev_portions = DATA(lv_portions)
|
||||
ev_dishes = DATA(lv_dishes)
|
||||
ev_subrc = DATA(lv_subrc) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '27.00' ) act = lv_total ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 3 act = lv_portions ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_dishes ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD distinct_dishes.
|
||||
DATA lt_positions TYPE STANDARD TABLE OF {{p}}pos.
|
||||
lt_positions = VALUE #(
|
||||
( client = sy-mandt order_id = 'T41A' pos_no = 1 dish_id = 'D001' qty = 2 )
|
||||
( client = sy-mandt order_id = 'T41A' pos_no = 2 dish_id = 'D001' qty = 3 )
|
||||
( client = sy-mandt order_id = 'T41A' pos_no = 3 dish_id = 'D003' qty = 1 ) ).
|
||||
insert_positions( lt_positions ).
|
||||
|
||||
call( EXPORTING iv_order_id = 'T41A'
|
||||
IMPORTING ev_total = DATA(lv_total)
|
||||
ev_portions = DATA(lv_portions)
|
||||
ev_dishes = DATA(lv_dishes)
|
||||
ev_subrc = DATA(lv_subrc) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '27.75' ) act = lv_total ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 6 act = lv_portions ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_dishes ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ignores_other_orders.
|
||||
DATA lt_positions TYPE STANDARD TABLE OF {{p}}pos.
|
||||
lt_positions = VALUE #(
|
||||
( client = sy-mandt order_id = 'T41B' pos_no = 1 dish_id = 'D002' qty = 10 )
|
||||
( client = sy-mandt order_id = 'T41A' pos_no = 1 dish_id = 'D001' qty = 2 ) ).
|
||||
insert_positions( lt_positions ).
|
||||
|
||||
call( EXPORTING iv_order_id = 'T41A'
|
||||
IMPORTING ev_total = DATA(lv_total)
|
||||
ev_portions = DATA(lv_portions)
|
||||
ev_dishes = DATA(lv_dishes)
|
||||
ev_subrc = DATA(lv_subrc) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '9.00' ) act = lv_total ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_portions ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_dishes ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_order.
|
||||
call( EXPORTING iv_order_id = 'T41Z'
|
||||
IMPORTING ev_subrc = DATA(lv_subrc) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_subrc ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_quantity.
|
||||
DATA lt_positions TYPE STANDARD TABLE OF {{p}}pos.
|
||||
lt_positions = VALUE #(
|
||||
( client = sy-mandt order_id = 'T41A' pos_no = 1 dish_id = 'D001' qty = 0 ) ).
|
||||
insert_positions( lt_positions ).
|
||||
|
||||
call( EXPORTING iv_order_id = 'T41A'
|
||||
IMPORTING ev_subrc = DATA(lv_subrc) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 3 act = lv_subrc ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_dish.
|
||||
DATA lt_positions TYPE STANDARD TABLE OF {{p}}pos.
|
||||
lt_positions = VALUE #(
|
||||
( client = sy-mandt order_id = 'T41A' pos_no = 1 dish_id = 'X999' qty = 2 ) ).
|
||||
insert_positions( lt_positions ).
|
||||
|
||||
call( EXPORTING iv_order_id = 'T41A'
|
||||
IMPORTING ev_subrc = DATA(lv_subrc) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_subrc ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD quantity_before_dish.
|
||||
DATA lt_positions TYPE STANDARD TABLE OF {{p}}pos.
|
||||
lt_positions = VALUE #(
|
||||
( client = sy-mandt order_id = 'T41A' pos_no = 1 dish_id = 'X999' qty = 0 ) ).
|
||||
insert_positions( lt_positions ).
|
||||
|
||||
call( EXPORTING iv_order_id = 'T41A'
|
||||
IMPORTING ev_subrc = DATA(lv_subrc) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 3 act = lv_subrc ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD discount_from_fifty.
|
||||
DATA lt_positions TYPE STANDARD TABLE OF {{p}}pos.
|
||||
lt_positions = VALUE #(
|
||||
( client = sy-mandt order_id = 'T41A' pos_no = 1 dish_id = 'D004' qty = 49 )
|
||||
( client = sy-mandt order_id = 'T41A' pos_no = 2 dish_id = 'D005' qty = 1 ) ).
|
||||
insert_positions( lt_positions ).
|
||||
|
||||
call( EXPORTING iv_order_id = 'T41A'
|
||||
IMPORTING ev_total = DATA(lv_total)
|
||||
ev_portions = DATA(lv_portions)
|
||||
ev_dishes = DATA(lv_dishes)
|
||||
ev_subrc = DATA(lv_subrc) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 50 act = lv_portions ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_dishes ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '95.05' ) act = lv_total ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD no_discount_below_fifty.
|
||||
DATA lt_positions TYPE STANDARD TABLE OF {{p}}pos.
|
||||
lt_positions = VALUE #(
|
||||
( client = sy-mandt order_id = 'T41A' pos_no = 1 dish_id = 'D004' qty = 49 ) ).
|
||||
insert_positions( lt_positions ).
|
||||
|
||||
call( EXPORTING iv_order_id = 'T41A'
|
||||
IMPORTING ev_total = DATA(lv_total)
|
||||
ev_portions = DATA(lv_portions)
|
||||
ev_subrc = DATA(lv_subrc) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 49 act = lv_portions ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '98.00' ) act = lv_total ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user