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>
This commit is contained in:
79
tasks_gen/eval/G0007/reference/loyalty_evaluator.clas.abap
Normal file
79
tasks_gen/eval/G0007/reference/loyalty_evaluator.clas.abap
Normal file
@@ -0,0 +1,79 @@
|
||||
CLASS {{p}}loyalty_evaluator DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_loyalty_rules.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_silver_threshold TYPE i VALUE 1000,
|
||||
c_gold_threshold TYPE i VALUE 5000,
|
||||
c_platinum_threshold TYPE i VALUE 20000.
|
||||
|
||||
METHODS normalize_points
|
||||
IMPORTING iv_points TYPE i
|
||||
RETURNING VALUE(rv_points) TYPE i.
|
||||
|
||||
METHODS tier_of
|
||||
IMPORTING iv_points TYPE i
|
||||
RETURNING VALUE(rv_tier) TYPE {{p}}if_loyalty_rules=>ty_tier.
|
||||
|
||||
METHODS points_to_tier
|
||||
IMPORTING iv_points TYPE i
|
||||
iv_tier TYPE {{p}}if_loyalty_rules=>ty_tier
|
||||
RETURNING VALUE(rv_points) TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}loyalty_evaluator IMPLEMENTATION.
|
||||
METHOD {{p}}if_loyalty_rules~get_tier.
|
||||
rv_tier = tier_of( normalize_points( iv_points ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD {{p}}if_loyalty_rules~get_discount.
|
||||
CASE iv_tier.
|
||||
WHEN {{p}}if_loyalty_rules=>c_tier-silver.
|
||||
rv_percent = 3.
|
||||
WHEN {{p}}if_loyalty_rules=>c_tier-gold.
|
||||
rv_percent = 7.
|
||||
WHEN {{p}}if_loyalty_rules=>c_tier-platinum.
|
||||
rv_percent = 12.
|
||||
WHEN OTHERS.
|
||||
rv_percent = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD {{p}}if_loyalty_rules~points_to_next_tier.
|
||||
DATA(lv_points) = normalize_points( iv_points ).
|
||||
DATA(lv_tier) = tier_of( lv_points ).
|
||||
rv_points = points_to_tier( iv_points = lv_points
|
||||
iv_tier = lv_tier ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD normalize_points.
|
||||
rv_points = COND #( WHEN iv_points < 0 THEN 0 ELSE iv_points ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD tier_of.
|
||||
IF iv_points >= c_platinum_threshold.
|
||||
rv_tier = {{p}}if_loyalty_rules=>c_tier-platinum.
|
||||
ELSEIF iv_points >= c_gold_threshold.
|
||||
rv_tier = {{p}}if_loyalty_rules=>c_tier-gold.
|
||||
ELSEIF iv_points >= c_silver_threshold.
|
||||
rv_tier = {{p}}if_loyalty_rules=>c_tier-silver.
|
||||
ELSE.
|
||||
rv_tier = {{p}}if_loyalty_rules=>c_tier-basic.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD points_to_tier.
|
||||
CASE iv_tier.
|
||||
WHEN {{p}}if_loyalty_rules=>c_tier-basic.
|
||||
rv_points = c_silver_threshold - iv_points.
|
||||
WHEN {{p}}if_loyalty_rules=>c_tier-silver.
|
||||
rv_points = c_gold_threshold - iv_points.
|
||||
WHEN {{p}}if_loyalty_rules=>c_tier-gold.
|
||||
rv_points = c_platinum_threshold - iv_points.
|
||||
WHEN OTHERS.
|
||||
rv_points = 0.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -0,0 +1,77 @@
|
||||
CLASS ltc_loyalty_evaluator DEFINITION FINAL FOR TESTING
|
||||
DURATION SHORT RISK LEVEL HARMLESS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}if_loyalty_rules.
|
||||
|
||||
METHODS setup.
|
||||
METHODS tier_of_boundary_points FOR TESTING.
|
||||
METHODS negative_points_are_basic FOR TESTING.
|
||||
METHODS discount_of_each_tier FOR TESTING.
|
||||
METHODS discount_of_unknown_tier FOR TESTING.
|
||||
METHODS points_to_silver FOR TESTING.
|
||||
METHODS points_to_gold FOR TESTING.
|
||||
METHODS points_to_platinum FOR TESTING.
|
||||
METHODS platinum_needs_no_points FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_loyalty_evaluator IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}loyalty_evaluator( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD tier_of_boundary_points.
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_loyalty_rules=>c_tier-basic
|
||||
act = mo_cut->get_tier( 0 ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_loyalty_rules=>c_tier-silver
|
||||
act = mo_cut->get_tier( 1000 ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_loyalty_rules=>c_tier-gold
|
||||
act = mo_cut->get_tier( 5000 ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_loyalty_rules=>c_tier-platinum
|
||||
act = mo_cut->get_tier( 20000 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD negative_points_are_basic.
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_loyalty_rules=>c_tier-basic
|
||||
act = mo_cut->get_tier( -100 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD discount_of_each_tier.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0
|
||||
act = mo_cut->get_discount( {{p}}if_loyalty_rules=>c_tier-basic ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 3
|
||||
act = mo_cut->get_discount( {{p}}if_loyalty_rules=>c_tier-silver ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 7
|
||||
act = mo_cut->get_discount( {{p}}if_loyalty_rules=>c_tier-gold ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 12
|
||||
act = mo_cut->get_discount( {{p}}if_loyalty_rules=>c_tier-platinum ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD discount_of_unknown_tier.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0
|
||||
act = mo_cut->get_discount( 'X' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD points_to_silver.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1000
|
||||
act = mo_cut->points_to_next_tier( 0 ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1
|
||||
act = mo_cut->points_to_next_tier( 999 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD points_to_gold.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 4000
|
||||
act = mo_cut->points_to_next_tier( 1000 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD points_to_platinum.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 15000
|
||||
act = mo_cut->points_to_next_tier( 5000 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD platinum_needs_no_points.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0
|
||||
act = mo_cut->points_to_next_tier( 20000 ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user