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:
235
tasks_gen/train/G1021/hidden/t41_hidden.clas.abap
Normal file
235
tasks_gen/train/G1021/hidden/t41_hidden.clas.abap
Normal file
@@ -0,0 +1,235 @@
|
||||
CLASS {{p}}t41_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}roast_merger.
|
||||
|
||||
METHODS setup.
|
||||
METHODS weight_of
|
||||
IMPORTING iv_text TYPE string
|
||||
RETURNING VALUE(rv_weight) TYPE {{p}}roast_merger=>ty_weight.
|
||||
METHODS total_of
|
||||
IMPORTING it_totals TYPE {{p}}roast_merger=>tt_lot_totals
|
||||
iv_lot TYPE {{p}}roast_merger=>ty_lot_id
|
||||
RETURNING VALUE(rs_total) TYPE {{p}}roast_merger=>ty_lot_total.
|
||||
|
||||
METHODS merges_two_plants FOR TESTING.
|
||||
METHODS result_sorted_by_lot FOR TESTING.
|
||||
METHODS dedup_keeps_larger FOR TESTING.
|
||||
METHODS dedup_keeps_first FOR TESTING.
|
||||
METHODS dedup_within_one_plant FOR TESTING.
|
||||
METHODS last_date_is_latest FOR TESTING.
|
||||
METHODS ignores_zero_weight FOR TESTING.
|
||||
METHODS ignores_empty_batch_id FOR TESTING.
|
||||
METHODS empty_input_gives_empty FOR TESTING.
|
||||
METHODS lot_with_only_invalid FOR TESTING.
|
||||
METHODS single_batch FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t41_hidden IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}roast_merger( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weight_of.
|
||||
rv_weight = iv_text.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD total_of.
|
||||
READ TABLE it_totals WITH KEY lot_id = iv_lot INTO rs_total.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD merges_two_plants.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240110' roasted_kg = '100.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT002'
|
||||
roast_date = '20240111' roasted_kg = '50.00' ) ).
|
||||
DATA(lt_b) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B3' plant = 'P002' lot_id = 'LOT002'
|
||||
roast_date = '20240112' roasted_kg = '25.00' )
|
||||
( batch_id = 'B4' plant = 'P002' lot_id = 'LOT003'
|
||||
roast_date = '20240113' roasted_kg = '10.00' ) ).
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 3 ).
|
||||
|
||||
DATA(ls_lot1) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot1-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot1-total_kg exp = weight_of( '100.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot1-last_date exp = '20240110' ).
|
||||
|
||||
DATA(ls_lot2) = total_of( it_totals = lt_totals iv_lot = 'LOT002' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot2-batch_count exp = 2 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot2-total_kg exp = weight_of( '75.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot2-last_date exp = '20240112' ).
|
||||
|
||||
DATA(ls_lot3) = total_of( it_totals = lt_totals iv_lot = 'LOT003' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot3-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot3-total_kg exp = weight_of( '10.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD result_sorted_by_lot.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT300'
|
||||
roast_date = '20240101' roasted_kg = '10.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT100'
|
||||
roast_date = '20240102' roasted_kg = '20.00' ) ).
|
||||
DATA(lt_b) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B3' plant = 'P002' lot_id = 'LOT200'
|
||||
roast_date = '20240103' roasted_kg = '30.00' ) ).
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 3 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lt_totals[ 1 ]-lot_id exp = 'LOT100' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lt_totals[ 2 ]-lot_id exp = 'LOT200' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lt_totals[ 3 ]-lot_id exp = 'LOT300' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD dedup_keeps_larger.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240101' roasted_kg = '40.00' ) ).
|
||||
DATA(lt_b) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P002' lot_id = 'LOT001'
|
||||
roast_date = '20240102' roasted_kg = '60.00' ) ).
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '60.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240102' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD dedup_keeps_first.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240105' roasted_kg = '70.00' ) ).
|
||||
DATA(lt_b) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P002' lot_id = 'LOT001'
|
||||
roast_date = '20240106' roasted_kg = '30.00' ) ).
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '70.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240105' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD dedup_within_one_plant.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240101' roasted_kg = '20.00' )
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240102' roasted_kg = '35.00' )
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240103' roasted_kg = '10.00' ) ).
|
||||
DATA lt_b TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '35.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240102' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD last_date_is_latest.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240120' roasted_kg = '10.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240105' roasted_kg = '10.00' )
|
||||
( batch_id = 'B3' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240131' roasted_kg = '10.00' ) ).
|
||||
DATA lt_b TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 3 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '30.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240131' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ignores_zero_weight.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240101' roasted_kg = '0.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240102' roasted_kg = '10.00' )
|
||||
( batch_id = 'B3' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240103' roasted_kg = '-5.00' ) ).
|
||||
DATA lt_b TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '10.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240102' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ignores_empty_batch_id.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = '' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240101' roasted_kg = '50.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240102' roasted_kg = '10.00' ) ).
|
||||
DATA lt_b TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '10.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240102' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_input_gives_empty.
|
||||
DATA lt_empty TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_empty it_plant_b = lt_empty ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 0 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD lot_with_only_invalid.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240101' roasted_kg = '0.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT002'
|
||||
roast_date = '20240102' roasted_kg = '10.00' ) ).
|
||||
DATA lt_b TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lt_totals[ 1 ]-lot_id exp = 'LOT002' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD single_batch.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240107' roasted_kg = '12.50' ) ).
|
||||
DATA lt_b TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '12.50' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240107' ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user