Snapshot: new training tasks (balanced generation), docs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
98
tasks_gen/train/G1939/reference/pluck_test.clas.abap
Normal file
98
tasks_gen/train/G1939/reference/pluck_test.clas.abap
Normal file
@@ -0,0 +1,98 @@
|
||||
CLASS {{p}}pluck_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 stores_a_batch FOR TESTING.
|
||||
METHODS rejects_duplicate_key FOR TESTING.
|
||||
METHODS keeps_empty_fields FOR TESTING.
|
||||
METHODS counts_the_batches FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}pluck_test IMPLEMENTATION.
|
||||
|
||||
METHOD class_setup.
|
||||
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}PLUCK' ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD class_teardown.
|
||||
go_env->destroy( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD setup.
|
||||
go_env->clear_doubles( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD stores_a_batch.
|
||||
DATA ls_row TYPE {{p}}pluck.
|
||||
DATA lv_date TYPE {{p}}pluck-pluck_date.
|
||||
DATA lv_weight TYPE {{p}}pluck-leaf_weight.
|
||||
lv_date = '20240401'.
|
||||
lv_weight = '850.250'.
|
||||
ls_row = VALUE #( pluck_id = 'B0001'
|
||||
field_id = 'F01'
|
||||
pluck_date = lv_date
|
||||
team_no = '0012'
|
||||
leaf_weight = lv_weight
|
||||
leaf_grade = 'A1'
|
||||
moisture = '3.50'
|
||||
wither_min = 120
|
||||
price_per_kg = '2.10'
|
||||
note = 'first flush' ).
|
||||
INSERT {{p}}pluck FROM @ls_row.
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
||||
SELECT SINGLE field_id, pluck_date, leaf_weight, wither_min, note
|
||||
FROM {{p}}pluck
|
||||
WHERE pluck_id = 'B0001'
|
||||
INTO @DATA(ls_read).
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'F01' act = ls_read-field_id ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_date act = ls_read-pluck_date ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_weight act = ls_read-leaf_weight ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 120 act = ls_read-wither_min ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'first flush' act = ls_read-note ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_duplicate_key.
|
||||
DATA ls_row TYPE {{p}}pluck.
|
||||
ls_row = VALUE #( pluck_id = 'B0002' field_id = 'F02' pluck_date = '20240402'
|
||||
leaf_weight = '100.000' ).
|
||||
INSERT {{p}}pluck FROM @ls_row.
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
||||
INSERT {{p}}pluck FROM @ls_row.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 4 act = sy-subrc ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD keeps_empty_fields.
|
||||
DATA ls_row TYPE {{p}}pluck.
|
||||
ls_row = VALUE #( pluck_id = 'B0003' field_id = 'F03' pluck_date = '20240403'
|
||||
leaf_weight = '0.000' ).
|
||||
INSERT {{p}}pluck FROM @ls_row.
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
||||
SELECT SINGLE team_no, leaf_grade, wither_min, note
|
||||
FROM {{p}}pluck
|
||||
WHERE pluck_id = 'B0003'
|
||||
INTO @DATA(ls_read).
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_read-team_no ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_read-leaf_grade ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_read-wither_min ).
|
||||
cl_abap_unit_assert=>assert_initial( act = ls_read-note ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD counts_the_batches.
|
||||
DATA lt_rows TYPE STANDARD TABLE OF {{p}}pluck WITH EMPTY KEY.
|
||||
lt_rows = VALUE #( ( pluck_id = 'B0001' field_id = 'F01' pluck_date = '20240401'
|
||||
leaf_weight = '1.000' )
|
||||
( pluck_id = 'B0002' field_id = 'F01' pluck_date = '20240402'
|
||||
leaf_weight = '2.000' ) ).
|
||||
INSERT {{p}}pluck FROM TABLE @lt_rows.
|
||||
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
||||
SELECT COUNT(*) FROM {{p}}pluck INTO @DATA(lv_count).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_count ).
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
Reference in New Issue
Block a user