Files
abap-llm/tasks_gen/eval/G0020/hidden/t20_hidden.clas.abap
Kral 5de5e2851c Generator: pilot analysis and fixes; G0002-G0021 tasks; handover notes merged
- Static bundle checks (name length, seed type, reserved words, contract test classes,
  testclasses_file), local abaplint parser check before SAP, max_tokens, robust JSON parse
- Runner: G2 for CDS views with parameters, contract_check detail in report
- G0020 and G0013 fixed by review and revalidated (oracle 100, null 0)
- Pilot results in docs/faz1-tasarim.md 11e; handover notes merged into CLAUDE.md and docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 05:04:23 +02:00

158 lines
5.3 KiB
ABAP

CLASS {{p}}t20_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 revenue_in_period FOR TESTING.
METHODS sold_quantity_in_period FOR TESTING.
METHODS books_in_period FOR TESTING.
METHODS title_and_category FOR TESTING.
METHODS revenue_has_two_decimals FOR TESTING.
METHODS period_limits_included FOR TESTING.
METHODS empty_period FOR TESTING.
METHODS book_outside_period_hidden FOR TESTING.
ENDCLASS.
CLASS {{p}}t20_hidden IMPLEMENTATION.
METHOD class_setup.
go_env = cl_cds_test_environment=>create( i_for_entity = '{{P}}I_BOOK_REVENUE' ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD setup.
DATA lt_book TYPE STANDARD TABLE OF {{p}}book WITH EMPTY KEY.
DATA lt_sale TYPE STANDARD TABLE OF {{p}}sale WITH EMPTY KEY.
go_env->clear_doubles( ).
lt_book = VALUE #(
( book_id = 'B1' title = 'ABAP Basics' category = 'TECH' price = '40.00' )
( book_id = 'B2' title = 'SQL Guide' category = 'TECH' price = '25.50' )
( book_id = 'B3' title = 'Cooking Fun' category = 'HOME' price = '15.00' )
( book_id = 'B4' title = 'Space Novel' category = 'FICTION' price = '9.99' )
( book_id = 'B5' title = 'Old Book' category = 'TECH' price = '5.00' ) ).
lt_sale = VALUE #(
( book_id = 'B1' sale_date = '20240110' quantity = 2 )
( book_id = 'B1' sale_date = '20240215' quantity = 1 )
( book_id = 'B1' sale_date = '20240601' quantity = 5 )
( book_id = 'B2' sale_date = '20240120' quantity = 4 )
( book_id = 'B3' sale_date = '20240305' quantity = 3 )
( book_id = 'B4' sale_date = '20240201' quantity = 1 )
( book_id = 'B4' sale_date = '20240202' quantity = 2 )
( book_id = 'B5' sale_date = '20240615' quantity = 7 ) ).
go_env->insert_test_data( lt_book ).
go_env->insert_test_data( lt_sale ).
ENDMETHOD.
METHOD revenue_in_period.
DATA lv_from TYPE d.
DATA lv_to TYPE d.
lv_from = '20240101'.
lv_to = '20240331'.
SELECT SINGLE revenue
FROM {{p}}i_book_revenue( p_from = @lv_from, p_to = @lv_to )
WHERE book_id = 'B1'
INTO @DATA(lv_revenue).
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '120.00' )
act = CONV decfloat34( lv_revenue ) ).
ENDMETHOD.
METHOD sold_quantity_in_period.
DATA lv_from TYPE d.
DATA lv_to TYPE d.
lv_from = '20240101'.
lv_to = '20240331'.
SELECT SINGLE sold_quantity
FROM {{p}}i_book_revenue( p_from = @lv_from, p_to = @lv_to )
WHERE book_id = 'B1'
INTO @DATA(lv_sold).
cl_abap_unit_assert=>assert_equals( exp = 3 act = CONV i( lv_sold ) ).
ENDMETHOD.
METHOD books_in_period.
DATA lv_from TYPE d.
DATA lv_to TYPE d.
lv_from = '20240101'.
lv_to = '20240331'.
SELECT COUNT(*)
FROM {{p}}i_book_revenue( p_from = @lv_from, p_to = @lv_to )
INTO @DATA(lv_rows).
cl_abap_unit_assert=>assert_equals( exp = 4 act = lv_rows ).
ENDMETHOD.
METHOD title_and_category.
DATA lv_from TYPE d.
DATA lv_to TYPE d.
lv_from = '20240101'.
lv_to = '20240331'.
SELECT SINGLE title, category
FROM {{p}}i_book_revenue( p_from = @lv_from, p_to = @lv_to )
WHERE book_id = 'B2'
INTO @DATA(ls_row).
cl_abap_unit_assert=>assert_equals( exp = 'SQL Guide' act = ls_row-title ).
cl_abap_unit_assert=>assert_equals( exp = 'TECH' act = ls_row-category ).
ENDMETHOD.
METHOD revenue_has_two_decimals.
DATA lv_from TYPE d.
DATA lv_to TYPE d.
lv_from = '20240101'.
lv_to = '20240331'.
SELECT SINGLE revenue
FROM {{p}}i_book_revenue( p_from = @lv_from, p_to = @lv_to )
WHERE book_id = 'B4'
INTO @DATA(lv_revenue).
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '29.97' )
act = CONV decfloat34( lv_revenue ) ).
ENDMETHOD.
METHOD period_limits_included.
DATA lv_from TYPE d.
DATA lv_to TYPE d.
lv_from = '20240110'.
lv_to = '20240110'.
SELECT SINGLE sold_quantity
FROM {{p}}i_book_revenue( p_from = @lv_from, p_to = @lv_to )
WHERE book_id = 'B1'
INTO @DATA(lv_sold_b1).
cl_abap_unit_assert=>assert_equals( exp = 2 act = CONV i( lv_sold_b1 ) ).
lv_from = '20240305'.
lv_to = '20240305'.
SELECT SINGLE sold_quantity
FROM {{p}}i_book_revenue( p_from = @lv_from, p_to = @lv_to )
WHERE book_id = 'B3'
INTO @DATA(lv_sold_b3).
cl_abap_unit_assert=>assert_equals( exp = 3 act = CONV i( lv_sold_b3 ) ).
ENDMETHOD.
METHOD empty_period.
DATA lv_from TYPE d.
DATA lv_to TYPE d.
lv_from = '20240501'.
lv_to = '20240531'.
SELECT COUNT(*)
FROM {{p}}i_book_revenue( p_from = @lv_from, p_to = @lv_to )
INTO @DATA(lv_rows).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rows ).
ENDMETHOD.
METHOD book_outside_period_hidden.
DATA lv_from TYPE d.
DATA lv_to TYPE d.
lv_from = '20240101'.
lv_to = '20240331'.
SELECT SINGLE book_id
FROM {{p}}i_book_revenue( p_from = @lv_from, p_to = @lv_to )
WHERE book_id = 'B5'
INTO @DATA(lv_book).
cl_abap_unit_assert=>assert_initial( lv_book ).
ENDMETHOD.
ENDCLASS.