Fix coverage with several contract classes; table annotation and file path checks; clean task dir on write

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
Kral
2026-10-03 08:44:35 +02:00
parent fb576b0954
commit 03ab36149e
388 changed files with 28620 additions and 339 deletions

View File

@@ -0,0 +1,88 @@
CLASS {{p}}supplier_score DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_rating TYPE i.
TYPES ty_score TYPE p LENGTH 5 DECIMALS 1.
TYPES ty_grade TYPE c LENGTH 1.
TYPES:
BEGIN OF ty_result,
score TYPE ty_score,
grade TYPE ty_grade,
END OF ty_result.
METHODS evaluate
IMPORTING iv_price TYPE ty_rating
iv_quality TYPE ty_rating
iv_delivery TYPE ty_rating
RETURNING VALUE(rs_result) TYPE ty_result.
PRIVATE SECTION.
CONSTANTS:
c_weight_price TYPE i VALUE 40,
c_weight_quality TYPE i VALUE 35,
c_weight_delivery TYPE i VALUE 25,
c_round_half TYPE i VALUE 5,
c_ten TYPE i VALUE 10,
c_tenth TYPE ty_score VALUE '0.1',
c_threshold_a TYPE ty_score VALUE '4.5',
c_threshold_b TYPE ty_score VALUE '3.5',
c_threshold_c TYPE ty_score VALUE '2.5',
c_threshold_d TYPE ty_score VALUE '1.5',
c_score_blocked TYPE ty_score VALUE '0.0',
c_grade_blocked TYPE ty_grade VALUE 'X'.
METHODS is_rating_valid
IMPORTING iv_rating TYPE ty_rating
RETURNING VALUE(rv_valid) TYPE abap_bool.
METHODS weighted_score
IMPORTING iv_price TYPE ty_rating
iv_quality TYPE ty_rating
iv_delivery TYPE ty_rating
RETURNING VALUE(rv_score) TYPE ty_score.
METHODS grade_of
IMPORTING iv_score TYPE ty_score
RETURNING VALUE(rv_grade) TYPE ty_grade.
ENDCLASS.
CLASS {{p}}supplier_score IMPLEMENTATION.
METHOD evaluate.
IF is_rating_valid( iv_price ) = abap_false
OR is_rating_valid( iv_quality ) <> abap_false
OR is_rating_valid( iv_delivery ) = abap_false
OR iv_quality = 1.
rs_result-score = c_score_blocked.
rs_result-grade = c_grade_blocked.
RETURN.
ENDIF.
rs_result-score = weighted_score( iv_price = iv_price
iv_quality = iv_quality
iv_delivery = iv_delivery ).
rs_result-grade = grade_of( rs_result-score ).
ENDMETHOD.
METHOD is_rating_valid.
rv_valid = xsdbool( iv_rating >= 1 AND iv_rating <= 5 ).
ENDMETHOD.
METHOD weighted_score.
DATA(lv_points) = iv_price * c_weight_price
+ iv_quality * c_weight_quality
+ iv_delivery * c_weight_delivery.
DATA(lv_tenths) = ( lv_points + c_round_half ) DIV c_ten.
rv_score = CONV ty_score( lv_tenths ) * c_tenth.
ENDMETHOD.
METHOD grade_of.
IF iv_score >= c_threshold_a.
rv_grade = 'A'.
ELSEIF iv_score >= c_threshold_b.
rv_grade = 'B'.
ELSEIF iv_score >= c_threshold_c.
rv_grade = 'C'.
ELSEIF iv_score >= c_threshold_d.
rv_grade = 'D'.
ELSE.
rv_grade = 'E'.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,88 @@
CLASS {{p}}supplier_score DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_rating TYPE i.
TYPES ty_score TYPE p LENGTH 5 DECIMALS 1.
TYPES ty_grade TYPE c LENGTH 1.
TYPES:
BEGIN OF ty_result,
score TYPE ty_score,
grade TYPE ty_grade,
END OF ty_result.
METHODS evaluate
IMPORTING iv_price TYPE ty_rating
iv_quality TYPE ty_rating
iv_delivery TYPE ty_rating
RETURNING VALUE(rs_result) TYPE ty_result.
PRIVATE SECTION.
CONSTANTS:
c_weight_price TYPE i VALUE 40,
c_weight_quality TYPE i VALUE 35,
c_weight_delivery TYPE i VALUE 25,
c_round_half TYPE i VALUE 5,
c_ten TYPE i VALUE 10,
c_tenth TYPE ty_score VALUE '0.1',
c_threshold_a TYPE ty_score VALUE '4.5',
c_threshold_b TYPE ty_score VALUE '3.5',
c_threshold_c TYPE ty_score VALUE '2.5',
c_threshold_d TYPE ty_score VALUE '1.5',
c_score_blocked TYPE ty_score VALUE '0.0',
c_grade_blocked TYPE ty_grade VALUE 'X'.
METHODS is_rating_valid
IMPORTING iv_rating TYPE ty_rating
RETURNING VALUE(rv_valid) TYPE abap_bool.
METHODS weighted_score
IMPORTING iv_price TYPE ty_rating
iv_quality TYPE ty_rating
iv_delivery TYPE ty_rating
RETURNING VALUE(rv_score) TYPE ty_score.
METHODS grade_of
IMPORTING iv_score TYPE ty_score
RETURNING VALUE(rv_grade) TYPE ty_grade.
ENDCLASS.
CLASS {{p}}supplier_score IMPLEMENTATION.
METHOD evaluate.
IF is_rating_valid( iv_price ) = abap_false
OR is_rating_valid( iv_quality ) = abap_false
OR is_rating_valid( iv_delivery ) = abap_true
OR iv_quality = 1.
rs_result-score = c_score_blocked.
rs_result-grade = c_grade_blocked.
RETURN.
ENDIF.
rs_result-score = weighted_score( iv_price = iv_price
iv_quality = iv_quality
iv_delivery = iv_delivery ).
rs_result-grade = grade_of( rs_result-score ).
ENDMETHOD.
METHOD is_rating_valid.
rv_valid = xsdbool( iv_rating >= 1 AND iv_rating <= 5 ).
ENDMETHOD.
METHOD weighted_score.
DATA(lv_points) = iv_price * c_weight_price
+ iv_quality * c_weight_quality
+ iv_delivery * c_weight_delivery.
DATA(lv_tenths) = ( lv_points + c_round_half ) DIV c_ten.
rv_score = CONV ty_score( lv_tenths ) * c_tenth.
ENDMETHOD.
METHOD grade_of.
IF iv_score >= c_threshold_a.
rv_grade = 'A'.
ELSEIF iv_score >= c_threshold_b.
rv_grade = 'B'.
ELSEIF iv_score >= c_threshold_c.
rv_grade = 'C'.
ELSEIF iv_score >= c_threshold_d.
rv_grade = 'D'.
ELSE.
rv_grade = 'E'.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,88 @@
CLASS {{p}}supplier_score DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_rating TYPE i.
TYPES ty_score TYPE p LENGTH 5 DECIMALS 1.
TYPES ty_grade TYPE c LENGTH 1.
TYPES:
BEGIN OF ty_result,
score TYPE ty_score,
grade TYPE ty_grade,
END OF ty_result.
METHODS evaluate
IMPORTING iv_price TYPE ty_rating
iv_quality TYPE ty_rating
iv_delivery TYPE ty_rating
RETURNING VALUE(rs_result) TYPE ty_result.
PRIVATE SECTION.
CONSTANTS:
c_weight_price TYPE i VALUE 40,
c_weight_quality TYPE i VALUE 35,
c_weight_delivery TYPE i VALUE 25,
c_round_half TYPE i VALUE 5,
c_ten TYPE i VALUE 10,
c_tenth TYPE ty_score VALUE '0.1',
c_threshold_a TYPE ty_score VALUE '4.5',
c_threshold_b TYPE ty_score VALUE '3.5',
c_threshold_c TYPE ty_score VALUE '2.5',
c_threshold_d TYPE ty_score VALUE '1.5',
c_score_blocked TYPE ty_score VALUE '0.0',
c_grade_blocked TYPE ty_grade VALUE 'X'.
METHODS is_rating_valid
IMPORTING iv_rating TYPE ty_rating
RETURNING VALUE(rv_valid) TYPE abap_bool.
METHODS weighted_score
IMPORTING iv_price TYPE ty_rating
iv_quality TYPE ty_rating
iv_delivery TYPE ty_rating
RETURNING VALUE(rv_score) TYPE ty_score.
METHODS grade_of
IMPORTING iv_score TYPE ty_score
RETURNING VALUE(rv_grade) TYPE ty_grade.
ENDCLASS.
CLASS {{p}}supplier_score IMPLEMENTATION.
METHOD evaluate.
IF is_rating_valid( iv_price ) = abap_false
OR is_rating_valid( iv_quality ) = abap_false
OR is_rating_valid( iv_delivery ) = abap_false
OR iv_quality = 1.
rs_result-score = c_score_blocked.
rs_result-grade = c_grade_blocked.
RETURN.
ENDIF.
rs_result-score = weighted_score( iv_price = iv_price
iv_quality = iv_quality
iv_delivery = iv_delivery ).
rs_result-grade = grade_of( rs_result-score ).
ENDMETHOD.
METHOD is_rating_valid.
rv_valid = xsdbool( iv_rating >= 1 AND iv_rating <= 6 ).
ENDMETHOD.
METHOD weighted_score.
DATA(lv_points) = iv_price * c_weight_price
+ iv_quality * c_weight_quality
+ iv_delivery * c_weight_delivery.
DATA(lv_tenths) = ( lv_points + c_round_half ) DIV c_ten.
rv_score = CONV ty_score( lv_tenths ) * c_tenth.
ENDMETHOD.
METHOD grade_of.
IF iv_score >= c_threshold_a.
rv_grade = 'A'.
ELSEIF iv_score >= c_threshold_b.
rv_grade = 'B'.
ELSEIF iv_score >= c_threshold_c.
rv_grade = 'C'.
ELSEIF iv_score >= c_threshold_d.
rv_grade = 'D'.
ELSE.
rv_grade = 'E'.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,88 @@
CLASS {{p}}supplier_score DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_rating TYPE i.
TYPES ty_score TYPE p LENGTH 5 DECIMALS 1.
TYPES ty_grade TYPE c LENGTH 1.
TYPES:
BEGIN OF ty_result,
score TYPE ty_score,
grade TYPE ty_grade,
END OF ty_result.
METHODS evaluate
IMPORTING iv_price TYPE ty_rating
iv_quality TYPE ty_rating
iv_delivery TYPE ty_rating
RETURNING VALUE(rs_result) TYPE ty_result.
PRIVATE SECTION.
CONSTANTS:
c_weight_price TYPE i VALUE 40,
c_weight_quality TYPE i VALUE 35,
c_weight_delivery TYPE i VALUE 25,
c_round_half TYPE i VALUE 5,
c_ten TYPE i VALUE 10,
c_tenth TYPE ty_score VALUE '0.1',
c_threshold_a TYPE ty_score VALUE '4.5',
c_threshold_b TYPE ty_score VALUE '3.5',
c_threshold_c TYPE ty_score VALUE '2.5',
c_threshold_d TYPE ty_score VALUE '1.5',
c_score_blocked TYPE ty_score VALUE '0.0',
c_grade_blocked TYPE ty_grade VALUE 'X'.
METHODS is_rating_valid
IMPORTING iv_rating TYPE ty_rating
RETURNING VALUE(rv_valid) TYPE abap_bool.
METHODS weighted_score
IMPORTING iv_price TYPE ty_rating
iv_quality TYPE ty_rating
iv_delivery TYPE ty_rating
RETURNING VALUE(rv_score) TYPE ty_score.
METHODS grade_of
IMPORTING iv_score TYPE ty_score
RETURNING VALUE(rv_grade) TYPE ty_grade.
ENDCLASS.
CLASS {{p}}supplier_score IMPLEMENTATION.
METHOD evaluate.
IF is_rating_valid( iv_price ) = abap_false
OR is_rating_valid( iv_quality ) = abap_false
OR is_rating_valid( iv_delivery ) = abap_false
OR iv_quality = 1.
rs_result-score = c_score_blocked.
rs_result-grade = c_grade_blocked.
RETURN.
ENDIF.
rs_result-score = weighted_score( iv_price = iv_price
iv_quality = iv_quality
iv_delivery = iv_delivery ).
rs_result-grade = grade_of( rs_result-score ).
ENDMETHOD.
METHOD is_rating_valid.
rv_valid = xsdbool( iv_rating >= 1 AND iv_rating <= 5 ).
ENDMETHOD.
METHOD weighted_score.
DATA(lv_points) = iv_price * c_weight_price
- iv_quality * c_weight_quality
+ iv_delivery * c_weight_delivery.
DATA(lv_tenths) = ( lv_points + c_round_half ) DIV c_ten.
rv_score = CONV ty_score( lv_tenths ) * c_tenth.
ENDMETHOD.
METHOD grade_of.
IF iv_score >= c_threshold_a.
rv_grade = 'A'.
ELSEIF iv_score >= c_threshold_b.
rv_grade = 'B'.
ELSEIF iv_score >= c_threshold_c.
rv_grade = 'C'.
ELSEIF iv_score >= c_threshold_d.
rv_grade = 'D'.
ELSE.
rv_grade = 'E'.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,88 @@
CLASS {{p}}supplier_score DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_rating TYPE i.
TYPES ty_score TYPE p LENGTH 5 DECIMALS 1.
TYPES ty_grade TYPE c LENGTH 1.
TYPES:
BEGIN OF ty_result,
score TYPE ty_score,
grade TYPE ty_grade,
END OF ty_result.
METHODS evaluate
IMPORTING iv_price TYPE ty_rating
iv_quality TYPE ty_rating
iv_delivery TYPE ty_rating
RETURNING VALUE(rs_result) TYPE ty_result.
PRIVATE SECTION.
CONSTANTS:
c_weight_price TYPE i VALUE 40,
c_weight_quality TYPE i VALUE 35,
c_weight_delivery TYPE i VALUE 25,
c_round_half TYPE i VALUE 5,
c_ten TYPE i VALUE 10,
c_tenth TYPE ty_score VALUE '0.1',
c_threshold_a TYPE ty_score VALUE '4.5',
c_threshold_b TYPE ty_score VALUE '3.5',
c_threshold_c TYPE ty_score VALUE '2.5',
c_threshold_d TYPE ty_score VALUE '1.5',
c_score_blocked TYPE ty_score VALUE '0.0',
c_grade_blocked TYPE ty_grade VALUE 'X'.
METHODS is_rating_valid
IMPORTING iv_rating TYPE ty_rating
RETURNING VALUE(rv_valid) TYPE abap_bool.
METHODS weighted_score
IMPORTING iv_price TYPE ty_rating
iv_quality TYPE ty_rating
iv_delivery TYPE ty_rating
RETURNING VALUE(rv_score) TYPE ty_score.
METHODS grade_of
IMPORTING iv_score TYPE ty_score
RETURNING VALUE(rv_grade) TYPE ty_grade.
ENDCLASS.
CLASS {{p}}supplier_score IMPLEMENTATION.
METHOD evaluate.
IF is_rating_valid( iv_price ) = abap_false
OR is_rating_valid( iv_quality ) = abap_false
OR is_rating_valid( iv_delivery ) = abap_false
OR iv_quality = 1.
rs_result-score = c_score_blocked.
rs_result-grade = c_grade_blocked.
RETURN.
ENDIF.
rs_result-score = weighted_score( iv_price = iv_price
iv_quality = iv_quality
iv_delivery = iv_delivery ).
rs_result-grade = grade_of( rs_result-score ).
ENDMETHOD.
METHOD is_rating_valid.
rv_valid = xsdbool( iv_rating >= 1 AND iv_rating <= 5 ).
ENDMETHOD.
METHOD weighted_score.
DATA(lv_points) = iv_price * c_weight_price
+ iv_quality * c_weight_quality
+ iv_delivery * c_weight_delivery.
DATA(lv_tenths) = ( lv_points + c_round_half ) DIV c_ten.
rv_score = CONV ty_score( lv_tenths ) * c_tenth.
ENDMETHOD.
METHOD grade_of.
IF iv_score < c_threshold_a.
rv_grade = 'A'.
ELSEIF iv_score >= c_threshold_b.
rv_grade = 'B'.
ELSEIF iv_score >= c_threshold_c.
rv_grade = 'C'.
ELSEIF iv_score >= c_threshold_d.
rv_grade = 'D'.
ELSE.
rv_grade = 'E'.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,29 @@
{
"id": "G0100",
"pool": "eval",
"object_type": "CLAS",
"category": "A",
"attempts": [
{
"stage": "validate",
"oracle": 68.5,
"null": 0
},
{
"stage": "validate",
"oracle": 68.5,
"null": 0
},
{
"stage": "validate",
"oracle": 100.0,
"null": 0,
"mutation": {
"valid": 5,
"killed": 5,
"ok": true
}
}
],
"accepted": true
}

View File

@@ -0,0 +1,98 @@
CLASS {{p}}t02_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CONSTANTS:
c_score_5_0 TYPE {{p}}supplier_score=>ty_score VALUE '5.0',
c_score_0_0 TYPE {{p}}supplier_score=>ty_score VALUE '0.0',
c_score_4_5 TYPE {{p}}supplier_score=>ty_score VALUE '4.5',
c_score_3_5 TYPE {{p}}supplier_score=>ty_score VALUE '3.5',
c_score_2_5 TYPE {{p}}supplier_score=>ty_score VALUE '2.5',
c_score_1_9 TYPE {{p}}supplier_score=>ty_score VALUE '1.9',
c_score_1_4 TYPE {{p}}supplier_score=>ty_score VALUE '1.4',
c_score_3_7 TYPE {{p}}supplier_score=>ty_score VALUE '3.7',
c_grade_a TYPE {{p}}supplier_score=>ty_grade VALUE 'A',
c_grade_b TYPE {{p}}supplier_score=>ty_grade VALUE 'B',
c_grade_c TYPE {{p}}supplier_score=>ty_grade VALUE 'C',
c_grade_d TYPE {{p}}supplier_score=>ty_grade VALUE 'D',
c_grade_e TYPE {{p}}supplier_score=>ty_grade VALUE 'E',
c_grade_x TYPE {{p}}supplier_score=>ty_grade VALUE 'X'.
DATA mo_cut TYPE REF TO {{p}}supplier_score.
METHODS setup.
METHODS perfect_supplier FOR TESTING.
METHODS quality_one_blocks FOR TESTING.
METHODS rating_below_range FOR TESTING.
METHODS rating_above_range FOR TESTING.
METHODS grade_a_boundary FOR TESTING.
METHODS rounds_up_to_b FOR TESTING.
METHODS grade_c_boundary FOR TESTING.
METHODS grade_d FOR TESTING.
METHODS grade_e FOR TESTING.
METHODS weights_quality FOR TESTING.
ENDCLASS.
CLASS {{p}}t02_hidden IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}supplier_score( ).
ENDMETHOD.
METHOD perfect_supplier.
DATA(ls_result) = mo_cut->evaluate( iv_price = 5 iv_quality = 5 iv_delivery = 5 ).
cl_abap_unit_assert=>assert_equals( exp = c_score_5_0 act = ls_result-score ).
cl_abap_unit_assert=>assert_equals( exp = c_grade_a act = ls_result-grade ).
ENDMETHOD.
METHOD quality_one_blocks.
DATA(ls_result) = mo_cut->evaluate( iv_price = 5 iv_quality = 1 iv_delivery = 5 ).
cl_abap_unit_assert=>assert_equals( exp = c_score_0_0 act = ls_result-score ).
cl_abap_unit_assert=>assert_equals( exp = c_grade_x act = ls_result-grade ).
ENDMETHOD.
METHOD rating_below_range.
DATA(ls_result) = mo_cut->evaluate( iv_price = 0 iv_quality = 3 iv_delivery = 3 ).
cl_abap_unit_assert=>assert_equals( exp = c_score_0_0 act = ls_result-score ).
cl_abap_unit_assert=>assert_equals( exp = c_grade_x act = ls_result-grade ).
ENDMETHOD.
METHOD rating_above_range.
DATA(ls_result) = mo_cut->evaluate( iv_price = 3 iv_quality = 3 iv_delivery = 6 ).
cl_abap_unit_assert=>assert_equals( exp = c_score_0_0 act = ls_result-score ).
cl_abap_unit_assert=>assert_equals( exp = c_grade_x act = ls_result-grade ).
ENDMETHOD.
METHOD grade_a_boundary.
DATA(ls_result) = mo_cut->evaluate( iv_price = 5 iv_quality = 5 iv_delivery = 3 ).
cl_abap_unit_assert=>assert_equals( exp = c_score_4_5 act = ls_result-score ).
cl_abap_unit_assert=>assert_equals( exp = c_grade_a act = ls_result-grade ).
ENDMETHOD.
METHOD rounds_up_to_b.
DATA(ls_result) = mo_cut->evaluate( iv_price = 5 iv_quality = 2 iv_delivery = 3 ).
cl_abap_unit_assert=>assert_equals( exp = c_score_3_5 act = ls_result-score ).
cl_abap_unit_assert=>assert_equals( exp = c_grade_b act = ls_result-grade ).
ENDMETHOD.
METHOD grade_c_boundary.
DATA(ls_result) = mo_cut->evaluate( iv_price = 2 iv_quality = 2 iv_delivery = 4 ).
cl_abap_unit_assert=>assert_equals( exp = c_score_2_5 act = ls_result-score ).
cl_abap_unit_assert=>assert_equals( exp = c_grade_c act = ls_result-grade ).
ENDMETHOD.
METHOD grade_d.
DATA(ls_result) = mo_cut->evaluate( iv_price = 1 iv_quality = 2 iv_delivery = 3 ).
cl_abap_unit_assert=>assert_equals( exp = c_score_1_9 act = ls_result-score ).
cl_abap_unit_assert=>assert_equals( exp = c_grade_d act = ls_result-grade ).
ENDMETHOD.
METHOD grade_e.
DATA(ls_result) = mo_cut->evaluate( iv_price = 1 iv_quality = 2 iv_delivery = 1 ).
cl_abap_unit_assert=>assert_equals( exp = c_score_1_4 act = ls_result-score ).
cl_abap_unit_assert=>assert_equals( exp = c_grade_e act = ls_result-grade ).
ENDMETHOD.
METHOD weights_quality.
DATA(ls_result) = mo_cut->evaluate( iv_price = 3 iv_quality = 5 iv_delivery = 3 ).
cl_abap_unit_assert=>assert_equals( exp = c_score_3_7 act = ls_result-score ).
cl_abap_unit_assert=>assert_equals( exp = c_grade_b act = ls_result-grade ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,79 @@
{
"task": "G0100",
"mutants": [
{
"object": "{{P}}SUPPLIER_SCORE",
"mutant": "line 50: = -> <> (eq)",
"status": "killed",
"hidden": "3/10",
"failed_tests": [
"GRADE_A_BOUNDARY",
"GRADE_C_BOUNDARY",
"GRADE_D",
"GRADE_E",
"PERFECT_SUPPLIER",
"ROUNDS_UP_TO_B",
"WEIGHTS_QUALITY"
]
},
{
"object": "{{P}}SUPPLIER_SCORE",
"mutant": "line 51: abap_false -> abap_true (bool)",
"status": "killed",
"hidden": "2/10",
"failed_tests": [
"GRADE_A_BOUNDARY",
"GRADE_C_BOUNDARY",
"GRADE_D",
"GRADE_E",
"PERFECT_SUPPLIER",
"RATING_ABOVE_RANGE",
"ROUNDS_UP_TO_B",
"WEIGHTS_QUALITY"
]
},
{
"object": "{{P}}SUPPLIER_SCORE",
"mutant": "line 64: 5 -> 6 (const)",
"status": "killed",
"hidden": "9/10",
"failed_tests": [
"RATING_ABOVE_RANGE"
]
},
{
"object": "{{P}}SUPPLIER_SCORE",
"mutant": "line 69: + -> - (arith)",
"status": "killed",
"hidden": "3/10",
"failed_tests": [
"GRADE_A_BOUNDARY",
"GRADE_C_BOUNDARY",
"GRADE_D",
"GRADE_E",
"PERFECT_SUPPLIER",
"ROUNDS_UP_TO_B",
"WEIGHTS_QUALITY"
]
},
{
"object": "{{P}}SUPPLIER_SCORE",
"mutant": "line 76: >= -> < (rel)",
"status": "killed",
"hidden": "3/10",
"failed_tests": [
"GRADE_A_BOUNDARY",
"GRADE_C_BOUNDARY",
"GRADE_D",
"GRADE_E",
"PERFECT_SUPPLIER",
"ROUNDS_UP_TO_B",
"WEIGHTS_QUALITY"
]
}
],
"valid": 5,
"killed": 5,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,88 @@
CLASS {{p}}supplier_score DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_rating TYPE i.
TYPES ty_score TYPE p LENGTH 5 DECIMALS 1.
TYPES ty_grade TYPE c LENGTH 1.
TYPES:
BEGIN OF ty_result,
score TYPE ty_score,
grade TYPE ty_grade,
END OF ty_result.
METHODS evaluate
IMPORTING iv_price TYPE ty_rating
iv_quality TYPE ty_rating
iv_delivery TYPE ty_rating
RETURNING VALUE(rs_result) TYPE ty_result.
PRIVATE SECTION.
CONSTANTS:
c_weight_price TYPE i VALUE 40,
c_weight_quality TYPE i VALUE 35,
c_weight_delivery TYPE i VALUE 25,
c_round_half TYPE i VALUE 5,
c_ten TYPE i VALUE 10,
c_tenth TYPE ty_score VALUE '0.1',
c_threshold_a TYPE ty_score VALUE '4.5',
c_threshold_b TYPE ty_score VALUE '3.5',
c_threshold_c TYPE ty_score VALUE '2.5',
c_threshold_d TYPE ty_score VALUE '1.5',
c_score_blocked TYPE ty_score VALUE '0.0',
c_grade_blocked TYPE ty_grade VALUE 'X'.
METHODS is_rating_valid
IMPORTING iv_rating TYPE ty_rating
RETURNING VALUE(rv_valid) TYPE abap_bool.
METHODS weighted_score
IMPORTING iv_price TYPE ty_rating
iv_quality TYPE ty_rating
iv_delivery TYPE ty_rating
RETURNING VALUE(rv_score) TYPE ty_score.
METHODS grade_of
IMPORTING iv_score TYPE ty_score
RETURNING VALUE(rv_grade) TYPE ty_grade.
ENDCLASS.
CLASS {{p}}supplier_score IMPLEMENTATION.
METHOD evaluate.
IF is_rating_valid( iv_price ) = abap_false
OR is_rating_valid( iv_quality ) = abap_false
OR is_rating_valid( iv_delivery ) = abap_false
OR iv_quality = 1.
rs_result-score = c_score_blocked.
rs_result-grade = c_grade_blocked.
RETURN.
ENDIF.
rs_result-score = weighted_score( iv_price = iv_price
iv_quality = iv_quality
iv_delivery = iv_delivery ).
rs_result-grade = grade_of( rs_result-score ).
ENDMETHOD.
METHOD is_rating_valid.
rv_valid = xsdbool( iv_rating >= 1 AND iv_rating <= 5 ).
ENDMETHOD.
METHOD weighted_score.
DATA(lv_points) = iv_price * c_weight_price
+ iv_quality * c_weight_quality
+ iv_delivery * c_weight_delivery.
DATA(lv_tenths) = ( lv_points + c_round_half ) DIV c_ten.
rv_score = CONV ty_score( lv_tenths ) * c_tenth.
ENDMETHOD.
METHOD grade_of.
IF iv_score >= c_threshold_a.
rv_grade = 'A'.
ELSEIF iv_score >= c_threshold_b.
rv_grade = 'B'.
ELSEIF iv_score >= c_threshold_c.
rv_grade = 'C'.
ELSEIF iv_score >= c_threshold_d.
rv_grade = 'D'.
ELSE.
rv_grade = 'E'.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,54 @@
CLASS ltc_supplier_score DEFINITION FINAL FOR TESTING
DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CONSTANTS:
c_score_5_0 TYPE {{p}}supplier_score=>ty_score VALUE '5.0',
c_score_0_0 TYPE {{p}}supplier_score=>ty_score VALUE '0.0',
c_score_3_5 TYPE {{p}}supplier_score=>ty_score VALUE '3.5',
c_grade_a TYPE {{p}}supplier_score=>ty_grade VALUE 'A',
c_grade_b TYPE {{p}}supplier_score=>ty_grade VALUE 'B',
c_grade_x TYPE {{p}}supplier_score=>ty_grade VALUE 'X'.
DATA mo_cut TYPE REF TO {{p}}supplier_score.
METHODS setup.
METHODS perfect_supplier FOR TESTING.
METHODS blocked_quality FOR TESTING.
METHODS invalid_rating FOR TESTING.
METHODS rounded_score FOR TESTING.
METHODS grade_check FOR TESTING.
ENDCLASS.
CLASS ltc_supplier_score IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}supplier_score( ).
ENDMETHOD.
METHOD perfect_supplier.
DATA(ls_result) = mo_cut->evaluate( iv_price = 5 iv_quality = 5 iv_delivery = 5 ).
cl_abap_unit_assert=>assert_equals( exp = c_score_5_0 act = ls_result-score ).
cl_abap_unit_assert=>assert_equals( exp = c_grade_a act = ls_result-grade ).
ENDMETHOD.
METHOD blocked_quality.
DATA(ls_result) = mo_cut->evaluate( iv_price = 5 iv_quality = 1 iv_delivery = 5 ).
cl_abap_unit_assert=>assert_equals( exp = c_score_0_0 act = ls_result-score ).
cl_abap_unit_assert=>assert_equals( exp = c_grade_x act = ls_result-grade ).
ENDMETHOD.
METHOD invalid_rating.
DATA(ls_result) = mo_cut->evaluate( iv_price = 7 iv_quality = 3 iv_delivery = 3 ).
cl_abap_unit_assert=>assert_equals( exp = c_score_0_0 act = ls_result-score ).
cl_abap_unit_assert=>assert_equals( exp = c_grade_x act = ls_result-grade ).
ENDMETHOD.
METHOD rounded_score.
DATA(ls_result) = mo_cut->evaluate( iv_price = 5 iv_quality = 2 iv_delivery = 3 ).
cl_abap_unit_assert=>assert_equals( exp = c_score_3_5 act = ls_result-score ).
cl_abap_unit_assert=>assert_equals( exp = c_grade_b act = ls_result-grade ).
ENDMETHOD.
METHOD grade_check.
DATA(ls_result) = mo_cut->evaluate( iv_price = 1 iv_quality = 2 iv_delivery = 1 ).
cl_abap_unit_assert=>assert_equals( exp = 'E' act = ls_result-grade ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,62 @@
# 1. Goal
A purchasing department rates its suppliers. A scorecard program calls the rating
before it prints the scorecard. The program needs the weighted score and the grade
of a supplier.
# 2. Open questions
None.
# 3. Context
- All objects are in package $TMP.
- A supplier is rated in three criteria: price, quality, and delivery.
- Each criterion gets an integer rating from 1 (very poor) to 5 (very good).
- The scorecard program passes the three ratings to the class. It reads the score
and the grade from the result.
# 4. Contract
- Create the class {{P}}SUPPLIER_SCORE in package $TMP.
- The class is public, final, and has a public constructor without parameters.
- The class has these public types:
- TY_RATING: an integer type for one rating.
- TY_SCORE: a packed number with length 5 and 1 decimal place.
- TY_GRADE: a character type with length 1.
- TY_RESULT: a structure with the components SCORE (type TY_SCORE) and GRADE
(type TY_GRADE).
- The class has exactly this public method:
METHODS evaluate
IMPORTING iv_price TYPE ty_rating
iv_quality TYPE ty_rating
iv_delivery TYPE ty_rating
RETURNING VALUE(rs_result) TYPE ty_result.
- Do not add other public methods.
# 5. Business rules
Apply the rules in this sequence.
1. A rating is valid if it is an integer from 1 to 5. If at least one of the three
ratings is not valid, return score 0.0 and grade 'X'.
2. Quality is a knock-out criterion. If the quality rating is 1, return score 0.0
and grade 'X'.
3. Calculate the weighted score:
score = (price * 40 + quality * 35 + delivery * 25) / 100.
4. Round the score to one decimal place. Use commercial rounding, that is, round
half away from zero.
5. Derive the grade from the rounded score:
- 4.5 or more: 'A'
- 3.5 or more: 'B'
- 2.5 or more: 'C'
- 1.5 or more: 'D'
- less than 1.5: 'E'
# 6. Constraints
- Release target: SAP_BASIS 816.
- Coding standards: Clean ABAP. Every method has fewer than 40 statements. No
global variables. No comment that restates the code.
- Out of scope: database access, ALV, dynpro, and changes to other objects.
# 7. Acceptance
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.

View File

@@ -0,0 +1,41 @@
{
"id": "G0100",
"category": "A",
"object_type": "CLAS",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 50,
"max_activations": 12
},
"seed": [],
"contract": [
{
"type": "CLAS",
"name": "{{P}}SUPPLIER_SCORE"
}
],
"out_of_scope": [],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T02_HIDDEN",
"file": "hidden/t02_hidden.clas.abap",
"description": "T02 hidden tests for the supplier score"
}
],
"reference": [
{
"type": "CLAS",
"name": "{{P}}SUPPLIER_SCORE",
"file": "reference/supplier_score.clas.abap",
"description": "Supplier score calculator",
"testclasses_file": "reference/supplier_score.testclasses.abap"
}
],
"craft_checks": [
"method_length",
"db_operation_in_loop"
]
}