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:
147
tasks_gen/train/G1021/reference/roast_merger.testclasses.abap
Normal file
147
tasks_gen/train/G1021/reference/roast_merger.testclasses.abap
Normal file
@@ -0,0 +1,147 @@
|
||||
CLASS ltc_roast_merger DEFINITION FINAL 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 keeps_larger_weight FOR TESTING.
|
||||
METHODS ignores_invalid FOR TESTING.
|
||||
METHODS sorts_by_lot FOR TESTING.
|
||||
METHODS empty_input FOR TESTING.
|
||||
METHODS last_date_is_latest FOR TESTING.
|
||||
METHODS single_batch FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_roast_merger 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' ) ).
|
||||
|
||||
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 = 2 ).
|
||||
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' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD keeps_larger_weight.
|
||||
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' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ignores_invalid.
|
||||
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 = 'LOT002'
|
||||
roast_date = '20240102' roasted_kg = '0.00' )
|
||||
( batch_id = 'B3' plant = 'P001' lot_id = 'LOT002'
|
||||
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 = 'LOT002' ).
|
||||
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' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD sorts_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 empty_input.
|
||||
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 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 ).
|
||||
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240131' ).
|
||||
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