Generator: pilot analysis and fixes; G0002-G0021 tasks; handover notes merged
- Static bundle checks (name length, seed type, reserved words, contract test classes, testclasses_file), local abaplint parser check before SAP, max_tokens, robust JSON parse - Runner: G2 for CDS views with parameters, contract_check detail in report - G0020 and G0013 fixed by review and revalidated (oracle 100, null 0) - Pilot results in docs/faz1-tasarim.md 11e; handover notes merged into CLAUDE.md and docs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
29
tasks_gen/eval/G0005/generation.json
Normal file
29
tasks_gen/eval/G0005/generation.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"id": "G0005",
|
||||
"pool": "eval",
|
||||
"object_type": "CLAS",
|
||||
"category": "D",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": null,
|
||||
"null": null
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
}
|
||||
],
|
||||
"accepted": false
|
||||
}
|
||||
158
tasks_gen/eval/G0005/hidden/t02_hidden.clas.abap
Normal file
158
tasks_gen/eval/G0005/hidden/t02_hidden.clas.abap
Normal file
@@ -0,0 +1,158 @@
|
||||
CLASS {{p}}t02_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
TYPES ty_cost TYPE p LENGTH 15 DECIMALS 2.
|
||||
TYPES ty_currency TYPE c LENGTH 5.
|
||||
TYPES ty_zone_code TYPE c LENGTH 4.
|
||||
TYPES ty_weight TYPE p LENGTH 15 DECIMALS 3.
|
||||
|
||||
DATA mo_cut TYPE REF TO {{p}}freight_calc.
|
||||
|
||||
METHODS setup.
|
||||
|
||||
METHODS calculate_result
|
||||
IMPORTING iv_zone_code TYPE ty_zone_code
|
||||
iv_weight_kg TYPE ty_weight
|
||||
iv_express TYPE abap_bool DEFAULT abap_false
|
||||
RETURNING VALUE(rs_result) TYPE {{p}}freight_calc=>ty_result.
|
||||
|
||||
METHODS assert_cost
|
||||
IMPORTING iv_cost TYPE ty_cost
|
||||
iv_currency TYPE ty_currency
|
||||
is_result TYPE {{p}}freight_calc=>ty_result.
|
||||
|
||||
METHODS assert_weight
|
||||
IMPORTING iv_expected TYPE ty_weight
|
||||
iv_actual TYPE ty_weight
|
||||
iv_msg TYPE string.
|
||||
|
||||
METHODS standard_cost FOR TESTING.
|
||||
METHODS express_surcharge FOR TESTING.
|
||||
METHODS express_no_early_rounding FOR TESTING.
|
||||
METHODS minimum_charge FOR TESTING.
|
||||
METHODS rounding FOR TESTING.
|
||||
METHODS zone_code_normalized FOR TESTING.
|
||||
METHODS weight_at_limit FOR TESTING.
|
||||
METHODS unknown_zone FOR TESTING.
|
||||
METHODS invalid_weight FOR TESTING.
|
||||
METHODS weight_limit FOR TESTING.
|
||||
METHODS weight_check_before_zone_lookup FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t02_hidden IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}freight_calc( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD calculate_result.
|
||||
TRY.
|
||||
rs_result = mo_cut->calculate( iv_zone_code = iv_zone_code
|
||||
iv_weight_kg = iv_weight_kg
|
||||
iv_express = iv_express ).
|
||||
CATCH {{p}}cx_freight_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>fail( msg = lo_error->get_reason_text( ) ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_cost.
|
||||
cl_abap_unit_assert=>assert_equals( exp = iv_cost act = is_result-cost msg = 'cost' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = iv_currency act = is_result-currency msg = 'currency' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_weight.
|
||||
cl_abap_unit_assert=>assert_equals( exp = iv_expected act = iv_actual msg = iv_msg ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD standard_cost.
|
||||
DATA(ls_result) = calculate_result( iv_zone_code = 'DE01' iv_weight_kg = '10.000' ).
|
||||
assert_cost( iv_cost = '17.00' iv_currency = 'EUR' is_result = ls_result ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD express_surcharge.
|
||||
DATA(ls_result) = calculate_result( iv_zone_code = 'DE01'
|
||||
iv_weight_kg = '10.000'
|
||||
iv_express = abap_true ).
|
||||
assert_cost( iv_cost = '25.50' iv_currency = 'EUR' is_result = ls_result ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD express_no_early_rounding.
|
||||
DATA(ls_result) = calculate_result( iv_zone_code = 'DE01'
|
||||
iv_weight_kg = '10.004'
|
||||
iv_express = abap_true ).
|
||||
assert_cost( iv_cost = '25.51' iv_currency = 'EUR' is_result = ls_result ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD minimum_charge.
|
||||
DATA(ls_result) = calculate_result( iv_zone_code = 'DE01' iv_weight_kg = '0.500' ).
|
||||
assert_cost( iv_cost = '6.00' iv_currency = 'EUR' is_result = ls_result ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rounding.
|
||||
DATA(ls_result) = calculate_result( iv_zone_code = 'FR01' iv_weight_kg = '1.234' ).
|
||||
assert_cost( iv_cost = '12.09' iv_currency = 'EUR' is_result = ls_result ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zone_code_normalized.
|
||||
DATA(ls_result) = calculate_result( iv_zone_code = 'de01' iv_weight_kg = '10.000' ).
|
||||
assert_cost( iv_cost = '17.00' iv_currency = 'EUR' is_result = ls_result ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weight_at_limit.
|
||||
DATA(ls_result) = calculate_result( iv_zone_code = 'CN01' iv_weight_kg = '20.000' ).
|
||||
assert_cost( iv_cost = '103.00' iv_currency = 'CNY' is_result = ls_result ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_zone.
|
||||
TRY.
|
||||
mo_cut->calculate( iv_zone_code = 'xx99' iv_weight_kg = '1.000' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'CX_UNKNOWN_ZONE expected' ).
|
||||
CATCH {{p}}cx_unknown_zone INTO DATA(lo_unknown).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'XX99' act = lo_unknown->mv_zone_code ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Zone XX99 is not known`
|
||||
act = lo_unknown->get_reason_text( ) ).
|
||||
CATCH {{p}}cx_freight_error INTO DATA(lo_other).
|
||||
cl_abap_unit_assert=>fail( msg = |Wrong exception class: { lo_other->get_reason_text( ) }| ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_weight.
|
||||
TRY.
|
||||
mo_cut->calculate( iv_zone_code = 'DE01' iv_weight_kg = '0.000' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'CX_INVALID_WEIGHT expected' ).
|
||||
CATCH {{p}}cx_invalid_weight INTO DATA(lo_invalid).
|
||||
assert_weight( iv_expected = '0.000' iv_actual = lo_invalid->mv_weight_kg iv_msg = 'weight' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'DE01' act = lo_invalid->mv_zone_code ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Weight must be greater than zero`
|
||||
act = lo_invalid->get_reason_text( ) ).
|
||||
CATCH {{p}}cx_freight_error INTO DATA(lo_other).
|
||||
cl_abap_unit_assert=>fail( msg = |Wrong exception class: { lo_other->get_reason_text( ) }| ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weight_limit.
|
||||
TRY.
|
||||
mo_cut->calculate( iv_zone_code = 'CN01' iv_weight_kg = '20.001' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'CX_WEIGHT_LIMIT expected' ).
|
||||
CATCH {{p}}cx_weight_limit INTO DATA(lo_limit).
|
||||
assert_weight( iv_expected = '20.001' iv_actual = lo_limit->mv_weight_kg iv_msg = 'weight' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 20 act = lo_limit->mv_max_weight_kg msg = 'max weight' ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'CN01' act = lo_limit->mv_zone_code ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Weight exceeds the zone limit`
|
||||
act = lo_limit->get_reason_text( ) ).
|
||||
CATCH {{p}}cx_freight_error INTO DATA(lo_other).
|
||||
cl_abap_unit_assert=>fail( msg = |Wrong exception class: { lo_other->get_reason_text( ) }| ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weight_check_before_zone_lookup.
|
||||
TRY.
|
||||
mo_cut->calculate( iv_zone_code = 'ZZZZ' iv_weight_kg = '0.000' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'CX_INVALID_WEIGHT expected' ).
|
||||
CATCH {{p}}cx_invalid_weight INTO DATA(lo_invalid).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'ZZZZ' act = lo_invalid->mv_zone_code ).
|
||||
CATCH {{p}}cx_freight_error INTO DATA(lo_other).
|
||||
cl_abap_unit_assert=>fail( msg = |Wrong exception class: { lo_other->get_reason_text( ) }| ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
11
tasks_gen/eval/G0005/reference/cx_freight_error.clas.abap
Normal file
11
tasks_gen/eval/G0005/reference/cx_freight_error.clas.abap
Normal file
@@ -0,0 +1,11 @@
|
||||
CLASS {{p}}cx_freight_error DEFINITION PUBLIC INHERITING FROM cx_static_check ABSTRACT.
|
||||
PUBLIC SECTION.
|
||||
DATA mv_zone_code TYPE c LENGTH 4.
|
||||
|
||||
METHODS get_reason_text ABSTRACT
|
||||
RETURNING VALUE(rv_text) TYPE string.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cx_freight_error IMPLEMENTATION.
|
||||
ENDCLASS.
|
||||
13
tasks_gen/eval/G0005/reference/cx_invalid_weight.clas.abap
Normal file
13
tasks_gen/eval/G0005/reference/cx_invalid_weight.clas.abap
Normal file
@@ -0,0 +1,13 @@
|
||||
CLASS {{p}}cx_invalid_weight DEFINITION PUBLIC INHERITING FROM {{p}}cx_freight_error FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
DATA mv_weight_kg TYPE p LENGTH 15 DECIMALS 3.
|
||||
|
||||
METHODS get_reason_text REDEFINITION.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cx_invalid_weight IMPLEMENTATION.
|
||||
METHOD get_reason_text.
|
||||
rv_text = 'Weight must be greater than zero'.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
11
tasks_gen/eval/G0005/reference/cx_unknown_zone.clas.abap
Normal file
11
tasks_gen/eval/G0005/reference/cx_unknown_zone.clas.abap
Normal file
@@ -0,0 +1,11 @@
|
||||
CLASS {{p}}cx_unknown_zone DEFINITION PUBLIC INHERITING FROM {{p}}cx_freight_error FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
METHODS get_reason_text REDEFINITION.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cx_unknown_zone IMPLEMENTATION.
|
||||
METHOD get_reason_text.
|
||||
rv_text = |Zone { condense( mv_zone_code ) } is not known|.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
14
tasks_gen/eval/G0005/reference/cx_weight_limit.clas.abap
Normal file
14
tasks_gen/eval/G0005/reference/cx_weight_limit.clas.abap
Normal file
@@ -0,0 +1,14 @@
|
||||
CLASS {{p}}cx_weight_limit DEFINITION PUBLIC INHERITING FROM {{p}}cx_freight_error FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
DATA mv_weight_kg TYPE p LENGTH 15 DECIMALS 3.
|
||||
DATA mv_max_weight_kg TYPE i.
|
||||
|
||||
METHODS get_reason_text REDEFINITION.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cx_weight_limit IMPLEMENTATION.
|
||||
METHOD get_reason_text.
|
||||
rv_text = 'Weight exceeds the zone limit'.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
73
tasks_gen/eval/G0005/reference/freight_calc.clas.abap
Normal file
73
tasks_gen/eval/G0005/reference/freight_calc.clas.abap
Normal file
@@ -0,0 +1,73 @@
|
||||
CLASS {{p}}freight_calc DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES ty_cost TYPE p LENGTH 15 DECIMALS 2.
|
||||
TYPES ty_weight TYPE p LENGTH 15 DECIMALS 3.
|
||||
TYPES: BEGIN OF ty_result,
|
||||
cost TYPE ty_cost,
|
||||
currency TYPE c LENGTH 5,
|
||||
END OF ty_result.
|
||||
|
||||
METHODS calculate
|
||||
IMPORTING iv_zone_code TYPE c LENGTH 4
|
||||
iv_weight_kg TYPE ty_weight
|
||||
iv_express TYPE abap_bool DEFAULT abap_false
|
||||
RETURNING VALUE(rs_result) TYPE ty_result
|
||||
RAISING {{p}}cx_freight_error.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS c_express_factor TYPE p LENGTH 5 DECIMALS 2 VALUE '1.50'.
|
||||
CONSTANTS c_minimum_charge TYPE ty_cost VALUE '6.00'.
|
||||
|
||||
METHODS find_zone
|
||||
IMPORTING iv_zone_code TYPE c LENGTH 4
|
||||
RETURNING VALUE(rs_zone) TYPE {{p}}zone_master=>ty_zone
|
||||
RAISING {{p}}cx_freight_error.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}freight_calc IMPLEMENTATION.
|
||||
METHOD calculate.
|
||||
DATA lv_zone_code TYPE c LENGTH 4.
|
||||
lv_zone_code = to_upper( iv_zone_code ).
|
||||
|
||||
IF iv_weight_kg <= 0.
|
||||
DATA(lo_invalid) = NEW {{p}}cx_invalid_weight( ).
|
||||
lo_invalid->mv_zone_code = lv_zone_code.
|
||||
lo_invalid->mv_weight_kg = iv_weight_kg.
|
||||
RAISE EXCEPTION lo_invalid.
|
||||
ENDIF.
|
||||
|
||||
DATA(ls_zone) = find_zone( lv_zone_code ).
|
||||
|
||||
IF iv_weight_kg > ls_zone-max_weight_kg.
|
||||
DATA(lo_limit) = NEW {{p}}cx_weight_limit( ).
|
||||
lo_limit->mv_zone_code = lv_zone_code.
|
||||
lo_limit->mv_weight_kg = iv_weight_kg.
|
||||
lo_limit->mv_max_weight_kg = ls_zone-max_weight_kg.
|
||||
RAISE EXCEPTION lo_limit.
|
||||
ENDIF.
|
||||
|
||||
DATA lv_cost TYPE p LENGTH 15 DECIMALS 5.
|
||||
lv_cost = ls_zone-base_fee + iv_weight_kg * ls_zone-price_per_kg.
|
||||
IF iv_express = abap_true.
|
||||
lv_cost = lv_cost * c_express_factor.
|
||||
ENDIF.
|
||||
lv_cost = round( val = lv_cost dec = 2 ).
|
||||
IF lv_cost < c_minimum_charge.
|
||||
lv_cost = c_minimum_charge.
|
||||
ENDIF.
|
||||
|
||||
rs_result-cost = lv_cost.
|
||||
rs_result-currency = ls_zone-currency.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD find_zone.
|
||||
DATA(lt_zone) = {{p}}zone_master=>get_all( ).
|
||||
READ TABLE lt_zone INTO rs_zone WITH KEY zone_code = iv_zone_code.
|
||||
IF sy-subrc <> 0.
|
||||
DATA(lo_unknown) = NEW {{p}}cx_unknown_zone( ).
|
||||
lo_unknown->mv_zone_code = iv_zone_code.
|
||||
RAISE EXCEPTION lo_unknown.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
98
tasks_gen/eval/G0005/reference/freight_calc.testclasses.abap
Normal file
98
tasks_gen/eval/G0005/reference/freight_calc.testclasses.abap
Normal file
@@ -0,0 +1,98 @@
|
||||
CLASS ltc_freight_calc DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
TYPES ty_cost TYPE p LENGTH 15 DECIMALS 2.
|
||||
TYPES ty_currency TYPE c LENGTH 5.
|
||||
TYPES ty_zone_code TYPE c LENGTH 4.
|
||||
TYPES ty_weight TYPE p LENGTH 15 DECIMALS 3.
|
||||
|
||||
DATA mo_cut TYPE REF TO {{p}}freight_calc.
|
||||
|
||||
METHODS setup.
|
||||
METHODS assert_cost
|
||||
IMPORTING iv_cost TYPE ty_cost
|
||||
iv_currency TYPE ty_currency
|
||||
is_result TYPE {{p}}freight_calc=>ty_result.
|
||||
METHODS calculate_result
|
||||
IMPORTING iv_zone_code TYPE ty_zone_code
|
||||
iv_weight_kg TYPE ty_weight
|
||||
iv_express TYPE abap_bool DEFAULT abap_false
|
||||
RETURNING VALUE(rs_result) TYPE {{p}}freight_calc=>ty_result.
|
||||
METHODS standard_cost FOR TESTING.
|
||||
METHODS express_cost FOR TESTING.
|
||||
METHODS minimum_charge FOR TESTING.
|
||||
METHODS unknown_zone FOR TESTING.
|
||||
METHODS invalid_weight FOR TESTING.
|
||||
METHODS weight_limit FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_freight_calc IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}freight_calc( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_cost.
|
||||
cl_abap_unit_assert=>assert_equals( exp = iv_cost act = is_result-cost ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = iv_currency act = is_result-currency ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD calculate_result.
|
||||
TRY.
|
||||
rs_result = mo_cut->calculate( iv_zone_code = iv_zone_code
|
||||
iv_weight_kg = iv_weight_kg
|
||||
iv_express = iv_express ).
|
||||
CATCH {{p}}cx_freight_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>fail( msg = lo_error->get_reason_text( ) ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD standard_cost.
|
||||
DATA(ls_result) = calculate_result( iv_zone_code = 'DE01' iv_weight_kg = '10.000' ).
|
||||
assert_cost( iv_cost = '17.00' iv_currency = 'EUR' is_result = ls_result ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD express_cost.
|
||||
DATA(ls_result) = calculate_result( iv_zone_code = 'DE01'
|
||||
iv_weight_kg = '10.000'
|
||||
iv_express = abap_true ).
|
||||
assert_cost( iv_cost = '25.50' iv_currency = 'EUR' is_result = ls_result ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD minimum_charge.
|
||||
DATA(ls_result) = calculate_result( iv_zone_code = 'DE01' iv_weight_kg = '0.500' ).
|
||||
assert_cost( iv_cost = '6.00' iv_currency = 'EUR' is_result = ls_result ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_zone.
|
||||
TRY.
|
||||
mo_cut->calculate( iv_zone_code = 'XX99' iv_weight_kg = '1.000' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'CX_UNKNOWN_ZONE expected' ).
|
||||
CATCH {{p}}cx_unknown_zone INTO DATA(lo_unknown).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'XX99' act = lo_unknown->mv_zone_code ).
|
||||
CATCH {{p}}cx_freight_error INTO DATA(lo_other).
|
||||
cl_abap_unit_assert=>fail( msg = |Wrong exception class: { lo_other->get_reason_text( ) }| ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD invalid_weight.
|
||||
TRY.
|
||||
mo_cut->calculate( iv_zone_code = 'DE01' iv_weight_kg = '0.000' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'CX_INVALID_WEIGHT expected' ).
|
||||
CATCH {{p}}cx_invalid_weight INTO DATA(lo_invalid).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'DE01' act = lo_invalid->mv_zone_code ).
|
||||
CATCH {{p}}cx_freight_error INTO DATA(lo_other).
|
||||
cl_abap_unit_assert=>fail( msg = |Wrong exception class: { lo_other->get_reason_text( ) }| ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weight_limit.
|
||||
TRY.
|
||||
mo_cut->calculate( iv_zone_code = 'CN01' iv_weight_kg = '20.001' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'CX_WEIGHT_LIMIT expected' ).
|
||||
CATCH {{p}}cx_weight_limit INTO DATA(lo_limit).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'CN01' act = lo_limit->mv_zone_code ).
|
||||
CATCH {{p}}cx_freight_error INTO DATA(lo_other).
|
||||
cl_abap_unit_assert=>fail( msg = |Wrong exception class: { lo_other->get_reason_text( ) }| ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
18
tasks_gen/eval/G0005/seed/seed_data.clas.abap
Normal file
18
tasks_gen/eval/G0005/seed/seed_data.clas.abap
Normal file
@@ -0,0 +1,18 @@
|
||||
CLASS {{p}}seed_data DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES if_oo_adt_classrun.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}seed_data IMPLEMENTATION.
|
||||
METHOD if_oo_adt_classrun~main.
|
||||
DELETE FROM {{p}}zones.
|
||||
INSERT {{p}}zones FROM TABLE @( VALUE #(
|
||||
( zone_code = 'DE01' country = 'DE' base_fee = '5.00' price_per_kg = '1.20' max_weight_kg = 31 currency = 'EUR' )
|
||||
( zone_code = 'DE02' country = 'DE' base_fee = '8.00' price_per_kg = '1.80' max_weight_kg = 31 currency = 'EUR' )
|
||||
( zone_code = 'FR01' country = 'FR' base_fee = '9.50' price_per_kg = '2.10' max_weight_kg = 30 currency = 'EUR' )
|
||||
( zone_code = 'US01' country = 'US' base_fee = '14.00' price_per_kg = '3.40' max_weight_kg = 25 currency = 'USD' )
|
||||
( zone_code = 'CN01' country = 'CN' base_fee = '18.00' price_per_kg = '4.25' max_weight_kg = 20 currency = 'CNY' ) ) ).
|
||||
out->write( |Zones seeded| ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
27
tasks_gen/eval/G0005/seed/zone_master.clas.abap
Normal file
27
tasks_gen/eval/G0005/seed/zone_master.clas.abap
Normal file
@@ -0,0 +1,27 @@
|
||||
CLASS {{p}}zone_master DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES: BEGIN OF ty_zone,
|
||||
zone_code TYPE c LENGTH 4,
|
||||
country TYPE c LENGTH 2,
|
||||
base_fee TYPE p LENGTH 15 DECIMALS 2,
|
||||
price_per_kg TYPE p LENGTH 15 DECIMALS 2,
|
||||
max_weight_kg TYPE i,
|
||||
currency TYPE c LENGTH 5,
|
||||
END OF ty_zone,
|
||||
tt_zone TYPE SORTED TABLE OF ty_zone WITH UNIQUE KEY zone_code.
|
||||
|
||||
CLASS-METHODS get_all
|
||||
RETURNING VALUE(rt_zone) TYPE tt_zone.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}zone_master IMPLEMENTATION.
|
||||
METHOD get_all.
|
||||
rt_zone = VALUE #(
|
||||
( zone_code = 'DE01' country = 'DE' base_fee = '5.00' price_per_kg = '1.20' max_weight_kg = 31 currency = 'EUR' )
|
||||
( zone_code = 'DE02' country = 'DE' base_fee = '8.00' price_per_kg = '1.80' max_weight_kg = 31 currency = 'EUR' )
|
||||
( zone_code = 'FR01' country = 'FR' base_fee = '9.50' price_per_kg = '2.10' max_weight_kg = 30 currency = 'EUR' )
|
||||
( zone_code = 'US01' country = 'US' base_fee = '14.00' price_per_kg = '3.40' max_weight_kg = 25 currency = 'USD' )
|
||||
( zone_code = 'CN01' country = 'CN' base_fee = '18.00' price_per_kg = '4.25' max_weight_kg = 20 currency = 'CNY' ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
10
tasks_gen/eval/G0005/seed/zones.tabl.abap
Normal file
10
tasks_gen/eval/G0005/seed/zones.tabl.abap
Normal file
@@ -0,0 +1,10 @@
|
||||
@EndUserText.label : 'Zone tariff'
|
||||
define table {{p}}zones {
|
||||
key mandt : abap.clnt not null;
|
||||
key zone_code : abap.char(4) not null;
|
||||
country : abap.char(2) not null;
|
||||
base_fee : abap.dec(15,2) not null;
|
||||
price_per_kg : abap.dec(15,2) not null;
|
||||
max_weight_kg : abap.int4 not null;
|
||||
currency : abap.char(5) not null;
|
||||
}
|
||||
103
tasks_gen/eval/G0005/spec.md
Normal file
103
tasks_gen/eval/G0005/spec.md
Normal file
@@ -0,0 +1,103 @@
|
||||
# 1. Goal
|
||||
A parcel service calculates the freight cost of a parcel from a zone code and a
|
||||
weight. Each rejected input must be reported as its own class-based exception, so
|
||||
that the calling program can react to the exact reason.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- The class {{P}}ZONE_MASTER exists in package $TMP and is active. It provides the
|
||||
zone master data. Do not change it.
|
||||
- {{P}}ZONE_MASTER has these public components:
|
||||
- TYPES TY_ZONE with the components ZONE_CODE (c LENGTH 4), COUNTRY (c LENGTH 2),
|
||||
BASE_FEE (p LENGTH 15 DECIMALS 2), PRICE_PER_KG (p LENGTH 15 DECIMALS 2),
|
||||
MAX_WEIGHT_KG (i), CURRENCY (c LENGTH 5).
|
||||
- TYPES TT_ZONE, a sorted table of TY_ZONE with the unique key ZONE_CODE.
|
||||
- CLASS-METHOD GET_ALL returning the table TT_ZONE.
|
||||
- The zone master data contains these entries:
|
||||
|
||||
| ZONE_CODE | COUNTRY | BASE_FEE | PRICE_PER_KG | MAX_WEIGHT_KG | CURRENCY |
|
||||
| --------- | ------- | -------- | ------------ | ------------- | -------- |
|
||||
| DE01 | DE | 5.00 | 1.20 | 31 | EUR |
|
||||
| DE02 | DE | 8.00 | 1.80 | 31 | EUR |
|
||||
| FR01 | FR | 9.50 | 2.10 | 30 | EUR |
|
||||
| US01 | US | 14.00 | 3.40 | 25 | USD |
|
||||
| CN01 | CN | 18.00 | 4.25 | 20 | CNY |
|
||||
|
||||
# 4. Contract
|
||||
Create these classes in package $TMP.
|
||||
|
||||
{{P}}CX_FREIGHT_ERROR
|
||||
- public, abstract, inherits from CX_STATIC_CHECK.
|
||||
- public attribute MV_ZONE_CODE type c LENGTH 4.
|
||||
- public method GET_REASON_TEXT returning VALUE(rv_text) type string.
|
||||
|
||||
{{P}}CX_UNKNOWN_ZONE
|
||||
- public, inherits from {{P}}CX_FREIGHT_ERROR.
|
||||
|
||||
{{P}}CX_INVALID_WEIGHT
|
||||
- public, inherits from {{P}}CX_FREIGHT_ERROR.
|
||||
- public attribute MV_WEIGHT_KG type p LENGTH 15 DECIMALS 3.
|
||||
|
||||
{{P}}CX_WEIGHT_LIMIT
|
||||
- public, inherits from {{P}}CX_FREIGHT_ERROR.
|
||||
- public attribute MV_WEIGHT_KG type p LENGTH 15 DECIMALS 3.
|
||||
- public attribute MV_MAX_WEIGHT_KG type i.
|
||||
|
||||
GET_REASON_TEXT returns the reason text of the exception. Each of the three
|
||||
concrete exception classes returns its own text, see the business rules.
|
||||
|
||||
{{P}}FREIGHT_CALC
|
||||
- public, final, create public, constructor without parameters.
|
||||
- public type TY_COST (p LENGTH 15 DECIMALS 2).
|
||||
- public type TY_WEIGHT (p LENGTH 15 DECIMALS 3).
|
||||
- public type TY_RESULT with the components COST (type TY_COST) and CURRENCY
|
||||
(c LENGTH 5).
|
||||
- public method CALCULATE:
|
||||
|
||||
IMPORTING iv_zone_code TYPE c LENGTH 4
|
||||
iv_weight_kg TYPE ty_weight
|
||||
iv_express TYPE abap_bool DEFAULT abap_false
|
||||
RETURNING VALUE(rs_result) TYPE ty_result
|
||||
RAISING {{p}}cx_freight_error
|
||||
|
||||
- no other public methods.
|
||||
|
||||
Use the named types of this contract in the method interfaces. Do not write the
|
||||
additions LENGTH or DECIMALS in a method interface.
|
||||
|
||||
# 5. Business rules
|
||||
CALCULATE applies these rules in this sequence.
|
||||
1. Convert the zone code to upper case. Use this value in all further steps and in
|
||||
the attribute MV_ZONE_CODE of every exception.
|
||||
2. If the weight is less than or equal to zero, raise {{P}}CX_INVALID_WEIGHT. Set
|
||||
MV_ZONE_CODE to the zone code and MV_WEIGHT_KG to the given weight.
|
||||
3. Read the zone master data with {{P}}ZONE_MASTER=>GET_ALL and find the entry
|
||||
whose ZONE_CODE equals the zone code. If there is no such entry, raise
|
||||
{{P}}CX_UNKNOWN_ZONE and set MV_ZONE_CODE to the zone code.
|
||||
4. If the weight is greater than MAX_WEIGHT_KG, raise {{P}}CX_WEIGHT_LIMIT. Set
|
||||
MV_ZONE_CODE to the zone code, MV_WEIGHT_KG to the given weight and
|
||||
MV_MAX_WEIGHT_KG to MAX_WEIGHT_KG.
|
||||
5. Calculate the cost as BASE_FEE + weight x PRICE_PER_KG.
|
||||
6. If IV_EXPRESS is ABAP_TRUE, multiply the cost by 1.5.
|
||||
7. Keep the full precision of the cost until this step. Do not round the cost
|
||||
before this step. Round the cost to 2 decimal places with commercial rounding.
|
||||
8. If the rounded cost is less than 6.00, use 6.00.
|
||||
9. Return the cost in COST and the CURRENCY of the zone in CURRENCY.
|
||||
|
||||
GET_REASON_TEXT returns:
|
||||
- in {{P}}CX_UNKNOWN_ZONE: 'Zone ', then the zone code, then ' is not known'.
|
||||
Example: 'Zone XX99 is not known'.
|
||||
- in {{P}}CX_INVALID_WEIGHT: 'Weight must be greater than zero'.
|
||||
- in {{P}}CX_WEIGHT_LIMIT: 'Weight exceeds the zone limit'.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
|
||||
- Coding standards: Clean ABAP. Methods below 40 statements. No global variables.
|
||||
- Out of scope: do not change {{P}}ZONE_MASTER.
|
||||
|
||||
# 7. Acceptance
|
||||
- All classes are active and have no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests for {{P}}FREIGHT_CALC.
|
||||
90
tasks_gen/eval/G0005/task.json
Normal file
90
tasks_gen/eval/G0005/task.json
Normal file
@@ -0,0 +1,90 @@
|
||||
{
|
||||
"id": "G0005",
|
||||
"category": "D",
|
||||
"object_type": "CLAS",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 20
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}ZONE_MASTER",
|
||||
"file": "seed/zone_master.clas.abap",
|
||||
"description": "Zone master data provider"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_FREIGHT_ERROR"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_UNKNOWN_ZONE"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_INVALID_WEIGHT"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_WEIGHT_LIMIT"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}FREIGHT_CALC"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"{{P}}ZONE_MASTER"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T02_HIDDEN",
|
||||
"file": "hidden/t02_hidden.clas.abap",
|
||||
"description": "T02 hidden tests"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_FREIGHT_ERROR",
|
||||
"file": "reference/cx_freight_error.clas.abap",
|
||||
"description": "Abstract base exception"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_UNKNOWN_ZONE",
|
||||
"file": "reference/cx_unknown_zone.clas.abap",
|
||||
"description": "Unknown zone exception"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_INVALID_WEIGHT",
|
||||
"file": "reference/cx_invalid_weight.clas.abap",
|
||||
"description": "Invalid weight exception"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_WEIGHT_LIMIT",
|
||||
"file": "reference/cx_weight_limit.clas.abap",
|
||||
"description": "Weight limit exception"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}FREIGHT_CALC",
|
||||
"file": "reference/freight_calc.clas.abap",
|
||||
"description": "Freight cost calculator",
|
||||
"testclasses_file": "reference/freight_calc.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"exception_handling"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user