Stage 2 summary at 50 accepted trajectories
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
25
tasks_gen/train/G1080/reference/i_vend_state.ddls.asddls
Normal file
25
tasks_gen/train/G1080/reference/i_vend_state.ddls.asddls
Normal file
@@ -0,0 +1,25 @@
|
||||
@AccessControl.authorizationCheck: #NOT_REQUIRED
|
||||
@EndUserText.label: 'Vending machine state'
|
||||
define view entity {{P}}I_VEND_STATE
|
||||
as select from {{p}}vmach as machine
|
||||
inner join {{p}}vslot as slot on slot.machine_id = machine.machine_id
|
||||
{
|
||||
key machine.machine_id as machine_id,
|
||||
upper( machine.location ) as location,
|
||||
count( * ) as slot_count,
|
||||
cast( sum( case when slot.fill_level = 0
|
||||
then 1
|
||||
else 0
|
||||
end ) as abap.int4 ) as empty_slots,
|
||||
division( sum( slot.fill_level ) * 100,
|
||||
sum( slot.max_units ), 1 ) as fill_rate,
|
||||
case
|
||||
when sum( slot.fill_level ) = 0 then 'EMPTY'
|
||||
when division( sum( slot.fill_level ) * 100,
|
||||
sum( slot.max_units ), 1 ) < 25 then 'LOW'
|
||||
else 'OK'
|
||||
end as status
|
||||
}
|
||||
group by
|
||||
machine.machine_id,
|
||||
machine.location
|
||||
56
tasks_gen/train/G1080/reference/t16_test.clas.abap
Normal file
56
tasks_gen/train/G1080/reference/t16_test.clas.abap
Normal file
@@ -0,0 +1,56 @@
|
||||
CLASS {{p}}t16_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
CLASS-DATA go_env TYPE REF TO if_cds_test_environment.
|
||||
CLASS-METHODS class_setup.
|
||||
CLASS-METHODS class_teardown.
|
||||
METHODS setup.
|
||||
METHODS low_machine FOR TESTING.
|
||||
METHODS empty_machine FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t16_test IMPLEMENTATION.
|
||||
METHOD class_setup.
|
||||
go_env = cl_cds_test_environment=>create( i_for_entity = '{{P}}I_VEND_STATE' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD class_teardown.
|
||||
go_env->destroy( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD setup.
|
||||
go_env->clear_doubles( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD low_machine.
|
||||
DATA lt_mach TYPE STANDARD TABLE OF {{p}}vmach WITH EMPTY KEY.
|
||||
DATA lt_slot TYPE STANDARD TABLE OF {{p}}vslot WITH EMPTY KEY.
|
||||
lt_mach = VALUE #( ( machine_id = 'A' location = 'Hall' ) ).
|
||||
lt_slot = VALUE #( ( machine_id = 'A' slot_no = 1 product = 'COLA' fill_level = 1 max_units = 4 )
|
||||
( machine_id = 'A' slot_no = 2 product = 'TEA' fill_level = 0 max_units = 4 ) ).
|
||||
go_env->insert_test_data( lt_mach ).
|
||||
go_env->insert_test_data( lt_slot ).
|
||||
SELECT SINGLE slot_count, empty_slots, fill_rate, status FROM {{p}}i_vend_state
|
||||
WHERE machine_id = 'A' INTO @DATA(ls_row).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = ls_row-slot_count ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = ls_row-empty_slots ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '12.5' )
|
||||
act = CONV decfloat34( ls_row-fill_rate ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'LOW' act = ls_row-status ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_machine.
|
||||
DATA lt_mach TYPE STANDARD TABLE OF {{p}}vmach WITH EMPTY KEY.
|
||||
DATA lt_slot TYPE STANDARD TABLE OF {{p}}vslot WITH EMPTY KEY.
|
||||
lt_mach = VALUE #( ( machine_id = 'B' location = 'Gate' ) ).
|
||||
lt_slot = VALUE #( ( machine_id = 'B' slot_no = 1 product = 'NUTS' fill_level = 0 max_units = 6 ) ).
|
||||
go_env->insert_test_data( lt_mach ).
|
||||
go_env->insert_test_data( lt_slot ).
|
||||
SELECT SINGLE fill_rate, status FROM {{p}}i_vend_state
|
||||
WHERE machine_id = 'B' INTO @DATA(ls_row).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '0.0' )
|
||||
act = CONV decfloat34( ls_row-fill_rate ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'EMPTY' act = ls_row-status ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user