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:
237
tasks_gen/eval/G0184/hidden/d01_hidden.clas.abap
Normal file
237
tasks_gen/eval/G0184/hidden/d01_hidden.clas.abap
Normal file
@@ -0,0 +1,237 @@
|
||||
CLASS {{p}}d01_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
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_passes FOR TESTING.
|
||||
METHODS zero_amount_rejected FOR TESTING.
|
||||
METHODS negative_amount_rejected FOR TESTING.
|
||||
METHODS unknown_currency_rejected FOR TESTING.
|
||||
METHODS future_date_rejected FOR TESTING.
|
||||
METHODS today_is_accepted FOR TESTING.
|
||||
METHODS receipt_required FOR TESTING.
|
||||
METHODS receipt_not_required_below FOR TESTING.
|
||||
METHODS cost_center_required FOR TESTING.
|
||||
METHODS cost_center_not_required FOR TESTING.
|
||||
METHODS amount_rule_has_priority FOR TESTING.
|
||||
METHODS receipt_rule_has_priority FOR TESTING.
|
||||
METHODS other_currencies_pass 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 {{p}}d01_hidden 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_passes.
|
||||
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 other_currencies_pass.
|
||||
LOOP AT VALUE string_table( ( `USD` ) ( `GBP` ) ( `CHF` ) ) INTO DATA(lv_currency).
|
||||
DATA(ls_claim) = build_claim( iv_amount = '250.00' iv_currency = CONV #( lv_currency )
|
||||
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 = |{ lv_currency }: { lx->get_message( ) }| ).
|
||||
ENDTRY.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_amount_rejected.
|
||||
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 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'Amount must be positive'
|
||||
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 negative_amount_rejected.
|
||||
DATA(ls_claim) = build_claim( iv_amount = '-50.00' 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( '-50.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_rejected.
|
||||
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 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'Currency is not supported'
|
||||
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 future_date_rejected.
|
||||
DATA lv_tomorrow TYPE d.
|
||||
lv_tomorrow = sy-datum + 1.
|
||||
DATA(ls_claim) = build_claim( iv_amount = '250.00' iv_currency = 'EUR'
|
||||
iv_date = lv_tomorrow 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_tomorrow
|
||||
act = lx->mv_claim_date ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'Claim date is in the future'
|
||||
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 today_is_accepted.
|
||||
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 receipt_required.
|
||||
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 = CONV ty_amount( '250.00' )
|
||||
act = lx->mv_amount ).
|
||||
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 receipt_not_required_below.
|
||||
DATA(ls_claim) = build_claim( iv_amount = '99.99' iv_currency = 'EUR'
|
||||
iv_date = sy-datum iv_cc = 'CC1000'
|
||||
iv_receipt = abap_false ).
|
||||
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 cost_center_required.
|
||||
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 = CONV ty_amount( '1500.00' )
|
||||
act = lx->mv_amount ).
|
||||
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.
|
||||
|
||||
METHOD cost_center_not_required.
|
||||
DATA(ls_claim) = build_claim( iv_amount = '999.99' iv_currency = 'EUR'
|
||||
iv_date = sy-datum iv_cc = ''
|
||||
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 amount_rule_has_priority.
|
||||
DATA lv_future TYPE d.
|
||||
lv_future = sy-datum + 1.
|
||||
DATA(ls_claim) = build_claim( iv_amount = 0 iv_currency = 'JPY'
|
||||
iv_date = lv_future iv_cc = ''
|
||||
iv_receipt = abap_false ).
|
||||
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 receipt_rule_has_priority.
|
||||
DATA(ls_claim) = build_claim( iv_amount = '1500.00' iv_currency = 'EUR'
|
||||
iv_date = sy-datum iv_cc = ''
|
||||
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 = CONV ty_amount( '1500.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.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user