Pipeline controller: plan 2 (hard +, error +50 %), backlog throttle, 2 trajectory workers, stop rules, summaries every 50; budget reserve
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
29
tasks_gen/train/G1041/generation.json
Normal file
29
tasks_gen/train/G1041/generation.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"id": "G1041",
|
||||
"pool": "train",
|
||||
"object_type": "CLAS",
|
||||
"category": "C",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 91.7,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
}
|
||||
],
|
||||
"accepted": false
|
||||
}
|
||||
232
tasks_gen/train/G1041/hidden/feed_hidden.clas.abap
Normal file
232
tasks_gen/train/G1041/hidden/feed_hidden.clas.abap
Normal file
@@ -0,0 +1,232 @@
|
||||
CLASS {{p}}feed_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_feed_stock.
|
||||
|
||||
METHODS setup.
|
||||
METHODS assert_stock
|
||||
IMPORTING it_exp TYPE {{p}}if_feed_stock=>tt_stock
|
||||
it_act TYPE {{p}}if_feed_stock=>tt_stock.
|
||||
|
||||
METHODS empty_inputs FOR TESTING.
|
||||
METHODS sums_one_supplier FOR TESTING.
|
||||
METHODS merges_same_feed_type FOR TESTING.
|
||||
METHODS ignores_empty_feed_type FOR TESTING.
|
||||
METHODS ignores_zero_quantity FOR TESTING.
|
||||
METHODS negative_reduces_total FOR TESTING.
|
||||
METHODS removes_zero_total FOR TESTING.
|
||||
METHODS result_sorted FOR TESTING.
|
||||
METHODS unit_from_first_row FOR TESTING.
|
||||
METHODS counts_deliveries FOR TESTING.
|
||||
METHODS quantity_of_lookup FOR TESTING.
|
||||
METHODS top_feed_and_tie FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}feed_hidden IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}feed_stock( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_stock.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lines( it_exp )
|
||||
act = lines( it_act )
|
||||
msg = `row count` ).
|
||||
DATA(lv_index) = 0.
|
||||
LOOP AT it_exp ASSIGNING FIELD-SYMBOL(<ls_exp>).
|
||||
lv_index = lv_index + 1.
|
||||
READ TABLE it_act ASSIGNING FIELD-SYMBOL(<ls_act>) INDEX lv_index.
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 act = sy-subrc msg = `row missing` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = <ls_exp>-feed_type
|
||||
act = <ls_act>-feed_type
|
||||
msg = `feed type` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = <ls_exp>-unit
|
||||
act = <ls_act>-unit
|
||||
msg = `unit` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = <ls_exp>-quantity
|
||||
act = <ls_act>-quantity
|
||||
msg = `quantity` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = <ls_exp>-deliveries
|
||||
act = <ls_act>-deliveries
|
||||
msg = `deliveries` ).
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_inputs.
|
||||
DATA(lt_stock) = mo_cut->consolidate(
|
||||
it_supplier_a = VALUE {{p}}if_feed_stock=>tt_delivery( )
|
||||
it_supplier_b = VALUE {{p}}if_feed_stock=>tt_delivery( ) ).
|
||||
cl_abap_unit_assert=>assert_initial( lt_stock ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD sums_one_supplier.
|
||||
DATA(lt_stock) = mo_cut->consolidate(
|
||||
it_supplier_a = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '10.500' )
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '4.500' )
|
||||
( feed_type = 'PELLETS' unit = 'KG' quantity = '20.000' ) )
|
||||
it_supplier_b = VALUE {{p}}if_feed_stock=>tt_delivery( ) ).
|
||||
assert_stock(
|
||||
it_exp = VALUE {{p}}if_feed_stock=>tt_stock(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '15.000' deliveries = 2 )
|
||||
( feed_type = 'PELLETS' unit = 'KG' quantity = '20.000' deliveries = 1 ) )
|
||||
it_act = lt_stock ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD merges_same_feed_type.
|
||||
DATA(lt_stock) = mo_cut->consolidate(
|
||||
it_supplier_a = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '10.000' ) )
|
||||
it_supplier_b = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '5.000' )
|
||||
( feed_type = 'FISH' unit = 'KG' quantity = '3.000' ) ) ).
|
||||
assert_stock(
|
||||
it_exp = VALUE {{p}}if_feed_stock=>tt_stock(
|
||||
( feed_type = 'FISH' unit = 'KG' quantity = '3.000' deliveries = 1 )
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '15.000' deliveries = 2 ) )
|
||||
it_act = lt_stock ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ignores_empty_feed_type.
|
||||
DATA(lt_stock) = mo_cut->consolidate(
|
||||
it_supplier_a = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = '' unit = 'KG' quantity = '100.000' )
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '5.000' ) )
|
||||
it_supplier_b = VALUE {{p}}if_feed_stock=>tt_delivery( ) ).
|
||||
assert_stock(
|
||||
it_exp = VALUE {{p}}if_feed_stock=>tt_stock(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '5.000' deliveries = 1 ) )
|
||||
it_act = lt_stock ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ignores_zero_quantity.
|
||||
DATA(lt_stock) = mo_cut->consolidate(
|
||||
it_supplier_a = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'HAY' unit = 'BOX' quantity = '0.000' )
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '5.000' ) )
|
||||
it_supplier_b = VALUE {{p}}if_feed_stock=>tt_delivery( ) ).
|
||||
assert_stock(
|
||||
it_exp = VALUE {{p}}if_feed_stock=>tt_stock(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '5.000' deliveries = 1 ) )
|
||||
it_act = lt_stock ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD negative_reduces_total.
|
||||
DATA(lt_stock) = mo_cut->consolidate(
|
||||
it_supplier_a = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '10.000' )
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '-4.000' ) )
|
||||
it_supplier_b = VALUE {{p}}if_feed_stock=>tt_delivery( ) ).
|
||||
assert_stock(
|
||||
it_exp = VALUE {{p}}if_feed_stock=>tt_stock(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '6.000' deliveries = 2 ) )
|
||||
it_act = lt_stock ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD removes_zero_total.
|
||||
DATA(lt_stock) = mo_cut->consolidate(
|
||||
it_supplier_a = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '10.000' )
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '-10.000' ) )
|
||||
it_supplier_b = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'PELLETS' unit = 'KG' quantity = '5.000' ) ) ).
|
||||
assert_stock(
|
||||
it_exp = VALUE {{p}}if_feed_stock=>tt_stock(
|
||||
( feed_type = 'PELLETS' unit = 'KG' quantity = '5.000' deliveries = 1 ) )
|
||||
it_act = lt_stock ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD result_sorted.
|
||||
DATA(lt_stock) = mo_cut->consolidate(
|
||||
it_supplier_a = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'PELLETS' unit = 'KG' quantity = '1.000' )
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '2.000' ) )
|
||||
it_supplier_b = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'FISH' unit = 'KG' quantity = '3.000' ) ) ).
|
||||
assert_stock(
|
||||
it_exp = VALUE {{p}}if_feed_stock=>tt_stock(
|
||||
( feed_type = 'FISH' unit = 'KG' quantity = '3.000' deliveries = 1 )
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '2.000' deliveries = 1 )
|
||||
( feed_type = 'PELLETS' unit = 'KG' quantity = '1.000' deliveries = 1 ) )
|
||||
it_act = lt_stock ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unit_from_first_row.
|
||||
DATA(lt_stock) = mo_cut->consolidate(
|
||||
it_supplier_a = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'HAY' unit = 'BOX' quantity = '5.000' )
|
||||
( feed_type = 'PELLETS' unit = 'KG' quantity = '2.000' ) )
|
||||
it_supplier_b = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '7.000' )
|
||||
( feed_type = 'PELLETS' unit = 'BOX' quantity = '3.000' ) ) ).
|
||||
assert_stock(
|
||||
it_exp = VALUE {{p}}if_feed_stock=>tt_stock(
|
||||
( feed_type = 'HAY' unit = 'BOX' quantity = '12.000' deliveries = 2 )
|
||||
( feed_type = 'PELLETS' unit = 'KG' quantity = '5.000' deliveries = 2 ) )
|
||||
it_act = lt_stock ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD counts_deliveries.
|
||||
DATA(lt_stock) = mo_cut->consolidate(
|
||||
it_supplier_a = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '1.000' )
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '1.000' )
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '1.000' ) )
|
||||
it_supplier_b = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '-1.000' ) ) ).
|
||||
assert_stock(
|
||||
it_exp = VALUE {{p}}if_feed_stock=>tt_stock(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '2.000' deliveries = 4 ) )
|
||||
it_act = lt_stock ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD quantity_of_lookup.
|
||||
DATA(lt_stock) = mo_cut->consolidate(
|
||||
it_supplier_a = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '10.000' )
|
||||
( feed_type = 'PELLETS' unit = 'KG' quantity = '4.000' ) )
|
||||
it_supplier_b = VALUE {{p}}if_feed_stock=>tt_delivery( ) ).
|
||||
|
||||
DATA lv_expected TYPE {{p}}if_feed_stock=>ty_quantity.
|
||||
lv_expected = '10.000'.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = lv_expected
|
||||
act = mo_cut->quantity_of( it_stock = lt_stock iv_feed_type = 'HAY' )
|
||||
msg = `HAY` ).
|
||||
|
||||
CLEAR lv_expected.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = lv_expected
|
||||
act = mo_cut->quantity_of( it_stock = lt_stock iv_feed_type = 'FISH' )
|
||||
msg = `FISH` ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = lv_expected
|
||||
act = mo_cut->quantity_of(
|
||||
it_stock = VALUE {{p}}if_feed_stock=>tt_stock( )
|
||||
iv_feed_type = 'HAY' )
|
||||
msg = `empty list` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD top_feed_and_tie.
|
||||
cl_abap_unit_assert=>assert_initial(
|
||||
mo_cut->top_feed( it_stock = VALUE {{p}}if_feed_stock=>tt_stock( ) ) ).
|
||||
|
||||
DATA(lt_stock) = VALUE {{p}}if_feed_stock=>tt_stock(
|
||||
( feed_type = 'PELLETS' unit = 'KG' quantity = '9.000' deliveries = 1 )
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '5.000' deliveries = 1 ) ).
|
||||
DATA lv_expected TYPE {{p}}if_feed_stock=>ty_feed_type.
|
||||
lv_expected = 'PELLETS'.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = lv_expected
|
||||
act = mo_cut->top_feed( it_stock = lt_stock ) ).
|
||||
|
||||
DATA(lt_tie) = VALUE {{p}}if_feed_stock=>tt_stock(
|
||||
( feed_type = 'PELLETS' unit = 'KG' quantity = '5.000' deliveries = 1 )
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '5.000' deliveries = 1 ) ).
|
||||
lv_expected = 'HAY'.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = lv_expected
|
||||
act = mo_cut->top_feed( it_stock = lt_tie ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
90
tasks_gen/train/G1041/reference/feed_stock.clas.abap
Normal file
90
tasks_gen/train/G1041/reference/feed_stock.clas.abap
Normal file
@@ -0,0 +1,90 @@
|
||||
CLASS {{p}}feed_stock DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_feed_stock.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES tt_sum TYPE HASHED TABLE OF {{p}}if_feed_stock=>ty_stock
|
||||
WITH UNIQUE KEY feed_type.
|
||||
|
||||
METHODS sum_deliveries
|
||||
IMPORTING it_supplier_a TYPE {{p}}if_feed_stock=>tt_delivery
|
||||
it_supplier_b TYPE {{p}}if_feed_stock=>tt_delivery
|
||||
RETURNING VALUE(rt_sum) TYPE tt_sum.
|
||||
|
||||
METHODS add_delivery
|
||||
IMPORTING is_delivery TYPE {{p}}if_feed_stock=>ty_delivery
|
||||
CHANGING ct_sum TYPE tt_sum.
|
||||
|
||||
METHODS is_counted
|
||||
IMPORTING is_delivery TYPE {{p}}if_feed_stock=>ty_delivery
|
||||
RETURNING VALUE(rv_counted) TYPE abap_bool.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}feed_stock IMPLEMENTATION.
|
||||
METHOD {{p}}if_feed_stock~consolidate.
|
||||
DATA(lt_sum) = sum_deliveries( it_supplier_a = it_supplier_a
|
||||
it_supplier_b = it_supplier_b ).
|
||||
LOOP AT lt_sum ASSIGNING FIELD-SYMBOL(<ls_sum>).
|
||||
IF <ls_sum>-quantity IS INITIAL.
|
||||
CONTINUE.
|
||||
ENDIF.
|
||||
APPEND <ls_sum> TO rt_stock.
|
||||
ENDLOOP.
|
||||
SORT rt_stock BY feed_type.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD {{p}}if_feed_stock~quantity_of.
|
||||
DATA lt_stock TYPE {{p}}if_feed_stock=>tt_stock.
|
||||
lt_stock = it_stock.
|
||||
SORT lt_stock BY feed_type.
|
||||
READ TABLE lt_stock ASSIGNING FIELD-SYMBOL(<ls_stock>)
|
||||
WITH KEY feed_type = iv_feed_type BINARY SEARCH.
|
||||
IF sy-subrc = 0.
|
||||
rv_quantity = <ls_stock>-quantity.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD {{p}}if_feed_stock~top_feed.
|
||||
IF it_stock IS INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lt_ranked) = it_stock.
|
||||
SORT lt_ranked BY quantity DESCENDING feed_type ASCENDING.
|
||||
rv_feed_type = lt_ranked[ 1 ]-feed_type.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD sum_deliveries.
|
||||
DATA lt_all TYPE {{p}}if_feed_stock=>tt_delivery.
|
||||
DATA lt_sum TYPE tt_sum.
|
||||
APPEND LINES OF it_supplier_a TO lt_all.
|
||||
APPEND LINES OF it_supplier_b TO lt_all.
|
||||
LOOP AT lt_all ASSIGNING FIELD-SYMBOL(<ls_delivery>).
|
||||
IF is_counted( <ls_delivery> ) = abap_false.
|
||||
CONTINUE.
|
||||
ENDIF.
|
||||
add_delivery( EXPORTING is_delivery = <ls_delivery>
|
||||
CHANGING ct_sum = lt_sum ).
|
||||
ENDLOOP.
|
||||
rt_sum = lt_sum.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD add_delivery.
|
||||
ASSIGN ct_sum[ feed_type = is_delivery-feed_type ] TO FIELD-SYMBOL(<ls_sum>).
|
||||
IF sy-subrc <> 0.
|
||||
INSERT VALUE #( feed_type = is_delivery-feed_type
|
||||
unit = is_delivery-unit
|
||||
quantity = is_delivery-quantity
|
||||
deliveries = 1 )
|
||||
INTO TABLE ct_sum ASSIGNING <ls_sum>.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
<ls_sum>-quantity = <ls_sum>-quantity + is_delivery-quantity.
|
||||
<ls_sum>-deliveries = <ls_sum>-deliveries + 1.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_counted.
|
||||
rv_counted = xsdbool( is_delivery-feed_type IS NOT INITIAL
|
||||
AND is_delivery-quantity IS NOT INITIAL ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
85
tasks_gen/train/G1041/reference/feed_stock.testclasses.abap
Normal file
85
tasks_gen/train/G1041/reference/feed_stock.testclasses.abap
Normal file
@@ -0,0 +1,85 @@
|
||||
CLASS ltc_feed_stock DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}feed_stock.
|
||||
|
||||
METHODS setup.
|
||||
METHODS assert_stock
|
||||
IMPORTING it_exp TYPE {{p}}if_feed_stock=>tt_stock
|
||||
it_act TYPE {{p}}if_feed_stock=>tt_stock.
|
||||
|
||||
METHODS merges_two_suppliers FOR TESTING.
|
||||
METHODS ignores_uncounted FOR TESTING.
|
||||
METHODS removes_zero_total FOR TESTING.
|
||||
METHODS quantity_of_missing FOR TESTING.
|
||||
METHODS top_feed_tie FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_feed_stock IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}feed_stock( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_stock.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lines( it_exp ) act = lines( it_act ) ).
|
||||
DATA(lv_index) = 0.
|
||||
LOOP AT it_exp ASSIGNING FIELD-SYMBOL(<ls_exp>).
|
||||
lv_index = lv_index + 1.
|
||||
READ TABLE it_act ASSIGNING FIELD-SYMBOL(<ls_act>) INDEX lv_index.
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 act = sy-subrc ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = <ls_exp>-feed_type act = <ls_act>-feed_type ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = <ls_exp>-unit act = <ls_act>-unit ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = <ls_exp>-quantity act = <ls_act>-quantity ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = <ls_exp>-deliveries act = <ls_act>-deliveries ).
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD merges_two_suppliers.
|
||||
DATA(lt_stock) = mo_cut->consolidate(
|
||||
it_supplier_a = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '10.000' ) )
|
||||
it_supplier_b = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '5.000' ) ) ).
|
||||
assert_stock(
|
||||
it_exp = VALUE {{p}}if_feed_stock=>tt_stock(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '15.000' deliveries = 2 ) )
|
||||
it_act = lt_stock ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ignores_uncounted.
|
||||
DATA(lt_stock) = mo_cut->consolidate(
|
||||
it_supplier_a = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = '' unit = 'KG' quantity = '9.000' )
|
||||
( feed_type = 'FISH' unit = 'KG' quantity = '0.000' ) )
|
||||
it_supplier_b = VALUE {{p}}if_feed_stock=>tt_delivery( ) ).
|
||||
cl_abap_unit_assert=>assert_initial( lt_stock ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD removes_zero_total.
|
||||
DATA(lt_stock) = mo_cut->consolidate(
|
||||
it_supplier_a = VALUE {{p}}if_feed_stock=>tt_delivery(
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '4.000' )
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '-4.000' ) )
|
||||
it_supplier_b = VALUE {{p}}if_feed_stock=>tt_delivery( ) ).
|
||||
cl_abap_unit_assert=>assert_initial( lt_stock ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD quantity_of_missing.
|
||||
DATA lv_expected TYPE {{p}}if_feed_stock=>ty_quantity.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = lv_expected
|
||||
act = mo_cut->quantity_of(
|
||||
it_stock = VALUE {{p}}if_feed_stock=>tt_stock( )
|
||||
iv_feed_type = 'HAY' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD top_feed_tie.
|
||||
DATA(lt_stock) = VALUE {{p}}if_feed_stock=>tt_stock(
|
||||
( feed_type = 'PELLETS' unit = 'KG' quantity = '5.000' deliveries = 1 )
|
||||
( feed_type = 'HAY' unit = 'KG' quantity = '5.000' deliveries = 1 ) ).
|
||||
DATA lv_expected TYPE {{p}}if_feed_stock=>ty_feed_type.
|
||||
lv_expected = 'HAY'.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_expected
|
||||
act = mo_cut->top_feed( it_stock = lt_stock ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
33
tasks_gen/train/G1041/seed/if_feed_stock.intf.abap
Normal file
33
tasks_gen/train/G1041/seed/if_feed_stock.intf.abap
Normal file
@@ -0,0 +1,33 @@
|
||||
INTERFACE {{p}}if_feed_stock PUBLIC.
|
||||
TYPES:
|
||||
ty_feed_type TYPE c LENGTH 8,
|
||||
ty_unit TYPE c LENGTH 3,
|
||||
ty_quantity TYPE p LENGTH 13 DECIMALS 3,
|
||||
BEGIN OF ty_delivery,
|
||||
feed_type TYPE ty_feed_type,
|
||||
unit TYPE ty_unit,
|
||||
quantity TYPE ty_quantity,
|
||||
END OF ty_delivery,
|
||||
tt_delivery TYPE STANDARD TABLE OF ty_delivery WITH EMPTY KEY,
|
||||
BEGIN OF ty_stock,
|
||||
feed_type TYPE ty_feed_type,
|
||||
unit TYPE ty_unit,
|
||||
quantity TYPE ty_quantity,
|
||||
deliveries TYPE i,
|
||||
END OF ty_stock,
|
||||
tt_stock TYPE STANDARD TABLE OF ty_stock WITH EMPTY KEY.
|
||||
|
||||
METHODS consolidate
|
||||
IMPORTING it_supplier_a TYPE tt_delivery
|
||||
it_supplier_b TYPE tt_delivery
|
||||
RETURNING VALUE(rt_stock) TYPE tt_stock.
|
||||
|
||||
METHODS quantity_of
|
||||
IMPORTING it_stock TYPE tt_stock
|
||||
iv_feed_type TYPE ty_feed_type
|
||||
RETURNING VALUE(rv_quantity) TYPE ty_quantity.
|
||||
|
||||
METHODS top_feed
|
||||
IMPORTING it_stock TYPE tt_stock
|
||||
RETURNING VALUE(rv_feed_type) TYPE ty_feed_type.
|
||||
ENDINTERFACE.
|
||||
76
tasks_gen/train/G1041/spec.md
Normal file
76
tasks_gen/train/G1041/spec.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# 1. Goal
|
||||
A zoo keeps a feed store. Two suppliers send their feed deliveries. The store
|
||||
manager needs one consolidated stock list per feed type, the quantity of one
|
||||
feed type, and the feed type with the highest quantity. A store program calls
|
||||
the class for each delivery round.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- Interface {{P}}IF_FEED_STOCK exists in package $TMP. It is active.
|
||||
- The interface has these types:
|
||||
- TY_FEED_TYPE (CHAR 8), TY_UNIT (CHAR 3), TY_QUANTITY (packed, 3 decimals).
|
||||
- TY_DELIVERY with the fields FEED_TYPE, UNIT and QUANTITY.
|
||||
- TT_DELIVERY: a table of TY_DELIVERY.
|
||||
- TY_STOCK with the fields FEED_TYPE, UNIT, QUANTITY and DELIVERIES
|
||||
(integer).
|
||||
- TT_STOCK: a table of TY_STOCK.
|
||||
- The interface has three methods:
|
||||
- CONSOLIDATE with the importing parameters IT_SUPPLIER_A and IT_SUPPLIER_B
|
||||
(both TT_DELIVERY) and the returning parameter RT_STOCK (TT_STOCK).
|
||||
- QUANTITY_OF with the importing parameters IT_STOCK (TT_STOCK) and
|
||||
IV_FEED_TYPE (TY_FEED_TYPE) and the returning parameter RV_QUANTITY
|
||||
(TY_QUANTITY).
|
||||
- TOP_FEED with the importing parameter IT_STOCK (TT_STOCK) and the
|
||||
returning parameter RV_FEED_TYPE (TY_FEED_TYPE).
|
||||
|
||||
# 4. Contract
|
||||
- Create the class {{P}}FEED_STOCK in package $TMP.
|
||||
- The class is public, final, and has a public constructor without parameters.
|
||||
- The class implements {{P}}IF_FEED_STOCK.
|
||||
- Do not add other public methods.
|
||||
|
||||
# 5. Business rules
|
||||
|
||||
## 5.1 Input
|
||||
- A delivery row has the fields FEED_TYPE, UNIT and QUANTITY.
|
||||
- The caller passes two delivery lists: supplier A and supplier B. Each list
|
||||
can hold any number of rows, including none.
|
||||
|
||||
## 5.2 CONSOLIDATE
|
||||
1. Count a row only when its feed type is not empty and its quantity is not
|
||||
zero. Ignore every other row.
|
||||
2. Read the counted rows of supplier A first, in the given order, then the
|
||||
counted rows of supplier B, in the given order.
|
||||
3. Group the counted rows by feed type. The result has one row per feed type.
|
||||
4. The quantity of a result row is the sum of the quantities of the counted
|
||||
rows of this feed type. A negative quantity reduces the sum.
|
||||
5. The unit of a result row is the unit of the first counted row of this feed
|
||||
type.
|
||||
6. The deliveries of a result row is the number of counted rows of this feed
|
||||
type.
|
||||
7. Remove a result row whose quantity is zero.
|
||||
8. Sort the result rows by feed type in ascending order.
|
||||
9. Return an empty list when no result row remains.
|
||||
|
||||
## 5.3 QUANTITY_OF
|
||||
1. Return the quantity of the result row with the given feed type.
|
||||
2. Return zero when the list has no row with this feed type.
|
||||
|
||||
## 5.4 TOP_FEED
|
||||
1. Return the feed type with the highest quantity in the list.
|
||||
2. When more than one feed type has the same highest quantity, return the feed
|
||||
type that comes first in ascending order.
|
||||
3. Return an empty feed type when the list is empty.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: 8.16.
|
||||
- Coding standards: Clean ABAP. Method length below 40 statements. No global
|
||||
variables. No comment that restates the code.
|
||||
- Out of scope: do not change {{P}}IF_FEED_STOCK.
|
||||
|
||||
# 7. Acceptance
|
||||
- The class is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests for the class.
|
||||
52
tasks_gen/train/G1041/task.json
Normal file
52
tasks_gen/train/G1041/task.json
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"id": "G1041",
|
||||
"category": "C",
|
||||
"object_type": "CLAS",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "INTF",
|
||||
"name": "{{P}}IF_FEED_STOCK",
|
||||
"file": "seed/if_feed_stock.intf.abap",
|
||||
"description": "Feed stock contract with the delivery and stock types"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}FEED_STOCK",
|
||||
"implements": "{{P}}IF_FEED_STOCK"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"{{P}}IF_FEED_STOCK"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}FEED_HIDDEN",
|
||||
"file": "hidden/feed_hidden.clas.abap",
|
||||
"description": "T41 hidden tests for the feed stock consolidation"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}FEED_STOCK",
|
||||
"file": "reference/feed_stock.clas.abap",
|
||||
"description": "Feed stock consolidation, lookup and top feed",
|
||||
"testclasses_file": "reference/feed_stock.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"nested_loop",
|
||||
"linear_search_in_loop"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user