Harness: runner, generator, tasks T01 T13 T14 T15, CLAUDE.md

This commit is contained in:
Kral
2026-10-02 21:42:51 +02:00
commit 1c6c85492e
54 changed files with 3732 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
{
"id": "G0001",
"pool": "eval",
"object_type": "CLAS",
"category": "C",
"attempts": [
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "validate",
"oracle": null,
"null": null
},
{
"stage": "validate",
"oracle": 89.2,
"null": 0
}
],
"accepted": false
}

View 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.

View File

@@ -0,0 +1,143 @@
CLASS {{P}}TOUR_PLANNER DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_status TYPE c LENGTH 10.
TYPES ty_tour_id TYPE c LENGTH 4.
TYPES ty_customer TYPE c LENGTH 10.
TYPES ty_weight TYPE p LENGTH 8 DECIMALS 2.
CONSTANTS:
BEGIN OF c_status,
ok TYPE ty_status VALUE 'OK',
invalid TYPE ty_status VALUE 'INVALID',
duplicate TYPE ty_status VALUE 'DUPLICATE',
END OF c_status.
TYPES:
BEGIN OF ty_item,
tour_id TYPE ty_tour_id,
stop_no TYPE i,
customer TYPE ty_customer,
packages TYPE i,
weight TYPE ty_weight,
END OF ty_item,
tt_item TYPE STANDARD TABLE OF ty_item WITH EMPTY KEY,
BEGIN OF ty_tour,
tour_id TYPE ty_tour_id,
stops TYPE i,
packages TYPE i,
weight TYPE ty_weight,
END OF ty_tour,
tt_tour TYPE STANDARD TABLE OF ty_tour WITH EMPTY KEY.
METHODS add_item
IMPORTING iv_tour_id TYPE ty_tour_id
iv_stop_no TYPE i
iv_customer TYPE ty_customer
iv_packages TYPE i
iv_weight TYPE ty_weight
RETURNING VALUE(rv_status) TYPE ty_status.
METHODS remove_tour
IMPORTING iv_tour_id TYPE ty_tour_id
RETURNING VALUE(rv_count) TYPE i.
METHODS items
RETURNING VALUE(rt_item) TYPE tt_item.
METHODS stops_of_tour
IMPORTING iv_tour_id TYPE ty_tour_id
RETURNING VALUE(rt_item) TYPE tt_item.
METHODS find_stop
IMPORTING iv_tour_id TYPE ty_tour_id
iv_stop_no TYPE i
RETURNING VALUE(rs_item) TYPE ty_item.
METHODS tour_summary
RETURNING VALUE(rt_tour) TYPE tt_tour.
PRIVATE SECTION.
TYPES tt_stop TYPE SORTED TABLE OF ty_item WITH UNIQUE KEY tour_id stop_no.
DATA mt_stop TYPE tt_stop.
METHODS is_invalid
IMPORTING iv_tour_id TYPE ty_tour_id
iv_stop_no TYPE i
iv_packages TYPE i
iv_weight TYPE ty_weight
RETURNING VALUE(rv_invalid) TYPE abap_bool.
ENDCLASS.
CLASS {{P}}TOUR_PLANNER IMPLEMENTATION.
METHOD add_item.
IF is_invalid( iv_tour_id = iv_tour_id
iv_stop_no = iv_stop_no
iv_packages = iv_packages
iv_weight = iv_weight ) = abap_true.
rv_status = c_status-invalid.
RETURN.
ENDIF.
DATA(ls_stop) = VALUE ty_item( tour_id = iv_tour_id
stop_no = iv_stop_no
customer = iv_customer
packages = iv_packages
weight = iv_weight ).
INSERT ls_stop INTO TABLE mt_stop.
IF sy-subrc <> 0.
rv_status = c_status-duplicate.
RETURN.
ENDIF.
rv_status = c_status-ok.
ENDMETHOD.
METHOD remove_tour.
DELETE mt_stop WHERE tour_id = iv_tour_id.
rv_count = sy-dbcnt.
ENDMETHOD.
METHOD items.
rt_item = mt_stop.
ENDMETHOD.
METHOD stops_of_tour.
rt_item = VALUE #( FOR ls_stop IN mt_stop WHERE ( tour_id = iv_tour_id ) ( ls_stop ) ).
ENDMETHOD.
METHOD find_stop.
READ TABLE mt_stop WITH KEY tour_id = iv_tour_id
stop_no = iv_stop_no INTO rs_item.
IF sy-subrc <> 0.
CLEAR rs_item.
ENDIF.
ENDMETHOD.
METHOD tour_summary.
DATA lt_tour TYPE SORTED TABLE OF ty_tour WITH UNIQUE KEY tour_id.
LOOP AT mt_stop INTO DATA(ls_stop).
READ TABLE lt_tour WITH KEY tour_id = ls_stop-tour_id ASSIGNING FIELD-SYMBOL(<ls_tour>).
IF sy-subrc <> 0.
INSERT VALUE ty_tour( tour_id = ls_stop-tour_id )
INTO TABLE lt_tour ASSIGNING <ls_tour>.
ENDIF.
<ls_tour>-stops = <ls_tour>-stops + 1.
<ls_tour>-packages = <ls_tour>-packages + ls_stop-packages.
<ls_tour>-weight = <ls_tour>-weight + ls_stop-weight.
ENDLOOP.
rt_tour = lt_tour.
ENDMETHOD.
METHOD is_invalid.
rv_invalid = xsdbool( iv_tour_id IS INITIAL
OR iv_stop_no < 1
OR iv_packages < 0
OR iv_weight < 0 ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,93 @@
CLASS ltc_tour_planner DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mo_cut TYPE REF TO {{P}}TOUR_PLANNER.
METHODS setup.
METHODS add_and_read_item FOR TESTING.
METHODS duplicate_is_rejected FOR TESTING.
METHODS invalid_input_is_rejected FOR TESTING.
METHODS summary_totals FOR TESTING.
METHODS remove_tour_works FOR TESTING.
ENDCLASS.
CLASS ltc_tour_planner IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{P}}TOUR_PLANNER( ).
ENDMETHOD.
METHOD add_and_read_item.
DATA(lv_status) = mo_cut->add_item( iv_tour_id = 'T001'
iv_stop_no = 1
iv_customer = 'CUST01'
iv_packages = 3
iv_weight = '12.50' ).
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-ok act = lv_status ).
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 = 'CUST01' act = lt_item[ 1 ]-customer ).
ENDMETHOD.
METHOD duplicate_is_rejected.
DATA(lv_status) = mo_cut->add_item( iv_tour_id = 'T001'
iv_stop_no = 1
iv_customer = 'CUST01'
iv_packages = 3
iv_weight = '12.50' ).
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-ok act = lv_status ).
lv_status = mo_cut->add_item( iv_tour_id = 'T001'
iv_stop_no = 1
iv_customer = 'CUST02'
iv_packages = 1
iv_weight = '1.00' ).
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-duplicate act = lv_status ).
ENDMETHOD.
METHOD invalid_input_is_rejected.
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 summary_totals.
DATA(lv_status) = mo_cut->add_item( iv_tour_id = 'T001'
iv_stop_no = 1
iv_customer = 'CUST01'
iv_packages = 2
iv_weight = '10.00' ).
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-ok act = lv_status ).
lv_status = mo_cut->add_item( iv_tour_id = 'T001'
iv_stop_no = 2
iv_customer = 'CUST02'
iv_packages = 3
iv_weight = '20.00' ).
cl_abap_unit_assert=>assert_equals( exp = {{P}}TOUR_PLANNER=>c_status-ok act = lv_status ).
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 = 2 act = lt_tour[ 1 ]-stops ).
cl_abap_unit_assert=>assert_equals( exp = 5 act = lt_tour[ 1 ]-packages ).
ENDMETHOD.
METHOD remove_tour_works.
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-ok act = lv_status ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = mo_cut->remove_tour( 'T001' ) ).
DATA(lt_item) = mo_cut->items( ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines( lt_item ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,55 @@
INTERFACE {{p}}if_tour_planner PUBLIC.
TYPES ty_status TYPE c LENGTH 10.
CONSTANTS:
BEGIN OF c_status,
ok TYPE ty_status VALUE 'OK',
invalid TYPE ty_status VALUE 'INVALID',
duplicate TYPE ty_status VALUE 'DUPLICATE',
END OF c_status.
TYPES:
BEGIN OF ty_item,
tour_id TYPE c LENGTH 4,
stop_no TYPE i,
customer TYPE c LENGTH 10,
packages TYPE i,
weight TYPE p LENGTH 8 DECIMALS 2,
END OF ty_item,
tt_item TYPE STANDARD TABLE OF ty_item WITH EMPTY KEY,
BEGIN OF ty_tour,
tour_id TYPE c LENGTH 4,
stops TYPE i,
packages TYPE i,
weight TYPE p LENGTH 8 DECIMALS 2,
END OF ty_tour,
tt_tour TYPE STANDARD TABLE OF ty_tour WITH EMPTY KEY.
METHODS add_item
IMPORTING iv_tour_id TYPE c LENGTH 4
iv_stop_no TYPE i
iv_customer TYPE c LENGTH 10
iv_packages TYPE i
iv_weight TYPE p LENGTH 8 DECIMALS 2
RETURNING VALUE(rv_status) TYPE ty_status.
METHODS remove_tour
IMPORTING iv_tour_id TYPE c LENGTH 4
RETURNING VALUE(rv_count) TYPE i.
METHODS items
RETURNING VALUE(rt_item) TYPE tt_item.
METHODS stops_of_tour
IMPORTING iv_tour_id TYPE c LENGTH 4
RETURNING VALUE(rt_item) TYPE tt_item.
METHODS find_stop
IMPORTING iv_tour_id TYPE c LENGTH 4
iv_stop_no TYPE i
RETURNING VALUE(rs_item) TYPE ty_item.
METHODS tour_summary
RETURNING VALUE(rt_tour) TYPE tt_tour.
ENDINTERFACE.

View File

@@ -0,0 +1,118 @@
# 1. Goal
A transportation planner collects the stops of delivery tours. The planner needs one
class that stores the stops and reports the load of each tour.
# 2. Open questions
None.
# 3. Context
- The class {{P}}TOUR_PLANNER is new. Create it in package $TMP.
- A tour ID has 4 characters, for example T001. A stop number is a whole number.
A customer number has 10 characters. The weight is in kilograms with 2 decimal
places.
- No other object of this task exists.
# 4. Contract
- Create the class {{P}}TOUR_PLANNER in package $TMP.
- The class is public, final, and has a public constructor without parameters.
- The class has these public elementary types:
TYPES ty_status TYPE c LENGTH 10.
TYPES ty_tour_id TYPE c LENGTH 4.
TYPES ty_customer TYPE c LENGTH 10.
TYPES ty_weight TYPE p LENGTH 8 DECIMALS 2.
- The class has this public constant structure:
CONSTANTS:
BEGIN OF c_status,
ok TYPE ty_status VALUE 'OK',
invalid TYPE ty_status VALUE 'INVALID',
duplicate TYPE ty_status VALUE 'DUPLICATE',
END OF c_status.
- The class has these public structured types:
TYPES:
BEGIN OF ty_item,
tour_id TYPE ty_tour_id,
stop_no TYPE i,
customer TYPE ty_customer,
packages TYPE i,
weight TYPE ty_weight,
END OF ty_item,
tt_item TYPE STANDARD TABLE OF ty_item WITH EMPTY KEY,
BEGIN OF ty_tour,
tour_id TYPE ty_tour_id,
stops TYPE i,
packages TYPE i,
weight TYPE ty_weight,
END OF ty_tour,
tt_tour TYPE STANDARD TABLE OF ty_tour WITH EMPTY KEY.
- The class has these public methods:
METHODS add_item
IMPORTING iv_tour_id TYPE ty_tour_id
iv_stop_no TYPE i
iv_customer TYPE ty_customer
iv_packages TYPE i
iv_weight TYPE ty_weight
RETURNING VALUE(rv_status) TYPE ty_status.
METHODS remove_tour
IMPORTING iv_tour_id TYPE ty_tour_id
RETURNING VALUE(rv_count) TYPE i.
METHODS items
RETURNING VALUE(rt_item) TYPE tt_item.
METHODS stops_of_tour
IMPORTING iv_tour_id TYPE ty_tour_id
RETURNING VALUE(rt_item) TYPE tt_item.
METHODS find_stop
IMPORTING iv_tour_id TYPE ty_tour_id
iv_stop_no TYPE i
RETURNING VALUE(rs_item) TYPE ty_item.
METHODS tour_summary
RETURNING VALUE(rt_tour) TYPE tt_tour.
- Do not add other public methods.
# 5. Business rules
1. The tour ID and the stop number identify a stop.
2. ADD_ITEM stores one stop. It returns INVALID and changes no data if one of these
conditions is true:
- IV_TOUR_ID is empty,
- IV_STOP_NO is smaller than 1,
- IV_PACKAGES is smaller than 0,
- IV_WEIGHT is smaller than 0.
IV_CUSTOMER can be empty.
3. ADD_ITEM returns DUPLICATE and changes no data if a stop with the same tour ID and
the same stop number is already stored. The stored stop keeps its values.
4. Otherwise ADD_ITEM stores the stop and returns OK.
5. ITEMS returns all stored stops, sorted by tour ID ascending and, for the same tour
ID, by stop number ascending.
6. STOPS_OF_TOUR returns the stops of one tour, sorted by stop number ascending. The
result is empty if the tour is not known.
7. FIND_STOP returns the stop with the given tour ID and stop number. If the stop is
not known, all components of the result are initial.
8. TOUR_SUMMARY returns one line for each tour that has at least one stop. A line
contains the tour ID, the number of stops, the sum of the packages and the sum of
the weight. The result is sorted by tour ID ascending.
9. REMOVE_TOUR deletes all stops of the tour and returns the number of deleted stops.
It returns 0 if the tour is not known.
# 6. Constraints
- Release target: 7.58.
- Coding standards: Clean ABAP. Method length below 40 statements. No global variables.
No comment that restates the code.
- Out of scope: do not change objects that are not part of this task.
# 7. Acceptance
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.

View File

@@ -0,0 +1,41 @@
{
"id": "G0001",
"category": "C",
"object_type": "CLAS",
"difficulty": 2,
"release_target": "v758",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [],
"contract": [
{
"type": "CLAS",
"name": "{{P}}TOUR_PLANNER"
}
],
"out_of_scope": [],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T07_HIDDEN",
"file": "hidden/t07_hidden.clas.abap",
"description": "T07 hidden tests for the tour planner"
}
],
"reference": [
{
"type": "CLAS",
"name": "{{P}}TOUR_PLANNER",
"file": "reference/tour_planner.clas.abap",
"description": "Tour planner with stored stops and tour summary",
"testclasses_file": "reference/tour_planner.testclasses.abap"
}
],
"craft_checks": [
"method_length",
"db_operation_in_loop"
]
}

View File

@@ -0,0 +1,25 @@
{
"id": "G0002",
"pool": "eval",
"object_type": "CLAS",
"category": "A",
"attempts": [
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "bundle",
"errors": [
"invalid JSON: Extra data: line 1 column 14723 (char 14722)"
]
},
{
"stage": "validate",
"oracle": 100.0,
"null": 0
}
],
"accepted": true
}

View File

@@ -0,0 +1,132 @@
CLASS {{p}}t02_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CONSTANTS:
c_fri_05 TYPE d VALUE '20240105',
c_sat_06 TYPE d VALUE '20240106',
c_sun_07 TYPE d VALUE '20240107',
c_mon_08 TYPE d VALUE '20240108',
c_tue_09 TYPE d VALUE '20240109',
c_wed_10 TYPE d VALUE '20240110',
c_thu_11 TYPE d VALUE '20240111',
c_fri_12 TYPE d VALUE '20240112'.
DATA mo_cut TYPE REF TO {{p}}delivery_schedule.
DATA mt_holidays TYPE {{p}}delivery_schedule=>ty_holidays.
DATA mt_no_holidays TYPE {{p}}delivery_schedule=>ty_holidays.
METHODS setup.
METHODS weekend_is_not_working FOR TESTING.
METHODS working_day_is_true FOR TESTING.
METHODS holiday_is_not_working FOR TESTING.
METHODS next_day_same_for_workday FOR TESTING.
METHODS next_day_from_weekend FOR TESTING.
METHODS next_day_skips_holidays FOR TESTING.
METHODS add_zero_days FOR TESTING.
METHODS add_days_forward FOR TESTING.
METHODS add_forward_skips_holiday FOR TESTING.
METHODS add_days_backward FOR TESTING.
METHODS count_working_days_inclusive FOR TESTING.
METHODS count_reversed_range_is_zero FOR TESTING.
ENDCLASS.
CLASS {{p}}t02_hidden IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}delivery_schedule( ).
mt_holidays = VALUE #( ( c_tue_09 ) ( c_wed_10 ) ).
ENDMETHOD.
METHOD weekend_is_not_working.
cl_abap_unit_assert=>assert_equals(
exp = abap_false
act = mo_cut->is_working_day( iv_date = c_sat_06 it_holidays = mt_no_holidays )
msg = 'Saturday is not a working day' ).
cl_abap_unit_assert=>assert_equals(
exp = abap_false
act = mo_cut->is_working_day( iv_date = c_sun_07 it_holidays = mt_no_holidays )
msg = 'Sunday is not a working day' ).
ENDMETHOD.
METHOD working_day_is_true.
cl_abap_unit_assert=>assert_equals(
exp = abap_true
act = mo_cut->is_working_day( iv_date = c_mon_08 it_holidays = mt_holidays ) ).
ENDMETHOD.
METHOD holiday_is_not_working.
cl_abap_unit_assert=>assert_equals(
exp = abap_false
act = mo_cut->is_working_day( iv_date = c_tue_09 it_holidays = mt_holidays ) ).
ENDMETHOD.
METHOD next_day_same_for_workday.
cl_abap_unit_assert=>assert_equals(
exp = c_mon_08
act = mo_cut->next_working_day( iv_date = c_mon_08 it_holidays = mt_holidays ) ).
ENDMETHOD.
METHOD next_day_from_weekend.
cl_abap_unit_assert=>assert_equals(
exp = c_mon_08
act = mo_cut->next_working_day( iv_date = c_sat_06 it_holidays = mt_no_holidays ) ).
ENDMETHOD.
METHOD next_day_skips_holidays.
cl_abap_unit_assert=>assert_equals(
exp = c_thu_11
act = mo_cut->next_working_day( iv_date = c_tue_09 it_holidays = mt_holidays ) ).
ENDMETHOD.
METHOD add_zero_days.
cl_abap_unit_assert=>assert_equals(
exp = c_sat_06
act = mo_cut->add_working_days( iv_start = c_sat_06 iv_days = 0 it_holidays = mt_holidays ) ).
ENDMETHOD.
METHOD add_days_forward.
cl_abap_unit_assert=>assert_equals(
exp = c_tue_09
act = mo_cut->add_working_days( iv_start = c_fri_05 iv_days = 2 it_holidays = mt_no_holidays ) ).
ENDMETHOD.
METHOD add_forward_skips_holiday.
cl_abap_unit_assert=>assert_equals(
exp = c_thu_11
act = mo_cut->add_working_days( iv_start = c_fri_05 iv_days = 2 it_holidays = mt_holidays ) ).
ENDMETHOD.
METHOD add_days_backward.
cl_abap_unit_assert=>assert_equals(
exp = c_fri_05
act = mo_cut->add_working_days( iv_start = c_mon_08 iv_days = -1 it_holidays = mt_no_holidays ) ).
ENDMETHOD.
METHOD count_working_days_inclusive.
cl_abap_unit_assert=>assert_equals(
exp = 5
act = mo_cut->count_working_days( iv_from = c_mon_08 iv_to = c_fri_12 it_holidays = mt_no_holidays )
msg = 'Monday to Friday without holidays' ).
cl_abap_unit_assert=>assert_equals(
exp = 3
act = mo_cut->count_working_days( iv_from = c_mon_08 iv_to = c_fri_12 it_holidays = mt_holidays )
msg = 'Two holidays in the interval' ).
cl_abap_unit_assert=>assert_equals(
exp = 1
act = mo_cut->count_working_days( iv_from = c_mon_08 iv_to = c_mon_08 it_holidays = mt_no_holidays )
msg = 'One working day' ).
cl_abap_unit_assert=>assert_equals(
exp = 0
act = mo_cut->count_working_days( iv_from = c_tue_09 iv_to = c_tue_09 it_holidays = mt_holidays )
msg = 'One holiday' ).
ENDMETHOD.
METHOD count_reversed_range_is_zero.
cl_abap_unit_assert=>assert_equals(
exp = 0
act = mo_cut->count_working_days( iv_from = c_fri_12 iv_to = c_mon_08 it_holidays = mt_holidays ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,104 @@
CLASS {{p}}delivery_schedule DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_holidays TYPE STANDARD TABLE OF d WITH EMPTY KEY.
METHODS is_working_day
IMPORTING iv_date TYPE d
it_holidays TYPE ty_holidays
RETURNING VALUE(rv_working) TYPE abap_bool.
METHODS next_working_day
IMPORTING iv_date TYPE d
it_holidays TYPE ty_holidays
RETURNING VALUE(rv_date) TYPE d.
METHODS add_working_days
IMPORTING iv_start TYPE d
iv_days TYPE i
it_holidays TYPE ty_holidays
RETURNING VALUE(rv_date) TYPE d.
METHODS count_working_days
IMPORTING iv_from TYPE d
iv_to TYPE d
it_holidays TYPE ty_holidays
RETURNING VALUE(rv_count) TYPE i.
PRIVATE SECTION.
CONSTANTS c_reference_monday TYPE d VALUE '19000101'.
METHODS is_weekend
IMPORTING iv_date TYPE d
RETURNING VALUE(rv_weekend) TYPE abap_bool.
METHODS is_holiday
IMPORTING iv_date TYPE d
it_holidays TYPE ty_holidays
RETURNING VALUE(rv_holiday) TYPE abap_bool.
ENDCLASS.
CLASS {{p}}delivery_schedule IMPLEMENTATION.
METHOD is_working_day.
rv_working = xsdbool( is_weekend( iv_date ) = abap_false
AND is_holiday( iv_date = iv_date
it_holidays = it_holidays ) = abap_false ).
ENDMETHOD.
METHOD next_working_day.
rv_date = iv_date.
WHILE is_working_day( iv_date = rv_date
it_holidays = it_holidays ) = abap_false.
rv_date = rv_date + 1.
ENDWHILE.
ENDMETHOD.
METHOD add_working_days.
rv_date = iv_start.
IF iv_days = 0.
RETURN.
ENDIF.
DATA(lv_remaining) = iv_days.
DATA(lv_step) = COND i( WHEN iv_days > 0 THEN 1 ELSE -1 ).
WHILE lv_remaining <> 0.
rv_date = rv_date + lv_step.
IF is_working_day( iv_date = rv_date
it_holidays = it_holidays ) = abap_true.
lv_remaining = lv_remaining - lv_step.
ENDIF.
ENDWHILE.
ENDMETHOD.
METHOD count_working_days.
rv_count = 0.
DATA(lv_date) = iv_from.
WHILE lv_date <= iv_to.
IF is_working_day( iv_date = lv_date
it_holidays = it_holidays ) = abap_true.
rv_count = rv_count + 1.
ENDIF.
lv_date = lv_date + 1.
ENDWHILE.
ENDMETHOD.
METHOD is_weekend.
DATA(lv_days) = iv_date - c_reference_monday.
rv_weekend = xsdbool( lv_days MOD 7 >= 5 ).
ENDMETHOD.
METHOD is_holiday.
rv_holiday = abap_false.
LOOP AT it_holidays INTO DATA(lv_holiday).
IF lv_holiday = iv_date.
rv_holiday = abap_true.
RETURN.
ENDIF.
ENDLOOP.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,72 @@
CLASS ltc_delivery_schedule DEFINITION FINAL FOR TESTING
DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CONSTANTS:
c_fri_05 TYPE d VALUE '20240105',
c_sat_06 TYPE d VALUE '20240106',
c_sun_07 TYPE d VALUE '20240107',
c_mon_08 TYPE d VALUE '20240108',
c_tue_09 TYPE d VALUE '20240109',
c_wed_10 TYPE d VALUE '20240110',
c_thu_11 TYPE d VALUE '20240111',
c_fri_12 TYPE d VALUE '20240112'.
DATA mo_cut TYPE REF TO {{p}}delivery_schedule.
DATA mt_holidays TYPE {{p}}delivery_schedule=>ty_holidays.
DATA mt_no_holidays TYPE {{p}}delivery_schedule=>ty_holidays.
METHODS setup.
METHODS weekend_is_not_working FOR TESTING.
METHODS holiday_is_not_working FOR TESTING.
METHODS next_day_skips_weekend FOR TESTING.
METHODS add_days_forward FOR TESTING.
METHODS add_days_backward FOR TESTING.
METHODS count_working_days FOR TESTING.
ENDCLASS.
CLASS ltc_delivery_schedule IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}delivery_schedule( ).
mt_holidays = VALUE #( ( c_tue_09 ) ( c_wed_10 ) ).
ENDMETHOD.
METHOD weekend_is_not_working.
cl_abap_unit_assert=>assert_equals(
exp = abap_false
act = mo_cut->is_working_day( iv_date = c_sat_06 it_holidays = mt_no_holidays ) ).
ENDMETHOD.
METHOD holiday_is_not_working.
cl_abap_unit_assert=>assert_equals(
exp = abap_false
act = mo_cut->is_working_day( iv_date = c_tue_09 it_holidays = mt_holidays ) ).
ENDMETHOD.
METHOD next_day_skips_weekend.
cl_abap_unit_assert=>assert_equals(
exp = c_mon_08
act = mo_cut->next_working_day( iv_date = c_sun_07 it_holidays = mt_holidays ) ).
ENDMETHOD.
METHOD add_days_forward.
cl_abap_unit_assert=>assert_equals(
exp = c_thu_11
act = mo_cut->add_working_days( iv_start = c_fri_05 iv_days = 2 it_holidays = mt_holidays ) ).
ENDMETHOD.
METHOD add_days_backward.
cl_abap_unit_assert=>assert_equals(
exp = c_fri_05
act = mo_cut->add_working_days( iv_start = c_mon_08 iv_days = -1 it_holidays = mt_holidays ) ).
ENDMETHOD.
METHOD count_working_days.
cl_abap_unit_assert=>assert_equals(
exp = 3
act = mo_cut->count_working_days( iv_from = c_mon_08 iv_to = c_fri_12 it_holidays = mt_holidays ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,84 @@
# 1. Goal
Calculate delivery dates for sales orders. A delivery date must be a working day.
Weekends and plant holidays are not working days. A planner uses the class before
the system confirms a delivery date.
# 2. Open questions
None.
# 3. Context
- The class {{P}}DELIVERY_SCHEDULE does not exist. Create it in package $TMP.
- The caller gives the plant holidays as a table of dates. The class does not read
a factory calendar. The class does not read the system date.
# 4. Contract
- Create the class {{P}}DELIVERY_SCHEDULE in package $TMP.
- The class is public, final, and has a public constructor without parameters.
- The class has the public type TY_HOLIDAYS. TY_HOLIDAYS is a standard table of
dates (TYPE d) with an empty key.
- The class has the public methods below. Do not add other public methods.
```abap
METHODS is_working_day
IMPORTING iv_date TYPE d
it_holidays TYPE ty_holidays
RETURNING VALUE(rv_working) TYPE abap_bool.
METHODS next_working_day
IMPORTING iv_date TYPE d
it_holidays TYPE ty_holidays
RETURNING VALUE(rv_date) TYPE d.
METHODS add_working_days
IMPORTING iv_start TYPE d
iv_days TYPE i
it_holidays TYPE ty_holidays
RETURNING VALUE(rv_date) TYPE d.
METHODS count_working_days
IMPORTING iv_from TYPE d
iv_to TYPE d
it_holidays TYPE ty_holidays
RETURNING VALUE(rv_count) TYPE i.
```
# 5. Business rules
1. The days of the week are Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,
Sunday.
2. A date is a working day when these two conditions are true:
- The date is not a Saturday and not a Sunday.
- The date is not in it_holidays.
3. IS_WORKING_DAY returns abap_true for a working day. It returns abap_false for
all other days.
4. NEXT_WORKING_DAY returns the first working day that is on iv_date or after
iv_date.
5. ADD_WORKING_DAYS counts working days.
- If iv_days is 0, the result is iv_start.
- If iv_days is greater than 0, the result is the date that is iv_days working
days after iv_start. Count only working days. Ignore all other days.
- If iv_days is less than 0, the result is the date that is the absolute value
of iv_days working days before iv_start. Count only working days. Ignore all
other days.
- Example: iv_start is a Friday and iv_days is 1. The result is the next Monday.
- Example: iv_start is a Monday and iv_days is -1. The result is the Friday
before.
6. COUNT_WORKING_DAYS counts the working days in the interval from iv_from to
iv_to. The interval contains iv_from and iv_to.
- If iv_from is after iv_to, the result is 0.
- If iv_from is equal to iv_to, the result is 1 for a working day and 0 for all
other days.
7. it_holidays can be empty. it_holidays can contain dates that are outside the
interval. it_holidays can contain the same date more than one time. A date that
occurs more than one time in it_holidays is a holiday.
# 6. Constraints
- Release target: 8.16.
- Coding standards: Clean ABAP. A method has less than 40 statements. No global
variables. No comment that restates the code.
- Out of scope: do not read a factory calendar. Do not read the system date. Do
not create other objects.
# 7. Acceptance
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.

View File

@@ -0,0 +1,41 @@
{
"id": "G0002",
"category": "A",
"object_type": "CLAS",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 50,
"max_activations": 12
},
"seed": [],
"contract": [
{
"type": "CLAS",
"name": "{{P}}DELIVERY_SCHEDULE"
}
],
"out_of_scope": [],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T02_HIDDEN",
"file": "hidden/t02_hidden.clas.abap",
"description": "Working day and delivery date rules"
}
],
"reference": [
{
"type": "CLAS",
"name": "{{P}}DELIVERY_SCHEDULE",
"file": "reference/delivery_schedule.clas.abap",
"description": "Delivery date calculation with weekends and plant holidays",
"testclasses_file": "reference/delivery_schedule.testclasses.abap"
}
],
"craft_checks": [
"method_length",
"no_global_variables"
]
}