Snapshot: new training tasks (balanced generation), docs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 22:08:59 +02:00
parent eb13453097
commit 6984fc7917
572 changed files with 30024 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Table fee of a visit'
define view entity {{P}}I_VISIT_FEE
with parameters p_rate : abap.dec( 5, 2 )
as select from {{p}}visit as v
left outer join {{p}}area as a on a.area_id = v.area_id
{
key v.visit_id as visit_id,
v.guest as guest,
a.area_name as area_name,
v.num_hours as num_hours,
v.num_hours * $parameters.p_rate as fee
}
where v.visit_state = 'O'

View File

@@ -0,0 +1,14 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Table fee of a visit'
define view entity {{P}}I_VISIT_FEE
with parameters p_rate : abap.dec( 5, 2 )
as select from {{p}}visit as v
inner join {{p}}area as a on a.area_id <> v.area_id
{
key v.visit_id as visit_id,
v.guest as guest,
a.area_name as area_name,
v.num_hours as num_hours,
v.num_hours * $parameters.p_rate as fee
}
where v.visit_state = 'O'

View File

@@ -0,0 +1,14 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Table fee of a visit'
define view entity {{P}}I_VISIT_FEE
with parameters p_rate : abap.dec( 5, 2 )
as select from {{p}}visit as v
inner join {{p}}area as a on a.area_id = v.area_id
{
key v.visit_id as visit_id,
v.guest as guest,
a.area_name as area_name,
v.num_hours as num_hours,
v.num_hours * $parameters.p_rate as fee
}
where v.visit_state <> 'O'

View File

@@ -0,0 +1,14 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Table fee of a visit'
define view entity {{P}}I_VISIT_FEE
with parameters p_rate : abap.dec( 5, 2 )
as select from {{p}}visit as v
inner join {{p}}area as a on a.area_id = v.area_id
{
key v.visit_id as visit_id,
v.guest as guest,
a.area_name as area_name,
v.num_hours as num_hours,
v.num_hours * $parameters.p_rate as fee
}
where v.visit_state = 'Z'

View File

@@ -0,0 +1,24 @@
{
"id": "G1930",
"pool": "train",
"object_type": "DDLS",
"category": "E",
"attempts": [
{
"stage": "validate",
"oracle": null,
"null": null
},
{
"stage": "validate",
"oracle": 100.0,
"null": 0,
"mutation": {
"valid": 4,
"killed": 4,
"ok": true
}
}
],
"accepted": true
}

View File

@@ -0,0 +1,102 @@
CLASS {{p}}visit_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CLASS-DATA go_env TYPE REF TO if_cds_test_environment.
CLASS-METHODS class_setup.
CLASS-METHODS class_teardown.
METHODS setup.
METHODS fee_of_one_visit FOR TESTING.
METHODS fee_of_two_hours FOR TESTING.
METHODS fee_of_zero_hours FOR TESTING.
METHODS cancelled_visit_hidden FOR TESTING.
METHODS orphan_visit_hidden FOR TESTING.
METHODS open_visits_shown FOR TESTING.
METHODS area_name_shown FOR TESTING.
METHODS guest_shown FOR TESTING.
METHODS num_hours_shown FOR TESTING.
ENDCLASS.
CLASS {{p}}visit_hidden IMPLEMENTATION.
METHOD class_setup.
go_env = cl_cds_test_environment=>create( i_for_entity = '{{P}}I_VISIT_FEE' ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD setup.
DATA lt_area TYPE STANDARD TABLE OF {{p}}area WITH EMPTY KEY.
DATA lt_visit TYPE STANDARD TABLE OF {{p}}visit WITH EMPTY KEY.
go_env->clear_doubles( ).
lt_area = VALUE #( ( area_id = 'A1' area_name = 'Window' seats = 4 )
( area_id = 'A2' area_name = 'Corner' seats = 2 ) ).
lt_visit = VALUE #( ( visit_id = 'V1' area_id = 'A1' guest = 'ANNA' num_hours = 3 visit_state = 'O' )
( visit_id = 'V2' area_id = 'A2' guest = 'BEN' num_hours = 2 visit_state = 'O' )
( visit_id = 'V3' area_id = 'A1' guest = 'CARA' num_hours = 5 visit_state = 'C' )
( visit_id = 'V4' area_id = 'A2' guest = 'DAN' num_hours = 0 visit_state = 'O' )
( visit_id = 'V5' area_id = 'A9' guest = 'EVE' num_hours = 4 visit_state = 'O' ) ).
go_env->insert_test_data( lt_area ).
go_env->insert_test_data( lt_visit ).
ENDMETHOD.
METHOD fee_of_one_visit.
SELECT SINGLE fee FROM {{p}}i_visit_fee( p_rate = '7.50' )
WHERE visit_id = 'V1' INTO @DATA(lv_fee).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '22.50' )
act = CONV decfloat34( lv_fee ) ).
ENDMETHOD.
METHOD fee_of_two_hours.
SELECT SINGLE fee FROM {{p}}i_visit_fee( p_rate = '7.50' )
WHERE visit_id = 'V2' INTO @DATA(lv_fee).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '15.00' )
act = CONV decfloat34( lv_fee ) ).
ENDMETHOD.
METHOD fee_of_zero_hours.
SELECT COUNT(*) FROM {{p}}i_visit_fee( p_rate = '7.50' )
WHERE visit_id = 'V4' INTO @DATA(lv_rows).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rows ).
SELECT SINGLE fee FROM {{p}}i_visit_fee( p_rate = '7.50' )
WHERE visit_id = 'V4' INTO @DATA(lv_fee).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '0.00' )
act = CONV decfloat34( lv_fee ) ).
ENDMETHOD.
METHOD cancelled_visit_hidden.
SELECT COUNT(*) FROM {{p}}i_visit_fee( p_rate = '7.50' )
WHERE visit_id = 'V3' INTO @DATA(lv_rows).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rows ).
ENDMETHOD.
METHOD orphan_visit_hidden.
SELECT COUNT(*) FROM {{p}}i_visit_fee( p_rate = '7.50' )
WHERE visit_id = 'V5' INTO @DATA(lv_rows).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rows ).
ENDMETHOD.
METHOD open_visits_shown.
SELECT COUNT(*) FROM {{p}}i_visit_fee( p_rate = '7.50' ) INTO @DATA(lv_rows).
cl_abap_unit_assert=>assert_equals( exp = 3 act = lv_rows ).
ENDMETHOD.
METHOD area_name_shown.
SELECT SINGLE area_name FROM {{p}}i_visit_fee( p_rate = '7.50' )
WHERE visit_id = 'V1' INTO @DATA(lv_name).
cl_abap_unit_assert=>assert_equals( exp = 'Window' act = lv_name ).
ENDMETHOD.
METHOD guest_shown.
SELECT SINGLE guest FROM {{p}}i_visit_fee( p_rate = '7.50' )
WHERE visit_id = 'V2' INTO @DATA(lv_guest).
cl_abap_unit_assert=>assert_equals( exp = 'BEN' act = lv_guest ).
ENDMETHOD.
METHOD num_hours_shown.
SELECT SINGLE num_hours FROM {{p}}i_visit_fee( p_rate = '7.50' )
WHERE visit_id = 'V1' INTO @DATA(lv_hours).
cl_abap_unit_assert=>assert_equals( exp = 3 act = lv_hours ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,61 @@
{
"task": "G1930",
"mutants": [
{
"object": "{{P}}I_VISIT_FEE",
"mutant": "line 6: inner join -> left outer join (join)",
"status": "killed",
"hidden": "7/9",
"failed_tests": [
"OPEN_VISITS_SHOWN",
"ORPHAN_VISIT_HIDDEN"
]
},
{
"object": "{{P}}I_VISIT_FEE",
"mutant": "line 6: = -> <> (eq)",
"status": "killed",
"hidden": "6/9",
"failed_tests": [
"AREA_NAME_SHOWN",
"OPEN_VISITS_SHOWN",
"ORPHAN_VISIT_HIDDEN"
]
},
{
"object": "{{P}}I_VISIT_FEE",
"mutant": "line 14: = -> <> (eq)",
"status": "killed",
"hidden": "1/9",
"failed_tests": [
"AREA_NAME_SHOWN",
"CANCELLED_VISIT_HIDDEN",
"FEE_OF_ONE_VISIT",
"FEE_OF_TWO_HOURS",
"FEE_OF_ZERO_HOURS",
"GUEST_SHOWN",
"NUM_HOURS_SHOWN",
"OPEN_VISITS_SHOWN"
]
},
{
"object": "{{P}}I_VISIT_FEE",
"mutant": "line 14: 'O' -> 'Z' (lit)",
"status": "killed",
"hidden": "2/9",
"failed_tests": [
"AREA_NAME_SHOWN",
"FEE_OF_ONE_VISIT",
"FEE_OF_TWO_HOURS",
"FEE_OF_ZERO_HOURS",
"GUEST_SHOWN",
"NUM_HOURS_SHOWN",
"OPEN_VISITS_SHOWN"
]
}
],
"valid": 4,
"killed": 4,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,14 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Table fee of a visit'
define view entity {{P}}I_VISIT_FEE
with parameters p_rate : abap.dec( 5, 2 )
as select from {{p}}visit as v
inner join {{p}}area as a on a.area_id = v.area_id
{
key v.visit_id as visit_id,
v.guest as guest,
a.area_name as area_name,
v.num_hours as num_hours,
v.num_hours * $parameters.p_rate as fee
}
where v.visit_state = 'O'

View File

@@ -0,0 +1,46 @@
CLASS {{p}}visit_test DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CLASS-DATA go_env TYPE REF TO if_cds_test_environment.
CLASS-METHODS class_setup.
CLASS-METHODS class_teardown.
METHODS setup.
METHODS fee_of_one_visit FOR TESTING.
METHODS fee_for_another_rate FOR TESTING.
ENDCLASS.
CLASS {{p}}visit_test IMPLEMENTATION.
METHOD class_setup.
go_env = cl_cds_test_environment=>create( i_for_entity = '{{P}}I_VISIT_FEE' ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD setup.
DATA lt_area TYPE STANDARD TABLE OF {{p}}area WITH EMPTY KEY.
DATA lt_visit TYPE STANDARD TABLE OF {{p}}visit WITH EMPTY KEY.
go_env->clear_doubles( ).
lt_area = VALUE #( ( area_id = 'A1' area_name = 'Window' seats = 4 ) ).
lt_visit = VALUE #( ( visit_id = 'V1' area_id = 'A1' guest = 'ANNA'
num_hours = 3 visit_state = 'O' ) ).
go_env->insert_test_data( lt_area ).
go_env->insert_test_data( lt_visit ).
ENDMETHOD.
METHOD fee_of_one_visit.
SELECT SINGLE fee FROM {{p}}i_visit_fee( p_rate = '7.50' )
WHERE visit_id = 'V1' INTO @DATA(lv_fee).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '22.50' )
act = CONV decfloat34( lv_fee ) ).
ENDMETHOD.
METHOD fee_for_another_rate.
SELECT SINGLE fee FROM {{p}}i_visit_fee( p_rate = '10.00' )
WHERE visit_id = 'V1' INTO @DATA(lv_fee).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '30.00' )
act = CONV decfloat34( lv_fee ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,11 @@
@EndUserText.label : 'Areas of the cafe'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}area {
key client : abap.clnt not null;
key area_id : abap.char(4) not null;
area_name : abap.char(20);
seats : abap.int4;
}

View File

@@ -0,0 +1,13 @@
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Table fee of a visit'
define view entity {{P}}I_VISIT_FEE
as select from {{p}}visit as v
inner join {{p}}area as a on a.area_id = v.area_id
{
key v.visit_id as visit_id,
v.guest as guest,
a.area_name as area_name,
v.num_hours as num_hours,
v.num_hours * cast( 7.50 as abap.dec( 5, 2 ) ) as fee
}
where v.visit_state = 'O'

View File

@@ -0,0 +1,13 @@
@EndUserText.label : 'Visits of guests'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}visit {
key client : abap.clnt not null;
key visit_id : abap.char(10) not null;
area_id : abap.char(4);
guest : abap.char(10);
num_hours : abap.int4;
visit_state : abap.char(1);
}

View File

@@ -0,0 +1,44 @@
# 1. Goal
A board game cafe rents its areas to guests by the hour. The cafe needs the fee
of every open visit together with the area and the guest. A report and an OData
service read this data, so the fee must be calculated in the database, in a CDS
view.
# 2. Open questions
None.
# 3. Context
- Table {{P}}AREA (the areas of the cafe), package $TMP. Key: AREA_ID (CHAR 4).
Fields: AREA_NAME (CHAR 20), SEATS (INT4).
- Table {{P}}VISIT (one visit of a guest), package $TMP. Key: VISIT_ID (CHAR 10).
Fields: AREA_ID (CHAR 4), GUEST (CHAR 10), NUM_HOURS (INT4),
VISIT_STATE (CHAR 1).
- The CDS view entity {{P}}I_VISIT_FEE is in package $TMP. It is active and it is
already used by a report and by an OData service. The view is legacy code.
# 4. Contract
- Refactor the CDS view entity {{P}}I_VISIT_FEE in package $TMP. The name of the
view stays the same.
- The view keeps these elements, with these names: VISIT_ID (key), GUEST,
AREA_NAME, NUM_HOURS, FEE.
- The view gets one parameter: P_RATE, type abap.dec( 5, 2 ). P_RATE is the
hourly rate of the cafe in euro.
- No authorization check (#NOT_REQUIRED).
# 5. Business rules
The legacy view {{P}}I_VISIT_FEE contains the business rules. Read the legacy
view. The behavior of the view stays the same. The only change is the source of
the hourly rate: the view takes the hourly rate from the parameter P_RATE and
not from a literal value.
# 6. Constraints
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
- Coding standards: Clean ABAP. Keep the view short and clear.
- Out of scope: do not change {{P}}AREA and {{P}}VISIT.
# 7. Acceptance
- The view is active and has no syntax error.
- The view does not contain the hourly rate as a literal value. The view takes
the hourly rate from the parameter P_RATE.
- The hidden tests pass.
- Write ABAP Unit tests with CL_CDS_TEST_ENVIRONMENT in a global test class.

View File

@@ -0,0 +1,72 @@
{
"id": "G1930",
"category": "E",
"object_type": "DDLS",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "TABL",
"name": "{{P}}AREA",
"file": "seed/area.tabl.asabap",
"description": "Areas of the cafe"
},
{
"type": "TABL",
"name": "{{P}}VISIT",
"file": "seed/visit.tabl.asabap",
"description": "Visits of guests"
},
{
"type": "DDLS",
"name": "{{P}}I_VISIT_FEE",
"file": "seed/i_visit_fee.ddls.asddls",
"description": "Legacy view: table fee of a visit"
}
],
"contract": [
{
"type": "DDLS",
"name": "{{P}}I_VISIT_FEE",
"fields": [
"VISIT_ID",
"GUEST",
"AREA_NAME",
"NUM_HOURS",
"FEE"
]
}
],
"out_of_scope": [
"{{P}}AREA",
"{{P}}VISIT"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}VISIT_HIDDEN",
"file": "hidden/visit_hidden.clas.abap",
"description": "Hidden tests for the visit fee view"
}
],
"reference": [
{
"type": "DDLS",
"name": "{{P}}I_VISIT_FEE",
"file": "reference/i_visit_fee.ddls.asddls",
"description": "Refactored view with the parameter P_RATE"
},
{
"type": "CLAS",
"name": "{{P}}VISIT_TEST",
"file": "reference/visit_test.clas.abap",
"description": "Own tests with CL_CDS_TEST_ENVIRONMENT"
}
],
"craft_checks": []
}