Files
abap-llm/tasks_gen/eval/G0005/reference/freight_calc.testclasses.abap
Kral 5de5e2851c 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>
2026-10-03 05:04:23 +02:00

99 lines
3.9 KiB
ABAP

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.