Stage 2 summary at 50 accepted trajectories
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
74
tasks_gen/train/G1076/faulty/m0_claim_checker.clas.abap
Normal file
74
tasks_gen/train/G1076/faulty/m0_claim_checker.clas.abap
Normal file
@@ -0,0 +1,74 @@
|
||||
CLASS {{p}}claim_checker DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
ty_policy_id TYPE c LENGTH 10,
|
||||
ty_amount TYPE p LENGTH 8 DECIMALS 2,
|
||||
BEGIN OF ty_claim,
|
||||
policy_id TYPE ty_policy_id,
|
||||
vehicle_age TYPE i,
|
||||
damage TYPE ty_amount,
|
||||
deductible TYPE ty_amount,
|
||||
report_days TYPE i,
|
||||
photo_count TYPE i,
|
||||
END OF ty_claim.
|
||||
|
||||
CONSTANTS c_max_payout TYPE ty_amount VALUE '10000.00'.
|
||||
|
||||
METHODS check_claim
|
||||
IMPORTING is_claim TYPE ty_claim
|
||||
RETURNING VALUE(rv_payout) TYPE ty_amount
|
||||
RAISING {{p}}cx_claim_error.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS validate
|
||||
IMPORTING is_claim TYPE ty_claim
|
||||
RAISING {{p}}cx_claim_error.
|
||||
|
||||
METHODS raise_error
|
||||
IMPORTING iv_reason TYPE {{p}}cx_claim_error=>ty_reason
|
||||
RAISING {{p}}cx_claim_error.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}claim_checker IMPLEMENTATION.
|
||||
METHOD check_claim.
|
||||
validate( is_claim ).
|
||||
rv_payout = is_claim-damage + is_claim-deductible.
|
||||
IF rv_payout > c_max_payout.
|
||||
rv_payout = c_max_payout.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD validate.
|
||||
IF substring( val = is_claim-policy_id len = 1 ) <> 'P'
|
||||
OR substring( val = is_claim-policy_id off = 1 ) CN '0123456789'.
|
||||
raise_error( 'POLICY' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-report_days < 0 OR is_claim-report_days > 14.
|
||||
raise_error( 'LATE' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-vehicle_age < 0 OR is_claim-vehicle_age > 12.
|
||||
raise_error( 'AGED' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-photo_count < 2.
|
||||
raise_error( 'PHOTOS' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-damage <= 0.
|
||||
raise_error( 'DAMAGE' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-deductible < 0 OR is_claim-deductible > is_claim-damage.
|
||||
raise_error( 'DEDUCT' ).
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD raise_error.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_claim_error
|
||||
EXPORTING
|
||||
iv_reason = iv_reason.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
74
tasks_gen/train/G1076/faulty/m3_claim_checker.clas.abap
Normal file
74
tasks_gen/train/G1076/faulty/m3_claim_checker.clas.abap
Normal file
@@ -0,0 +1,74 @@
|
||||
CLASS {{p}}claim_checker DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
ty_policy_id TYPE c LENGTH 10,
|
||||
ty_amount TYPE p LENGTH 8 DECIMALS 2,
|
||||
BEGIN OF ty_claim,
|
||||
policy_id TYPE ty_policy_id,
|
||||
vehicle_age TYPE i,
|
||||
damage TYPE ty_amount,
|
||||
deductible TYPE ty_amount,
|
||||
report_days TYPE i,
|
||||
photo_count TYPE i,
|
||||
END OF ty_claim.
|
||||
|
||||
CONSTANTS c_max_payout TYPE ty_amount VALUE '10000.00'.
|
||||
|
||||
METHODS check_claim
|
||||
IMPORTING is_claim TYPE ty_claim
|
||||
RETURNING VALUE(rv_payout) TYPE ty_amount
|
||||
RAISING {{p}}cx_claim_error.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS validate
|
||||
IMPORTING is_claim TYPE ty_claim
|
||||
RAISING {{p}}cx_claim_error.
|
||||
|
||||
METHODS raise_error
|
||||
IMPORTING iv_reason TYPE {{p}}cx_claim_error=>ty_reason
|
||||
RAISING {{p}}cx_claim_error.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}claim_checker IMPLEMENTATION.
|
||||
METHOD check_claim.
|
||||
validate( is_claim ).
|
||||
rv_payout = is_claim-damage - is_claim-deductible.
|
||||
IF rv_payout > c_max_payout.
|
||||
rv_payout = c_max_payout.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD validate.
|
||||
IF substring( val = is_claim-policy_id len = 1 ) <> 'P'
|
||||
OR substring( val = is_claim-policy_id off = 1 ) CN '0123456789'.
|
||||
raise_error( 'POLICY' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-report_days < 0 AND is_claim-report_days > 14.
|
||||
raise_error( 'LATE' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-vehicle_age < 0 OR is_claim-vehicle_age > 12.
|
||||
raise_error( 'AGED' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-photo_count < 2.
|
||||
raise_error( 'PHOTOS' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-damage <= 0.
|
||||
raise_error( 'DAMAGE' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-deductible < 0 OR is_claim-deductible > is_claim-damage.
|
||||
raise_error( 'DEDUCT' ).
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD raise_error.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_claim_error
|
||||
EXPORTING
|
||||
iv_reason = iv_reason.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
74
tasks_gen/train/G1076/faulty/m4_claim_checker.clas.abap
Normal file
74
tasks_gen/train/G1076/faulty/m4_claim_checker.clas.abap
Normal file
@@ -0,0 +1,74 @@
|
||||
CLASS {{p}}claim_checker DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
ty_policy_id TYPE c LENGTH 10,
|
||||
ty_amount TYPE p LENGTH 8 DECIMALS 2,
|
||||
BEGIN OF ty_claim,
|
||||
policy_id TYPE ty_policy_id,
|
||||
vehicle_age TYPE i,
|
||||
damage TYPE ty_amount,
|
||||
deductible TYPE ty_amount,
|
||||
report_days TYPE i,
|
||||
photo_count TYPE i,
|
||||
END OF ty_claim.
|
||||
|
||||
CONSTANTS c_max_payout TYPE ty_amount VALUE '10000.00'.
|
||||
|
||||
METHODS check_claim
|
||||
IMPORTING is_claim TYPE ty_claim
|
||||
RETURNING VALUE(rv_payout) TYPE ty_amount
|
||||
RAISING {{p}}cx_claim_error.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS validate
|
||||
IMPORTING is_claim TYPE ty_claim
|
||||
RAISING {{p}}cx_claim_error.
|
||||
|
||||
METHODS raise_error
|
||||
IMPORTING iv_reason TYPE {{p}}cx_claim_error=>ty_reason
|
||||
RAISING {{p}}cx_claim_error.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}claim_checker IMPLEMENTATION.
|
||||
METHOD check_claim.
|
||||
validate( is_claim ).
|
||||
rv_payout = is_claim-damage - is_claim-deductible.
|
||||
IF rv_payout > c_max_payout.
|
||||
rv_payout = c_max_payout.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD validate.
|
||||
IF substring( val = is_claim-policy_id len = 1 ) <> 'P'
|
||||
OR substring( val = is_claim-policy_id off = 1 ) CN '0123456789'.
|
||||
raise_error( 'POLICY' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-report_days < 0 OR is_claim-report_days > 14.
|
||||
raise_error( 'LATE' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-vehicle_age < 0 OR is_claim-vehicle_age > 12.
|
||||
raise_error( 'AGED' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-photo_count >= 2.
|
||||
raise_error( 'PHOTOS' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-damage <= 0.
|
||||
raise_error( 'DAMAGE' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-deductible < 0 OR is_claim-deductible > is_claim-damage.
|
||||
raise_error( 'DEDUCT' ).
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD raise_error.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_claim_error
|
||||
EXPORTING
|
||||
iv_reason = iv_reason.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
34
tasks_gen/train/G1076/generation.json
Normal file
34
tasks_gen/train/G1076/generation.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"id": "G1076",
|
||||
"pool": "train",
|
||||
"object_type": "CLAS",
|
||||
"category": "D",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100.0,
|
||||
"null": 0,
|
||||
"mutation": {
|
||||
"valid": 4,
|
||||
"killed": 3,
|
||||
"ok": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"accepted": true
|
||||
}
|
||||
158
tasks_gen/train/G1076/hidden/claim_check_hidden.clas.abap
Normal file
158
tasks_gen/train/G1076/hidden/claim_check_hidden.clas.abap
Normal file
@@ -0,0 +1,158 @@
|
||||
CLASS {{p}}claim_check_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}claim_checker.
|
||||
|
||||
METHODS setup.
|
||||
METHODS valid_claim
|
||||
RETURNING VALUE(rs_claim) TYPE {{p}}claim_checker=>ty_claim.
|
||||
METHODS payout
|
||||
IMPORTING is_claim TYPE {{p}}claim_checker=>ty_claim
|
||||
RETURNING VALUE(rv_payout) TYPE {{p}}claim_checker=>ty_amount.
|
||||
METHODS assert_reason
|
||||
IMPORTING is_claim TYPE {{p}}claim_checker=>ty_claim
|
||||
iv_reason TYPE {{p}}cx_claim_error=>ty_reason.
|
||||
|
||||
METHODS rejects_wrong_prefix FOR TESTING.
|
||||
METHODS rejects_blank_policy FOR TESTING.
|
||||
METHODS rejects_late_report FOR TESTING.
|
||||
METHODS rejects_negative_days FOR TESTING.
|
||||
METHODS rejects_old_vehicle FOR TESTING.
|
||||
METHODS accepts_max_age FOR TESTING.
|
||||
METHODS rejects_few_photos FOR TESTING.
|
||||
METHODS rejects_zero_damage FOR TESTING.
|
||||
METHODS rejects_high_deductible FOR TESTING.
|
||||
METHODS pays_damage_minus_deduct FOR TESTING.
|
||||
METHODS caps_high_payout FOR TESTING.
|
||||
METHODS policy_before_late FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}claim_check_hidden IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}claim_checker( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_claim.
|
||||
rs_claim = VALUE #( policy_id = 'P123456789'
|
||||
vehicle_age = 3
|
||||
damage = '2500.00'
|
||||
deductible = '500.00'
|
||||
report_days = 5
|
||||
photo_count = 3 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD payout.
|
||||
TRY.
|
||||
rv_payout = mo_cut->check_claim( is_claim ).
|
||||
CATCH {{p}}cx_claim_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>fail(
|
||||
msg = |Unexpected rejection { lo_error->mv_reason }| ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_reason.
|
||||
TRY.
|
||||
mo_cut->check_claim( is_claim ).
|
||||
cl_abap_unit_assert=>fail(
|
||||
msg = |No exception with reason { iv_reason }| ).
|
||||
CATCH {{p}}cx_claim_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals( exp = iv_reason
|
||||
act = lo_error->mv_reason
|
||||
msg = 'reason' ).
|
||||
cl_abap_unit_assert=>assert_char_cp( act = lo_error->get_text( )
|
||||
exp = |*{ iv_reason }*|
|
||||
msg = 'message text' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_wrong_prefix.
|
||||
DATA(ls_claim) = valid_claim( ).
|
||||
ls_claim-policy_id = 'X123456789'.
|
||||
assert_reason( is_claim = ls_claim
|
||||
iv_reason = 'POLICY' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_blank_policy.
|
||||
DATA(ls_claim) = valid_claim( ).
|
||||
ls_claim-policy_id = 'P12 456789'.
|
||||
assert_reason( is_claim = ls_claim
|
||||
iv_reason = 'POLICY' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_late_report.
|
||||
DATA(ls_claim) = valid_claim( ).
|
||||
ls_claim-report_days = 15.
|
||||
assert_reason( is_claim = ls_claim
|
||||
iv_reason = 'LATE' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_negative_days.
|
||||
DATA(ls_claim) = valid_claim( ).
|
||||
ls_claim-report_days = -1.
|
||||
assert_reason( is_claim = ls_claim
|
||||
iv_reason = 'LATE' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_old_vehicle.
|
||||
DATA(ls_claim) = valid_claim( ).
|
||||
ls_claim-vehicle_age = 13.
|
||||
assert_reason( is_claim = ls_claim
|
||||
iv_reason = 'AGED' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD accepts_max_age.
|
||||
DATA(ls_claim) = valid_claim( ).
|
||||
ls_claim-vehicle_age = 12.
|
||||
ls_claim-photo_count = 2.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}claim_checker=>ty_amount( '2000.00' )
|
||||
act = payout( ls_claim ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_few_photos.
|
||||
DATA(ls_claim) = valid_claim( ).
|
||||
ls_claim-photo_count = 1.
|
||||
assert_reason( is_claim = ls_claim
|
||||
iv_reason = 'PHOTOS' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_zero_damage.
|
||||
DATA(ls_claim) = valid_claim( ).
|
||||
ls_claim-damage = 0.
|
||||
assert_reason( is_claim = ls_claim
|
||||
iv_reason = 'DAMAGE' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_high_deductible.
|
||||
DATA(ls_claim) = valid_claim( ).
|
||||
ls_claim-deductible = '3000.00'.
|
||||
assert_reason( is_claim = ls_claim
|
||||
iv_reason = 'DEDUCT' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD pays_damage_minus_deduct.
|
||||
DATA(ls_claim) = valid_claim( ).
|
||||
ls_claim-report_days = 14.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}claim_checker=>ty_amount( '2000.00' )
|
||||
act = payout( ls_claim ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD caps_high_payout.
|
||||
DATA(ls_claim) = valid_claim( ).
|
||||
ls_claim-damage = '20000.00'.
|
||||
ls_claim-deductible = '1000.00'.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}claim_checker=>c_max_payout
|
||||
act = payout( ls_claim ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD policy_before_late.
|
||||
DATA(ls_claim) = valid_claim( ).
|
||||
ls_claim-policy_id = 'X123456789'.
|
||||
ls_claim-report_days = 30.
|
||||
assert_reason( is_claim = ls_claim
|
||||
iv_reason = 'POLICY' ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
57
tasks_gen/train/G1076/mutation.json
Normal file
57
tasks_gen/train/G1076/mutation.json
Normal file
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"task": "G1076",
|
||||
"mutants": [
|
||||
{
|
||||
"object": "{{P}}CLAIM_CHECKER",
|
||||
"mutant": "line 36: - -> + (arith)",
|
||||
"status": "killed",
|
||||
"hidden": "10/12",
|
||||
"failed_tests": [
|
||||
"ACCEPTS_MAX_AGE",
|
||||
"PAYS_DAMAGE_MINUS_DEDUCT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CLAIM_CHECKER",
|
||||
"mutant": "line 43: = -> <> (eq)",
|
||||
"status": "invalid",
|
||||
"hidden": "0/0",
|
||||
"failed_tests": []
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CLAIM_CHECKER",
|
||||
"mutant": "line 44: 1 -> 2 (const)",
|
||||
"status": "survived",
|
||||
"hidden": "12/12",
|
||||
"failed_tests": []
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CLAIM_CHECKER",
|
||||
"mutant": "line 48: OR -> AND (logic)",
|
||||
"status": "killed",
|
||||
"hidden": "10/12",
|
||||
"failed_tests": [
|
||||
"REJECTS_LATE_REPORT",
|
||||
"REJECTS_NEGATIVE_DAYS"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CLAIM_CHECKER",
|
||||
"mutant": "line 56: < -> >= (rel)",
|
||||
"status": "killed",
|
||||
"hidden": "6/12",
|
||||
"failed_tests": [
|
||||
"ACCEPTS_MAX_AGE",
|
||||
"CAPS_HIGH_PAYOUT",
|
||||
"PAYS_DAMAGE_MINUS_DEDUCT",
|
||||
"REJECTS_FEW_PHOTOS",
|
||||
"REJECTS_HIGH_DEDUCTIBLE",
|
||||
"REJECTS_ZERO_DAMAGE"
|
||||
]
|
||||
}
|
||||
],
|
||||
"valid": 4,
|
||||
"killed": 3,
|
||||
"kill_rate": 0.75,
|
||||
"ok": true
|
||||
}
|
||||
74
tasks_gen/train/G1076/reference/claim_checker.clas.abap
Normal file
74
tasks_gen/train/G1076/reference/claim_checker.clas.abap
Normal file
@@ -0,0 +1,74 @@
|
||||
CLASS {{p}}claim_checker DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
ty_policy_id TYPE c LENGTH 10,
|
||||
ty_amount TYPE p LENGTH 8 DECIMALS 2,
|
||||
BEGIN OF ty_claim,
|
||||
policy_id TYPE ty_policy_id,
|
||||
vehicle_age TYPE i,
|
||||
damage TYPE ty_amount,
|
||||
deductible TYPE ty_amount,
|
||||
report_days TYPE i,
|
||||
photo_count TYPE i,
|
||||
END OF ty_claim.
|
||||
|
||||
CONSTANTS c_max_payout TYPE ty_amount VALUE '10000.00'.
|
||||
|
||||
METHODS check_claim
|
||||
IMPORTING is_claim TYPE ty_claim
|
||||
RETURNING VALUE(rv_payout) TYPE ty_amount
|
||||
RAISING {{p}}cx_claim_error.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS validate
|
||||
IMPORTING is_claim TYPE ty_claim
|
||||
RAISING {{p}}cx_claim_error.
|
||||
|
||||
METHODS raise_error
|
||||
IMPORTING iv_reason TYPE {{p}}cx_claim_error=>ty_reason
|
||||
RAISING {{p}}cx_claim_error.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}claim_checker IMPLEMENTATION.
|
||||
METHOD check_claim.
|
||||
validate( is_claim ).
|
||||
rv_payout = is_claim-damage - is_claim-deductible.
|
||||
IF rv_payout > c_max_payout.
|
||||
rv_payout = c_max_payout.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD validate.
|
||||
IF substring( val = is_claim-policy_id len = 1 ) <> 'P'
|
||||
OR substring( val = is_claim-policy_id off = 1 ) CN '0123456789'.
|
||||
raise_error( 'POLICY' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-report_days < 0 OR is_claim-report_days > 14.
|
||||
raise_error( 'LATE' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-vehicle_age < 0 OR is_claim-vehicle_age > 12.
|
||||
raise_error( 'AGED' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-photo_count < 2.
|
||||
raise_error( 'PHOTOS' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-damage <= 0.
|
||||
raise_error( 'DAMAGE' ).
|
||||
ENDIF.
|
||||
|
||||
IF is_claim-deductible < 0 OR is_claim-deductible > is_claim-damage.
|
||||
raise_error( 'DEDUCT' ).
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD raise_error.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_claim_error
|
||||
EXPORTING
|
||||
iv_reason = iv_reason.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
132
tasks_gen/train/G1076/reference/claim_checker.testclasses.abap
Normal file
132
tasks_gen/train/G1076/reference/claim_checker.testclasses.abap
Normal file
@@ -0,0 +1,132 @@
|
||||
CLASS ltc_claim_checker DEFINITION FINAL FOR TESTING
|
||||
DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}claim_checker.
|
||||
|
||||
METHODS setup.
|
||||
METHODS claim
|
||||
RETURNING VALUE(rs_claim) TYPE {{p}}claim_checker=>ty_claim.
|
||||
METHODS payout
|
||||
IMPORTING is_claim TYPE {{p}}claim_checker=>ty_claim
|
||||
RETURNING VALUE(rv_payout) TYPE {{p}}claim_checker=>ty_amount.
|
||||
|
||||
METHODS pays_claim FOR TESTING.
|
||||
METHODS caps_payout FOR TESTING.
|
||||
METHODS rejects_policy FOR TESTING.
|
||||
METHODS rejects_late FOR TESTING.
|
||||
METHODS rejects_old_car FOR TESTING.
|
||||
METHODS rejects_photos FOR TESTING.
|
||||
METHODS rejects_damage FOR TESTING.
|
||||
METHODS rejects_deductible FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_claim_checker IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}claim_checker( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD claim.
|
||||
rs_claim = VALUE #( policy_id = 'P123456789'
|
||||
vehicle_age = 3
|
||||
damage = '2500.00'
|
||||
deductible = '500.00'
|
||||
report_days = 5
|
||||
photo_count = 3 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD payout.
|
||||
TRY.
|
||||
rv_payout = mo_cut->check_claim( is_claim ).
|
||||
CATCH {{p}}cx_claim_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>fail(
|
||||
msg = |Unexpected rejection { lo_error->mv_reason }| ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD pays_claim.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = CONV {{p}}claim_checker=>ty_amount( '2000.00' )
|
||||
act = payout( claim( ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD caps_payout.
|
||||
DATA(ls_claim) = claim( ).
|
||||
ls_claim-damage = '50000.00'.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}claim_checker=>c_max_payout
|
||||
act = payout( ls_claim ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_policy.
|
||||
DATA(ls_claim) = claim( ).
|
||||
ls_claim-policy_id = 'X123456789'.
|
||||
TRY.
|
||||
mo_cut->check_claim( ls_claim ).
|
||||
cl_abap_unit_assert=>fail( msg = 'no exception' ).
|
||||
CATCH {{p}}cx_claim_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'POLICY'
|
||||
act = lo_error->mv_reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_late.
|
||||
DATA(ls_claim) = claim( ).
|
||||
ls_claim-report_days = 20.
|
||||
TRY.
|
||||
mo_cut->check_claim( ls_claim ).
|
||||
cl_abap_unit_assert=>fail( msg = 'no exception' ).
|
||||
CATCH {{p}}cx_claim_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'LATE'
|
||||
act = lo_error->mv_reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_old_car.
|
||||
DATA(ls_claim) = claim( ).
|
||||
ls_claim-vehicle_age = 20.
|
||||
TRY.
|
||||
mo_cut->check_claim( ls_claim ).
|
||||
cl_abap_unit_assert=>fail( msg = 'no exception' ).
|
||||
CATCH {{p}}cx_claim_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'AGED'
|
||||
act = lo_error->mv_reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_photos.
|
||||
DATA(ls_claim) = claim( ).
|
||||
ls_claim-photo_count = 0.
|
||||
TRY.
|
||||
mo_cut->check_claim( ls_claim ).
|
||||
cl_abap_unit_assert=>fail( msg = 'no exception' ).
|
||||
CATCH {{p}}cx_claim_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'PHOTOS'
|
||||
act = lo_error->mv_reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_damage.
|
||||
DATA(ls_claim) = claim( ).
|
||||
ls_claim-damage = 0.
|
||||
TRY.
|
||||
mo_cut->check_claim( ls_claim ).
|
||||
cl_abap_unit_assert=>fail( msg = 'no exception' ).
|
||||
CATCH {{p}}cx_claim_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'DAMAGE'
|
||||
act = lo_error->mv_reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_deductible.
|
||||
DATA(ls_claim) = claim( ).
|
||||
ls_claim-deductible = '9000.00'.
|
||||
TRY.
|
||||
mo_cut->check_claim( ls_claim ).
|
||||
cl_abap_unit_assert=>fail( msg = 'no exception' ).
|
||||
CATCH {{p}}cx_claim_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'DEDUCT'
|
||||
act = lo_error->mv_reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
24
tasks_gen/train/G1076/seed/cx_claim_error.clas.abap
Normal file
24
tasks_gen/train/G1076/seed/cx_claim_error.clas.abap
Normal file
@@ -0,0 +1,24 @@
|
||||
CLASS {{p}}cx_claim_error DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
INHERITING FROM cx_static_check.
|
||||
PUBLIC SECTION.
|
||||
TYPES ty_reason TYPE c LENGTH 12.
|
||||
DATA mv_reason TYPE ty_reason READ-ONLY.
|
||||
METHODS constructor
|
||||
IMPORTING iv_reason TYPE ty_reason.
|
||||
METHODS get_text REDEFINITION.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS c_prefix TYPE string VALUE 'Claim rejected:'.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cx_claim_error IMPLEMENTATION.
|
||||
METHOD constructor.
|
||||
super->constructor( ).
|
||||
mv_reason = iv_reason.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_text.
|
||||
result = |{ c_prefix } { mv_reason }|.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
58
tasks_gen/train/G1076/spec.md
Normal file
58
tasks_gen/train/G1076/spec.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# 1. Goal
|
||||
Check a car damage claim of an insurance company before the company pays it.
|
||||
The claims program calls the check for each claim. The check returns the payout
|
||||
amount or it stops with a reason.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- The exception class {{P}}CX_CLAIM_ERROR exists in package $TMP. It is active.
|
||||
- The class inherits from CX_STATIC_CHECK.
|
||||
- The class has the public type TY_REASON (CHAR 12) and the read-only attribute
|
||||
MV_REASON of type TY_REASON.
|
||||
- The constructor of the class has the importing parameter IV_REASON of type
|
||||
TY_REASON.
|
||||
- The class redefines GET_TEXT. The text of the exception contains the reason.
|
||||
|
||||
# 4. Contract
|
||||
- Create the class {{P}}CLAIM_CHECKER in package $TMP.
|
||||
- The class is public, final, and has a public constructor without parameters.
|
||||
- Public types of the class:
|
||||
- TY_POLICY_ID TYPE c LENGTH 10.
|
||||
- TY_AMOUNT TYPE p LENGTH 8 DECIMALS 2.
|
||||
- TY_CLAIM, a structure with the components POLICY_ID (type TY_POLICY_ID),
|
||||
VEHICLE_AGE (type i), DAMAGE (type TY_AMOUNT), DEDUCTIBLE (type TY_AMOUNT),
|
||||
REPORT_DAYS (type i) and PHOTO_COUNT (type i).
|
||||
- The public constant C_MAX_PAYOUT TYPE TY_AMOUNT has the value 10000.00.
|
||||
- One public method:
|
||||
CHECK_CLAIM
|
||||
IMPORTING is_claim TYPE ty_claim
|
||||
RETURNING VALUE(rv_payout) TYPE ty_amount
|
||||
RAISING {{P}}CX_CLAIM_ERROR.
|
||||
- Do not add other public methods.
|
||||
|
||||
# 5. Business rules
|
||||
Apply the rules in this sequence. Raise the exception {{P}}CX_CLAIM_ERROR with
|
||||
the reason of the first rule that fails. The reason is the text that the rule
|
||||
shows.
|
||||
1. The policy ID must start with the letter P. The other 9 characters must be
|
||||
digits. Else raise the reason 'POLICY'.
|
||||
2. REPORT_DAYS must be between 0 and 14. Else raise the reason 'LATE'.
|
||||
3. VEHICLE_AGE must be between 0 and 12. Else raise the reason 'AGED'.
|
||||
4. PHOTO_COUNT must be at least 2. Else raise the reason 'PHOTOS'.
|
||||
5. DAMAGE must be greater than 0. Else raise the reason 'DAMAGE'.
|
||||
6. DEDUCTIBLE must be between 0 and DAMAGE. Else raise the reason 'DEDUCT'.
|
||||
7. The payout is DAMAGE minus DEDUCTIBLE.
|
||||
8. If the payout is greater than C_MAX_PAYOUT, the payout is C_MAX_PAYOUT.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: 8.16.
|
||||
- Coding standards: Clean ABAP. Method length below 40 statements. No global
|
||||
variables. No comment that restates the code.
|
||||
- Out of scope: do not change {{P}}CX_CLAIM_ERROR.
|
||||
|
||||
# 7. Acceptance
|
||||
- The class is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests for the class.
|
||||
50
tasks_gen/train/G1076/task.json
Normal file
50
tasks_gen/train/G1076/task.json
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"id": "G1076",
|
||||
"category": "D",
|
||||
"object_type": "CLAS",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 70,
|
||||
"max_activations": 18
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_CLAIM_ERROR",
|
||||
"file": "seed/cx_claim_error.clas.abap",
|
||||
"description": "Claim exception with a reason and a message text"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CLAIM_CHECKER"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"{{P}}CX_CLAIM_ERROR"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CLAIM_CHECK_HIDDEN",
|
||||
"file": "hidden/claim_check_hidden.clas.abap",
|
||||
"description": "Hidden tests for the car damage claim check"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CLAIM_CHECKER",
|
||||
"file": "reference/claim_checker.clas.abap",
|
||||
"description": "Car damage claim checker",
|
||||
"testclasses_file": "reference/claim_checker.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"cyclomatic_complexity"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user