Stage 2 summary at 50 accepted trajectories

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 18:02:52 +02:00
parent 332fb4601d
commit 5bcd1bf9cd
1230 changed files with 77563 additions and 33 deletions

View File

@@ -0,0 +1,72 @@
CLASS {{p}}tyre_checker DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
METHODS constructor
IMPORTING is_vehicle TYPE {{p}}if_tyre_order=>ty_vehicle.
METHODS check_order
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_qty
{{p}}cx_tyre_size
{{p}}cx_tyre_load
{{p}}cx_tyre_speed.
PRIVATE SECTION.
DATA ms_vehicle TYPE {{p}}if_tyre_order=>ty_vehicle.
METHODS check_qty
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_qty.
METHODS check_size
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_size.
METHODS check_load
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_load.
METHODS check_speed
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_speed.
ENDCLASS.
CLASS {{p}}tyre_checker IMPLEMENTATION.
METHOD constructor.
ms_vehicle = is_vehicle.
ENDMETHOD.
METHOD check_order.
check_qty( is_order ).
check_size( is_order ).
check_load( is_order ).
check_speed( is_order ).
ENDMETHOD.
METHOD check_qty.
IF is_order-qty >= 1 OR is_order-qty > 4.
RAISE EXCEPTION TYPE {{p}}cx_tyre_qty.
ENDIF.
ENDMETHOD.
METHOD check_size.
IF is_order-width_mm <> ms_vehicle-width_mm
OR is_order-profile_pct <> ms_vehicle-profile_pct
OR is_order-rim_inch <> ms_vehicle-rim_inch.
RAISE EXCEPTION TYPE {{p}}cx_tyre_size.
ENDIF.
ENDMETHOD.
METHOD check_load.
IF is_order-load_index < ms_vehicle-load_index.
RAISE EXCEPTION TYPE {{p}}cx_tyre_load.
ENDIF.
ENDMETHOD.
METHOD check_speed.
IF is_order-speed_kmh < ms_vehicle-speed_kmh.
RAISE EXCEPTION TYPE {{p}}cx_tyre_speed.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,72 @@
CLASS {{p}}tyre_checker DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
METHODS constructor
IMPORTING is_vehicle TYPE {{p}}if_tyre_order=>ty_vehicle.
METHODS check_order
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_qty
{{p}}cx_tyre_size
{{p}}cx_tyre_load
{{p}}cx_tyre_speed.
PRIVATE SECTION.
DATA ms_vehicle TYPE {{p}}if_tyre_order=>ty_vehicle.
METHODS check_qty
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_qty.
METHODS check_size
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_size.
METHODS check_load
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_load.
METHODS check_speed
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_speed.
ENDCLASS.
CLASS {{p}}tyre_checker IMPLEMENTATION.
METHOD constructor.
ms_vehicle = is_vehicle.
ENDMETHOD.
METHOD check_order.
check_qty( is_order ).
check_size( is_order ).
check_load( is_order ).
check_speed( is_order ).
ENDMETHOD.
METHOD check_qty.
IF is_order-qty < 2 OR is_order-qty > 4.
RAISE EXCEPTION TYPE {{p}}cx_tyre_qty.
ENDIF.
ENDMETHOD.
METHOD check_size.
IF is_order-width_mm <> ms_vehicle-width_mm
OR is_order-profile_pct <> ms_vehicle-profile_pct
OR is_order-rim_inch <> ms_vehicle-rim_inch.
RAISE EXCEPTION TYPE {{p}}cx_tyre_size.
ENDIF.
ENDMETHOD.
METHOD check_load.
IF is_order-load_index < ms_vehicle-load_index.
RAISE EXCEPTION TYPE {{p}}cx_tyre_load.
ENDIF.
ENDMETHOD.
METHOD check_speed.
IF is_order-speed_kmh < ms_vehicle-speed_kmh.
RAISE EXCEPTION TYPE {{p}}cx_tyre_speed.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,72 @@
CLASS {{p}}tyre_checker DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
METHODS constructor
IMPORTING is_vehicle TYPE {{p}}if_tyre_order=>ty_vehicle.
METHODS check_order
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_qty
{{p}}cx_tyre_size
{{p}}cx_tyre_load
{{p}}cx_tyre_speed.
PRIVATE SECTION.
DATA ms_vehicle TYPE {{p}}if_tyre_order=>ty_vehicle.
METHODS check_qty
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_qty.
METHODS check_size
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_size.
METHODS check_load
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_load.
METHODS check_speed
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_speed.
ENDCLASS.
CLASS {{p}}tyre_checker IMPLEMENTATION.
METHOD constructor.
ms_vehicle = is_vehicle.
ENDMETHOD.
METHOD check_order.
check_qty( is_order ).
check_size( is_order ).
check_load( is_order ).
check_speed( is_order ).
ENDMETHOD.
METHOD check_qty.
IF is_order-qty < 1 OR is_order-qty > 4.
RAISE EXCEPTION TYPE {{p}}cx_tyre_qty.
ENDIF.
ENDMETHOD.
METHOD check_size.
IF is_order-width_mm = ms_vehicle-width_mm
OR is_order-profile_pct <> ms_vehicle-profile_pct
OR is_order-rim_inch <> ms_vehicle-rim_inch.
RAISE EXCEPTION TYPE {{p}}cx_tyre_size.
ENDIF.
ENDMETHOD.
METHOD check_load.
IF is_order-load_index < ms_vehicle-load_index.
RAISE EXCEPTION TYPE {{p}}cx_tyre_load.
ENDIF.
ENDMETHOD.
METHOD check_speed.
IF is_order-speed_kmh < ms_vehicle-speed_kmh.
RAISE EXCEPTION TYPE {{p}}cx_tyre_speed.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,72 @@
CLASS {{p}}tyre_checker DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
METHODS constructor
IMPORTING is_vehicle TYPE {{p}}if_tyre_order=>ty_vehicle.
METHODS check_order
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_qty
{{p}}cx_tyre_size
{{p}}cx_tyre_load
{{p}}cx_tyre_speed.
PRIVATE SECTION.
DATA ms_vehicle TYPE {{p}}if_tyre_order=>ty_vehicle.
METHODS check_qty
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_qty.
METHODS check_size
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_size.
METHODS check_load
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_load.
METHODS check_speed
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_speed.
ENDCLASS.
CLASS {{p}}tyre_checker IMPLEMENTATION.
METHOD constructor.
ms_vehicle = is_vehicle.
ENDMETHOD.
METHOD check_order.
check_qty( is_order ).
check_size( is_order ).
check_load( is_order ).
check_speed( is_order ).
ENDMETHOD.
METHOD check_qty.
IF is_order-qty < 1 OR is_order-qty > 4.
RAISE EXCEPTION TYPE {{p}}cx_tyre_qty.
ENDIF.
ENDMETHOD.
METHOD check_size.
IF is_order-width_mm <> ms_vehicle-width_mm
AND is_order-profile_pct <> ms_vehicle-profile_pct
OR is_order-rim_inch <> ms_vehicle-rim_inch.
RAISE EXCEPTION TYPE {{p}}cx_tyre_size.
ENDIF.
ENDMETHOD.
METHOD check_load.
IF is_order-load_index < ms_vehicle-load_index.
RAISE EXCEPTION TYPE {{p}}cx_tyre_load.
ENDIF.
ENDMETHOD.
METHOD check_speed.
IF is_order-speed_kmh < ms_vehicle-speed_kmh.
RAISE EXCEPTION TYPE {{p}}cx_tyre_speed.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,72 @@
CLASS {{p}}tyre_checker DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
METHODS constructor
IMPORTING is_vehicle TYPE {{p}}if_tyre_order=>ty_vehicle.
METHODS check_order
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_qty
{{p}}cx_tyre_size
{{p}}cx_tyre_load
{{p}}cx_tyre_speed.
PRIVATE SECTION.
DATA ms_vehicle TYPE {{p}}if_tyre_order=>ty_vehicle.
METHODS check_qty
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_qty.
METHODS check_size
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_size.
METHODS check_load
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_load.
METHODS check_speed
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_speed.
ENDCLASS.
CLASS {{p}}tyre_checker IMPLEMENTATION.
METHOD constructor.
ms_vehicle = is_vehicle.
ENDMETHOD.
METHOD check_order.
check_qty( is_order ).
check_size( is_order ).
check_load( is_order ).
check_speed( is_order ).
ENDMETHOD.
METHOD check_qty.
IF is_order-qty < 1 OR is_order-qty > 4.
RAISE EXCEPTION TYPE {{p}}cx_tyre_qty.
ENDIF.
ENDMETHOD.
METHOD check_size.
IF is_order-width_mm <> ms_vehicle-width_mm
OR is_order-profile_pct <> ms_vehicle-profile_pct
OR is_order-rim_inch <> ms_vehicle-rim_inch.
RAISE EXCEPTION TYPE {{p}}cx_tyre_size.
ENDIF.
ENDMETHOD.
METHOD check_load.
IF is_order-load_index >= ms_vehicle-load_index.
RAISE EXCEPTION TYPE {{p}}cx_tyre_load.
ENDIF.
ENDMETHOD.
METHOD check_speed.
IF is_order-speed_kmh < ms_vehicle-speed_kmh.
RAISE EXCEPTION TYPE {{p}}cx_tyre_speed.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

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

View File

@@ -0,0 +1,182 @@
CLASS {{p}}t20_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mo_cut TYPE REF TO {{p}}tyre_checker.
METHODS setup.
METHODS accepts_valid_order FOR TESTING.
METHODS accepts_higher_ratings FOR TESTING.
METHODS rejects_zero_qty FOR TESTING.
METHODS rejects_five_tyres FOR TESTING.
METHODS rejects_wrong_width FOR TESTING.
METHODS rejects_wrong_profile FOR TESTING.
METHODS rejects_wrong_rim FOR TESTING.
METHODS rejects_low_load FOR TESTING.
METHODS rejects_low_speed FOR TESTING.
METHODS qty_checked_first FOR TESTING.
METHODS size_checked_before_load FOR TESTING.
METHODS load_checked_before_speed FOR TESTING.
ENDCLASS.
CLASS {{p}}t20_hidden IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}tyre_checker(
is_vehicle = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16
load_index = 91 speed_kmh = 240 ) ).
ENDMETHOD.
METHOD accepts_valid_order.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16
load_index = 91 speed_kmh = 240 qty = 1 ) ).
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16
load_index = 91 speed_kmh = 240 qty = 4 ) ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>fail( |Unexpected exception: { lo_error->mv_text }| ).
ENDTRY.
ENDMETHOD.
METHOD accepts_higher_ratings.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16
load_index = 95 speed_kmh = 270 qty = 2 ) ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>fail( |Unexpected exception: { lo_error->mv_text }| ).
ENDTRY.
ENDMETHOD.
METHOD rejects_zero_qty.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16
load_index = 91 speed_kmh = 240 qty = 0 ) ).
cl_abap_unit_assert=>fail( `An exception is expected` ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>assert_equals(
exp = `Quantity must be between 1 and 4`
act = lo_error->mv_text ).
ENDTRY.
ENDMETHOD.
METHOD rejects_five_tyres.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16
load_index = 91 speed_kmh = 240 qty = 5 ) ).
cl_abap_unit_assert=>fail( `An exception is expected` ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>assert_equals(
exp = `Quantity must be between 1 and 4`
act = lo_error->mv_text ).
ENDTRY.
ENDMETHOD.
METHOD rejects_wrong_width.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 195 profile_pct = 55 rim_inch = 16
load_index = 91 speed_kmh = 240 qty = 2 ) ).
cl_abap_unit_assert=>fail( `An exception is expected` ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>assert_equals(
exp = `Tyre size does not match the vehicle`
act = lo_error->mv_text ).
ENDTRY.
ENDMETHOD.
METHOD rejects_wrong_profile.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 60 rim_inch = 16
load_index = 91 speed_kmh = 240 qty = 2 ) ).
cl_abap_unit_assert=>fail( `An exception is expected` ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>assert_equals(
exp = `Tyre size does not match the vehicle`
act = lo_error->mv_text ).
ENDTRY.
ENDMETHOD.
METHOD rejects_wrong_rim.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 15
load_index = 91 speed_kmh = 240 qty = 2 ) ).
cl_abap_unit_assert=>fail( `An exception is expected` ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>assert_equals(
exp = `Tyre size does not match the vehicle`
act = lo_error->mv_text ).
ENDTRY.
ENDMETHOD.
METHOD rejects_low_load.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16
load_index = 88 speed_kmh = 240 qty = 2 ) ).
cl_abap_unit_assert=>fail( `An exception is expected` ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>assert_equals(
exp = `Load index is too low`
act = lo_error->mv_text ).
ENDTRY.
ENDMETHOD.
METHOD rejects_low_speed.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16
load_index = 91 speed_kmh = 210 qty = 2 ) ).
cl_abap_unit_assert=>fail( `An exception is expected` ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>assert_equals(
exp = `Speed rating is too low`
act = lo_error->mv_text ).
ENDTRY.
ENDMETHOD.
METHOD qty_checked_first.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 999 profile_pct = 55 rim_inch = 16
load_index = 91 speed_kmh = 240 qty = 0 ) ).
cl_abap_unit_assert=>fail( `An exception is expected` ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>assert_equals(
exp = `Quantity must be between 1 and 4`
act = lo_error->mv_text ).
ENDTRY.
ENDMETHOD.
METHOD size_checked_before_load.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 999 profile_pct = 55 rim_inch = 16
load_index = 50 speed_kmh = 240 qty = 2 ) ).
cl_abap_unit_assert=>fail( `An exception is expected` ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>assert_equals(
exp = `Tyre size does not match the vehicle`
act = lo_error->mv_text ).
ENDTRY.
ENDMETHOD.
METHOD load_checked_before_speed.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16
load_index = 50 speed_kmh = 100 qty = 2 ) ).
cl_abap_unit_assert=>fail( `An exception is expected` ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>assert_equals(
exp = `Load index is too low`
act = lo_error->mv_text ).
ENDTRY.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,76 @@
{
"task": "G1056",
"mutants": [
{
"object": "{{P}}TYRE_CHECKER",
"mutant": "line 48: < -> >= (rel)",
"status": "killed",
"hidden": "1/12",
"failed_tests": [
"ACCEPTS_HIGHER_RATINGS",
"ACCEPTS_VALID_ORDER",
"LOAD_CHECKED_BEFORE_SPEED",
"QTY_CHECKED_FIRST",
"REJECTS_LOW_LOAD",
"REJECTS_LOW_SPEED",
"REJECTS_WRONG_PROFILE",
"REJECTS_WRONG_RIM",
"REJECTS_WRONG_WIDTH",
"REJECTS_ZERO_QTY",
"SIZE_CHECKED_BEFORE_LOAD"
]
},
{
"object": "{{P}}TYRE_CHECKER",
"mutant": "line 48: 1 -> 2 (const)",
"status": "killed",
"hidden": "11/12",
"failed_tests": [
"ACCEPTS_VALID_ORDER"
]
},
{
"object": "{{P}}TYRE_CHECKER",
"mutant": "line 54: <> -> = (rel)",
"status": "killed",
"hidden": "5/12",
"failed_tests": [
"ACCEPTS_HIGHER_RATINGS",
"ACCEPTS_VALID_ORDER",
"LOAD_CHECKED_BEFORE_SPEED",
"REJECTS_LOW_LOAD",
"REJECTS_LOW_SPEED",
"REJECTS_WRONG_WIDTH",
"SIZE_CHECKED_BEFORE_LOAD"
]
},
{
"object": "{{P}}TYRE_CHECKER",
"mutant": "line 55: OR -> AND (logic)",
"status": "killed",
"hidden": "9/12",
"failed_tests": [
"REJECTS_WRONG_PROFILE",
"REJECTS_WRONG_WIDTH",
"SIZE_CHECKED_BEFORE_LOAD"
]
},
{
"object": "{{P}}TYRE_CHECKER",
"mutant": "line 62: < -> >= (rel)",
"status": "killed",
"hidden": "7/12",
"failed_tests": [
"ACCEPTS_HIGHER_RATINGS",
"ACCEPTS_VALID_ORDER",
"LOAD_CHECKED_BEFORE_SPEED",
"REJECTS_LOW_LOAD",
"REJECTS_LOW_SPEED"
]
}
],
"valid": 5,
"killed": 5,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,19 @@
CLASS {{p}}cx_tyre_error DEFINITION
PUBLIC
INHERITING FROM cx_static_check
CREATE PUBLIC.
PUBLIC SECTION.
METHODS constructor
IMPORTING iv_text TYPE string.
DATA mv_text TYPE string READ-ONLY.
ENDCLASS.
CLASS {{p}}cx_tyre_error IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
mv_text = iv_text.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,16 @@
CLASS {{p}}cx_tyre_load DEFINITION
PUBLIC
INHERITING FROM {{p}}cx_tyre_error
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
METHODS constructor.
ENDCLASS.
CLASS {{p}}cx_tyre_load IMPLEMENTATION.
METHOD constructor.
super->constructor( iv_text = 'Load index is too low' ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,16 @@
CLASS {{p}}cx_tyre_qty DEFINITION
PUBLIC
INHERITING FROM {{p}}cx_tyre_error
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
METHODS constructor.
ENDCLASS.
CLASS {{p}}cx_tyre_qty IMPLEMENTATION.
METHOD constructor.
super->constructor( iv_text = 'Quantity must be between 1 and 4' ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,16 @@
CLASS {{p}}cx_tyre_size DEFINITION
PUBLIC
INHERITING FROM {{p}}cx_tyre_error
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
METHODS constructor.
ENDCLASS.
CLASS {{p}}cx_tyre_size IMPLEMENTATION.
METHOD constructor.
super->constructor( iv_text = 'Tyre size does not match the vehicle' ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,16 @@
CLASS {{p}}cx_tyre_speed DEFINITION
PUBLIC
INHERITING FROM {{p}}cx_tyre_error
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
METHODS constructor.
ENDCLASS.
CLASS {{p}}cx_tyre_speed IMPLEMENTATION.
METHOD constructor.
super->constructor( iv_text = 'Speed rating is too low' ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,72 @@
CLASS {{p}}tyre_checker DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
METHODS constructor
IMPORTING is_vehicle TYPE {{p}}if_tyre_order=>ty_vehicle.
METHODS check_order
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_qty
{{p}}cx_tyre_size
{{p}}cx_tyre_load
{{p}}cx_tyre_speed.
PRIVATE SECTION.
DATA ms_vehicle TYPE {{p}}if_tyre_order=>ty_vehicle.
METHODS check_qty
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_qty.
METHODS check_size
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_size.
METHODS check_load
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_load.
METHODS check_speed
IMPORTING is_order TYPE {{p}}if_tyre_order=>ty_order
RAISING {{p}}cx_tyre_speed.
ENDCLASS.
CLASS {{p}}tyre_checker IMPLEMENTATION.
METHOD constructor.
ms_vehicle = is_vehicle.
ENDMETHOD.
METHOD check_order.
check_qty( is_order ).
check_size( is_order ).
check_load( is_order ).
check_speed( is_order ).
ENDMETHOD.
METHOD check_qty.
IF is_order-qty < 1 OR is_order-qty > 4.
RAISE EXCEPTION TYPE {{p}}cx_tyre_qty.
ENDIF.
ENDMETHOD.
METHOD check_size.
IF is_order-width_mm <> ms_vehicle-width_mm
OR is_order-profile_pct <> ms_vehicle-profile_pct
OR is_order-rim_inch <> ms_vehicle-rim_inch.
RAISE EXCEPTION TYPE {{p}}cx_tyre_size.
ENDIF.
ENDMETHOD.
METHOD check_load.
IF is_order-load_index < ms_vehicle-load_index.
RAISE EXCEPTION TYPE {{p}}cx_tyre_load.
ENDIF.
ENDMETHOD.
METHOD check_speed.
IF is_order-speed_kmh < ms_vehicle-speed_kmh.
RAISE EXCEPTION TYPE {{p}}cx_tyre_speed.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,96 @@
CLASS ltc_tyre_checker DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mo_cut TYPE REF TO {{p}}tyre_checker.
METHODS setup.
METHODS accepts_valid_order FOR TESTING.
METHODS rejects_bad_qty FOR TESTING.
METHODS rejects_wrong_size FOR TESTING.
METHODS rejects_low_load FOR TESTING.
METHODS rejects_low_speed FOR TESTING.
METHODS reports_qty_message FOR TESTING.
ENDCLASS.
CLASS ltc_tyre_checker IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}tyre_checker(
is_vehicle = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16
load_index = 91 speed_kmh = 240 ) ).
ENDMETHOD.
METHOD accepts_valid_order.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16
load_index = 91 speed_kmh = 240 qty = 4 ) ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>fail( |Unexpected exception: { lo_error->mv_text }| ).
ENDTRY.
ENDMETHOD.
METHOD rejects_bad_qty.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16
load_index = 91 speed_kmh = 240 qty = 0 ) ).
cl_abap_unit_assert=>fail( `An exception is expected` ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>assert_equals(
exp = `Quantity must be between 1 and 4`
act = lo_error->mv_text ).
ENDTRY.
ENDMETHOD.
METHOD rejects_wrong_size.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 60 rim_inch = 16
load_index = 91 speed_kmh = 240 qty = 2 ) ).
cl_abap_unit_assert=>fail( `An exception is expected` ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>assert_equals(
exp = `Tyre size does not match the vehicle`
act = lo_error->mv_text ).
ENDTRY.
ENDMETHOD.
METHOD rejects_low_load.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16
load_index = 90 speed_kmh = 240 qty = 2 ) ).
cl_abap_unit_assert=>fail( `An exception is expected` ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>assert_equals(
exp = `Load index is too low`
act = lo_error->mv_text ).
ENDTRY.
ENDMETHOD.
METHOD rejects_low_speed.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16
load_index = 91 speed_kmh = 230 qty = 2 ) ).
cl_abap_unit_assert=>fail( `An exception is expected` ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>assert_equals(
exp = `Speed rating is too low`
act = lo_error->mv_text ).
ENDTRY.
ENDMETHOD.
METHOD reports_qty_message.
TRY.
mo_cut->check_order(
is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16
load_index = 91 speed_kmh = 240 qty = 5 ) ).
cl_abap_unit_assert=>fail( `An exception is expected` ).
CATCH {{p}}cx_tyre_error INTO DATA(lo_error).
cl_abap_unit_assert=>assert_equals(
exp = `Quantity must be between 1 and 4`
act = lo_error->mv_text ).
ENDTRY.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,18 @@
INTERFACE {{p}}if_tyre_order PUBLIC.
TYPES:
BEGIN OF ty_vehicle,
width_mm TYPE i,
profile_pct TYPE i,
rim_inch TYPE i,
load_index TYPE i,
speed_kmh TYPE i,
END OF ty_vehicle,
BEGIN OF ty_order,
width_mm TYPE i,
profile_pct TYPE i,
rim_inch TYPE i,
load_index TYPE i,
speed_kmh TYPE i,
qty TYPE i,
END OF ty_order.
ENDINTERFACE.

View File

@@ -0,0 +1,77 @@
# 1. Goal
A tyre shop fits tyres to a vehicle. Before the mechanic starts a job, the
shop checks the fitting order against the vehicle. The shop needs one reason
for each rejected order.
# 2. Open questions
None.
# 3. Context
- The interface {{P}}IF_TYRE_ORDER exists in package $TMP. It is active.
- The interface has two types:
- TY_VEHICLE with the components WIDTH_MM, PROFILE_PCT, RIM_INCH,
LOAD_INDEX and SPEED_KMH. All components have the type i.
- TY_ORDER with the components WIDTH_MM, PROFILE_PCT, RIM_INCH, LOAD_INDEX,
SPEED_KMH and QTY. All components have the type i.
- WIDTH_MM is the tyre width in millimetres. PROFILE_PCT is the aspect ratio
in percent. RIM_INCH is the rim diameter in inches. LOAD_INDEX is the load
index of the tyre. SPEED_KMH is the maximum speed in kilometres per hour.
QTY is the number of tyres of the order.
# 4. Contract
Create these objects in package $TMP.
- Class {{P}}TYRE_CHECKER. It is public and final.
- Public constructor:
CONSTRUCTOR IMPORTING is_vehicle TYPE {{P}}IF_TYRE_ORDER=>TY_VEHICLE.
- Public method:
CHECK_ORDER IMPORTING is_order TYPE {{P}}IF_TYRE_ORDER=>TY_ORDER
RAISING {{P}}CX_TYRE_QTY {{P}}CX_TYRE_SIZE {{P}}CX_TYRE_LOAD
{{P}}CX_TYRE_SPEED.
- Exception class {{P}}CX_TYRE_ERROR. It inherits from CX_STATIC_CHECK.
- Public read-only attribute MV_TEXT TYPE string.
- Public constructor:
CONSTRUCTOR IMPORTING iv_text TYPE string.
- Exception class {{P}}CX_TYRE_QTY. It inherits from {{P}}CX_TYRE_ERROR.
- Public constructor without parameters.
- Exception class {{P}}CX_TYRE_SIZE. It inherits from {{P}}CX_TYRE_ERROR.
- Public constructor without parameters.
- Exception class {{P}}CX_TYRE_LOAD. It inherits from {{P}}CX_TYRE_ERROR.
- Public constructor without parameters.
- Exception class {{P}}CX_TYRE_SPEED. It inherits from {{P}}CX_TYRE_ERROR.
- Public constructor without parameters.
Do not add other public methods to {{P}}TYRE_CHECKER.
# 5. Business rules
CHECK_ORDER compares the order with the vehicle of the constructor. Check the
rules in this sequence. Raise the exception of the first rule that fails. Do
not check a rule after a rule has failed.
1. QTY must be greater than or equal to 1 and less than or equal to 4. If not,
raise {{P}}CX_TYRE_QTY.
2. WIDTH_MM, PROFILE_PCT and RIM_INCH of the order must be equal to the
WIDTH_MM, PROFILE_PCT and RIM_INCH of the vehicle. If not, raise
{{P}}CX_TYRE_SIZE.
3. LOAD_INDEX of the order must be greater than or equal to the LOAD_INDEX of
the vehicle. If not, raise {{P}}CX_TYRE_LOAD.
4. SPEED_KMH of the order must be greater than or equal to the SPEED_KMH of
the vehicle. If not, raise {{P}}CX_TYRE_SPEED.
5. If no rule fails, the method returns without an exception.
Each exception class sets MV_TEXT in its own constructor:
- {{P}}CX_TYRE_QTY: 'Quantity must be between 1 and 4'
- {{P}}CX_TYRE_SIZE: 'Tyre size does not match the vehicle'
- {{P}}CX_TYRE_LOAD: 'Load index is too low'
- {{P}}CX_TYRE_SPEED: 'Speed rating is too low'
# 6. Constraints
- Release target: 8.16.
- 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_TYRE_ORDER.
# 7. Acceptance
- All objects are active and have no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.

View File

@@ -0,0 +1,100 @@
{
"id": "G1056",
"category": "D",
"object_type": "CLAS",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 80,
"max_activations": 20
},
"seed": [
{
"type": "INTF",
"name": "{{P}}IF_TYRE_ORDER",
"file": "seed/if_tyre_order.intf.abap",
"description": "Types for the fitting order and the vehicle"
}
],
"contract": [
{
"type": "CLAS",
"name": "{{P}}TYRE_CHECKER"
},
{
"type": "CLAS",
"name": "{{P}}CX_TYRE_ERROR"
},
{
"type": "CLAS",
"name": "{{P}}CX_TYRE_QTY"
},
{
"type": "CLAS",
"name": "{{P}}CX_TYRE_SIZE"
},
{
"type": "CLAS",
"name": "{{P}}CX_TYRE_LOAD"
},
{
"type": "CLAS",
"name": "{{P}}CX_TYRE_SPEED"
}
],
"out_of_scope": [
"{{P}}IF_TYRE_ORDER"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T20_HIDDEN",
"file": "hidden/t20_hidden.clas.abap",
"description": "T20 hidden tests"
}
],
"reference": [
{
"type": "CLAS",
"name": "{{P}}CX_TYRE_ERROR",
"file": "reference/cx_tyre_error.clas.abap",
"description": "Exception superclass with a message text"
},
{
"type": "CLAS",
"name": "{{P}}CX_TYRE_QTY",
"file": "reference/cx_tyre_qty.clas.abap",
"description": "Invalid quantity"
},
{
"type": "CLAS",
"name": "{{P}}CX_TYRE_SIZE",
"file": "reference/cx_tyre_size.clas.abap",
"description": "Tyre size does not fit the vehicle"
},
{
"type": "CLAS",
"name": "{{P}}CX_TYRE_LOAD",
"file": "reference/cx_tyre_load.clas.abap",
"description": "Load index too low"
},
{
"type": "CLAS",
"name": "{{P}}CX_TYRE_SPEED",
"file": "reference/cx_tyre_speed.clas.abap",
"description": "Speed rating too low"
},
{
"type": "CLAS",
"name": "{{P}}TYRE_CHECKER",
"file": "reference/tyre_checker.clas.abap",
"description": "Checks a tyre fitting order against a vehicle",
"testclasses_file": "reference/tyre_checker.testclasses.abap"
}
],
"craft_checks": [
"method_length",
"cyclomatic_complexity"
]
}