Harness: runner, generator, tasks T01 T13 T14 T15, CLAUDE.md
This commit is contained in:
335
tasks_gen/eval/G0001/hidden/t07_hidden.clas.abap
Normal file
335
tasks_gen/eval/G0001/hidden/t07_hidden.clas.abap
Normal file
@@ -0,0 +1,335 @@
|
||||
CLASS {{P}}T07_HIDDEN DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{P}}TOUR_PLANNER.
|
||||
|
||||
METHODS setup.
|
||||
METHODS add_stop
|
||||
IMPORTING iv_tour_id TYPE {{P}}TOUR_PLANNER=>ty_tour_id
|
||||
iv_stop_no TYPE i
|
||||
iv_customer TYPE {{P}}TOUR_PLANNER=>ty_customer
|
||||
iv_packages TYPE i
|
||||
iv_weight TYPE {{P}}TOUR_PLANNER=>ty_weight.
|
||||
METHODS assert_item
|
||||
IMPORTING is_exp TYPE {{P}}TOUR_PLANNER=>ty_item
|
||||
is_act TYPE {{P}}TOUR_PLANNER=>ty_item
|
||||
iv_msg TYPE string.
|
||||
METHODS assert_weight
|
||||
IMPORTING iv_exp TYPE {{P}}TOUR_PLANNER=>ty_weight
|
||||
iv_act TYPE {{P}}TOUR_PLANNER=>ty_weight
|
||||
iv_msg TYPE string.
|
||||
|
||||
METHODS add_one_item FOR TESTING.
|
||||
METHODS items_are_sorted FOR TESTING.
|
||||
METHODS duplicate_is_rejected FOR TESTING.
|
||||
METHODS empty_tour_id_is_invalid FOR TESTING.
|
||||
METHODS bad_stop_no_is_invalid FOR TESTING.
|
||||
METHODS negative_values_are_invalid FOR TESTING.
|
||||
METHODS zero_values_are_valid FOR TESTING.
|
||||
METHODS stops_of_tour_are_sorted FOR TESTING.
|
||||
METHODS unknown_tour_has_no_stops FOR TESTING.
|
||||
METHODS find_stop_works FOR TESTING.
|
||||
METHODS summary_totals FOR TESTING.
|
||||
METHODS remove_tour_works FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{P}}T07_HIDDEN IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{P}}TOUR_PLANNER( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD add_stop.
|
||||
DATA(lv_status) = mo_cut->add_item( iv_tour_id = iv_tour_id
|
||||
iv_stop_no = iv_stop_no
|
||||
iv_customer = iv_customer
|
||||
iv_packages = iv_packages
|
||||
iv_weight = iv_weight ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-ok
|
||||
act = lv_status
|
||||
msg = `add_item must store a valid stop` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_item.
|
||||
cl_abap_unit_assert=>assert_equals( exp = is_exp-tour_id act = is_act-tour_id msg = iv_msg ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = is_exp-stop_no act = is_act-stop_no msg = iv_msg ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = is_exp-customer act = is_act-customer msg = iv_msg ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = is_exp-packages act = is_act-packages msg = iv_msg ).
|
||||
assert_weight( iv_exp = is_exp-weight iv_act = is_act-weight iv_msg = iv_msg ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_weight.
|
||||
cl_abap_unit_assert=>assert_equals( exp = iv_exp act = iv_act msg = iv_msg ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD add_one_item.
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 3
|
||||
iv_weight = '12.50' ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_item ) ).
|
||||
assert_item( is_exp = VALUE #( tour_id = 'T001'
|
||||
stop_no = 1
|
||||
customer = 'CUST01'
|
||||
packages = 3
|
||||
weight = '12.50' )
|
||||
is_act = lt_item[ 1 ]
|
||||
iv_msg = `one stored stop` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD items_are_sorted.
|
||||
add_stop( iv_tour_id = 'T002'
|
||||
iv_stop_no = 2
|
||||
iv_customer = 'CUST02'
|
||||
iv_packages = 1
|
||||
iv_weight = '5.00' ).
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 3
|
||||
iv_customer = 'CUST03'
|
||||
iv_packages = 2
|
||||
iv_weight = '6.00' ).
|
||||
add_stop( iv_tour_id = 'T002'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST04'
|
||||
iv_packages = 4
|
||||
iv_weight = '7.00' ).
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST05'
|
||||
iv_packages = 5
|
||||
iv_weight = '8.00' ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 4 act = lines( lt_item ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T001' act = lt_item[ 1 ]-tour_id msg = `row 1 tour` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_item[ 1 ]-stop_no msg = `row 1 stop` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T001' act = lt_item[ 2 ]-tour_id msg = `row 2 tour` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 3 act = lt_item[ 2 ]-stop_no msg = `row 2 stop` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T002' act = lt_item[ 3 ]-tour_id msg = `row 3 tour` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_item[ 3 ]-stop_no msg = `row 3 stop` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T002' act = lt_item[ 4 ]-tour_id msg = `row 4 tour` ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_item[ 4 ]-stop_no msg = `row 4 stop` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD duplicate_is_rejected.
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 3
|
||||
iv_weight = '12.50' ).
|
||||
|
||||
DATA(lv_status) = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST99'
|
||||
iv_packages = 9
|
||||
iv_weight = '99.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-duplicate act = lv_status ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_item ) ).
|
||||
assert_item( is_exp = VALUE #( tour_id = 'T001'
|
||||
stop_no = 1
|
||||
customer = 'CUST01'
|
||||
packages = 3
|
||||
weight = '12.50' )
|
||||
is_act = lt_item[ 1 ]
|
||||
iv_msg = `stored stop keeps its values` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_tour_id_is_invalid.
|
||||
DATA(lv_status) = mo_cut->add_item( iv_tour_id = ''
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 1
|
||||
iv_weight = '1.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-invalid act = lv_status ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_item ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD bad_stop_no_is_invalid.
|
||||
DATA(lv_status) = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = 0
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 1
|
||||
iv_weight = '1.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-invalid act = lv_status ).
|
||||
|
||||
lv_status = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = -1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 1
|
||||
iv_weight = '1.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-invalid act = lv_status ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_item ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD negative_values_are_invalid.
|
||||
DATA(lv_status) = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = -1
|
||||
iv_weight = '1.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-invalid act = lv_status ).
|
||||
|
||||
lv_status = mo_cut->add_item( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 1
|
||||
iv_weight = '-1.00' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-invalid act = lv_status ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_item ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_values_are_valid.
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = ''
|
||||
iv_packages = 0
|
||||
iv_weight = '0.00' ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_item ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_item[ 1 ]-packages ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD stops_of_tour_are_sorted.
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 2
|
||||
iv_customer = 'CUST02'
|
||||
iv_packages = 1
|
||||
iv_weight = '5.00' ).
|
||||
add_stop( iv_tour_id = 'T002'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST03'
|
||||
iv_packages = 2
|
||||
iv_weight = '6.00' ).
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST04'
|
||||
iv_packages = 4
|
||||
iv_weight = '7.00' ).
|
||||
|
||||
DATA(lt_item) = mo_cut->stops_of_tour( 'T001' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_item ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_item[ 1 ]-stop_no ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'CUST04' act = lt_item[ 1 ]-customer ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_item[ 2 ]-stop_no ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_tour_has_no_stops.
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 1
|
||||
iv_weight = '1.00' ).
|
||||
|
||||
DATA(lt_item) = mo_cut->stops_of_tour( 'T999' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_item ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD find_stop_works.
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 3
|
||||
iv_weight = '12.50' ).
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 2
|
||||
iv_customer = 'CUST02'
|
||||
iv_packages = 4
|
||||
iv_weight = '13.50' ).
|
||||
|
||||
assert_item( is_exp = VALUE #( tour_id = 'T001'
|
||||
stop_no = 2
|
||||
customer = 'CUST02'
|
||||
packages = 4
|
||||
weight = '13.50' )
|
||||
is_act = mo_cut->find_stop( iv_tour_id = 'T001' iv_stop_no = 2 )
|
||||
iv_msg = `known stop` ).
|
||||
|
||||
DATA(ls_missing) = mo_cut->find_stop( iv_tour_id = 'T001' iv_stop_no = 9 ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_missing-tour_id ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_missing-stop_no ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_missing-customer ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_missing-packages ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_missing-weight ).
|
||||
|
||||
ls_missing = mo_cut->find_stop( iv_tour_id = 'T999' iv_stop_no = 1 ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_missing-tour_id ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD summary_totals.
|
||||
add_stop( iv_tour_id = 'T002'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 2
|
||||
iv_weight = '10.25' ).
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST02'
|
||||
iv_packages = 3
|
||||
iv_weight = '20.50' ).
|
||||
add_stop( iv_tour_id = 'T002'
|
||||
iv_stop_no = 2
|
||||
iv_customer = 'CUST03'
|
||||
iv_packages = 4
|
||||
iv_weight = '30.75' ).
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 2
|
||||
iv_customer = 'CUST04'
|
||||
iv_packages = 5
|
||||
iv_weight = '40.25' ).
|
||||
|
||||
DATA(lt_tour) = mo_cut->tour_summary( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_tour ) ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T001' act = lt_tour[ 1 ]-tour_id ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_tour[ 1 ]-stops ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 8 act = lt_tour[ 1 ]-packages ).
|
||||
assert_weight( iv_exp = '60.75' iv_act = lt_tour[ 1 ]-weight iv_msg = `T001 weight` ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T002' act = lt_tour[ 2 ]-tour_id ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_tour[ 2 ]-stops ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 6 act = lt_tour[ 2 ]-packages ).
|
||||
assert_weight( iv_exp = '41.00' iv_act = lt_tour[ 2 ]-weight iv_msg = `T002 weight` ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD remove_tour_works.
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST01'
|
||||
iv_packages = 1
|
||||
iv_weight = '1.00' ).
|
||||
add_stop( iv_tour_id = 'T001'
|
||||
iv_stop_no = 2
|
||||
iv_customer = 'CUST02'
|
||||
iv_packages = 2
|
||||
iv_weight = '2.00' ).
|
||||
add_stop( iv_tour_id = 'T002'
|
||||
iv_stop_no = 1
|
||||
iv_customer = 'CUST03'
|
||||
iv_packages = 3
|
||||
iv_weight = '3.00' ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = mo_cut->remove_tour( 'T001' ) ).
|
||||
|
||||
DATA(lt_item) = mo_cut->items( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_item ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T002' act = lt_item[ 1 ]-tour_id ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = mo_cut->remove_tour( 'T001' ) ).
|
||||
|
||||
DATA(lt_tour) = mo_cut->tour_summary( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_tour ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'T002' act = lt_tour[ 1 ]-tour_id ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user