STRU and exception tasks accepted; G6 cascade fix, exception class mutants, RTTI unit notes
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
45
tasks_gen/train/G1904/generation.json
Normal file
45
tasks_gen/train/G1904/generation.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"id": "G1904",
|
||||
"pool": "train",
|
||||
"object_type": "CLAS",
|
||||
"category": "D",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100.0,
|
||||
"null": 0,
|
||||
"mutation": {
|
||||
"valid": 0,
|
||||
"killed": 0,
|
||||
"ok": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100.0,
|
||||
"null": 0,
|
||||
"mutation": {
|
||||
"valid": 0,
|
||||
"killed": 0,
|
||||
"ok": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100.0,
|
||||
"null": 0,
|
||||
"mutation": {
|
||||
"valid": 0,
|
||||
"killed": 0,
|
||||
"ok": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"accepted": true,
|
||||
"note": "mutation check rerun after exception-class mutants were added (3 of 3 killed)"
|
||||
}
|
||||
259
tasks_gen/train/G1904/hidden/d02_hidden.clas.abap
Normal file
259
tasks_gen/train/G1904/hidden/d02_hidden.clas.abap
Normal file
@@ -0,0 +1,259 @@
|
||||
CLASS {{p}}d02_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS unknown_material_text FOR TESTING.
|
||||
METHODS zero_quantity_text FOR TESTING.
|
||||
METHODS over_limit_text FOR TESTING.
|
||||
METHODS default_text_cases FOR TESTING.
|
||||
METHODS context_of_each_case FOR TESTING.
|
||||
METHODS unknown_case_keeps_data FOR TESTING.
|
||||
METHODS text_via_cx_root FOR TESTING.
|
||||
METHODS case_constant_values FOR TESTING.
|
||||
METHODS is_static_check_exception FOR TESTING.
|
||||
METHODS instances_keep_own_data FOR TESTING.
|
||||
METHODS same_data_different_case FOR TESTING.
|
||||
METHODS text_exact_length FOR TESTING.
|
||||
METHODS caught_error
|
||||
IMPORTING iv_case TYPE {{p}}if_issue_error_info=>ty_case
|
||||
iv_material TYPE string
|
||||
iv_quantity TYPE i
|
||||
iv_limit TYPE i
|
||||
RETURNING VALUE(ro_error) TYPE REF TO {{p}}cx_issue_error.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}d02_hidden IMPLEMENTATION.
|
||||
|
||||
METHOD caught_error.
|
||||
TRY.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_issue_error
|
||||
EXPORTING
|
||||
iv_case = iv_case
|
||||
iv_material = iv_material
|
||||
iv_quantity = iv_quantity
|
||||
iv_limit = iv_limit.
|
||||
CATCH {{p}}cx_issue_error INTO ro_error.
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_material_text.
|
||||
DATA(lo_error) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-unknown_material
|
||||
iv_material = 'MAT-1'
|
||||
iv_quantity = 5
|
||||
iv_limit = 100 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Material MAT-1 is not known`
|
||||
act = lo_error->get_text( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_quantity_text.
|
||||
DATA(lo_error) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-zero_quantity
|
||||
iv_material = 'MAT-2'
|
||||
iv_quantity = 0
|
||||
iv_limit = 50 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Quantity must not be zero for material MAT-2`
|
||||
act = lo_error->get_text( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD over_limit_text.
|
||||
DATA(lo_error) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-over_limit
|
||||
iv_material = 'MAT-3'
|
||||
iv_quantity = 120
|
||||
iv_limit = 100 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Quantity 120 exceeds limit 100 for material MAT-3`
|
||||
act = lo_error->get_text( ) ).
|
||||
|
||||
DATA(lo_big) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-over_limit
|
||||
iv_material = 'M-BIG'
|
||||
iv_quantity = 12345
|
||||
iv_limit = 67890 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Quantity 12345 exceeds limit 67890 for material M-BIG`
|
||||
act = lo_big->get_text( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD default_text_cases.
|
||||
DATA(lo_other) = caught_error( iv_case = 'SOMETHING_ELSE'
|
||||
iv_material = 'MAT-4'
|
||||
iv_quantity = 7
|
||||
iv_limit = 70 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Stock issue failed for material MAT-4`
|
||||
act = lo_other->get_text( ) ).
|
||||
|
||||
DATA(lo_empty) = caught_error( iv_case = ''
|
||||
iv_material = 'MAT-5'
|
||||
iv_quantity = 1
|
||||
iv_limit = 10 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Stock issue failed for material MAT-5`
|
||||
act = lo_empty->get_text( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD context_of_each_case.
|
||||
DATA(lo_unknown) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-unknown_material
|
||||
iv_material = 'M-1'
|
||||
iv_quantity = 11
|
||||
iv_limit = 111 ).
|
||||
DATA(lo_zero) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-zero_quantity
|
||||
iv_material = 'M-2'
|
||||
iv_quantity = 0
|
||||
iv_limit = 222 ).
|
||||
DATA(lo_over) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-over_limit
|
||||
iv_material = 'M-3'
|
||||
iv_quantity = 33
|
||||
iv_limit = 333 ).
|
||||
DATA lo_info TYPE REF TO {{p}}if_issue_error_info.
|
||||
|
||||
lo_info = lo_unknown.
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}cx_issue_error=>c_case-unknown_material
|
||||
act = lo_info->get_case( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `M-1` act = lo_info->get_material( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 11 act = lo_info->get_quantity( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 111 act = lo_info->get_limit( ) ).
|
||||
|
||||
lo_info = lo_zero.
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}cx_issue_error=>c_case-zero_quantity
|
||||
act = lo_info->get_case( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `M-2` act = lo_info->get_material( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 0 act = lo_info->get_quantity( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 222 act = lo_info->get_limit( ) ).
|
||||
|
||||
lo_info = lo_over.
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}cx_issue_error=>c_case-over_limit
|
||||
act = lo_info->get_case( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `M-3` act = lo_info->get_material( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 33 act = lo_info->get_quantity( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 333 act = lo_info->get_limit( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_case_keeps_data.
|
||||
DATA(lo_error) = caught_error( iv_case = 'SOMETHING_ELSE'
|
||||
iv_material = 'M-X'
|
||||
iv_quantity = 55
|
||||
iv_limit = 66 ).
|
||||
DATA lo_info TYPE REF TO {{p}}if_issue_error_info.
|
||||
lo_info = lo_error.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'SOMETHING_ELSE' act = lo_info->get_case( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `M-X` act = lo_info->get_material( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 55 act = lo_info->get_quantity( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 66 act = lo_info->get_limit( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Stock issue failed for material M-X`
|
||||
act = lo_error->get_text( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD text_via_cx_root.
|
||||
DATA(lo_error) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-zero_quantity
|
||||
iv_material = 'MAT-6'
|
||||
iv_quantity = 0
|
||||
iv_limit = 60 ).
|
||||
DATA lo_root TYPE REF TO cx_root.
|
||||
lo_root = lo_error.
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Quantity must not be zero for material MAT-6`
|
||||
act = lo_root->get_text( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD case_constant_values.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'UNKNOWN_MATERIAL'
|
||||
act = {{p}}cx_issue_error=>c_case-unknown_material ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'ZERO_QUANTITY'
|
||||
act = {{p}}cx_issue_error=>c_case-zero_quantity ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'OVER_LIMIT'
|
||||
act = {{p}}cx_issue_error=>c_case-over_limit ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD is_static_check_exception.
|
||||
DATA lo_caught TYPE REF TO cx_static_check.
|
||||
TRY.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_issue_error
|
||||
EXPORTING
|
||||
iv_case = {{p}}cx_issue_error=>c_case-unknown_material
|
||||
iv_material = 'MAT-7'
|
||||
iv_quantity = 3
|
||||
iv_limit = 30.
|
||||
CATCH cx_static_check INTO lo_caught.
|
||||
ENDTRY.
|
||||
cl_abap_unit_assert=>assert_bound( act = lo_caught ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD instances_keep_own_data.
|
||||
DATA(lo_first) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-unknown_material
|
||||
iv_material = 'FIRST'
|
||||
iv_quantity = 1
|
||||
iv_limit = 10 ).
|
||||
DATA(lo_second) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-over_limit
|
||||
iv_material = 'SECOND'
|
||||
iv_quantity = 2
|
||||
iv_limit = 20 ).
|
||||
DATA lo_info TYPE REF TO {{p}}if_issue_error_info.
|
||||
|
||||
lo_info = lo_first.
|
||||
cl_abap_unit_assert=>assert_equals( exp = `FIRST` act = lo_info->get_material( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Material FIRST is not known`
|
||||
act = lo_first->get_text( ) ).
|
||||
|
||||
lo_info = lo_second.
|
||||
cl_abap_unit_assert=>assert_equals( exp = `SECOND` act = lo_info->get_material( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Quantity 2 exceeds limit 20 for material SECOND`
|
||||
act = lo_second->get_text( ) ).
|
||||
|
||||
lo_info = lo_first.
|
||||
cl_abap_unit_assert=>assert_equals( exp = `FIRST` act = lo_info->get_material( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 1 act = lo_info->get_quantity( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD same_data_different_case.
|
||||
DATA lv_material TYPE string.
|
||||
DATA lv_quantity TYPE i.
|
||||
DATA lv_limit TYPE i.
|
||||
lv_material = 'MAT-S'.
|
||||
lv_quantity = 5.
|
||||
lv_limit = 10.
|
||||
|
||||
DATA(lo_unknown) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-unknown_material
|
||||
iv_material = lv_material
|
||||
iv_quantity = lv_quantity
|
||||
iv_limit = lv_limit ).
|
||||
DATA(lo_zero) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-zero_quantity
|
||||
iv_material = lv_material
|
||||
iv_quantity = lv_quantity
|
||||
iv_limit = lv_limit ).
|
||||
DATA(lo_over) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-over_limit
|
||||
iv_material = lv_material
|
||||
iv_quantity = lv_quantity
|
||||
iv_limit = lv_limit ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Material MAT-S is not known`
|
||||
act = lo_unknown->get_text( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Quantity must not be zero for material MAT-S`
|
||||
act = lo_zero->get_text( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Quantity 5 exceeds limit 10 for material MAT-S`
|
||||
act = lo_over->get_text( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD text_exact_length.
|
||||
DATA(lo_unknown) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-unknown_material
|
||||
iv_material = 'MAT-1'
|
||||
iv_quantity = 5
|
||||
iv_limit = 100 ).
|
||||
DATA(lo_zero) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-zero_quantity
|
||||
iv_material = 'MAT-2'
|
||||
iv_quantity = 0
|
||||
iv_limit = 50 ).
|
||||
DATA(lo_over) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-over_limit
|
||||
iv_material = 'MAT-3'
|
||||
iv_quantity = 120
|
||||
iv_limit = 100 ).
|
||||
|
||||
DATA lv_unknown TYPE string.
|
||||
DATA lv_zero TYPE string.
|
||||
DATA lv_over TYPE string.
|
||||
lv_unknown = `Material MAT-1 is not known`.
|
||||
lv_zero = `Quantity must not be zero for material MAT-2`.
|
||||
lv_over = `Quantity 120 exceeds limit 100 for material MAT-3`.
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = strlen( lv_unknown )
|
||||
act = strlen( lo_unknown->get_text( ) ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = strlen( lv_zero )
|
||||
act = strlen( lo_zero->get_text( ) ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = strlen( lv_over )
|
||||
act = strlen( lo_over->get_text( ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
36
tasks_gen/train/G1904/mutation.json
Normal file
36
tasks_gen/train/G1904/mutation.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"task": "G1904",
|
||||
"mutants": [
|
||||
{
|
||||
"object": "{{P}}CX_ISSUE_ERROR",
|
||||
"mutant": "line 12: VALUE 'UNKNOWN_MATERIAL' -> VALUE 'ZNKNOWN_MATERIAL' (lit)",
|
||||
"status": "killed",
|
||||
"hidden": "11/12",
|
||||
"failed_tests": [
|
||||
"CASE_CONSTANT_VALUES"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CX_ISSUE_ERROR",
|
||||
"mutant": "line 13: VALUE 'ZERO_QUANTITY' -> VALUE 'YERO_QUANTITY' (lit)",
|
||||
"status": "killed",
|
||||
"hidden": "11/12",
|
||||
"failed_tests": [
|
||||
"CASE_CONSTANT_VALUES"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}CX_ISSUE_ERROR",
|
||||
"mutant": "line 14: VALUE 'OVER_LIMIT' -> VALUE 'ZVER_LIMIT' (lit)",
|
||||
"status": "killed",
|
||||
"hidden": "11/12",
|
||||
"failed_tests": [
|
||||
"CASE_CONSTANT_VALUES"
|
||||
]
|
||||
}
|
||||
],
|
||||
"valid": 3,
|
||||
"killed": 3,
|
||||
"kill_rate": 1.0,
|
||||
"ok": true
|
||||
}
|
||||
73
tasks_gen/train/G1904/reference/cx_issue_error.clas.abap
Normal file
73
tasks_gen/train/G1904/reference/cx_issue_error.clas.abap
Normal file
@@ -0,0 +1,73 @@
|
||||
CLASS {{p}}cx_issue_error DEFINITION
|
||||
PUBLIC
|
||||
INHERITING FROM cx_static_check
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_issue_error_info.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_case,
|
||||
unknown_material TYPE {{p}}if_issue_error_info=>ty_case VALUE 'UNKNOWN_MATERIAL',
|
||||
zero_quantity TYPE {{p}}if_issue_error_info=>ty_case VALUE 'ZERO_QUANTITY',
|
||||
over_limit TYPE {{p}}if_issue_error_info=>ty_case VALUE 'OVER_LIMIT',
|
||||
END OF c_case.
|
||||
|
||||
METHODS constructor
|
||||
IMPORTING
|
||||
iv_case TYPE {{p}}if_issue_error_info=>ty_case
|
||||
iv_material TYPE string
|
||||
iv_quantity TYPE i
|
||||
iv_limit TYPE i.
|
||||
|
||||
METHODS get_text REDEFINITION.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA mv_case TYPE {{p}}if_issue_error_info=>ty_case.
|
||||
DATA mv_material TYPE string.
|
||||
DATA mv_quantity TYPE i.
|
||||
DATA mv_limit TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cx_issue_error IMPLEMENTATION.
|
||||
|
||||
METHOD constructor.
|
||||
super->constructor( ).
|
||||
mv_case = iv_case.
|
||||
mv_material = iv_material.
|
||||
mv_quantity = iv_quantity.
|
||||
mv_limit = iv_limit.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD {{p}}if_issue_error_info~get_case.
|
||||
rv_case = mv_case.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD {{p}}if_issue_error_info~get_material.
|
||||
rv_material = mv_material.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD {{p}}if_issue_error_info~get_quantity.
|
||||
rv_quantity = mv_quantity.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD {{p}}if_issue_error_info~get_limit.
|
||||
rv_limit = mv_limit.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_text.
|
||||
CASE mv_case.
|
||||
WHEN c_case-unknown_material.
|
||||
result = |Material { mv_material } is not known|.
|
||||
WHEN c_case-zero_quantity.
|
||||
result = |Quantity must not be zero for material { mv_material }|.
|
||||
WHEN c_case-over_limit.
|
||||
result = |Quantity { mv_quantity } exceeds limit { mv_limit } for material { mv_material }|.
|
||||
WHEN OTHERS.
|
||||
result = |Stock issue failed for material { mv_material }|.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
@@ -0,0 +1,81 @@
|
||||
CLASS ltc_issue_error DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS unknown_material_text FOR TESTING.
|
||||
METHODS zero_quantity_text FOR TESTING.
|
||||
METHODS over_limit_text FOR TESTING.
|
||||
METHODS default_text FOR TESTING.
|
||||
METHODS keeps_context_data FOR TESTING.
|
||||
METHODS caught_error
|
||||
IMPORTING iv_case TYPE {{p}}if_issue_error_info=>ty_case
|
||||
iv_material TYPE string
|
||||
iv_quantity TYPE i
|
||||
iv_limit TYPE i
|
||||
RETURNING VALUE(ro_error) TYPE REF TO {{p}}cx_issue_error.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_issue_error IMPLEMENTATION.
|
||||
|
||||
METHOD caught_error.
|
||||
TRY.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_issue_error
|
||||
EXPORTING
|
||||
iv_case = iv_case
|
||||
iv_material = iv_material
|
||||
iv_quantity = iv_quantity
|
||||
iv_limit = iv_limit.
|
||||
CATCH {{p}}cx_issue_error INTO ro_error.
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_material_text.
|
||||
DATA(lo_error) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-unknown_material
|
||||
iv_material = 'MAT-A'
|
||||
iv_quantity = 1
|
||||
iv_limit = 10 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Material MAT-A is not known`
|
||||
act = lo_error->get_text( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_quantity_text.
|
||||
DATA(lo_error) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-zero_quantity
|
||||
iv_material = 'MAT-B'
|
||||
iv_quantity = 0
|
||||
iv_limit = 20 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Quantity must not be zero for material MAT-B`
|
||||
act = lo_error->get_text( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD over_limit_text.
|
||||
DATA(lo_error) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-over_limit
|
||||
iv_material = 'MAT-C'
|
||||
iv_quantity = 30
|
||||
iv_limit = 20 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Quantity 30 exceeds limit 20 for material MAT-C`
|
||||
act = lo_error->get_text( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD default_text.
|
||||
DATA(lo_error) = caught_error( iv_case = 'OTHER'
|
||||
iv_material = 'MAT-D'
|
||||
iv_quantity = 5
|
||||
iv_limit = 50 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = `Stock issue failed for material MAT-D`
|
||||
act = lo_error->get_text( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD keeps_context_data.
|
||||
DATA(lo_error) = caught_error( iv_case = {{p}}cx_issue_error=>c_case-over_limit
|
||||
iv_material = 'MAT-E'
|
||||
iv_quantity = 99
|
||||
iv_limit = 90 ).
|
||||
DATA lo_info TYPE REF TO {{p}}if_issue_error_info.
|
||||
lo_info = lo_error.
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}cx_issue_error=>c_case-over_limit
|
||||
act = lo_info->get_case( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'MAT-E' act = lo_info->get_material( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 99 act = lo_info->get_quantity( ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 90 act = lo_info->get_limit( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
12
tasks_gen/train/G1904/seed/if_issue_error_info.intf.abap
Normal file
12
tasks_gen/train/G1904/seed/if_issue_error_info.intf.abap
Normal file
@@ -0,0 +1,12 @@
|
||||
INTERFACE {{p}}if_issue_error_info PUBLIC.
|
||||
TYPES ty_case TYPE c LENGTH 20.
|
||||
|
||||
METHODS get_case
|
||||
RETURNING VALUE(rv_case) TYPE ty_case.
|
||||
METHODS get_material
|
||||
RETURNING VALUE(rv_material) TYPE string.
|
||||
METHODS get_quantity
|
||||
RETURNING VALUE(rv_quantity) TYPE i.
|
||||
METHODS get_limit
|
||||
RETURNING VALUE(rv_limit) TYPE i.
|
||||
ENDINTERFACE.
|
||||
58
tasks_gen/train/G1904/spec.md
Normal file
58
tasks_gen/train/G1904/spec.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# 1. Goal
|
||||
A stock issue program must stop with a clear reason when it cannot issue a
|
||||
quantity of a material. The caller needs one exception class that carries the
|
||||
reason and the data of the failed issue.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- The interface {{P}}IF_ISSUE_ERROR_INFO exists in package $TMP. It is active.
|
||||
- The interface has the type TY_CASE (CHAR 20) and the methods GET_CASE,
|
||||
GET_MATERIAL, GET_QUANTITY and GET_LIMIT.
|
||||
- The exception class {{P}}CX_ISSUE_ERROR is raised by the stock issue program
|
||||
and caught by the caller.
|
||||
|
||||
# 4. Contract
|
||||
- Create the class {{P}}CX_ISSUE_ERROR in package $TMP.
|
||||
- The class inherits from CX_STATIC_CHECK.
|
||||
- The class is public, final, and has a public constructor.
|
||||
- The class implements {{P}}IF_ISSUE_ERROR_INFO.
|
||||
- The class has the constant structure C_CASE. Its components are
|
||||
UNKNOWN_MATERIAL, ZERO_QUANTITY and OVER_LIMIT. The type of each component is
|
||||
{{P}}IF_ISSUE_ERROR_INFO=>TY_CASE. The value of each component is its name.
|
||||
- The constructor has these importing parameters, in this order:
|
||||
IV_CASE (type {{P}}IF_ISSUE_ERROR_INFO=>TY_CASE), IV_MATERIAL (type STRING),
|
||||
IV_QUANTITY (type I), IV_LIMIT (type I).
|
||||
- The class redefines the inherited method GET_TEXT. GET_TEXT has no importing
|
||||
parameter and returns the text as a string.
|
||||
- Do not add other public methods.
|
||||
|
||||
# 5. Business rules
|
||||
1. The constructor stores IV_CASE, IV_MATERIAL, IV_QUANTITY and IV_LIMIT.
|
||||
2. {{P}}IF_ISSUE_ERROR_INFO~GET_CASE returns the stored case, ~GET_MATERIAL the
|
||||
stored material, ~GET_QUANTITY the stored quantity and ~GET_LIMIT the stored
|
||||
limit.
|
||||
3. GET_TEXT returns one text that depends on the stored case:
|
||||
- C_CASE-UNKNOWN_MATERIAL: 'Material <material> is not known'
|
||||
- C_CASE-ZERO_QUANTITY: 'Quantity must not be zero for material <material>'
|
||||
- C_CASE-OVER_LIMIT: 'Quantity <quantity> exceeds limit <limit> for material
|
||||
<material>'
|
||||
- any other case, including an empty case: 'Stock issue failed for material
|
||||
<material>'
|
||||
<material>, <quantity> and <limit> are the stored values. Write the quantity
|
||||
and the limit as plain digits, for example 120 and 100. The text has no
|
||||
leading and no trailing blanks.
|
||||
4. The class is a static check exception. A caller must handle it or declare it
|
||||
in the RAISING clause.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: SAP_BASIS 816.
|
||||
- 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}}IF_ISSUE_ERROR_INFO.
|
||||
|
||||
# 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/G1904/task.json
Normal file
50
tasks_gen/train/G1904/task.json
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"id": "G1904",
|
||||
"category": "D",
|
||||
"object_type": "CLAS",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "INTF",
|
||||
"name": "{{P}}IF_ISSUE_ERROR_INFO",
|
||||
"file": "seed/if_issue_error_info.intf.abap",
|
||||
"description": "Contract interface with the case type and the getters of the issue error"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_ISSUE_ERROR",
|
||||
"implements": "{{P}}IF_ISSUE_ERROR_INFO"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"{{P}}IF_ISSUE_ERROR_INFO"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}D02_HIDDEN",
|
||||
"file": "hidden/d02_hidden.clas.abap",
|
||||
"description": "D02 hidden tests for the issue error exception class"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_ISSUE_ERROR",
|
||||
"file": "reference/cx_issue_error.clas.abap",
|
||||
"description": "Exception class with case constants, context data and a redefined GET_TEXT",
|
||||
"testclasses_file": "reference/cx_issue_error.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user