Pipeline controller: plan 2 (hard +, error +50 %), backlog throttle, 2 trajectory workers, stop rules, summaries every 50; budget reserve
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
59
tasks_gen/train/G1005/faulty/m0_credit_checker.clas.abap
Normal file
59
tasks_gen/train/G1005/faulty/m0_credit_checker.clas.abap
Normal file
@@ -0,0 +1,59 @@
|
||||
CLASS {{p}}credit_checker DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_credit_check.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS c_income_factor TYPE i VALUE 3.
|
||||
CONSTANTS c_plan_reduction TYPE {{p}}if_credit_check=>ty_amount VALUE '500.00'.
|
||||
CONSTANTS c_min_age TYPE i VALUE 18.
|
||||
CONSTANTS c_full_limit_age TYPE i VALUE 21.
|
||||
CONSTANTS c_max_open_plans TYPE i VALUE 2.
|
||||
CONSTANTS c_hundred TYPE i VALUE 100.
|
||||
|
||||
METHODS credit_limit_cents
|
||||
IMPORTING iv_age TYPE i
|
||||
iv_income TYPE {{p}}if_credit_check=>ty_amount
|
||||
iv_open_plans TYPE i
|
||||
RETURNING VALUE(rv_cents) TYPE i.
|
||||
METHODS to_cents
|
||||
IMPORTING iv_amount TYPE {{p}}if_credit_check=>ty_amount
|
||||
RETURNING VALUE(rv_cents) TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}credit_checker IMPLEMENTATION.
|
||||
METHOD {{p}}if_credit_check~check.
|
||||
IF iv_age < c_min_age.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-age.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_income > 0.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-income.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_open_plans >= c_max_open_plans.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-open_plan.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF to_cents( iv_order_amount ) > credit_limit_cents( iv_age = iv_age
|
||||
iv_income = iv_income
|
||||
iv_open_plans = iv_open_plans ).
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-limit.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD credit_limit_cents.
|
||||
rv_cents = to_cents( iv_income ) * c_income_factor
|
||||
- to_cents( c_plan_reduction ) * iv_open_plans.
|
||||
IF iv_age < c_full_limit_age.
|
||||
rv_cents = rv_cents DIV 2.
|
||||
rv_cents = rv_cents DIV c_hundred * c_hundred.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD to_cents.
|
||||
rv_cents = iv_amount * c_hundred.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
59
tasks_gen/train/G1005/faulty/m2_credit_checker.clas.abap
Normal file
59
tasks_gen/train/G1005/faulty/m2_credit_checker.clas.abap
Normal file
@@ -0,0 +1,59 @@
|
||||
CLASS {{p}}credit_checker DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_credit_check.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS c_income_factor TYPE i VALUE 3.
|
||||
CONSTANTS c_plan_reduction TYPE {{p}}if_credit_check=>ty_amount VALUE '500.00'.
|
||||
CONSTANTS c_min_age TYPE i VALUE 18.
|
||||
CONSTANTS c_full_limit_age TYPE i VALUE 21.
|
||||
CONSTANTS c_max_open_plans TYPE i VALUE 2.
|
||||
CONSTANTS c_hundred TYPE i VALUE 100.
|
||||
|
||||
METHODS credit_limit_cents
|
||||
IMPORTING iv_age TYPE i
|
||||
iv_income TYPE {{p}}if_credit_check=>ty_amount
|
||||
iv_open_plans TYPE i
|
||||
RETURNING VALUE(rv_cents) TYPE i.
|
||||
METHODS to_cents
|
||||
IMPORTING iv_amount TYPE {{p}}if_credit_check=>ty_amount
|
||||
RETURNING VALUE(rv_cents) TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}credit_checker IMPLEMENTATION.
|
||||
METHOD {{p}}if_credit_check~check.
|
||||
IF iv_age < c_min_age.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-age.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_income <= 0.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-income.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_open_plans >= c_max_open_plans.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-open_plan.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF to_cents( iv_order_amount ) > credit_limit_cents( iv_age = iv_age
|
||||
iv_income = iv_income
|
||||
iv_open_plans = iv_open_plans ).
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-limit.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD credit_limit_cents.
|
||||
rv_cents = to_cents( iv_income ) / c_income_factor
|
||||
- to_cents( c_plan_reduction ) * iv_open_plans.
|
||||
IF iv_age < c_full_limit_age.
|
||||
rv_cents = rv_cents DIV 2.
|
||||
rv_cents = rv_cents DIV c_hundred * c_hundred.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD to_cents.
|
||||
rv_cents = iv_amount * c_hundred.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
59
tasks_gen/train/G1005/faulty/m3_credit_checker.clas.abap
Normal file
59
tasks_gen/train/G1005/faulty/m3_credit_checker.clas.abap
Normal file
@@ -0,0 +1,59 @@
|
||||
CLASS {{p}}credit_checker DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_credit_check.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS c_income_factor TYPE i VALUE 3.
|
||||
CONSTANTS c_plan_reduction TYPE {{p}}if_credit_check=>ty_amount VALUE '500.00'.
|
||||
CONSTANTS c_min_age TYPE i VALUE 18.
|
||||
CONSTANTS c_full_limit_age TYPE i VALUE 21.
|
||||
CONSTANTS c_max_open_plans TYPE i VALUE 2.
|
||||
CONSTANTS c_hundred TYPE i VALUE 100.
|
||||
|
||||
METHODS credit_limit_cents
|
||||
IMPORTING iv_age TYPE i
|
||||
iv_income TYPE {{p}}if_credit_check=>ty_amount
|
||||
iv_open_plans TYPE i
|
||||
RETURNING VALUE(rv_cents) TYPE i.
|
||||
METHODS to_cents
|
||||
IMPORTING iv_amount TYPE {{p}}if_credit_check=>ty_amount
|
||||
RETURNING VALUE(rv_cents) TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}credit_checker IMPLEMENTATION.
|
||||
METHOD {{p}}if_credit_check~check.
|
||||
IF iv_age < c_min_age.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-age.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_income <= 0.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-income.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_open_plans >= c_max_open_plans.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-open_plan.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF to_cents( iv_order_amount ) > credit_limit_cents( iv_age = iv_age
|
||||
iv_income = iv_income
|
||||
iv_open_plans = iv_open_plans ).
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-limit.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD credit_limit_cents.
|
||||
rv_cents = to_cents( iv_income ) * c_income_factor
|
||||
- to_cents( c_plan_reduction ) / iv_open_plans.
|
||||
IF iv_age < c_full_limit_age.
|
||||
rv_cents = rv_cents DIV 2.
|
||||
rv_cents = rv_cents DIV c_hundred * c_hundred.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD to_cents.
|
||||
rv_cents = iv_amount * c_hundred.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
59
tasks_gen/train/G1005/faulty/m4_credit_checker.clas.abap
Normal file
59
tasks_gen/train/G1005/faulty/m4_credit_checker.clas.abap
Normal file
@@ -0,0 +1,59 @@
|
||||
CLASS {{p}}credit_checker DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_credit_check.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS c_income_factor TYPE i VALUE 3.
|
||||
CONSTANTS c_plan_reduction TYPE {{p}}if_credit_check=>ty_amount VALUE '500.00'.
|
||||
CONSTANTS c_min_age TYPE i VALUE 18.
|
||||
CONSTANTS c_full_limit_age TYPE i VALUE 21.
|
||||
CONSTANTS c_max_open_plans TYPE i VALUE 2.
|
||||
CONSTANTS c_hundred TYPE i VALUE 100.
|
||||
|
||||
METHODS credit_limit_cents
|
||||
IMPORTING iv_age TYPE i
|
||||
iv_income TYPE {{p}}if_credit_check=>ty_amount
|
||||
iv_open_plans TYPE i
|
||||
RETURNING VALUE(rv_cents) TYPE i.
|
||||
METHODS to_cents
|
||||
IMPORTING iv_amount TYPE {{p}}if_credit_check=>ty_amount
|
||||
RETURNING VALUE(rv_cents) TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}credit_checker IMPLEMENTATION.
|
||||
METHOD {{p}}if_credit_check~check.
|
||||
IF iv_age < c_min_age.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-age.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_income <= 0.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-income.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_open_plans >= c_max_open_plans.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-open_plan.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF to_cents( iv_order_amount ) > credit_limit_cents( iv_age = iv_age
|
||||
iv_income = iv_income
|
||||
iv_open_plans = iv_open_plans ).
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-limit.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD credit_limit_cents.
|
||||
rv_cents = to_cents( iv_income ) * c_income_factor
|
||||
- to_cents( c_plan_reduction ) * iv_open_plans.
|
||||
IF iv_age >= c_full_limit_age.
|
||||
rv_cents = rv_cents DIV 2.
|
||||
rv_cents = rv_cents DIV c_hundred * c_hundred.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD to_cents.
|
||||
rv_cents = iv_amount * c_hundred.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
24
tasks_gen/train/G1005/generation.json
Normal file
24
tasks_gen/train/G1005/generation.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"id": "G1005",
|
||||
"pool": "train",
|
||||
"object_type": "CLAS",
|
||||
"category": "F",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 96.4,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100.0,
|
||||
"null": 0,
|
||||
"mutation": {
|
||||
"valid": 4,
|
||||
"killed": 4,
|
||||
"ok": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"accepted": true
|
||||
}
|
||||
129
tasks_gen/train/G1005/hidden/t02_hidden.clas.abap
Normal file
129
tasks_gen/train/G1005/hidden/t02_hidden.clas.abap
Normal file
@@ -0,0 +1,129 @@
|
||||
CLASS {{p}}t02_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_credit_check.
|
||||
METHODS setup.
|
||||
METHODS too_young FOR TESTING.
|
||||
METHODS age_eighteen_is_ok FOR TESTING.
|
||||
METHODS zero_income FOR TESTING.
|
||||
METHODS two_open_plans FOR TESTING.
|
||||
METHODS order_above_limit FOR TESTING.
|
||||
METHODS order_at_limit_is_ok FOR TESTING.
|
||||
METHODS young_limit_halved FOR TESTING.
|
||||
METHODS adult_keeps_limit FOR TESTING.
|
||||
METHODS young_limit_is_floor FOR TESTING.
|
||||
METHODS plan_reduces_limit FOR TESTING.
|
||||
METHODS valid_adult FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t02_hidden IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}credit_checker( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD too_young.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-age
|
||||
act = mo_cut->check( iv_age = 17
|
||||
iv_income = '3000.00'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '100.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD age_eighteen_is_ok.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-ok
|
||||
act = mo_cut->check( iv_age = 18
|
||||
iv_income = '3000.00'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '100.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_income.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-income
|
||||
act = mo_cut->check( iv_age = 30
|
||||
iv_income = '0.00'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '100.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD two_open_plans.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-open_plan
|
||||
act = mo_cut->check( iv_age = 30
|
||||
iv_income = '3000.00'
|
||||
iv_open_plans = 2
|
||||
iv_order_amount = '100.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD order_above_limit.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-limit
|
||||
act = mo_cut->check( iv_age = 30
|
||||
iv_income = '1000.00'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '3000.01' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD order_at_limit_is_ok.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-ok
|
||||
act = mo_cut->check( iv_age = 30
|
||||
iv_income = '1000.00'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '3000.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD young_limit_halved.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-limit
|
||||
act = mo_cut->check( iv_age = 20
|
||||
iv_income = '1000.00'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '1500.01' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD adult_keeps_limit.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-ok
|
||||
act = mo_cut->check( iv_age = 21
|
||||
iv_income = '1000.00'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '1500.01' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD young_limit_is_floor.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-limit
|
||||
act = mo_cut->check( iv_age = 20
|
||||
iv_income = '2500.50'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '3750.50' ) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-ok
|
||||
act = mo_cut->check( iv_age = 20
|
||||
iv_income = '2500.50'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '3750.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD plan_reduces_limit.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-limit
|
||||
act = mo_cut->check( iv_age = 30
|
||||
iv_income = '1000.00'
|
||||
iv_open_plans = 1
|
||||
iv_order_amount = '2500.01' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_adult.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-ok
|
||||
act = mo_cut->check( iv_age = 35
|
||||
iv_income = '2000.00'
|
||||
iv_open_plans = 1
|
||||
iv_order_amount = '5500.00' ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
73
tasks_gen/train/G1005/mutation.json
Normal file
73
tasks_gen/train/G1005/mutation.json
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"task": "G1005",
|
||||
"mutants": [
|
||||
{
|
||||
"object": "{{P}}CREDIT_CHECKER",
|
||||
"mutant": "line 30: <= -> > (rel)",
|
||||
"status": "killed",
|
||||
"hidden": "1/11",
|
||||
"failed_tests": [
|
||||
"ADULT_KEEPS_LIMIT",
|
||||
"AGE_EIGHTEEN_IS_OK",
|
||||
"ORDER_ABOVE_LIMIT",
|
||||
"ORDER_AT_LIMIT_IS_OK",
|
||||
"PLAN_REDUCES_LIMIT",
|
||||
"TWO_OPEN_PLANS",
|
||||
"VALID_ADULT",
|
||||
"YOUNG_LIMIT_HALVED",
|
||||
"YOUNG_LIMIT_IS_FLOOR",
|
||||
"ZERO_INCOME"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CREDIT_CHECKER",
|
||||
"mutant": "line 38: = -> <> (eq)",
|
||||
"status": "invalid",
|
||||
"hidden": "0/0",
|
||||
"failed_tests": []
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CREDIT_CHECKER",
|
||||
"mutant": "line 48: * -> / (arith)",
|
||||
"status": "killed",
|
||||
"hidden": "7/11",
|
||||
"failed_tests": [
|
||||
"ADULT_KEEPS_LIMIT",
|
||||
"ORDER_AT_LIMIT_IS_OK",
|
||||
"VALID_ADULT",
|
||||
"YOUNG_LIMIT_IS_FLOOR"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CREDIT_CHECKER",
|
||||
"mutant": "line 49: * -> / (arith)",
|
||||
"status": "killed",
|
||||
"hidden": "5/11",
|
||||
"failed_tests": [
|
||||
"ADULT_KEEPS_LIMIT",
|
||||
"AGE_EIGHTEEN_IS_OK",
|
||||
"ORDER_ABOVE_LIMIT",
|
||||
"ORDER_AT_LIMIT_IS_OK",
|
||||
"YOUNG_LIMIT_HALVED",
|
||||
"YOUNG_LIMIT_IS_FLOOR"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CREDIT_CHECKER",
|
||||
"mutant": "line 50: < -> >= (rel)",
|
||||
"status": "killed",
|
||||
"hidden": "6/11",
|
||||
"failed_tests": [
|
||||
"ADULT_KEEPS_LIMIT",
|
||||
"ORDER_AT_LIMIT_IS_OK",
|
||||
"VALID_ADULT",
|
||||
"YOUNG_LIMIT_HALVED",
|
||||
"YOUNG_LIMIT_IS_FLOOR"
|
||||
]
|
||||
}
|
||||
],
|
||||
"valid": 4,
|
||||
"killed": 4,
|
||||
"kill_rate": 1.0,
|
||||
"ok": true
|
||||
}
|
||||
59
tasks_gen/train/G1005/reference/credit_checker.clas.abap
Normal file
59
tasks_gen/train/G1005/reference/credit_checker.clas.abap
Normal file
@@ -0,0 +1,59 @@
|
||||
CLASS {{p}}credit_checker DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_credit_check.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS c_income_factor TYPE i VALUE 3.
|
||||
CONSTANTS c_plan_reduction TYPE {{p}}if_credit_check=>ty_amount VALUE '500.00'.
|
||||
CONSTANTS c_min_age TYPE i VALUE 18.
|
||||
CONSTANTS c_full_limit_age TYPE i VALUE 21.
|
||||
CONSTANTS c_max_open_plans TYPE i VALUE 2.
|
||||
CONSTANTS c_hundred TYPE i VALUE 100.
|
||||
|
||||
METHODS credit_limit_cents
|
||||
IMPORTING iv_age TYPE i
|
||||
iv_income TYPE {{p}}if_credit_check=>ty_amount
|
||||
iv_open_plans TYPE i
|
||||
RETURNING VALUE(rv_cents) TYPE i.
|
||||
METHODS to_cents
|
||||
IMPORTING iv_amount TYPE {{p}}if_credit_check=>ty_amount
|
||||
RETURNING VALUE(rv_cents) TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}credit_checker IMPLEMENTATION.
|
||||
METHOD {{p}}if_credit_check~check.
|
||||
IF iv_age < c_min_age.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-age.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_income <= 0.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-income.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF iv_open_plans >= c_max_open_plans.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-open_plan.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF to_cents( iv_order_amount ) > credit_limit_cents( iv_age = iv_age
|
||||
iv_income = iv_income
|
||||
iv_open_plans = iv_open_plans ).
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-limit.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_reason = {{p}}if_credit_check=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD credit_limit_cents.
|
||||
rv_cents = to_cents( iv_income ) * c_income_factor
|
||||
- to_cents( c_plan_reduction ) * iv_open_plans.
|
||||
IF iv_age < c_full_limit_age.
|
||||
rv_cents = rv_cents DIV 2.
|
||||
rv_cents = rv_cents DIV c_hundred * c_hundred.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD to_cents.
|
||||
rv_cents = iv_amount * c_hundred.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -0,0 +1,98 @@
|
||||
CLASS ltc_credit_checker DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_credit_check.
|
||||
METHODS setup.
|
||||
METHODS too_young FOR TESTING.
|
||||
METHODS zero_income FOR TESTING.
|
||||
METHODS two_open_plans FOR TESTING.
|
||||
METHODS order_above_limit FOR TESTING.
|
||||
METHODS order_at_limit FOR TESTING.
|
||||
METHODS young_limit_halved FOR TESTING.
|
||||
METHODS young_limit_is_floor FOR TESTING.
|
||||
METHODS valid_adult FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_credit_checker IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}credit_checker( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD too_young.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-age
|
||||
act = mo_cut->check( iv_age = 17
|
||||
iv_income = '3000.00'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '100.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_income.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-income
|
||||
act = mo_cut->check( iv_age = 30
|
||||
iv_income = '0.00'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '100.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD two_open_plans.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-open_plan
|
||||
act = mo_cut->check( iv_age = 30
|
||||
iv_income = '3000.00'
|
||||
iv_open_plans = 2
|
||||
iv_order_amount = '100.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD order_above_limit.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-limit
|
||||
act = mo_cut->check( iv_age = 30
|
||||
iv_income = '1000.00'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '3000.01' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD order_at_limit.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-ok
|
||||
act = mo_cut->check( iv_age = 30
|
||||
iv_income = '1000.00'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '3000.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD young_limit_halved.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-limit
|
||||
act = mo_cut->check( iv_age = 20
|
||||
iv_income = '1000.00'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '1500.01' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD young_limit_is_floor.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-limit
|
||||
act = mo_cut->check( iv_age = 20
|
||||
iv_income = '2500.50'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '3750.50' ) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-ok
|
||||
act = mo_cut->check( iv_age = 20
|
||||
iv_income = '2500.50'
|
||||
iv_open_plans = 0
|
||||
iv_order_amount = '3750.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_adult.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}if_credit_check=>c_reason-ok
|
||||
act = mo_cut->check( iv_age = 35
|
||||
iv_income = '2000.00'
|
||||
iv_open_plans = 1
|
||||
iv_order_amount = '5500.00' ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
18
tasks_gen/train/G1005/seed/if_credit_check.intf.abap
Normal file
18
tasks_gen/train/G1005/seed/if_credit_check.intf.abap
Normal file
@@ -0,0 +1,18 @@
|
||||
INTERFACE {{p}}if_credit_check PUBLIC.
|
||||
TYPES ty_reason TYPE c LENGTH 10.
|
||||
TYPES ty_amount TYPE p LENGTH 11 DECIMALS 2.
|
||||
CONSTANTS:
|
||||
BEGIN OF c_reason,
|
||||
ok TYPE ty_reason VALUE 'OK',
|
||||
age TYPE ty_reason VALUE 'AGE',
|
||||
income TYPE ty_reason VALUE 'INCOME',
|
||||
open_plan TYPE ty_reason VALUE 'OPEN_PLAN',
|
||||
limit TYPE ty_reason VALUE 'LIMIT',
|
||||
END OF c_reason.
|
||||
METHODS check
|
||||
IMPORTING iv_age TYPE i
|
||||
iv_income TYPE ty_amount
|
||||
iv_open_plans TYPE i
|
||||
iv_order_amount TYPE ty_amount
|
||||
RETURNING VALUE(rv_reason) TYPE ty_reason.
|
||||
ENDINTERFACE.
|
||||
56
tasks_gen/train/G1005/spec.md
Normal file
56
tasks_gen/train/G1005/spec.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# 1. Goal
|
||||
|
||||
A furniture shop sells furniture on instalment plans. A checkout program calls one
|
||||
check before the shop grants an instalment plan to a customer. The program needs
|
||||
one reason code for each customer.
|
||||
|
||||
# 2. Open questions
|
||||
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
|
||||
- The interface {{P}}IF_CREDIT_CHECK exists in package $TMP. It is active.
|
||||
- The interface declares the type of the reason, the type of a money amount, the
|
||||
constants of the reason codes, and one method.
|
||||
- The method name, the parameter names and the parameter types are not in this
|
||||
document. Read the interface in the system.
|
||||
- The reason constants have the names OK, AGE, INCOME, OPEN_PLAN and LIMIT.
|
||||
|
||||
# 4. Contract
|
||||
|
||||
- Create the class {{P}}CREDIT_CHECKER in package $TMP.
|
||||
- The class is public and final. It has a public constructor without parameters.
|
||||
- The class implements the interface {{P}}IF_CREDIT_CHECK.
|
||||
- Do not add other public methods.
|
||||
|
||||
# 5. Business rules
|
||||
|
||||
The check receives the age of the customer in years, the net monthly income of the
|
||||
customer, the number of open instalment plans of the customer, and the amount of
|
||||
the new order. Apply the rules in this sequence. Return the reason of the first
|
||||
rule that fails.
|
||||
|
||||
1. If the age is less than 18, return AGE.
|
||||
2. If the net monthly income is zero or less, return INCOME.
|
||||
3. If the number of open instalment plans is 2 or more, return OPEN_PLAN.
|
||||
4. Calculate the credit limit:
|
||||
- Start with three times the net monthly income.
|
||||
- Subtract 500 for each open instalment plan.
|
||||
- If the age is less than 21, halve the limit and round the result down to
|
||||
whole euros. Example: 3750.75 becomes 3750.00.
|
||||
5. If the amount of the new order is more than the credit limit, return LIMIT.
|
||||
6. Else return OK.
|
||||
|
||||
# 6. Constraints
|
||||
|
||||
- Release target: SAP_BASIS 8.16 (ABAP Platform 2025).
|
||||
- Coding standards: Clean ABAP. Method length below 40 statements. No global
|
||||
variables. No comment that restates the code.
|
||||
- Out of scope: do not change the interface {{P}}IF_CREDIT_CHECK.
|
||||
|
||||
# 7. Acceptance
|
||||
|
||||
- The class is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests for the class.
|
||||
51
tasks_gen/train/G1005/task.json
Normal file
51
tasks_gen/train/G1005/task.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"id": "G1005",
|
||||
"category": "F",
|
||||
"object_type": "CLAS",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 70,
|
||||
"max_activations": 18
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "INTF",
|
||||
"name": "{{P}}IF_CREDIT_CHECK",
|
||||
"file": "seed/if_credit_check.intf.abap",
|
||||
"description": "Instalment plan check contract"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CREDIT_CHECKER",
|
||||
"implements": "{{P}}IF_CREDIT_CHECK"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"{{P}}IF_CREDIT_CHECK"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T02_HIDDEN",
|
||||
"file": "hidden/t02_hidden.clas.abap",
|
||||
"description": "T02 hidden tests"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CREDIT_CHECKER",
|
||||
"file": "reference/credit_checker.clas.abap",
|
||||
"description": "Instalment plan credit checker",
|
||||
"testclasses_file": "reference/credit_checker.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"no_global_variables"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user