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,34 @@
{
"id": "G0126",
"pool": "eval",
"object_type": "CLAS",
"category": "D",
"attempts": [
{
"stage": "bundle",
"errors": [
"hidden/t_bag_drop_hidden.clas.abap line 85: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"mo_cut\"",
"hidden/t_bag_drop_hidden.clas.abap line 86: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"01\""
],
"by_check": {
"abaplint": 2
}
},
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "validate",
"oracle": 92.5,
"null": 0
},
{
"stage": "validate",
"oracle": 92.5,
"null": 0
}
],
"accepted": false
}

View File

@@ -0,0 +1,219 @@
CLASS {{p}}t_bag_drop_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mo_cut TYPE REF TO {{p}}bag_drop.
METHODS setup.
METHODS accepts_valid_bag FOR TESTING.
METHODS rejects_bad_tag FOR TESTING.
METHODS accepts_max_weight FOR TESTING.
METHODS rejects_overweight FOR TESTING.
METHODS accepts_max_size FOR TESTING.
METHODS rejects_oversize FOR TESTING.
METHODS accepts_one_bag FOR TESTING.
METHODS rejects_third_bag FOR TESTING.
METHODS accepts_40_minutes FOR TESTING.
METHODS rejects_39_minutes FOR TESTING.
METHODS tag_checked_first FOR TESTING.
ENDCLASS.
CLASS {{p}}t_bag_drop_hidden IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}bag_drop( ).
ENDMETHOD.
METHOD accepts_valid_bag.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 20
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 0
iv_min_to_dep = 90 ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'A valid bag was rejected' ).
ENDTRY.
ENDMETHOD.
METHOD rejects_bad_tag.
DATA lv_tag TYPE {{p}}bag_drop=>ty_tag.
DATA lo_tag TYPE REF TO {{p}}cx_bag_tag.
TRY.
mo_cut->accept_bag( iv_tag = lv_tag
iv_weight = 20
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 0
iv_min_to_dep = 90 ).
cl_abap_unit_assert=>fail( msg = 'An empty tag was accepted' ).
CATCH {{p}}cx_bag_tag INTO lo_tag.
cl_abap_unit_assert=>assert_equals( exp = `Invalid bag tag` act = lo_tag->mv_text ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
ENDTRY.
TRY.
mo_cut->accept_bag( iv_tag = 'AB1234567'
iv_weight = 20
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 0
iv_min_to_dep = 90 ).
cl_abap_unit_assert=>fail( msg = 'A short tag was accepted' ).
CATCH {{p}}cx_bag_tag INTO lo_tag.
cl_abap_unit_assert=>assert_equals( exp = `Invalid bag tag` act = lo_tag->mv_text ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
ENDTRY.
ENDMETHOD.
METHOD accepts_max_weight.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 23
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 0
iv_min_to_dep = 90 ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'A bag at the weight limit was rejected' ).
ENDTRY.
ENDMETHOD.
METHOD rejects_overweight.
DATA lv_weight TYPE {{p}}bag_drop=>ty_weight.
DATA lo_weight TYPE REF TO {{p}}cx_bag_weight.
lv_weight = '23.01'.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = lv_weight
iv_length = 100
iv_width = 100
iv_height = 100
iv_bags_checked = 0
iv_min_to_dep = 90 ).
cl_abap_unit_assert=>fail( msg = 'An overweight bag was accepted' ).
CATCH {{p}}cx_bag_weight INTO lo_weight.
cl_abap_unit_assert=>assert_equals( exp = `Bag is too heavy` act = lo_weight->mv_text ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
ENDTRY.
ENDMETHOD.
METHOD accepts_max_size.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 20
iv_length = 70
iv_width = 50
iv_height = 38
iv_bags_checked = 0
iv_min_to_dep = 90 ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'A bag at the size limit was rejected' ).
ENDTRY.
ENDMETHOD.
METHOD rejects_oversize.
DATA lo_size TYPE REF TO {{p}}cx_bag_size.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 20
iv_length = 70
iv_width = 50
iv_height = 39
iv_bags_checked = 0
iv_min_to_dep = 90 ).
cl_abap_unit_assert=>fail( msg = 'An oversize bag was accepted' ).
CATCH {{p}}cx_bag_size INTO lo_size.
cl_abap_unit_assert=>assert_equals( exp = `Bag is too large` act = lo_size->mv_text ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
ENDTRY.
ENDMETHOD.
METHOD accepts_one_bag.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 20
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 1
iv_min_to_dep = 90 ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'A second bag was rejected' ).
ENDTRY.
ENDMETHOD.
METHOD rejects_third_bag.
DATA lo_limit TYPE REF TO {{p}}cx_bag_limit.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 20
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 2
iv_min_to_dep = 90 ).
cl_abap_unit_assert=>fail( msg = 'A third bag was accepted' ).
CATCH {{p}}cx_bag_limit INTO lo_limit.
cl_abap_unit_assert=>assert_equals( exp = `Bag limit reached` act = lo_limit->mv_text ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
ENDTRY.
ENDMETHOD.
METHOD accepts_40_minutes.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 20
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 0
iv_min_to_dep = 40 ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'A bag at the time limit was rejected' ).
ENDTRY.
ENDMETHOD.
METHOD rejects_39_minutes.
DATA lo_late TYPE REF TO {{p}}cx_bag_late.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 20
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 0
iv_min_to_dep = 39 ).
cl_abap_unit_assert=>fail( msg = 'A late bag was accepted' ).
CATCH {{p}}cx_bag_late INTO lo_late.
cl_abap_unit_assert=>assert_equals( exp = `Check-in closed` act = lo_late->mv_text ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
ENDTRY.
ENDMETHOD.
METHOD tag_checked_first.
DATA lo_tag TYPE REF TO {{p}}cx_bag_tag.
TRY.
mo_cut->accept_bag( iv_tag = 'ab12345678'
iv_weight = 30
iv_length = 200
iv_width = 100
iv_height = 100
iv_bags_checked = 5
iv_min_to_dep = 10 ).
cl_abap_unit_assert=>fail( msg = 'A bag with a bad tag was accepted' ).
CATCH {{p}}cx_bag_tag INTO lo_tag.
cl_abap_unit_assert=>assert_equals( exp = `Invalid bag tag` act = lo_tag->mv_text ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
ENDTRY.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,93 @@
CLASS {{p}}bag_drop DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES:
ty_tag TYPE c LENGTH 10,
ty_weight TYPE p LENGTH 5 DECIMALS 2,
ty_size TYPE i,
ty_count TYPE i,
ty_minutes TYPE i.
METHODS accept_bag
IMPORTING
iv_tag TYPE ty_tag
iv_weight TYPE ty_weight
iv_length TYPE ty_size
iv_width TYPE ty_size
iv_height TYPE ty_size
iv_bags_checked TYPE ty_count
iv_min_to_dep TYPE ty_minutes
RAISING
{{p}}cx_bag_tag
{{p}}cx_bag_weight
{{p}}cx_bag_size
{{p}}cx_bag_limit
{{p}}cx_bag_late.
PRIVATE SECTION.
CONSTANTS:
c_max_weight TYPE ty_weight VALUE 23,
c_max_size TYPE ty_size VALUE 158,
c_max_bags TYPE ty_count VALUE 2,
c_min_minutes TYPE ty_minutes VALUE 40.
METHODS check_tag
IMPORTING iv_tag TYPE ty_tag
RAISING {{p}}cx_bag_tag.
METHODS check_weight
IMPORTING iv_weight TYPE ty_weight
RAISING {{p}}cx_bag_weight.
METHODS check_size
IMPORTING iv_length TYPE ty_size
iv_width TYPE ty_size
iv_height TYPE ty_size
RAISING {{p}}cx_bag_size.
METHODS check_bag_count
IMPORTING iv_bags_checked TYPE ty_count
RAISING {{p}}cx_bag_limit.
METHODS check_departure
IMPORTING iv_min_to_dep TYPE ty_minutes
RAISING {{p}}cx_bag_late.
ENDCLASS.
CLASS {{p}}bag_drop IMPLEMENTATION.
METHOD accept_bag.
check_tag( iv_tag ).
check_weight( iv_weight ).
check_size( iv_length = iv_length
iv_width = iv_width
iv_height = iv_height ).
check_bag_count( iv_bags_checked ).
check_departure( iv_min_to_dep ).
ENDMETHOD.
METHOD check_tag.
IF iv_tag CN '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
RAISE EXCEPTION TYPE {{p}}cx_bag_tag.
ENDIF.
ENDMETHOD.
METHOD check_weight.
IF iv_weight > c_max_weight.
RAISE EXCEPTION TYPE {{p}}cx_bag_weight.
ENDIF.
ENDMETHOD.
METHOD check_size.
IF iv_length + iv_width + iv_height > c_max_size.
RAISE EXCEPTION TYPE {{p}}cx_bag_size.
ENDIF.
ENDMETHOD.
METHOD check_bag_count.
IF iv_bags_checked >= c_max_bags.
RAISE EXCEPTION TYPE {{p}}cx_bag_limit.
ENDIF.
ENDMETHOD.
METHOD check_departure.
IF iv_min_to_dep < c_min_minutes.
RAISE EXCEPTION TYPE {{p}}cx_bag_late.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,218 @@
CLASS ltc_bag_drop DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mo_cut TYPE REF TO {{p}}bag_drop.
METHODS setup.
METHODS accepts_valid_bag FOR TESTING.
METHODS rejects_bad_tag FOR TESTING.
METHODS accepts_max_weight FOR TESTING.
METHODS rejects_overweight FOR TESTING.
METHODS accepts_max_size FOR TESTING.
METHODS rejects_oversize FOR TESTING.
METHODS accepts_one_bag FOR TESTING.
METHODS rejects_third_bag FOR TESTING.
METHODS accepts_40_minutes FOR TESTING.
METHODS rejects_39_minutes FOR TESTING.
METHODS tag_checked_first FOR TESTING.
ENDCLASS.
CLASS ltc_bag_drop IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}bag_drop( ).
ENDMETHOD.
METHOD accepts_valid_bag.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 20
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 0
iv_min_to_dep = 90 ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'A valid bag was rejected' ).
ENDTRY.
ENDMETHOD.
METHOD rejects_bad_tag.
DATA lv_tag TYPE {{p}}bag_drop=>ty_tag.
DATA lo_tag TYPE REF TO {{p}}cx_bag_tag.
TRY.
mo_cut->accept_bag( iv_tag = lv_tag
iv_weight = 20
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 0
iv_min_to_dep = 90 ).
cl_abap_unit_assert=>fail( msg = 'An empty tag was accepted' ).
CATCH {{p}}cx_bag_tag INTO lo_tag.
cl_abap_unit_assert=>assert_equals( exp = `Invalid bag tag` act = lo_tag->mv_text ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
ENDTRY.
TRY.
mo_cut->accept_bag( iv_tag = 'AB-2345678'
iv_weight = 20
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 0
iv_min_to_dep = 90 ).
cl_abap_unit_assert=>fail( msg = 'A bag with a bad tag was accepted' ).
CATCH {{p}}cx_bag_tag INTO lo_tag.
cl_abap_unit_assert=>assert_equals( exp = `Invalid bag tag` act = lo_tag->mv_text ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
ENDTRY.
ENDMETHOD.
METHOD accepts_max_weight.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 23
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 0
iv_min_to_dep = 90 ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'A bag at the weight limit was rejected' ).
ENDTRY.
ENDMETHOD.
METHOD rejects_overweight.
DATA lv_weight TYPE {{p}}bag_drop=>ty_weight.
DATA lo_weight TYPE REF TO {{p}}cx_bag_weight.
lv_weight = '23.01'.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = lv_weight
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 0
iv_min_to_dep = 90 ).
cl_abap_unit_assert=>fail( msg = 'An overweight bag was accepted' ).
CATCH {{p}}cx_bag_weight INTO lo_weight.
cl_abap_unit_assert=>assert_equals( exp = `Bag is too heavy` act = lo_weight->mv_text ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
ENDTRY.
ENDMETHOD.
METHOD accepts_max_size.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 20
iv_length = 70
iv_width = 50
iv_height = 38
iv_bags_checked = 0
iv_min_to_dep = 90 ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'A bag at the size limit was rejected' ).
ENDTRY.
ENDMETHOD.
METHOD rejects_oversize.
DATA lo_size TYPE REF TO {{p}}cx_bag_size.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 20
iv_length = 70
iv_width = 50
iv_height = 39
iv_bags_checked = 0
iv_min_to_dep = 90 ).
cl_abap_unit_assert=>fail( msg = 'An oversize bag was accepted' ).
CATCH {{p}}cx_bag_size INTO lo_size.
cl_abap_unit_assert=>assert_equals( exp = `Bag is too large` act = lo_size->mv_text ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
ENDTRY.
ENDMETHOD.
METHOD accepts_one_bag.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 20
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 1
iv_min_to_dep = 90 ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'A second bag was rejected' ).
ENDTRY.
ENDMETHOD.
METHOD rejects_third_bag.
DATA lo_limit TYPE REF TO {{p}}cx_bag_limit.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 20
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 2
iv_min_to_dep = 90 ).
cl_abap_unit_assert=>fail( msg = 'A third bag was accepted' ).
CATCH {{p}}cx_bag_limit INTO lo_limit.
cl_abap_unit_assert=>assert_equals( exp = `Bag limit reached` act = lo_limit->mv_text ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
ENDTRY.
ENDMETHOD.
METHOD accepts_40_minutes.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 20
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 0
iv_min_to_dep = 40 ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'A bag at the time limit was rejected' ).
ENDTRY.
ENDMETHOD.
METHOD rejects_39_minutes.
DATA lo_late TYPE REF TO {{p}}cx_bag_late.
TRY.
mo_cut->accept_bag( iv_tag = 'AB12345678'
iv_weight = 20
iv_length = 55
iv_width = 40
iv_height = 20
iv_bags_checked = 0
iv_min_to_dep = 39 ).
cl_abap_unit_assert=>fail( msg = 'A late bag was accepted' ).
CATCH {{p}}cx_bag_late INTO lo_late.
cl_abap_unit_assert=>assert_equals( exp = `Check-in closed` act = lo_late->mv_text ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
ENDTRY.
ENDMETHOD.
METHOD tag_checked_first.
DATA lo_tag TYPE REF TO {{p}}cx_bag_tag.
TRY.
mo_cut->accept_bag( iv_tag = 'ab12345678'
iv_weight = 30
iv_length = 200
iv_width = 100
iv_height = 100
iv_bags_checked = 5
iv_min_to_dep = 10 ).
cl_abap_unit_assert=>fail( msg = 'A bag with a bad tag was accepted' ).
CATCH {{p}}cx_bag_tag INTO lo_tag.
cl_abap_unit_assert=>assert_equals( exp = `Invalid bag tag` act = lo_tag->mv_text ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
ENDTRY.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,13 @@
CLASS {{p}}cx_bag_late DEFINITION PUBLIC FINAL CREATE PUBLIC INHERITING FROM cx_static_check.
PUBLIC SECTION.
DATA mv_text TYPE string READ-ONLY.
METHODS constructor.
ENDCLASS.
CLASS {{p}}cx_bag_late IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
mv_text = 'Check-in closed'.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,13 @@
CLASS {{p}}cx_bag_limit DEFINITION PUBLIC FINAL CREATE PUBLIC INHERITING FROM cx_static_check.
PUBLIC SECTION.
DATA mv_text TYPE string READ-ONLY.
METHODS constructor.
ENDCLASS.
CLASS {{p}}cx_bag_limit IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
mv_text = 'Bag limit reached'.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,13 @@
CLASS {{p}}cx_bag_size DEFINITION PUBLIC FINAL CREATE PUBLIC INHERITING FROM cx_static_check.
PUBLIC SECTION.
DATA mv_text TYPE string READ-ONLY.
METHODS constructor.
ENDCLASS.
CLASS {{p}}cx_bag_size IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
mv_text = 'Bag is too large'.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,13 @@
CLASS {{p}}cx_bag_tag DEFINITION PUBLIC FINAL CREATE PUBLIC INHERITING FROM cx_static_check.
PUBLIC SECTION.
DATA mv_text TYPE string READ-ONLY.
METHODS constructor.
ENDCLASS.
CLASS {{p}}cx_bag_tag IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
mv_text = 'Invalid bag tag'.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,13 @@
CLASS {{p}}cx_bag_weight DEFINITION PUBLIC FINAL CREATE PUBLIC INHERITING FROM cx_static_check.
PUBLIC SECTION.
DATA mv_text TYPE string READ-ONLY.
METHODS constructor.
ENDCLASS.
CLASS {{p}}cx_bag_weight IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
mv_text = 'Bag is too heavy'.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,93 @@
# 1. Goal
A baggage drop-off counter at an airport checks a bag before it accepts the bag.
The counter program calls the check. If the check rejects the bag, the program
shows the reason to the agent. The reason is a class-based exception.
# 2. Open questions
None.
# 3. Context
- All objects are in package $TMP.
- The check needs only the parameters of the method. No database table and no
helper object is necessary.
- The classes of the contract do not exist yet.
# 4. Contract
## 4.1 Class {{P}}BAG_DROP
- The class is public and final. It has a public constructor without parameters.
- The class has these public types:
- TY_TAG TYPE c LENGTH 10
- TY_WEIGHT TYPE p LENGTH 5 DECIMALS 2
- TY_SIZE TYPE i
- TY_COUNT TYPE i
- TY_MINUTES TYPE i
- The class has exactly one public method:
ACCEPT_BAG
IMPORTING
iv_tag TYPE ty_tag
iv_weight TYPE ty_weight
iv_length TYPE ty_size
iv_width TYPE ty_size
iv_height TYPE ty_size
iv_bags_checked TYPE ty_count
iv_min_to_dep TYPE ty_minutes
RAISING
{{P}}CX_BAG_TAG
{{P}}CX_BAG_WEIGHT
{{P}}CX_BAG_SIZE
{{P}}CX_BAG_LIMIT
{{P}}CX_BAG_LATE
- Do not add other public methods.
## 4.2 Exception classes
Create the classes {{P}}CX_BAG_TAG, {{P}}CX_BAG_WEIGHT, {{P}}CX_BAG_SIZE,
{{P}}CX_BAG_LIMIT and {{P}}CX_BAG_LATE.
- Each class is public and final. Each class inherits from CX_STATIC_CHECK.
- Each class has a public constructor without parameters.
- Each class has the public read-only attribute MV_TEXT of type string. MV_TEXT
contains the message text of the class. The business rules give the message
texts.
# 5. Business rules
The method ACCEPT_BAG checks the bag. It applies the rules in this sequence and
raises the exception of the first rule that fails. It raises no exception if all
rules pass.
1. Every character of the tag is a digit 0 to 9 or an upper-case letter A to Z.
If not, raise {{P}}CX_BAG_TAG. The message text is "Invalid bag tag".
2. The weight in kg is not greater than 23. If it is greater, raise
{{P}}CX_BAG_WEIGHT. The message text is "Bag is too heavy".
3. The sum of the length, the width and the height in cm is not greater than 158.
If it is greater, raise {{P}}CX_BAG_SIZE. The message text is "Bag is too
large".
4. The number of bags that the passenger already checked in is less than 2. If
it is 2 or more, raise {{P}}CX_BAG_LIMIT. The message text is "Bag limit
reached".
5. The minutes until the departure are 40 or more. If they are less, raise
{{P}}CX_BAG_LATE. The message text is "Check-in closed".
# 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 the standard classes CX_ROOT and CX_STATIC_CHECK.
# 7. Acceptance
- All objects are active and have no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class {{P}}BAG_DROP. Your tests cover
every business rule, the exact limits, and the sequence of the rules. Your
tests handle every exception that the method can raise.
- The ATC check of your objects has no finding of priority 1 or 2.

View File

@@ -0,0 +1,94 @@
{
"id": "G0126",
"category": "D",
"object_type": "CLAS",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 70,
"max_activations": 15
},
"seed": [],
"contract": [
{
"type": "CLAS",
"name": "{{P}}BAG_DROP"
},
{
"type": "CLAS",
"name": "{{P}}CX_BAG_TAG"
},
{
"type": "CLAS",
"name": "{{P}}CX_BAG_WEIGHT"
},
{
"type": "CLAS",
"name": "{{P}}CX_BAG_SIZE"
},
{
"type": "CLAS",
"name": "{{P}}CX_BAG_LIMIT"
},
{
"type": "CLAS",
"name": "{{P}}CX_BAG_LATE"
}
],
"out_of_scope": [
"CX_ROOT",
"CX_STATIC_CHECK"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T_BAG_DROP_HIDDEN",
"file": "hidden/t_bag_drop_hidden.clas.abap",
"description": "Hidden tests for the baggage acceptance check"
}
],
"reference": [
{
"type": "CLAS",
"name": "{{P}}CX_BAG_TAG",
"file": "reference/cx_bag_tag.clas.abap",
"description": "Invalid bag tag"
},
{
"type": "CLAS",
"name": "{{P}}CX_BAG_WEIGHT",
"file": "reference/cx_bag_weight.clas.abap",
"description": "Bag is too heavy"
},
{
"type": "CLAS",
"name": "{{P}}CX_BAG_SIZE",
"file": "reference/cx_bag_size.clas.abap",
"description": "Bag is too large"
},
{
"type": "CLAS",
"name": "{{P}}CX_BAG_LIMIT",
"file": "reference/cx_bag_limit.clas.abap",
"description": "Bag limit reached"
},
{
"type": "CLAS",
"name": "{{P}}CX_BAG_LATE",
"file": "reference/cx_bag_late.clas.abap",
"description": "Check-in closed"
},
{
"type": "CLAS",
"name": "{{P}}BAG_DROP",
"file": "reference/bag_drop.clas.abap",
"description": "Baggage acceptance check",
"testclasses_file": "reference/bag_drop.testclasses.abap"
}
],
"craft_checks": [
"method_length",
"exception_messages"
]
}