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:
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.
|
||||
Reference in New Issue
Block a user