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,17 @@
@EndUserText.label : 'Maple sap delivery'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}syrup {
key client : abap.clnt not null;
delivery_id : abap.char(10) not null;
grove_id : abap.char(8);
delivery_date : abap.dats;
sap_liters : abap.dec(9,2);
brix : abap.dec(4,1);
quality_grade : abap.numc(2);
@Semantics.amount.currencyCode : '{{p}}syrup.currency_code'
payout : abap.curr(15,2);
currency_code : abap.cuky;
}

View File

@@ -0,0 +1,17 @@
@EndUserText.label : 'Maple sap delivery'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}syrup {
key client : abap.clnt not null;
key delivery_id : abap.char(10) not null;
grove_id : abap.char(7);
delivery_date : abap.dats;
sap_liters : abap.dec(9,2);
brix : abap.dec(4,1);
quality_grade : abap.numc(2);
@Semantics.amount.currencyCode : '{{p}}syrup.currency_code'
payout : abap.curr(15,2);
currency_code : abap.cuky;
}

View File

@@ -0,0 +1,17 @@
@EndUserText.label : 'Maple sap delivery'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}syrup {
key client : abap.clnt not null;
key delivery_id : abap.char(10) not null;
grove_id : abap.char(8);
delivery_date : abap.dats;
sap_liters : abap.dec(9,2);
brix : abap.dec(4,2);
quality_grade : abap.numc(2);
@Semantics.amount.currencyCode : '{{p}}syrup.currency_code'
payout : abap.curr(15,2);
currency_code : abap.cuky;
}

View File

@@ -0,0 +1,17 @@
@EndUserText.label : 'Maple sap delivery'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}syrup {
key client : abap.clnt not null;
key delivery_id : abap.char(10) not null;
grove_id : abap.char(8);
delivery_date : abap.dats;
sap_liters : abap.dec(9,2);
brix : abap.dec(4,1);
quality_grade : abap.numc(1);
@Semantics.amount.currencyCode : '{{p}}syrup.currency_code'
payout : abap.curr(15,2);
currency_code : abap.cuky;
}

View File

@@ -0,0 +1,19 @@
{
"id": "G1936",
"pool": "train",
"object_type": "TABL",
"category": "B",
"attempts": [
{
"stage": "validate",
"oracle": 100.0,
"null": 0,
"mutation": {
"valid": 4,
"killed": 4,
"ok": true
}
}
],
"accepted": true
}

View File

@@ -0,0 +1,183 @@
CLASS {{p}}syrup_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
TYPES ty_fields TYPE dfies_table.
CLASS-DATA go_env TYPE REF TO if_osql_test_environment.
CLASS-METHODS class_setup.
CLASS-METHODS class_teardown.
METHODS setup.
METHODS all_fields_exist FOR TESTING.
METHODS field_types FOR TESTING.
METHODS key_structure FOR TESTING.
METHODS insert_and_read FOR TESTING.
METHODS amount_round_trip FOR TESTING.
METHODS duplicate_key FOR TESTING.
METHODS filter_by_delivery FOR TESTING.
METHODS get_fields
RETURNING VALUE(rt_fields) TYPE ty_fields.
METHODS assert_type
IMPORTING
it_fields TYPE ty_fields
iv_name TYPE fieldname
iv_type TYPE datatype_d
iv_leng TYPE i
iv_dec TYPE i.
METHODS assert_key
IMPORTING
it_fields TYPE ty_fields
iv_name TYPE fieldname
iv_key TYPE flag.
METHODS make_row
IMPORTING
iv_id TYPE {{p}}syrup-delivery_id
iv_grove TYPE {{p}}syrup-grove_id
RETURNING
VALUE(rs_row) TYPE {{p}}syrup.
ENDCLASS.
CLASS {{p}}syrup_hidden IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}SYRUP' ) ) ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD setup.
go_env->clear_doubles( ).
ENDMETHOD.
METHOD get_fields.
DATA(lo_struct) = CAST cl_abap_structdescr( cl_abap_typedescr=>describe_by_name( '{{P}}SYRUP' ) ).
rt_fields = lo_struct->get_ddic_field_list( ).
ENDMETHOD.
METHOD assert_type.
READ TABLE it_fields ASSIGNING FIELD-SYMBOL(<field>) WITH KEY fieldname = iv_name.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Field { iv_name } is missing| ).
DATA lv_leng TYPE i.
lv_leng = <field>-leng.
DATA lv_dec TYPE i.
lv_dec = <field>-decimals.
cl_abap_unit_assert=>assert_equals( exp = iv_type act = <field>-datatype msg = |Data type of { iv_name }| ).
cl_abap_unit_assert=>assert_equals( exp = iv_leng act = lv_leng msg = |Length of { iv_name }| ).
cl_abap_unit_assert=>assert_equals( exp = iv_dec act = lv_dec msg = |Decimals of { iv_name }| ).
ENDMETHOD.
METHOD assert_key.
READ TABLE it_fields ASSIGNING FIELD-SYMBOL(<field>) WITH KEY fieldname = iv_name.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Field { iv_name } is missing| ).
cl_abap_unit_assert=>assert_equals( exp = iv_key act = <field>-keyflag msg = |Key flag of { iv_name }| ).
ENDMETHOD.
METHOD make_row.
rs_row-client = sy-mandt.
rs_row-delivery_id = iv_id.
rs_row-grove_id = iv_grove.
rs_row-delivery_date = '20250210'.
rs_row-sap_liters = '120.50'.
rs_row-brix = '3.5'.
rs_row-quality_grade = '02'.
rs_row-payout = '250.00'.
rs_row-currency_code = 'EUR'.
ENDMETHOD.
METHOD all_fields_exist.
DATA(lt_fields) = get_fields( ).
cl_abap_unit_assert=>assert_equals( exp = 9 act = lines( lt_fields ) ).
DATA lt_expected TYPE STANDARD TABLE OF fieldname WITH EMPTY KEY.
lt_expected = VALUE #( ( 'CLIENT' ) ( 'DELIVERY_ID' ) ( 'GROVE_ID' )
( 'DELIVERY_DATE' ) ( 'SAP_LITERS' ) ( 'BRIX' )
( 'QUALITY_GRADE' ) ( 'PAYOUT' ) ( 'CURRENCY_CODE' ) ).
LOOP AT lt_expected ASSIGNING FIELD-SYMBOL(<name>).
READ TABLE lt_fields TRANSPORTING NO FIELDS WITH KEY fieldname = <name>.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Field { <name> } is missing| ).
ENDLOOP.
ENDMETHOD.
METHOD field_types.
DATA(lt_fields) = get_fields( ).
assert_type( it_fields = lt_fields iv_name = 'CLIENT' iv_type = 'CLNT' iv_leng = 3 iv_dec = 0 ).
assert_type( it_fields = lt_fields iv_name = 'DELIVERY_ID' iv_type = 'CHAR' iv_leng = 10 iv_dec = 0 ).
assert_type( it_fields = lt_fields iv_name = 'GROVE_ID' iv_type = 'CHAR' iv_leng = 8 iv_dec = 0 ).
assert_type( it_fields = lt_fields iv_name = 'DELIVERY_DATE' iv_type = 'DATS' iv_leng = 8 iv_dec = 0 ).
assert_type( it_fields = lt_fields iv_name = 'SAP_LITERS' iv_type = 'DEC' iv_leng = 9 iv_dec = 2 ).
assert_type( it_fields = lt_fields iv_name = 'BRIX' iv_type = 'DEC' iv_leng = 4 iv_dec = 1 ).
assert_type( it_fields = lt_fields iv_name = 'QUALITY_GRADE' iv_type = 'NUMC' iv_leng = 2 iv_dec = 0 ).
assert_type( it_fields = lt_fields iv_name = 'PAYOUT' iv_type = 'CURR' iv_leng = 15 iv_dec = 2 ).
assert_type( it_fields = lt_fields iv_name = 'CURRENCY_CODE' iv_type = 'CUKY' iv_leng = 5 iv_dec = 0 ).
ENDMETHOD.
METHOD key_structure.
DATA(lt_fields) = get_fields( ).
assert_key( it_fields = lt_fields iv_name = 'CLIENT' iv_key = 'X' ).
assert_key( it_fields = lt_fields iv_name = 'DELIVERY_ID' iv_key = 'X' ).
assert_key( it_fields = lt_fields iv_name = 'GROVE_ID' iv_key = '' ).
assert_key( it_fields = lt_fields iv_name = 'DELIVERY_DATE' iv_key = '' ).
assert_key( it_fields = lt_fields iv_name = 'SAP_LITERS' iv_key = '' ).
assert_key( it_fields = lt_fields iv_name = 'BRIX' iv_key = '' ).
assert_key( it_fields = lt_fields iv_name = 'QUALITY_GRADE' iv_key = '' ).
assert_key( it_fields = lt_fields iv_name = 'PAYOUT' iv_key = '' ).
assert_key( it_fields = lt_fields iv_name = 'CURRENCY_CODE' iv_key = '' ).
ENDMETHOD.
METHOD insert_and_read.
DATA(ls_row) = make_row( iv_id = 'D1' iv_grove = 'G1' ).
INSERT {{p}}syrup FROM @ls_row.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
SELECT SINGLE * FROM {{p}}syrup WHERE delivery_id = 'D1' INTO @DATA(ls_read).
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
cl_abap_unit_assert=>assert_equals( exp = 'G1' act = ls_read-grove_id ).
cl_abap_unit_assert=>assert_equals( exp = '20250210' act = ls_read-delivery_date ).
cl_abap_unit_assert=>assert_equals( exp = '02' act = ls_read-quality_grade ).
ENDMETHOD.
METHOD amount_round_trip.
DATA(ls_row) = make_row( iv_id = 'D3' iv_grove = 'G3' ).
ls_row-sap_liters = '88.25'.
ls_row-payout = '1234.56'.
ls_row-currency_code = 'CHF'.
INSERT {{p}}syrup FROM @ls_row.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
SELECT SINGLE sap_liters, payout, currency_code FROM {{p}}syrup
WHERE delivery_id = 'D3' INTO @DATA(ls_read).
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '88.25' )
act = CONV decfloat34( ls_read-sap_liters ) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '1234.56' )
act = CONV decfloat34( ls_read-payout ) ).
cl_abap_unit_assert=>assert_equals( exp = 'CHF' act = ls_read-currency_code ).
ENDMETHOD.
METHOD duplicate_key.
DATA(ls_row) = make_row( iv_id = 'D7' iv_grove = 'G7' ).
INSERT {{p}}syrup FROM @ls_row.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
INSERT {{p}}syrup FROM @ls_row.
cl_abap_unit_assert=>assert_subrc( exp = 4 ).
ENDMETHOD.
METHOD filter_by_delivery.
DATA(ls_first) = make_row( iv_id = 'D5' iv_grove = 'G5' ).
INSERT {{p}}syrup FROM @ls_first.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
DATA(ls_second) = make_row( iv_id = 'D6' iv_grove = 'G6' ).
INSERT {{p}}syrup FROM @ls_second.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
SELECT SINGLE grove_id FROM {{p}}syrup WHERE delivery_id = 'D6' INTO @DATA(lv_grove).
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
cl_abap_unit_assert=>assert_equals( exp = 'G6' act = lv_grove ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,53 @@
{
"task": "G1936",
"mutants": [
{
"object": "{{P}}SYRUP",
"mutant": "line 8: key delivery_id : -> delivery_id : (key)",
"status": "killed",
"hidden": "5/7",
"failed_tests": [
"FILTER_BY_DELIVERY",
"KEY_STRUCTURE"
]
},
{
"object": "{{P}}SYRUP",
"mutant": "line 9: abap.char(8) -> abap.numc(8) (type)",
"status": "invalid",
"hidden": "0/0",
"failed_tests": []
},
{
"object": "{{P}}SYRUP",
"mutant": "line 9: abap.char(8) -> abap.char(7) (length)",
"status": "killed",
"hidden": "6/7",
"failed_tests": [
"FIELD_TYPES"
]
},
{
"object": "{{P}}SYRUP",
"mutant": "line 12: abap.dec(4,1) -> abap.dec(4,2) (decimals)",
"status": "killed",
"hidden": "6/7",
"failed_tests": [
"FIELD_TYPES"
]
},
{
"object": "{{P}}SYRUP",
"mutant": "line 13: abap.numc(2) -> abap.numc(1) (length)",
"status": "killed",
"hidden": "6/7",
"failed_tests": [
"FIELD_TYPES"
]
}
],
"valid": 4,
"killed": 4,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,17 @@
@EndUserText.label : 'Maple sap delivery'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}syrup {
key client : abap.clnt not null;
key delivery_id : abap.char(10) not null;
grove_id : abap.char(8);
delivery_date : abap.dats;
sap_liters : abap.dec(9,2);
brix : abap.dec(4,1);
quality_grade : abap.numc(2);
@Semantics.amount.currencyCode : '{{p}}syrup.currency_code'
payout : abap.curr(15,2);
currency_code : abap.cuky;
}

View File

@@ -0,0 +1,65 @@
CLASS {{p}}syrup_test DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CLASS-DATA go_env TYPE REF TO if_osql_test_environment.
CLASS-METHODS class_setup.
CLASS-METHODS class_teardown.
METHODS setup.
METHODS fields_are_complete FOR TESTING.
METHODS insert_and_select FOR TESTING.
METHODS duplicate_is_rejected FOR TESTING.
ENDCLASS.
CLASS {{p}}syrup_test IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}SYRUP' ) ) ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD setup.
go_env->clear_doubles( ).
ENDMETHOD.
METHOD fields_are_complete.
DATA(lo_struct) = CAST cl_abap_structdescr( cl_abap_typedescr=>describe_by_name( '{{P}}SYRUP' ) ).
DATA(lt_fields) = lo_struct->get_ddic_field_list( ).
cl_abap_unit_assert=>assert_equals( exp = 9 act = lines( lt_fields ) ).
ENDMETHOD.
METHOD insert_and_select.
DATA ls_row TYPE {{p}}syrup.
ls_row-client = sy-mandt.
ls_row-delivery_id = 'A1'.
ls_row-grove_id = 'G1'.
ls_row-delivery_date = '20250301'.
ls_row-sap_liters = '100.00'.
ls_row-brix = '4.0'.
ls_row-quality_grade = '01'.
ls_row-payout = '300.00'.
ls_row-currency_code = 'EUR'.
INSERT {{p}}syrup FROM @ls_row.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
SELECT SINGLE grove_id FROM {{p}}syrup WHERE delivery_id = 'A1' INTO @DATA(lv_grove).
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
cl_abap_unit_assert=>assert_equals( exp = 'G1' act = lv_grove ).
ENDMETHOD.
METHOD duplicate_is_rejected.
DATA ls_row TYPE {{p}}syrup.
ls_row-client = sy-mandt.
ls_row-delivery_id = 'A2'.
INSERT {{p}}syrup FROM @ls_row.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
INSERT {{p}}syrup FROM @ls_row.
cl_abap_unit_assert=>assert_subrc( exp = 4 ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,54 @@
# 1. Goal
A maple syrup farm collects sap from its groves. The farm must store each sap
delivery in one database table. Later programs and views read the deliveries
from this table.
# 2. Open questions
None.
# 3. Context
- The farm works with several groves. Each grove has a grove number.
- One delivery belongs to exactly one grove and has exactly one delivery date.
- The farm measures the sap in litres. The farm measures the sugar content of
the sap in degrees Brix.
- The farm pays the grove for each delivery. The payment is an amount in a
currency.
- All objects are in package $TMP.
# 4. Contract
- Create the transparent database table {{P}}SYRUP in package $TMP.
- The table has exactly these fields, in this order:
client, delivery_id, grove_id, delivery_date, sap_liters, brix,
quality_grade, payout, currency_code.
# 5. Business rules
1. The table has the fields of the table below. The table below gives the data
type, the length and the number of decimals of each field.
| Field | Data type | Length | Decimals | Key | Not null |
| --- | --- | --- | --- | --- | --- |
| client | CLNT | 3 | - | yes | yes |
| delivery_id | CHAR | 10 | - | yes | yes |
| grove_id | CHAR | 8 | - | no | no |
| delivery_date | DATS | 8 | - | no | no |
| sap_liters | DEC | 9 | 2 | no | no |
| brix | DEC | 4 | 1 | no | no |
| quality_grade | NUMC | 2 | - | no | no |
| payout | CURR | 15 | 2 | no | no |
| currency_code | CUKY | 5 | - | no | no |
2. client and delivery_id are the key fields. No other field is a key field.
3. The key fields are not null.
4. payout is an amount. The currency of payout is the value of currency_code.
5. Two rows with the same client and the same delivery_id are not allowed.
# 6. Constraints
- Release target: 8.16.
- Coding standards: Clean ABAP.
- Out of scope: no other objects.
# 7. Acceptance
- The table is active and has no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests in a global test class. Check the field properties with
RTTI and check the table access with CL_OSQL_TEST_ENVIRONMENT.

View File

@@ -0,0 +1,54 @@
{
"id": "G1936",
"category": "B",
"object_type": "TABL",
"difficulty": 3,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [],
"contract": [
{
"type": "TABL",
"name": "{{P}}SYRUP",
"fields": [
"client",
"delivery_id",
"grove_id",
"delivery_date",
"sap_liters",
"brix",
"quality_grade",
"payout",
"currency_code"
]
}
],
"out_of_scope": [],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}SYRUP_HIDDEN",
"file": "hidden/syrup_hidden.clas.abap",
"description": "Hidden tests: RTTI on the table and access with CL_OSQL_TEST_ENVIRONMENT"
}
],
"reference": [
{
"type": "TABL",
"name": "{{P}}SYRUP",
"file": "reference/syrup.tabl.asabap",
"description": "Sap delivery table"
},
{
"type": "CLAS",
"name": "{{P}}SYRUP_TEST",
"file": "reference/syrup_test.clas.abap",
"description": "Own ABAP Unit tests for the table"
}
],
"craft_checks": []
}