Step F first pass: 81/92 accepted; budget floor 60 calls; rejected slots moved for regeneration
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
CLASS ltc_expense_validator DEFINITION FINAL FOR TESTING
|
||||
DURATION SHORT RISK LEVEL HARMLESS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES ty_amount TYPE {{p}}if_expense_claim=>ty_amount.
|
||||
|
||||
DATA mo_cut TYPE REF TO {{p}}expense_validator.
|
||||
|
||||
METHODS setup.
|
||||
METHODS valid_claim FOR TESTING.
|
||||
METHODS zero_amount FOR TESTING.
|
||||
METHODS unknown_currency FOR TESTING.
|
||||
METHODS future_date FOR TESTING.
|
||||
METHODS receipt_missing FOR TESTING.
|
||||
METHODS cost_center_missing FOR TESTING.
|
||||
|
||||
METHODS build_claim
|
||||
IMPORTING iv_amount TYPE ty_amount
|
||||
iv_currency TYPE {{p}}if_expense_claim=>ty_currency
|
||||
iv_date TYPE d
|
||||
iv_cc TYPE {{p}}if_expense_claim=>ty_cost_center
|
||||
iv_receipt TYPE abap_bool
|
||||
RETURNING VALUE(rs_claim) TYPE {{p}}if_expense_claim=>ty_claim.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_expense_validator IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}expense_validator( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD build_claim.
|
||||
rs_claim = VALUE #( amount = iv_amount
|
||||
currency = iv_currency
|
||||
claim_date = iv_date
|
||||
cost_center = iv_cc
|
||||
has_receipt = iv_receipt ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_claim.
|
||||
DATA(ls_claim) = build_claim( iv_amount = '250.00' iv_currency = 'EUR'
|
||||
iv_date = sy-datum iv_cc = 'CC1000'
|
||||
iv_receipt = abap_true ).
|
||||
TRY.
|
||||
mo_cut->validate( ls_claim ).
|
||||
CATCH {{p}}cx_claim_error INTO DATA(lx).
|
||||
cl_abap_unit_assert=>fail( msg = lx->get_message( ) ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_amount.
|
||||
DATA(ls_claim) = build_claim( iv_amount = 0 iv_currency = 'EUR'
|
||||
iv_date = sy-datum iv_cc = 'CC1000'
|
||||
iv_receipt = abap_true ).
|
||||
TRY.
|
||||
mo_cut->validate( ls_claim ).
|
||||
cl_abap_unit_assert=>fail( msg = 'Exception expected' ).
|
||||
CATCH {{p}}cx_claim_amount INTO DATA(lx).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '0.00' )
|
||||
act = lx->mv_amount ).
|
||||
CATCH {{p}}cx_claim_error INTO DATA(lx_other).
|
||||
cl_abap_unit_assert=>fail( msg = lx_other->get_message( ) ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_currency.
|
||||
DATA(ls_claim) = build_claim( iv_amount = '250.00' iv_currency = 'JPY'
|
||||
iv_date = sy-datum iv_cc = 'CC1000'
|
||||
iv_receipt = abap_true ).
|
||||
TRY.
|
||||
mo_cut->validate( ls_claim ).
|
||||
cl_abap_unit_assert=>fail( msg = 'Exception expected' ).
|
||||
CATCH {{p}}cx_claim_currency INTO DATA(lx).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'JPY'
|
||||
act = lx->mv_currency ).
|
||||
CATCH {{p}}cx_claim_error INTO DATA(lx_other).
|
||||
cl_abap_unit_assert=>fail( msg = lx_other->get_message( ) ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD future_date.
|
||||
DATA lv_future TYPE d.
|
||||
lv_future = sy-datum + 1.
|
||||
DATA(ls_claim) = build_claim( iv_amount = '250.00' iv_currency = 'EUR'
|
||||
iv_date = lv_future iv_cc = 'CC1000'
|
||||
iv_receipt = abap_true ).
|
||||
TRY.
|
||||
mo_cut->validate( ls_claim ).
|
||||
cl_abap_unit_assert=>fail( msg = 'Exception expected' ).
|
||||
CATCH {{p}}cx_claim_date INTO DATA(lx).
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_future
|
||||
act = lx->mv_claim_date ).
|
||||
CATCH {{p}}cx_claim_error INTO DATA(lx_other).
|
||||
cl_abap_unit_assert=>fail( msg = lx_other->get_message( ) ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD receipt_missing.
|
||||
DATA(ls_claim) = build_claim( iv_amount = '250.00' iv_currency = 'EUR'
|
||||
iv_date = sy-datum iv_cc = 'CC1000'
|
||||
iv_receipt = abap_false ).
|
||||
TRY.
|
||||
mo_cut->validate( ls_claim ).
|
||||
cl_abap_unit_assert=>fail( msg = 'Exception expected' ).
|
||||
CATCH {{p}}cx_claim_receipt INTO DATA(lx).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'Receipt is required'
|
||||
act = lx->get_message( ) ).
|
||||
CATCH {{p}}cx_claim_error INTO DATA(lx_other).
|
||||
cl_abap_unit_assert=>fail( msg = lx_other->get_message( ) ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD cost_center_missing.
|
||||
DATA(ls_claim) = build_claim( iv_amount = '1500.00' iv_currency = 'EUR'
|
||||
iv_date = sy-datum iv_cc = ''
|
||||
iv_receipt = abap_true ).
|
||||
TRY.
|
||||
mo_cut->validate( ls_claim ).
|
||||
cl_abap_unit_assert=>fail( msg = 'Exception expected' ).
|
||||
CATCH {{p}}cx_claim_costcenter INTO DATA(lx).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'Cost center is required'
|
||||
act = lx->get_message( ) ).
|
||||
CATCH {{p}}cx_claim_error INTO DATA(lx_other).
|
||||
cl_abap_unit_assert=>fail( msg = lx_other->get_message( ) ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user