- 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>
120 lines
5.2 KiB
ABAP
120 lines
5.2 KiB
ABAP
CLASS {{P}}T02_HIDDEN DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
CLASS-DATA mo_environment TYPE REF TO if_osql_test_environment.
|
|
DATA mo_cut TYPE REF TO {{P}}COURSE_BOOKING.
|
|
|
|
CLASS-METHODS class_setup.
|
|
CLASS-METHODS class_teardown.
|
|
METHODS setup.
|
|
METHODS fill_test_data.
|
|
|
|
METHODS free_seats_open_course FOR TESTING.
|
|
METHODS free_seats_never_neg FOR TESTING.
|
|
METHODS free_seats_unknown FOR TESTING.
|
|
METHODS bookable_exact_free FOR TESTING.
|
|
METHODS not_bookable_too_many FOR TESTING.
|
|
METHODS not_bookable_unknown FOR TESTING.
|
|
METHODS not_bookable_zero_seats FOR TESTING.
|
|
METHODS list_filter_cat_seats FOR TESTING.
|
|
METHODS list_sorted_by_course FOR TESTING.
|
|
METHODS list_empty_without_match FOR TESTING.
|
|
METHODS list_excludes_full FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{P}}T02_HIDDEN IMPLEMENTATION.
|
|
METHOD class_setup.
|
|
mo_environment = cl_osql_test_environment=>create( VALUE #( ( '{{P}}COURSE' ) ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD class_teardown.
|
|
mo_environment->destroy( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD setup.
|
|
mo_environment->clear_doubles( ).
|
|
fill_test_data( ).
|
|
mo_cut = NEW {{P}}COURSE_BOOKING( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD fill_test_data.
|
|
DATA lt_course TYPE STANDARD TABLE OF {{P}}COURSE WITH EMPTY KEY.
|
|
lt_course = VALUE #(
|
|
( mandt = sy-mandt course_id = 'ABAP101' category = 'IT' title = 'ABAP Basics' capacity = 20 booked = 5 )
|
|
( mandt = sy-mandt course_id = 'ABAP102' category = 'IT' title = 'ABAP Advanced' capacity = 10 booked = 10 )
|
|
( mandt = sy-mandt course_id = 'ABAP103' category = 'IT' title = 'ABAP Expert' capacity = 12 booked = 15 )
|
|
( mandt = sy-mandt course_id = 'SQL101' category = 'DB' title = 'SQL Basics' capacity = 30 booked = 10 )
|
|
( mandt = sy-mandt course_id = 'SQL102' category = 'DB' title = 'SQL Tuning' capacity = 8 booked = 8 )
|
|
( mandt = sy-mandt course_id = 'HR101' category = 'HR' title = 'HR Basics' capacity = 6 booked = 1 ) ).
|
|
INSERT {{P}}COURSE FROM TABLE @lt_course.
|
|
ENDMETHOD.
|
|
|
|
METHOD free_seats_open_course.
|
|
cl_abap_unit_assert=>assert_equals( exp = 15
|
|
act = mo_cut->get_free_seats( 'ABAP101' )
|
|
msg = 'ABAP101 must have 15 free seats' ).
|
|
ENDMETHOD.
|
|
|
|
METHOD free_seats_never_neg.
|
|
cl_abap_unit_assert=>assert_equals( exp = 0
|
|
act = mo_cut->get_free_seats( 'ABAP102' )
|
|
msg = 'full course' ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 0
|
|
act = mo_cut->get_free_seats( 'ABAP103' )
|
|
msg = 'overbooked course' ).
|
|
ENDMETHOD.
|
|
|
|
METHOD free_seats_unknown.
|
|
cl_abap_unit_assert=>assert_equals( exp = 0
|
|
act = mo_cut->get_free_seats( 'XX999' ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD bookable_exact_free.
|
|
cl_abap_unit_assert=>assert_true( mo_cut->is_bookable( iv_course_id = 'SQL101' iv_seats = 20 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD not_bookable_too_many.
|
|
cl_abap_unit_assert=>assert_false( mo_cut->is_bookable( iv_course_id = 'SQL101' iv_seats = 21 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD not_bookable_unknown.
|
|
cl_abap_unit_assert=>assert_false( mo_cut->is_bookable( iv_course_id = 'XX999' iv_seats = 1 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD not_bookable_zero_seats.
|
|
cl_abap_unit_assert=>assert_false( mo_cut->is_bookable( iv_course_id = 'SQL101' iv_seats = 0 ) ).
|
|
cl_abap_unit_assert=>assert_false( mo_cut->is_bookable( iv_course_id = 'SQL101' iv_seats = -5 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD list_filter_cat_seats.
|
|
DATA(lt_result) = mo_cut->list_bookable_courses( iv_category = 'DB' iv_seats = 5 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_result ) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 'SQL101' act = lt_result[ 1 ]-course_id ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 'SQL Basics' act = lt_result[ 1 ]-title ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 20 act = lt_result[ 1 ]-free_seats ).
|
|
ENDMETHOD.
|
|
|
|
METHOD list_sorted_by_course.
|
|
DATA(lt_result) = mo_cut->list_bookable_courses( iv_category = 'IT' iv_seats = 0 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 3 act = lines( lt_result ) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 'ABAP101' act = lt_result[ 1 ]-course_id ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 'ABAP102' act = lt_result[ 2 ]-course_id ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 'ABAP103' act = lt_result[ 3 ]-course_id ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_result[ 3 ]-free_seats ).
|
|
ENDMETHOD.
|
|
|
|
METHOD list_empty_without_match.
|
|
DATA(lt_hr) = mo_cut->list_bookable_courses( iv_category = 'HR' iv_seats = 6 ).
|
|
cl_abap_unit_assert=>assert_initial( lt_hr ).
|
|
DATA(lt_unknown) = mo_cut->list_bookable_courses( iv_category = 'XX' iv_seats = 1 ).
|
|
cl_abap_unit_assert=>assert_initial( lt_unknown ).
|
|
ENDMETHOD.
|
|
|
|
METHOD list_excludes_full.
|
|
DATA(lt_result) = mo_cut->list_bookable_courses( iv_category = 'IT' iv_seats = 1 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_result ) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 'ABAP101' act = lt_result[ 1 ]-course_id ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|