Review fixes G0019, G0108: added hidden tests; revalidated
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
115
tasks_gen/eval/G0122/reference/t14_test.clas.abap
Normal file
115
tasks_gen/eval/G0122/reference/t14_test.clas.abap
Normal file
@@ -0,0 +1,115 @@
|
||||
CLASS {{p}}t14_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
TYPES ty_plan TYPE STANDARD TABLE OF {{p}}botpln WITH EMPTY KEY.
|
||||
CLASS-DATA mo_env TYPE REF TO if_osql_test_environment.
|
||||
CLASS-METHODS class_setup.
|
||||
CLASS-METHODS class_teardown.
|
||||
METHODS setup.
|
||||
METHODS add_order
|
||||
IMPORTING iv_id TYPE {{p}}botord-order_id
|
||||
iv_type TYPE {{p}}botord-beer_type
|
||||
iv_volume TYPE {{p}}botord-volume_hl.
|
||||
METHODS run_plan
|
||||
IMPORTING iv_min_hl TYPE decfloat34
|
||||
EXPORTING ev_total TYPE decfloat34
|
||||
ev_count TYPE int4.
|
||||
METHODS read_plan RETURNING VALUE(rt_plan) TYPE ty_plan.
|
||||
METHODS groups_orders FOR TESTING.
|
||||
METHODS filters_by_min_volume FOR TESTING.
|
||||
METHODS sorts_plan FOR TESTING.
|
||||
METHODS replaces_plan FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t14_test IMPLEMENTATION.
|
||||
|
||||
METHOD class_setup.
|
||||
mo_env = cl_osql_test_environment=>create(
|
||||
i_dependency_list = VALUE #( ( '{{P}}BOTORD' ) ( '{{P}}BOTPLN' ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD class_teardown.
|
||||
IF mo_env IS BOUND.
|
||||
mo_env->destroy( ).
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD setup.
|
||||
DELETE FROM {{p}}botord.
|
||||
DELETE FROM {{p}}botpln.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD add_order.
|
||||
DATA ls_order TYPE {{p}}botord.
|
||||
ls_order-client = sy-mandt.
|
||||
ls_order-order_id = iv_id.
|
||||
ls_order-beer_type = iv_type.
|
||||
ls_order-volume_hl = iv_volume.
|
||||
INSERT {{p}}botord FROM @ls_order.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD run_plan.
|
||||
CALL FUNCTION '{{P}}BOT_PLAN'
|
||||
EXPORTING
|
||||
iv_min_hl = iv_min_hl
|
||||
IMPORTING
|
||||
ev_total_hl = ev_total
|
||||
ev_plan_count = ev_count.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD read_plan.
|
||||
SELECT beer_type, plan_pos, total_hl, order_count
|
||||
FROM {{p}}botpln
|
||||
INTO TABLE @rt_plan.
|
||||
SORT rt_plan BY plan_pos.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD groups_orders.
|
||||
add_order( iv_id = '1' iv_type = 'PILS' iv_volume = 100 ).
|
||||
add_order( iv_id = '2' iv_type = 'PILS' iv_volume = 50 ).
|
||||
run_plan( EXPORTING iv_min_hl = 0
|
||||
IMPORTING ev_total = DATA(lv_total) ev_count = DATA(lv_count) ).
|
||||
DATA(lt_plan) = read_plan( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_plan ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 150 act = lt_plan[ 1 ]-total_hl ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_plan[ 1 ]-order_count ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 150 ) act = lv_total ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_count ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD filters_by_min_volume.
|
||||
add_order( iv_id = '1' iv_type = 'PILS' iv_volume = 100 ).
|
||||
add_order( iv_id = '2' iv_type = 'ALE' iv_volume = 50 ).
|
||||
run_plan( EXPORTING iv_min_hl = 75
|
||||
IMPORTING ev_total = DATA(lv_total) ev_count = DATA(lv_count) ).
|
||||
DATA(lt_plan) = read_plan( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_plan ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'PILS' act = lt_plan[ 1 ]-beer_type ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 100 ) act = lv_total ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD sorts_plan.
|
||||
add_order( iv_id = '1' iv_type = 'PILS' iv_volume = 100 ).
|
||||
add_order( iv_id = '2' iv_type = 'ALE' iv_volume = 300 ).
|
||||
run_plan( EXPORTING iv_min_hl = 0
|
||||
IMPORTING ev_total = DATA(lv_total) ev_count = DATA(lv_count) ).
|
||||
DATA(lt_plan) = read_plan( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_plan ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'ALE' act = lt_plan[ 1 ]-beer_type ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_plan[ 1 ]-plan_pos ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'PILS' act = lt_plan[ 2 ]-beer_type ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_plan[ 2 ]-plan_pos ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD replaces_plan.
|
||||
add_order( iv_id = '1' iv_type = 'PILS' iv_volume = 0 ).
|
||||
run_plan( EXPORTING iv_min_hl = 0
|
||||
IMPORTING ev_total = DATA(lv_total) ev_count = DATA(lv_count) ).
|
||||
DATA(lt_plan) = read_plan( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_plan ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_total ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_count ).
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user