Snapshot: new training tasks (balanced generation), docs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
44
tasks_gen/train/G1940/faulty/m0_lift_check.clas.abap
Normal file
44
tasks_gen/train/G1940/faulty/m0_lift_check.clas.abap
Normal file
@@ -0,0 +1,44 @@
|
||||
CLASS {{p}}lift_check DEFINITION
|
||||
PUBLIC
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_lift_plan,
|
||||
plan_id TYPE string,
|
||||
crane_id TYPE string,
|
||||
load_kg TYPE decfloat34,
|
||||
capacity_kg TYPE decfloat34,
|
||||
wind_kmh TYPE decfloat34,
|
||||
END OF ty_lift_plan.
|
||||
|
||||
METHODS check_lift_plan
|
||||
IMPORTING
|
||||
iv_plan TYPE ty_lift_plan
|
||||
RAISING
|
||||
{{p}}cx_crane_error.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}lift_check IMPLEMENTATION.
|
||||
METHOD check_lift_plan.
|
||||
IF iv_plan-crane_id IS INITIAL.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_crane_error
|
||||
EXPORTING
|
||||
iv_msgno = '001'
|
||||
iv_attr1 = iv_plan-plan_id.
|
||||
ELSEIF iv_plan-load_kg <= iv_plan-capacity_kg.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_crane_error
|
||||
EXPORTING
|
||||
iv_msgno = '002'
|
||||
iv_attr1 = iv_plan-plan_id
|
||||
iv_attr2 = iv_plan-crane_id.
|
||||
ELSEIF iv_plan-wind_kmh > 60.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_crane_error
|
||||
EXPORTING
|
||||
iv_msgno = '003'
|
||||
iv_attr1 = iv_plan-plan_id.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
44
tasks_gen/train/G1940/faulty/m2_lift_check.clas.abap
Normal file
44
tasks_gen/train/G1940/faulty/m2_lift_check.clas.abap
Normal file
@@ -0,0 +1,44 @@
|
||||
CLASS {{p}}lift_check DEFINITION
|
||||
PUBLIC
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_lift_plan,
|
||||
plan_id TYPE string,
|
||||
crane_id TYPE string,
|
||||
load_kg TYPE decfloat34,
|
||||
capacity_kg TYPE decfloat34,
|
||||
wind_kmh TYPE decfloat34,
|
||||
END OF ty_lift_plan.
|
||||
|
||||
METHODS check_lift_plan
|
||||
IMPORTING
|
||||
iv_plan TYPE ty_lift_plan
|
||||
RAISING
|
||||
{{p}}cx_crane_error.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}lift_check IMPLEMENTATION.
|
||||
METHOD check_lift_plan.
|
||||
IF iv_plan-crane_id IS INITIAL.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_crane_error
|
||||
EXPORTING
|
||||
iv_msgno = '001'
|
||||
iv_attr1 = iv_plan-plan_id.
|
||||
ELSEIF iv_plan-load_kg > iv_plan-capacity_kg.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_crane_error
|
||||
EXPORTING
|
||||
iv_msgno = '002'
|
||||
iv_attr1 = iv_plan-plan_id
|
||||
iv_attr2 = iv_plan-crane_id.
|
||||
ELSEIF iv_plan-wind_kmh <= 60.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_crane_error
|
||||
EXPORTING
|
||||
iv_msgno = '003'
|
||||
iv_attr1 = iv_plan-plan_id.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
24
tasks_gen/train/G1940/generation.json
Normal file
24
tasks_gen/train/G1940/generation.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"id": "G1940",
|
||||
"pool": "train",
|
||||
"object_type": "MSAG",
|
||||
"category": "D",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100.0,
|
||||
"null": 0,
|
||||
"mutation": {
|
||||
"valid": 4,
|
||||
"killed": 4,
|
||||
"ok": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"accepted": true
|
||||
}
|
||||
139
tasks_gen/train/G1940/hidden/lift_hidden.clas.abap
Normal file
139
tasks_gen/train/G1940/hidden/lift_hidden.clas.abap
Normal file
@@ -0,0 +1,139 @@
|
||||
CLASS {{p}}lift_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS make_plan
|
||||
IMPORTING iv_crane TYPE string DEFAULT 'K-7'
|
||||
iv_load TYPE decfloat34 DEFAULT 1000
|
||||
iv_capacity TYPE decfloat34 DEFAULT 1000
|
||||
iv_wind TYPE decfloat34 DEFAULT 20
|
||||
RETURNING VALUE(rs_plan) TYPE {{p}}lift_check=>ty_lift_plan.
|
||||
|
||||
METHODS check_plan
|
||||
IMPORTING iv_crane TYPE string DEFAULT 'K-7'
|
||||
iv_load TYPE decfloat34 DEFAULT 1000
|
||||
iv_capacity TYPE decfloat34 DEFAULT 1000
|
||||
iv_wind TYPE decfloat34 DEFAULT 20
|
||||
EXPORTING ev_text TYPE string.
|
||||
|
||||
METHODS msg_001_text FOR TESTING.
|
||||
METHODS msg_002_text FOR TESTING.
|
||||
METHODS msg_003_text FOR TESTING.
|
||||
METHODS msg_004_text FOR TESTING.
|
||||
METHODS msg_005_text FOR TESTING.
|
||||
METHODS no_crane_raises FOR TESTING.
|
||||
METHODS overload_raises FOR TESTING.
|
||||
METHODS wind_raises FOR TESTING.
|
||||
METHODS crane_rule_first FOR TESTING.
|
||||
METHODS wind_limit_ok FOR TESTING.
|
||||
METHODS valid_plan_passes FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}lift_hidden IMPLEMENTATION.
|
||||
METHOD make_plan.
|
||||
rs_plan = VALUE #( plan_id = 'L-100'
|
||||
crane_id = iv_crane
|
||||
load_kg = iv_load
|
||||
capacity_kg = iv_capacity
|
||||
wind_kmh = iv_wind ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_plan.
|
||||
CLEAR ev_text.
|
||||
DATA(ls_plan) = make_plan( iv_crane = iv_crane
|
||||
iv_load = iv_load
|
||||
iv_capacity = iv_capacity
|
||||
iv_wind = iv_wind ).
|
||||
DATA(lo_check) = NEW {{p}}lift_check( ).
|
||||
TRY.
|
||||
lo_check->check_lift_plan( ls_plan ).
|
||||
CATCH {{p}}cx_crane_error INTO DATA(lo_error).
|
||||
ev_text = lo_error->get_message_text( ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD msg_001_text.
|
||||
DATA lv_text TYPE string.
|
||||
MESSAGE ID '{{P}}MSG_CRANE' TYPE 'E' NUMBER '001' WITH 'L-100' INTO lv_text.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-100 has no crane'
|
||||
act = lv_text ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD msg_002_text.
|
||||
DATA lv_text TYPE string.
|
||||
MESSAGE ID '{{P}}MSG_CRANE' TYPE 'E' NUMBER '002' WITH 'L-100' 'K-7' INTO lv_text.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-100 is too heavy for crane K-7'
|
||||
act = lv_text ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD msg_003_text.
|
||||
DATA lv_text TYPE string.
|
||||
MESSAGE ID '{{P}}MSG_CRANE' TYPE 'E' NUMBER '003' WITH 'L-100' INTO lv_text.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-100 is blocked because of wind'
|
||||
act = lv_text ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD msg_004_text.
|
||||
DATA lv_text TYPE string.
|
||||
MESSAGE ID '{{P}}MSG_CRANE' TYPE 'W' NUMBER '004' WITH 'L-100' INTO lv_text.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-100 is near the load limit'
|
||||
act = lv_text ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD msg_005_text.
|
||||
DATA lv_text TYPE string.
|
||||
MESSAGE ID '{{P}}MSG_CRANE' TYPE 'I' NUMBER '005' WITH 'L-100' INTO lv_text.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-100 is approved'
|
||||
act = lv_text ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD no_crane_raises.
|
||||
check_plan( EXPORTING iv_crane = ''
|
||||
IMPORTING ev_text = DATA(lv_text) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-100 has no crane'
|
||||
act = lv_text ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD overload_raises.
|
||||
check_plan( EXPORTING iv_load = 1200 iv_capacity = 1000
|
||||
IMPORTING ev_text = DATA(lv_text) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-100 is too heavy for crane K-7'
|
||||
act = lv_text ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD wind_raises.
|
||||
check_plan( EXPORTING iv_wind = 75
|
||||
IMPORTING ev_text = DATA(lv_text) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-100 is blocked because of wind'
|
||||
act = lv_text ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD crane_rule_first.
|
||||
check_plan( EXPORTING iv_crane = '' iv_load = 1200 iv_capacity = 1000 iv_wind = 90
|
||||
IMPORTING ev_text = DATA(lv_text) ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-100 has no crane'
|
||||
act = lv_text ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD wind_limit_ok.
|
||||
check_plan( EXPORTING iv_wind = 60
|
||||
IMPORTING ev_text = DATA(lv_text) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = '' act = lv_text ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_plan_passes.
|
||||
check_plan( EXPORTING iv_crane = 'K-9' iv_load = 900 iv_capacity = 1000 iv_wind = 10
|
||||
IMPORTING ev_text = DATA(lv_text) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = '' act = lv_text ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
58
tasks_gen/train/G1940/mutation.json
Normal file
58
tasks_gen/train/G1940/mutation.json
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"task": "G1940",
|
||||
"mutants": [
|
||||
{
|
||||
"object": "{{P}}LIFT_CHECK",
|
||||
"mutant": "line 31: > -> <= (rel)",
|
||||
"status": "killed",
|
||||
"hidden": "7/11",
|
||||
"failed_tests": [
|
||||
"OVERLOAD_RAISES",
|
||||
"VALID_PLAN_PASSES",
|
||||
"WIND_LIMIT_OK",
|
||||
"WIND_RAISES"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}MSG_CRANE",
|
||||
"mutant": "message 002: number + 50 (number)",
|
||||
"status": "invalid",
|
||||
"hidden": "0/0",
|
||||
"failed_tests": []
|
||||
},
|
||||
{
|
||||
"object": "{{P}}LIFT_CHECK",
|
||||
"mutant": "line 37: > -> <= (rel)",
|
||||
"status": "killed",
|
||||
"hidden": "8/11",
|
||||
"failed_tests": [
|
||||
"VALID_PLAN_PASSES",
|
||||
"WIND_LIMIT_OK",
|
||||
"WIND_RAISES"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}MSG_CRANE",
|
||||
"mutant": "message 003: text + ' x' (text)",
|
||||
"status": "killed",
|
||||
"hidden": "9/11",
|
||||
"failed_tests": [
|
||||
"MSG_003_TEXT",
|
||||
"WIND_RAISES"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}MSG_CRANE",
|
||||
"mutant": "message 004: &1 -> &2 (placeholder)",
|
||||
"status": "killed",
|
||||
"hidden": "10/11",
|
||||
"failed_tests": [
|
||||
"MSG_004_TEXT"
|
||||
]
|
||||
}
|
||||
],
|
||||
"valid": 4,
|
||||
"killed": 4,
|
||||
"kill_rate": 1.0,
|
||||
"ok": true
|
||||
}
|
||||
33
tasks_gen/train/G1940/reference/cx_crane_error.clas.abap
Normal file
33
tasks_gen/train/G1940/reference/cx_crane_error.clas.abap
Normal file
@@ -0,0 +1,33 @@
|
||||
CLASS {{p}}cx_crane_error DEFINITION
|
||||
PUBLIC
|
||||
INHERITING FROM cx_static_check
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
METHODS constructor
|
||||
IMPORTING
|
||||
iv_msgno TYPE symsgno
|
||||
iv_attr1 TYPE string OPTIONAL
|
||||
iv_attr2 TYPE string OPTIONAL.
|
||||
|
||||
METHODS get_message_text
|
||||
RETURNING
|
||||
VALUE(rv_text) TYPE string.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA mv_text TYPE string.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cx_crane_error IMPLEMENTATION.
|
||||
METHOD constructor.
|
||||
super->constructor( ).
|
||||
MESSAGE ID '{{P}}MSG_CRANE' TYPE 'I' NUMBER iv_msgno
|
||||
WITH iv_attr1 iv_attr2 INTO mv_text.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_message_text.
|
||||
rv_text = mv_text.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
44
tasks_gen/train/G1940/reference/lift_check.clas.abap
Normal file
44
tasks_gen/train/G1940/reference/lift_check.clas.abap
Normal file
@@ -0,0 +1,44 @@
|
||||
CLASS {{p}}lift_check DEFINITION
|
||||
PUBLIC
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
BEGIN OF ty_lift_plan,
|
||||
plan_id TYPE string,
|
||||
crane_id TYPE string,
|
||||
load_kg TYPE decfloat34,
|
||||
capacity_kg TYPE decfloat34,
|
||||
wind_kmh TYPE decfloat34,
|
||||
END OF ty_lift_plan.
|
||||
|
||||
METHODS check_lift_plan
|
||||
IMPORTING
|
||||
iv_plan TYPE ty_lift_plan
|
||||
RAISING
|
||||
{{p}}cx_crane_error.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}lift_check IMPLEMENTATION.
|
||||
METHOD check_lift_plan.
|
||||
IF iv_plan-crane_id IS INITIAL.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_crane_error
|
||||
EXPORTING
|
||||
iv_msgno = '001'
|
||||
iv_attr1 = iv_plan-plan_id.
|
||||
ELSEIF iv_plan-load_kg > iv_plan-capacity_kg.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_crane_error
|
||||
EXPORTING
|
||||
iv_msgno = '002'
|
||||
iv_attr1 = iv_plan-plan_id
|
||||
iv_attr2 = iv_plan-crane_id.
|
||||
ELSEIF iv_plan-wind_kmh > 60.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_crane_error
|
||||
EXPORTING
|
||||
iv_msgno = '003'
|
||||
iv_attr1 = iv_plan-plan_id.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -0,0 +1,66 @@
|
||||
CLASS ltc_lift_check DEFINITION FOR TESTING
|
||||
DURATION SHORT
|
||||
RISK LEVEL HARMLESS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS no_crane FOR TESTING.
|
||||
METHODS overload FOR TESTING.
|
||||
METHODS wind FOR TESTING.
|
||||
METHODS valid_plan FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_lift_check IMPLEMENTATION.
|
||||
METHOD no_crane.
|
||||
DATA(ls_plan) = VALUE {{p}}lift_check=>ty_lift_plan(
|
||||
plan_id = 'L-1' crane_id = '' ).
|
||||
DATA(lo_check) = NEW {{p}}lift_check( ).
|
||||
TRY.
|
||||
lo_check->check_lift_plan( ls_plan ).
|
||||
cl_abap_unit_assert=>fail( msg = 'Exception expected' ).
|
||||
CATCH {{p}}cx_crane_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-1 has no crane'
|
||||
act = lo_error->get_message_text( ) ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD overload.
|
||||
DATA(ls_plan) = VALUE {{p}}lift_check=>ty_lift_plan(
|
||||
plan_id = 'L-2' crane_id = 'K-1' load_kg = 2000 capacity_kg = 1000 ).
|
||||
DATA(lo_check) = NEW {{p}}lift_check( ).
|
||||
TRY.
|
||||
lo_check->check_lift_plan( ls_plan ).
|
||||
cl_abap_unit_assert=>fail( msg = 'Exception expected' ).
|
||||
CATCH {{p}}cx_crane_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-2 is too heavy for crane K-1'
|
||||
act = lo_error->get_message_text( ) ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD wind.
|
||||
DATA(ls_plan) = VALUE {{p}}lift_check=>ty_lift_plan(
|
||||
plan_id = 'L-3' crane_id = 'K-1' wind_kmh = 80 ).
|
||||
DATA(lo_check) = NEW {{p}}lift_check( ).
|
||||
TRY.
|
||||
lo_check->check_lift_plan( ls_plan ).
|
||||
cl_abap_unit_assert=>fail( msg = 'Exception expected' ).
|
||||
CATCH {{p}}cx_crane_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-3 is blocked because of wind'
|
||||
act = lo_error->get_message_text( ) ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_plan.
|
||||
DATA(ls_plan) = VALUE {{p}}lift_check=>ty_lift_plan(
|
||||
plan_id = 'L-4' crane_id = 'K-1' load_kg = 500 capacity_kg = 1000 wind_kmh = 30 ).
|
||||
DATA(lo_check) = NEW {{p}}lift_check( ).
|
||||
TRY.
|
||||
lo_check->check_lift_plan( ls_plan ).
|
||||
CATCH {{p}}cx_crane_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>fail( msg = lo_error->get_message_text( ) ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
63
tasks_gen/train/G1940/reference/lift_test.clas.abap
Normal file
63
tasks_gen/train/G1940/reference/lift_test.clas.abap
Normal file
@@ -0,0 +1,63 @@
|
||||
CLASS {{p}}lift_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS message_001 FOR TESTING.
|
||||
METHODS message_002 FOR TESTING.
|
||||
METHODS message_003 FOR TESTING.
|
||||
METHODS message_004 FOR TESTING.
|
||||
METHODS message_005 FOR TESTING.
|
||||
METHODS exception_text FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}lift_test IMPLEMENTATION.
|
||||
METHOD message_001.
|
||||
DATA lv_text TYPE string.
|
||||
MESSAGE ID '{{P}}MSG_CRANE' TYPE 'E' NUMBER '001' WITH 'L-100' INTO lv_text.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-100 has no crane'
|
||||
act = lv_text ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD message_002.
|
||||
DATA lv_text TYPE string.
|
||||
MESSAGE ID '{{P}}MSG_CRANE' TYPE 'E' NUMBER '002' WITH 'L-100' 'K-7' INTO lv_text.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-100 is too heavy for crane K-7'
|
||||
act = lv_text ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD message_003.
|
||||
DATA lv_text TYPE string.
|
||||
MESSAGE ID '{{P}}MSG_CRANE' TYPE 'E' NUMBER '003' WITH 'L-100' INTO lv_text.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-100 is blocked because of wind'
|
||||
act = lv_text ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD message_004.
|
||||
DATA lv_text TYPE string.
|
||||
MESSAGE ID '{{P}}MSG_CRANE' TYPE 'W' NUMBER '004' WITH 'L-100' INTO lv_text.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-100 is near the load limit'
|
||||
act = lv_text ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD message_005.
|
||||
DATA lv_text TYPE string.
|
||||
MESSAGE ID '{{P}}MSG_CRANE' TYPE 'I' NUMBER '005' WITH 'L-100' INTO lv_text.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-100 is approved'
|
||||
act = lv_text ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD exception_text.
|
||||
DATA(lo_error) = NEW {{p}}cx_crane_error( iv_msgno = '002'
|
||||
iv_attr1 = 'L-100'
|
||||
iv_attr2 = 'K-7' ).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'Lift plan L-100 is too heavy for crane K-7'
|
||||
act = lo_error->get_message_text( ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
81
tasks_gen/train/G1940/spec.md
Normal file
81
tasks_gen/train/G1940/spec.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# 1. Goal
|
||||
A mobile crane hire company checks a lift plan before it dispatches a crane. The
|
||||
dispatch office calls one check class for each lift plan. If the check fails, the
|
||||
check class raises a class-based exception. The exception carries a message from a
|
||||
new message class.
|
||||
|
||||
Create the message class, the exception class, and the check class.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- All objects are in package $TMP.
|
||||
- The dispatch office already exists. It calls the check class and shows the
|
||||
message text of the exception.
|
||||
- No message class for lift plans exists yet.
|
||||
|
||||
# 4. Contract
|
||||
|
||||
## Message class {{P}}MSG_CRANE
|
||||
Messages 001, 002, 003, 004 and 005 must exist. The Business rules give the
|
||||
number, the type and the exact text of each message.
|
||||
|
||||
## Exception class {{P}}CX_CRANE_ERROR
|
||||
- Public and final. It inherits from CX_STATIC_CHECK.
|
||||
- Public constructor with these parameters:
|
||||
- iv_msgno, TYPE symsgno
|
||||
- iv_attr1, TYPE string, optional
|
||||
- iv_attr2, TYPE string, optional
|
||||
- Public method get_message_text, returning VALUE rv_text TYPE string. The method
|
||||
returns the text of the message that the constructor received, with &1
|
||||
replaced by iv_attr1 and &2 replaced by iv_attr2.
|
||||
|
||||
## Check class {{P}}LIFT_CHECK
|
||||
- Public and final.
|
||||
- Public type ty_lift_plan with these components:
|
||||
- plan_id, TYPE string
|
||||
- crane_id, TYPE string
|
||||
- load_kg, TYPE decfloat34
|
||||
- capacity_kg, TYPE decfloat34
|
||||
- wind_kmh, TYPE decfloat34
|
||||
- Public method check_lift_plan with the importing parameter iv_plan of type
|
||||
ty_lift_plan. The method raises {{P}}CX_CRANE_ERROR.
|
||||
|
||||
# 5. Business rules
|
||||
|
||||
## 5.1 Messages of {{P}}MSG_CRANE
|
||||
|
||||
| Number | Type | Text |
|
||||
| ------ | ---- | ---- |
|
||||
| 001 | E | Lift plan &1 has no crane |
|
||||
| 002 | E | Lift plan &1 is too heavy for crane &2 |
|
||||
| 003 | E | Lift plan &1 is blocked because of wind |
|
||||
| 004 | W | Lift plan &1 is near the load limit |
|
||||
| 005 | I | Lift plan &1 is approved |
|
||||
|
||||
Messages 001, 002 and 003 are errors. Message 004 is a warning. Message 005 is an
|
||||
information message. The dispatch list shows messages 004 and 005.
|
||||
|
||||
## 5.2 Check of a lift plan
|
||||
The method check_lift_plan checks the lift plan in this order:
|
||||
|
||||
1. If crane_id is initial, raise {{P}}CX_CRANE_ERROR with message 001 and
|
||||
attribute 1 = plan_id.
|
||||
2. Else if load_kg is greater than capacity_kg, raise {{P}}CX_CRANE_ERROR with
|
||||
message 002, attribute 1 = plan_id, attribute 2 = crane_id.
|
||||
3. Else if wind_kmh is greater than 60, raise {{P}}CX_CRANE_ERROR with message
|
||||
003 and attribute 1 = plan_id.
|
||||
4. Else the method ends without an exception.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: ABAP Platform 2025 (SAP_BASIS 816).
|
||||
- Clean ABAP. Keep every method below 40 statements.
|
||||
- Out of scope: no database table, no CDS view, no report. Do not change other
|
||||
objects in package $TMP.
|
||||
|
||||
# 7. Acceptance
|
||||
- All objects are active and have no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write ABAP Unit tests: a global test class for the message class and the
|
||||
exception class, and local test classes for {{P}}LIFT_CHECK.
|
||||
109
tasks_gen/train/G1940/task.json
Normal file
109
tasks_gen/train/G1940/task.json
Normal file
@@ -0,0 +1,109 @@
|
||||
{
|
||||
"id": "G1940",
|
||||
"category": "D",
|
||||
"object_type": "MSAG",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [],
|
||||
"contract": [
|
||||
{
|
||||
"type": "MSAG",
|
||||
"name": "{{P}}MSG_CRANE",
|
||||
"messages": [
|
||||
{
|
||||
"msgno": "001"
|
||||
},
|
||||
{
|
||||
"msgno": "002"
|
||||
},
|
||||
{
|
||||
"msgno": "003"
|
||||
},
|
||||
{
|
||||
"msgno": "004"
|
||||
},
|
||||
{
|
||||
"msgno": "005"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_CRANE_ERROR"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}LIFT_CHECK"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"database tables",
|
||||
"CDS view entities",
|
||||
"reports",
|
||||
"changes to other objects in package $TMP"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}LIFT_HIDDEN",
|
||||
"file": "hidden/lift_hidden.clas.abap",
|
||||
"description": "Hidden tests for the crane message class, the crane exception class, and the lift plan check"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "MSAG",
|
||||
"name": "{{P}}MSG_CRANE",
|
||||
"description": "Messages of the mobile crane hire company",
|
||||
"messages": [
|
||||
{
|
||||
"msgno": "001",
|
||||
"text": "Lift plan &1 has no crane"
|
||||
},
|
||||
{
|
||||
"msgno": "002",
|
||||
"text": "Lift plan &1 is too heavy for crane &2"
|
||||
},
|
||||
{
|
||||
"msgno": "003",
|
||||
"text": "Lift plan &1 is blocked because of wind"
|
||||
},
|
||||
{
|
||||
"msgno": "004",
|
||||
"text": "Lift plan &1 is near the load limit"
|
||||
},
|
||||
{
|
||||
"msgno": "005",
|
||||
"text": "Lift plan &1 is approved"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_CRANE_ERROR",
|
||||
"file": "reference/cx_crane_error.clas.abap",
|
||||
"description": "Class-based exception that carries a crane message"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}LIFT_CHECK",
|
||||
"file": "reference/lift_check.clas.abap",
|
||||
"testclasses_file": "reference/lift_check.clas.testclasses.abap",
|
||||
"description": "Checks a lift plan and raises the crane exception"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}LIFT_TEST",
|
||||
"file": "reference/lift_test.clas.abap",
|
||||
"description": "Own tests for the crane message class and the crane exception"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user