Pipeline controller: plan 2 (hard +, error +50 %), backlog throttle, 2 trajectory workers, stop rules, summaries every 50; budget reserve

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 13:35:54 +02:00
parent 1c4667a0fc
commit 13360292dd
781 changed files with 50211 additions and 22 deletions

View File

@@ -0,0 +1,113 @@
CLASS {{p}}escape_checker DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_room TYPE c LENGTH 4.
TYPES ty_price TYPE p LENGTH 8 DECIMALS 2.
METHODS check_booking
IMPORTING iv_room TYPE ty_room
iv_players TYPE i
iv_youngest_age TYPE i
iv_lead_hours TYPE i
RETURNING VALUE(rv_price) TYPE ty_price
RAISING {{p}}cx_escape_room
{{p}}cx_escape_players
{{p}}cx_escape_age
{{p}}cx_escape_time.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_rule,
room_code TYPE ty_room,
min_players TYPE i,
max_players TYPE i,
min_age TYPE i,
price_per_player TYPE ty_price,
min_lead_hours TYPE i,
END OF ty_rule,
tt_rule TYPE HASHED TABLE OF ty_rule WITH UNIQUE KEY room_code.
METHODS rules
RETURNING VALUE(rt_rule) TYPE tt_rule.
METHODS find_rule
IMPORTING iv_room TYPE ty_room
RETURNING VALUE(rs_rule) TYPE ty_rule
RAISING {{p}}cx_escape_room.
METHODS check_players
IMPORTING is_rule TYPE ty_rule
iv_players TYPE i
RAISING {{p}}cx_escape_players.
METHODS check_age
IMPORTING is_rule TYPE ty_rule
iv_age TYPE i
RAISING {{p}}cx_escape_age.
METHODS check_lead_hours
IMPORTING is_rule TYPE ty_rule
iv_lead_hours TYPE i
RAISING {{p}}cx_escape_time.
METHODS booking_price
IMPORTING is_rule TYPE ty_rule
iv_players TYPE i
RETURNING VALUE(rv_price) TYPE ty_price.
ENDCLASS.
CLASS {{p}}escape_checker IMPLEMENTATION.
METHOD check_booking.
DATA(ls_rule) = find_rule( iv_room ).
check_players( is_rule = ls_rule iv_players = iv_players ).
check_age( is_rule = ls_rule iv_age = iv_youngest_age ).
check_lead_hours( is_rule = ls_rule iv_lead_hours = iv_lead_hours ).
rv_price = booking_price( is_rule = ls_rule iv_players = iv_players ).
ENDMETHOD.
METHOD rules.
rt_rule = VALUE #(
( room_code = 'MARS' min_players = 2 max_players = 6 min_age = 12 price_per_player = 25 min_lead_hours = 2 )
( room_code = 'DEEP' min_players = 3 max_players = 8 min_age = 17 price_per_player = 30 min_lead_hours = 4 )
( room_code = 'JUNG' min_players = 2 max_players = 4 min_age = 8 price_per_player = 22 min_lead_hours = 1 )
( room_code = 'BANK' min_players = 4 max_players = 10 min_age = 18 price_per_player = 35 min_lead_hours = 6 ) ).
ENDMETHOD.
METHOD find_rule.
DATA lv_room TYPE ty_room.
lv_room = to_upper( replace( val = iv_room sub = ` ` with = `` occ = 0 ) ).
DATA(lt_rule) = rules( ).
READ TABLE lt_rule INTO rs_rule WITH TABLE KEY room_code = lv_room.
IF sy-subrc <> 0.
RAISE EXCEPTION TYPE {{p}}cx_escape_room
EXPORTING iv_text = |Room { iv_room } is not known|.
ENDIF.
ENDMETHOD.
METHOD check_players.
IF iv_players < is_rule-min_players.
RAISE EXCEPTION TYPE {{p}}cx_escape_players
EXPORTING iv_text = 'The group is smaller than the minimum of the room'.
ENDIF.
IF iv_players > is_rule-max_players.
RAISE EXCEPTION TYPE {{p}}cx_escape_players
EXPORTING iv_text = 'The group is larger than the maximum of the room'.
ENDIF.
ENDMETHOD.
METHOD check_age.
IF iv_age < is_rule-min_age.
RAISE EXCEPTION TYPE {{p}}cx_escape_age
EXPORTING iv_text = 'The youngest player is too young for the room'.
ENDIF.
ENDMETHOD.
METHOD check_lead_hours.
IF iv_lead_hours < is_rule-min_lead_hours.
RAISE EXCEPTION TYPE {{p}}cx_escape_time
EXPORTING iv_text = 'The booking is too close to the start of the game'.
ENDIF.
ENDMETHOD.
METHOD booking_price.
rv_price = iv_players * is_rule-price_per_player.
IF iv_players = is_rule-max_players.
rv_price = rv_price * 90 / 100.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,113 @@
CLASS {{p}}escape_checker DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_room TYPE c LENGTH 4.
TYPES ty_price TYPE p LENGTH 8 DECIMALS 2.
METHODS check_booking
IMPORTING iv_room TYPE ty_room
iv_players TYPE i
iv_youngest_age TYPE i
iv_lead_hours TYPE i
RETURNING VALUE(rv_price) TYPE ty_price
RAISING {{p}}cx_escape_room
{{p}}cx_escape_players
{{p}}cx_escape_age
{{p}}cx_escape_time.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_rule,
room_code TYPE ty_room,
min_players TYPE i,
max_players TYPE i,
min_age TYPE i,
price_per_player TYPE ty_price,
min_lead_hours TYPE i,
END OF ty_rule,
tt_rule TYPE HASHED TABLE OF ty_rule WITH UNIQUE KEY room_code.
METHODS rules
RETURNING VALUE(rt_rule) TYPE tt_rule.
METHODS find_rule
IMPORTING iv_room TYPE ty_room
RETURNING VALUE(rs_rule) TYPE ty_rule
RAISING {{p}}cx_escape_room.
METHODS check_players
IMPORTING is_rule TYPE ty_rule
iv_players TYPE i
RAISING {{p}}cx_escape_players.
METHODS check_age
IMPORTING is_rule TYPE ty_rule
iv_age TYPE i
RAISING {{p}}cx_escape_age.
METHODS check_lead_hours
IMPORTING is_rule TYPE ty_rule
iv_lead_hours TYPE i
RAISING {{p}}cx_escape_time.
METHODS booking_price
IMPORTING is_rule TYPE ty_rule
iv_players TYPE i
RETURNING VALUE(rv_price) TYPE ty_price.
ENDCLASS.
CLASS {{p}}escape_checker IMPLEMENTATION.
METHOD check_booking.
DATA(ls_rule) = find_rule( iv_room ).
check_players( is_rule = ls_rule iv_players = iv_players ).
check_age( is_rule = ls_rule iv_age = iv_youngest_age ).
check_lead_hours( is_rule = ls_rule iv_lead_hours = iv_lead_hours ).
rv_price = booking_price( is_rule = ls_rule iv_players = iv_players ).
ENDMETHOD.
METHOD rules.
rt_rule = VALUE #(
( room_code = 'MARS' min_players = 2 max_players = 6 min_age = 12 price_per_player = 25 min_lead_hours = 2 )
( room_code = 'DEEP' min_players = 3 max_players = 8 min_age = 16 price_per_player = 30 min_lead_hours = 4 )
( room_code = 'JUNG' min_players = 2 max_players = 4 min_age = 8 price_per_player = 22 min_lead_hours = 1 )
( room_code = 'BANK' min_players = 4 max_players = 10 min_age = 18 price_per_player = 36 min_lead_hours = 6 ) ).
ENDMETHOD.
METHOD find_rule.
DATA lv_room TYPE ty_room.
lv_room = to_upper( replace( val = iv_room sub = ` ` with = `` occ = 0 ) ).
DATA(lt_rule) = rules( ).
READ TABLE lt_rule INTO rs_rule WITH TABLE KEY room_code = lv_room.
IF sy-subrc <> 0.
RAISE EXCEPTION TYPE {{p}}cx_escape_room
EXPORTING iv_text = |Room { iv_room } is not known|.
ENDIF.
ENDMETHOD.
METHOD check_players.
IF iv_players < is_rule-min_players.
RAISE EXCEPTION TYPE {{p}}cx_escape_players
EXPORTING iv_text = 'The group is smaller than the minimum of the room'.
ENDIF.
IF iv_players > is_rule-max_players.
RAISE EXCEPTION TYPE {{p}}cx_escape_players
EXPORTING iv_text = 'The group is larger than the maximum of the room'.
ENDIF.
ENDMETHOD.
METHOD check_age.
IF iv_age < is_rule-min_age.
RAISE EXCEPTION TYPE {{p}}cx_escape_age
EXPORTING iv_text = 'The youngest player is too young for the room'.
ENDIF.
ENDMETHOD.
METHOD check_lead_hours.
IF iv_lead_hours < is_rule-min_lead_hours.
RAISE EXCEPTION TYPE {{p}}cx_escape_time
EXPORTING iv_text = 'The booking is too close to the start of the game'.
ENDIF.
ENDMETHOD.
METHOD booking_price.
rv_price = iv_players * is_rule-price_per_player.
IF iv_players = is_rule-max_players.
rv_price = rv_price * 90 / 100.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,161 @@
CLASS {{p}}t02_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mo_cut TYPE REF TO {{p}}escape_checker.
METHODS setup.
METHODS price_mars_ok FOR TESTING.
METHODS price_group_discount FOR TESTING.
METHODS price_deep_ok FOR TESTING.
METHODS price_bank_ok FOR TESTING.
METHODS price_jung_ok FOR TESTING.
METHODS unknown_room FOR TESTING.
METHODS empty_room FOR TESTING.
METHODS lower_case_room FOR TESTING.
METHODS too_few_players FOR TESTING.
METHODS too_many_players FOR TESTING.
METHODS too_young FOR TESTING.
METHODS lead_time_too_short FOR TESTING.
METHODS assert_price
IMPORTING iv_room TYPE {{p}}escape_checker=>ty_room
iv_players TYPE i
iv_age TYPE i
iv_lead TYPE i
iv_exp TYPE {{p}}escape_checker=>ty_price.
METHODS assert_room_error
IMPORTING iv_room TYPE {{p}}escape_checker=>ty_room
iv_players TYPE i
iv_age TYPE i
iv_lead TYPE i.
METHODS assert_players_error
IMPORTING iv_room TYPE {{p}}escape_checker=>ty_room
iv_players TYPE i
iv_age TYPE i
iv_lead TYPE i.
METHODS assert_age_error
IMPORTING iv_room TYPE {{p}}escape_checker=>ty_room
iv_players TYPE i
iv_age TYPE i
iv_lead TYPE i.
METHODS assert_time_error
IMPORTING iv_room TYPE {{p}}escape_checker=>ty_room
iv_players TYPE i
iv_age TYPE i
iv_lead TYPE i.
ENDCLASS.
CLASS {{p}}t02_hidden IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}escape_checker( ).
ENDMETHOD.
METHOD price_mars_ok.
assert_price( iv_room = 'MARS' iv_players = 2 iv_age = 12 iv_lead = 2 iv_exp = '50.00' ).
ENDMETHOD.
METHOD price_group_discount.
assert_price( iv_room = 'MARS' iv_players = 6 iv_age = 12 iv_lead = 2 iv_exp = '135.00' ).
ENDMETHOD.
METHOD price_deep_ok.
assert_price( iv_room = 'DEEP' iv_players = 3 iv_age = 16 iv_lead = 4 iv_exp = '90.00' ).
ENDMETHOD.
METHOD price_bank_ok.
assert_price( iv_room = 'BANK' iv_players = 4 iv_age = 18 iv_lead = 6 iv_exp = '140.00' ).
ENDMETHOD.
METHOD price_jung_ok.
assert_price( iv_room = 'JUNG' iv_players = 2 iv_age = 8 iv_lead = 1 iv_exp = '44.00' ).
ENDMETHOD.
METHOD unknown_room.
assert_room_error( iv_room = 'XXXX' iv_players = 99 iv_age = 1 iv_lead = 0 ).
ENDMETHOD.
METHOD empty_room.
assert_room_error( iv_room = '' iv_players = 2 iv_age = 12 iv_lead = 2 ).
ENDMETHOD.
METHOD lower_case_room.
assert_price( iv_room = 'mars' iv_players = 2 iv_age = 12 iv_lead = 2 iv_exp = '50.00' ).
ENDMETHOD.
METHOD too_few_players.
assert_players_error( iv_room = 'MARS' iv_players = 1 iv_age = 5 iv_lead = 0 ).
ENDMETHOD.
METHOD too_many_players.
assert_players_error( iv_room = 'MARS' iv_players = 7 iv_age = 12 iv_lead = 2 ).
ENDMETHOD.
METHOD too_young.
assert_age_error( iv_room = 'MARS' iv_players = 2 iv_age = 11 iv_lead = 0 ).
ENDMETHOD.
METHOD lead_time_too_short.
assert_time_error( iv_room = 'MARS' iv_players = 2 iv_age = 12 iv_lead = 1 ).
ENDMETHOD.
METHOD assert_price.
TRY.
cl_abap_unit_assert=>assert_equals(
exp = iv_exp
act = mo_cut->check_booking( iv_room = iv_room iv_players = iv_players
iv_youngest_age = iv_age iv_lead_hours = iv_lead )
msg = |Room { iv_room }| ).
CATCH {{p}}cx_escape_error INTO DATA(lo_error).
cl_abap_unit_assert=>fail( |Unexpected exception: { lo_error->get_text( ) }| ).
ENDTRY.
ENDMETHOD.
METHOD assert_room_error.
TRY.
mo_cut->check_booking( iv_room = iv_room iv_players = iv_players
iv_youngest_age = iv_age iv_lead_hours = iv_lead ).
cl_abap_unit_assert=>fail( 'Exception expected' ).
CATCH {{p}}cx_escape_room INTO DATA(lo_expected).
cl_abap_unit_assert=>assert_bound( lo_expected ).
CATCH {{p}}cx_escape_error INTO DATA(lo_other).
cl_abap_unit_assert=>fail( |Wrong exception: { lo_other->get_text( ) }| ).
ENDTRY.
ENDMETHOD.
METHOD assert_players_error.
TRY.
mo_cut->check_booking( iv_room = iv_room iv_players = iv_players
iv_youngest_age = iv_age iv_lead_hours = iv_lead ).
cl_abap_unit_assert=>fail( 'Exception expected' ).
CATCH {{p}}cx_escape_players INTO DATA(lo_expected).
cl_abap_unit_assert=>assert_bound( lo_expected ).
CATCH {{p}}cx_escape_error INTO DATA(lo_other).
cl_abap_unit_assert=>fail( |Wrong exception: { lo_other->get_text( ) }| ).
ENDTRY.
ENDMETHOD.
METHOD assert_age_error.
TRY.
mo_cut->check_booking( iv_room = iv_room iv_players = iv_players
iv_youngest_age = iv_age iv_lead_hours = iv_lead ).
cl_abap_unit_assert=>fail( 'Exception expected' ).
CATCH {{p}}cx_escape_age INTO DATA(lo_expected).
cl_abap_unit_assert=>assert_bound( lo_expected ).
CATCH {{p}}cx_escape_error INTO DATA(lo_other).
cl_abap_unit_assert=>fail( |Wrong exception: { lo_other->get_text( ) }| ).
ENDTRY.
ENDMETHOD.
METHOD assert_time_error.
TRY.
mo_cut->check_booking( iv_room = iv_room iv_players = iv_players
iv_youngest_age = iv_age iv_lead_hours = iv_lead ).
cl_abap_unit_assert=>fail( 'Exception expected' ).
CATCH {{p}}cx_escape_time INTO DATA(lo_expected).
cl_abap_unit_assert=>assert_bound( lo_expected ).
CATCH {{p}}cx_escape_error INTO DATA(lo_other).
cl_abap_unit_assert=>fail( |Wrong exception: { lo_other->get_text( ) }| ).
ENDTRY.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,113 @@
CLASS {{p}}escape_checker DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_room TYPE c LENGTH 4.
TYPES ty_price TYPE p LENGTH 8 DECIMALS 2.
METHODS check_booking
IMPORTING iv_room TYPE ty_room
iv_players TYPE i
iv_youngest_age TYPE i
iv_lead_hours TYPE i
RETURNING VALUE(rv_price) TYPE ty_price
RAISING {{p}}cx_escape_room
{{p}}cx_escape_players
{{p}}cx_escape_age
{{p}}cx_escape_time.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_rule,
room_code TYPE ty_room,
min_players TYPE i,
max_players TYPE i,
min_age TYPE i,
price_per_player TYPE ty_price,
min_lead_hours TYPE i,
END OF ty_rule,
tt_rule TYPE HASHED TABLE OF ty_rule WITH UNIQUE KEY room_code.
METHODS rules
RETURNING VALUE(rt_rule) TYPE tt_rule.
METHODS find_rule
IMPORTING iv_room TYPE ty_room
RETURNING VALUE(rs_rule) TYPE ty_rule
RAISING {{p}}cx_escape_room.
METHODS check_players
IMPORTING is_rule TYPE ty_rule
iv_players TYPE i
RAISING {{p}}cx_escape_players.
METHODS check_age
IMPORTING is_rule TYPE ty_rule
iv_age TYPE i
RAISING {{p}}cx_escape_age.
METHODS check_lead_hours
IMPORTING is_rule TYPE ty_rule
iv_lead_hours TYPE i
RAISING {{p}}cx_escape_time.
METHODS booking_price
IMPORTING is_rule TYPE ty_rule
iv_players TYPE i
RETURNING VALUE(rv_price) TYPE ty_price.
ENDCLASS.
CLASS {{p}}escape_checker IMPLEMENTATION.
METHOD check_booking.
DATA(ls_rule) = find_rule( iv_room ).
check_players( is_rule = ls_rule iv_players = iv_players ).
check_age( is_rule = ls_rule iv_age = iv_youngest_age ).
check_lead_hours( is_rule = ls_rule iv_lead_hours = iv_lead_hours ).
rv_price = booking_price( is_rule = ls_rule iv_players = iv_players ).
ENDMETHOD.
METHOD rules.
rt_rule = VALUE #(
( room_code = 'MARS' min_players = 2 max_players = 6 min_age = 12 price_per_player = 25 min_lead_hours = 2 )
( room_code = 'DEEP' min_players = 3 max_players = 8 min_age = 16 price_per_player = 30 min_lead_hours = 4 )
( room_code = 'JUNG' min_players = 2 max_players = 4 min_age = 8 price_per_player = 22 min_lead_hours = 1 )
( room_code = 'BANK' min_players = 4 max_players = 10 min_age = 18 price_per_player = 35 min_lead_hours = 6 ) ).
ENDMETHOD.
METHOD find_rule.
DATA lv_room TYPE ty_room.
lv_room = to_upper( replace( val = iv_room sub = ` ` with = `` occ = 0 ) ).
DATA(lt_rule) = rules( ).
READ TABLE lt_rule INTO rs_rule WITH TABLE KEY room_code = lv_room.
IF sy-subrc <> 0.
RAISE EXCEPTION TYPE {{p}}cx_escape_room
EXPORTING iv_text = |Room { iv_room } is not known|.
ENDIF.
ENDMETHOD.
METHOD check_players.
IF iv_players < is_rule-min_players.
RAISE EXCEPTION TYPE {{p}}cx_escape_players
EXPORTING iv_text = 'The group is smaller than the minimum of the room'.
ENDIF.
IF iv_players > is_rule-max_players.
RAISE EXCEPTION TYPE {{p}}cx_escape_players
EXPORTING iv_text = 'The group is larger than the maximum of the room'.
ENDIF.
ENDMETHOD.
METHOD check_age.
IF iv_age < is_rule-min_age.
RAISE EXCEPTION TYPE {{p}}cx_escape_age
EXPORTING iv_text = 'The youngest player is too young for the room'.
ENDIF.
ENDMETHOD.
METHOD check_lead_hours.
IF iv_lead_hours < is_rule-min_lead_hours.
RAISE EXCEPTION TYPE {{p}}cx_escape_time
EXPORTING iv_text = 'The booking is too close to the start of the game'.
ENDIF.
ENDMETHOD.
METHOD booking_price.
rv_price = iv_players * is_rule-price_per_player.
IF iv_players = is_rule-max_players.
rv_price = rv_price * 90 / 100.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,98 @@
CLASS ltc_escape_checker DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mo_cut TYPE REF TO {{p}}escape_checker.
METHODS setup.
METHODS mars_price FOR TESTING.
METHODS group_discount FOR TESTING.
METHODS deep_price FOR TESTING.
METHODS unknown_room FOR TESTING.
METHODS too_many_players FOR TESTING.
METHODS too_young FOR TESTING.
METHODS lead_time_too_short FOR TESTING.
METHODS assert_price
IMPORTING iv_room TYPE {{p}}escape_checker=>ty_room
iv_players TYPE i
iv_age TYPE i
iv_lead TYPE i
iv_exp TYPE {{p}}escape_checker=>ty_price.
ENDCLASS.
CLASS ltc_escape_checker IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}escape_checker( ).
ENDMETHOD.
METHOD mars_price.
assert_price( iv_room = 'MARS' iv_players = 2 iv_age = 12 iv_lead = 2 iv_exp = '50.00' ).
ENDMETHOD.
METHOD group_discount.
assert_price( iv_room = 'MARS' iv_players = 6 iv_age = 12 iv_lead = 2 iv_exp = '135.00' ).
ENDMETHOD.
METHOD deep_price.
assert_price( iv_room = 'DEEP' iv_players = 3 iv_age = 16 iv_lead = 4 iv_exp = '90.00' ).
ENDMETHOD.
METHOD unknown_room.
TRY.
mo_cut->check_booking( iv_room = 'XXXX' iv_players = 2
iv_youngest_age = 12 iv_lead_hours = 2 ).
cl_abap_unit_assert=>fail( 'Exception expected' ).
CATCH {{p}}cx_escape_room INTO DATA(lo_error).
cl_abap_unit_assert=>assert_bound( lo_error ).
CATCH {{p}}cx_escape_error INTO DATA(lo_other).
cl_abap_unit_assert=>fail( |Wrong exception: { lo_other->get_text( ) }| ).
ENDTRY.
ENDMETHOD.
METHOD too_many_players.
TRY.
mo_cut->check_booking( iv_room = 'MARS' iv_players = 7
iv_youngest_age = 12 iv_lead_hours = 2 ).
cl_abap_unit_assert=>fail( 'Exception expected' ).
CATCH {{p}}cx_escape_players INTO DATA(lo_error).
cl_abap_unit_assert=>assert_bound( lo_error ).
CATCH {{p}}cx_escape_error INTO DATA(lo_other).
cl_abap_unit_assert=>fail( |Wrong exception: { lo_other->get_text( ) }| ).
ENDTRY.
ENDMETHOD.
METHOD too_young.
TRY.
mo_cut->check_booking( iv_room = 'MARS' iv_players = 2
iv_youngest_age = 11 iv_lead_hours = 2 ).
cl_abap_unit_assert=>fail( 'Exception expected' ).
CATCH {{p}}cx_escape_age INTO DATA(lo_error).
cl_abap_unit_assert=>assert_bound( lo_error ).
CATCH {{p}}cx_escape_error INTO DATA(lo_other).
cl_abap_unit_assert=>fail( |Wrong exception: { lo_other->get_text( ) }| ).
ENDTRY.
ENDMETHOD.
METHOD lead_time_too_short.
TRY.
mo_cut->check_booking( iv_room = 'MARS' iv_players = 2
iv_youngest_age = 12 iv_lead_hours = 1 ).
cl_abap_unit_assert=>fail( 'Exception expected' ).
CATCH {{p}}cx_escape_time INTO DATA(lo_error).
cl_abap_unit_assert=>assert_bound( lo_error ).
CATCH {{p}}cx_escape_error INTO DATA(lo_other).
cl_abap_unit_assert=>fail( |Wrong exception: { lo_other->get_text( ) }| ).
ENDTRY.
ENDMETHOD.
METHOD assert_price.
TRY.
cl_abap_unit_assert=>assert_equals(
exp = iv_exp
act = mo_cut->check_booking( iv_room = iv_room iv_players = iv_players
iv_youngest_age = iv_age iv_lead_hours = iv_lead ) ).
CATCH {{p}}cx_escape_error INTO DATA(lo_error).
cl_abap_unit_assert=>fail( |Unexpected exception: { lo_error->get_text( ) }| ).
ENDTRY.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,7 @@
CLASS {{p}}cx_escape_age DEFINITION PUBLIC FINAL INHERITING FROM {{p}}cx_escape_error CREATE PUBLIC.
PRIVATE SECTION.
ENDCLASS.
CLASS {{p}}cx_escape_age IMPLEMENTATION.
ENDCLASS.

View File

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

View File

@@ -0,0 +1,7 @@
CLASS {{p}}cx_escape_players DEFINITION PUBLIC FINAL INHERITING FROM {{p}}cx_escape_error CREATE PUBLIC.
PRIVATE SECTION.
ENDCLASS.
CLASS {{p}}cx_escape_players IMPLEMENTATION.
ENDCLASS.

View File

@@ -0,0 +1,7 @@
CLASS {{p}}cx_escape_room DEFINITION PUBLIC FINAL INHERITING FROM {{p}}cx_escape_error CREATE PUBLIC.
PRIVATE SECTION.
ENDCLASS.
CLASS {{p}}cx_escape_room IMPLEMENTATION.
ENDCLASS.

View File

@@ -0,0 +1,7 @@
CLASS {{p}}cx_escape_time DEFINITION PUBLIC FINAL INHERITING FROM {{p}}cx_escape_error CREATE PUBLIC.
PRIVATE SECTION.
ENDCLASS.
CLASS {{p}}cx_escape_time IMPLEMENTATION.
ENDCLASS.

View File

@@ -0,0 +1,72 @@
# 1. Goal
Check a booking request for an escape room and calculate the price of the game.
The booking program calls the check before it confirms a booking. The check
raises a class-based exception for each rule that fails.
# 2. Open questions
None.
# 3. Context
- The exception classes {{P}}CX_ESCAPE_ERROR, {{P}}CX_ESCAPE_ROOM,
{{P}}CX_ESCAPE_PLAYERS, {{P}}CX_ESCAPE_AGE and {{P}}CX_ESCAPE_TIME exist in
package $TMP. They are active.
- {{P}}CX_ESCAPE_ERROR is abstract and inherits from CX_STATIC_CHECK. It has a
public constructor with the importing parameter iv_text (TYPE string) and the
public read-only attribute mv_text (TYPE string). The constructor writes
iv_text to mv_text.
- {{P}}CX_ESCAPE_ROOM, {{P}}CX_ESCAPE_PLAYERS, {{P}}CX_ESCAPE_AGE and
{{P}}CX_ESCAPE_TIME inherit from {{P}}CX_ESCAPE_ERROR and add no members.
- The rooms of the escape room operator and their rules are fixed:
- MARS: 2 to 6 players, minimum age 12, 25.00 per player, minimum lead time 2 hours.
- DEEP: 3 to 8 players, minimum age 16, 30.00 per player, minimum lead time 4 hours.
- JUNG: 2 to 4 players, minimum age 8, 22.00 per player, minimum lead time 1 hour.
- BANK: 4 to 10 players, minimum age 18, 35.00 per player, minimum lead time 6 hours.
# 4. Contract
- Create the class {{P}}ESCAPE_CHECKER in package $TMP.
- The class is public, final, and has a public constructor without parameters.
- The class has these public types:
- TY_ROOM: type c, length 4.
- TY_PRICE: type p, length 8, 2 decimal places.
- The class has one public method:
CHECK_BOOKING
IMPORTING iv_room TYPE ty_room
iv_players TYPE i
iv_youngest_age TYPE i
iv_lead_hours TYPE i
RETURNING VALUE(rv_price) TYPE ty_price
RAISING {{P}}CX_ESCAPE_ROOM
{{P}}CX_ESCAPE_PLAYERS
{{P}}CX_ESCAPE_AGE
{{P}}CX_ESCAPE_TIME
- Do not add other public methods.
# 5. Business rules
Apply the rules in this sequence. Raise the exception of the first rule that
fails. Every exception carries a short text in iv_text. The text is free.
1. Remove all spaces from iv_room and convert the letters to upper case. The
result must be MARS, DEEP, JUNG or BANK. If not, raise {{P}}CX_ESCAPE_ROOM.
2. iv_players must be at least the minimum number of players of the room and at
most the maximum number of players of the room. If not, raise
{{P}}CX_ESCAPE_PLAYERS.
3. iv_youngest_age must be at least the minimum age of the room. If not, raise
{{P}}CX_ESCAPE_AGE.
4. iv_lead_hours must be at least the minimum lead time of the room. If not,
raise {{P}}CX_ESCAPE_TIME.
5. The price is iv_players multiplied by the price per player of the room. If
iv_players equals the maximum number of players of the room, the group gets a
discount of 10 %. Return the price with 2 decimal places.
# 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. Every ABAP Unit test handles all
exceptions that the tested method declares.
- Out of scope: do not change {{P}}CX_ESCAPE_ERROR, {{P}}CX_ESCAPE_ROOM,
{{P}}CX_ESCAPE_PLAYERS, {{P}}CX_ESCAPE_AGE and {{P}}CX_ESCAPE_TIME.
# 7. Acceptance
- The class is active and has no syntax error.
- The class and its test classes have no ATC priority 1 or 2 finding.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.

View File

@@ -0,0 +1,78 @@
{
"id": "G1044",
"category": "D",
"object_type": "CLAS",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "CLAS",
"name": "{{P}}CX_ESCAPE_ERROR",
"file": "seed/cx_escape_error.clas.abap",
"description": "Abstract base exception of the escape room check"
},
{
"type": "CLAS",
"name": "{{P}}CX_ESCAPE_ROOM",
"file": "seed/cx_escape_room.clas.abap",
"description": "Exception for an unknown room"
},
{
"type": "CLAS",
"name": "{{P}}CX_ESCAPE_PLAYERS",
"file": "seed/cx_escape_players.clas.abap",
"description": "Exception for a player number outside the room limits"
},
{
"type": "CLAS",
"name": "{{P}}CX_ESCAPE_AGE",
"file": "seed/cx_escape_age.clas.abap",
"description": "Exception for a player below the minimum age"
},
{
"type": "CLAS",
"name": "{{P}}CX_ESCAPE_TIME",
"file": "seed/cx_escape_time.clas.abap",
"description": "Exception for a lead time below the minimum"
}
],
"contract": [
{
"type": "CLAS",
"name": "{{P}}ESCAPE_CHECKER"
}
],
"out_of_scope": [
"{{P}}CX_ESCAPE_ERROR",
"{{P}}CX_ESCAPE_ROOM",
"{{P}}CX_ESCAPE_PLAYERS",
"{{P}}CX_ESCAPE_AGE",
"{{P}}CX_ESCAPE_TIME"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T02_HIDDEN",
"file": "hidden/t02_hidden.clas.abap",
"description": "T02 hidden tests"
}
],
"reference": [
{
"type": "CLAS",
"name": "{{P}}ESCAPE_CHECKER",
"file": "reference/escape_checker.clas.abap",
"description": "Escape room booking check",
"testclasses_file": "reference/escape_checker.testclasses.abap"
}
],
"craft_checks": [
"method_length",
"nesting_depth"
]
}