Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
219 lines
8.5 KiB
ABAP
219 lines
8.5 KiB
ABAP
CLASS ltc_bag_drop DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
DATA mo_cut TYPE REF TO {{p}}bag_drop.
|
|
METHODS setup.
|
|
METHODS accepts_valid_bag FOR TESTING.
|
|
METHODS rejects_bad_tag FOR TESTING.
|
|
METHODS accepts_max_weight FOR TESTING.
|
|
METHODS rejects_overweight FOR TESTING.
|
|
METHODS accepts_max_size FOR TESTING.
|
|
METHODS rejects_oversize FOR TESTING.
|
|
METHODS accepts_one_bag FOR TESTING.
|
|
METHODS rejects_third_bag FOR TESTING.
|
|
METHODS accepts_40_minutes FOR TESTING.
|
|
METHODS rejects_39_minutes FOR TESTING.
|
|
METHODS tag_checked_first FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS ltc_bag_drop IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}bag_drop( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD accepts_valid_bag.
|
|
TRY.
|
|
mo_cut->accept_bag( iv_tag = 'AB12345678'
|
|
iv_weight = 20
|
|
iv_length = 55
|
|
iv_width = 40
|
|
iv_height = 20
|
|
iv_bags_checked = 0
|
|
iv_min_to_dep = 90 ).
|
|
CATCH cx_root.
|
|
cl_abap_unit_assert=>fail( msg = 'A valid bag was rejected' ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
|
|
METHOD rejects_bad_tag.
|
|
DATA lv_tag TYPE {{p}}bag_drop=>ty_tag.
|
|
DATA lo_tag TYPE REF TO {{p}}cx_bag_tag.
|
|
TRY.
|
|
mo_cut->accept_bag( iv_tag = lv_tag
|
|
iv_weight = 20
|
|
iv_length = 55
|
|
iv_width = 40
|
|
iv_height = 20
|
|
iv_bags_checked = 0
|
|
iv_min_to_dep = 90 ).
|
|
cl_abap_unit_assert=>fail( msg = 'An empty tag was accepted' ).
|
|
CATCH {{p}}cx_bag_tag INTO lo_tag.
|
|
cl_abap_unit_assert=>assert_equals( exp = `Invalid bag tag` act = lo_tag->mv_text ).
|
|
CATCH cx_root.
|
|
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
|
|
ENDTRY.
|
|
TRY.
|
|
mo_cut->accept_bag( iv_tag = 'AB-2345678'
|
|
iv_weight = 20
|
|
iv_length = 55
|
|
iv_width = 40
|
|
iv_height = 20
|
|
iv_bags_checked = 0
|
|
iv_min_to_dep = 90 ).
|
|
cl_abap_unit_assert=>fail( msg = 'A bag with a bad tag was accepted' ).
|
|
CATCH {{p}}cx_bag_tag INTO lo_tag.
|
|
cl_abap_unit_assert=>assert_equals( exp = `Invalid bag tag` act = lo_tag->mv_text ).
|
|
CATCH cx_root.
|
|
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
|
|
METHOD accepts_max_weight.
|
|
TRY.
|
|
mo_cut->accept_bag( iv_tag = 'AB12345678'
|
|
iv_weight = 23
|
|
iv_length = 55
|
|
iv_width = 40
|
|
iv_height = 20
|
|
iv_bags_checked = 0
|
|
iv_min_to_dep = 90 ).
|
|
CATCH cx_root.
|
|
cl_abap_unit_assert=>fail( msg = 'A bag at the weight limit was rejected' ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
|
|
METHOD rejects_overweight.
|
|
DATA lv_weight TYPE {{p}}bag_drop=>ty_weight.
|
|
DATA lo_weight TYPE REF TO {{p}}cx_bag_weight.
|
|
lv_weight = '23.01'.
|
|
TRY.
|
|
mo_cut->accept_bag( iv_tag = 'AB12345678'
|
|
iv_weight = lv_weight
|
|
iv_length = 55
|
|
iv_width = 40
|
|
iv_height = 20
|
|
iv_bags_checked = 0
|
|
iv_min_to_dep = 90 ).
|
|
cl_abap_unit_assert=>fail( msg = 'An overweight bag was accepted' ).
|
|
CATCH {{p}}cx_bag_weight INTO lo_weight.
|
|
cl_abap_unit_assert=>assert_equals( exp = `Bag is too heavy` act = lo_weight->mv_text ).
|
|
CATCH cx_root.
|
|
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
|
|
METHOD accepts_max_size.
|
|
TRY.
|
|
mo_cut->accept_bag( iv_tag = 'AB12345678'
|
|
iv_weight = 20
|
|
iv_length = 70
|
|
iv_width = 50
|
|
iv_height = 38
|
|
iv_bags_checked = 0
|
|
iv_min_to_dep = 90 ).
|
|
CATCH cx_root.
|
|
cl_abap_unit_assert=>fail( msg = 'A bag at the size limit was rejected' ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
|
|
METHOD rejects_oversize.
|
|
DATA lo_size TYPE REF TO {{p}}cx_bag_size.
|
|
TRY.
|
|
mo_cut->accept_bag( iv_tag = 'AB12345678'
|
|
iv_weight = 20
|
|
iv_length = 70
|
|
iv_width = 50
|
|
iv_height = 39
|
|
iv_bags_checked = 0
|
|
iv_min_to_dep = 90 ).
|
|
cl_abap_unit_assert=>fail( msg = 'An oversize bag was accepted' ).
|
|
CATCH {{p}}cx_bag_size INTO lo_size.
|
|
cl_abap_unit_assert=>assert_equals( exp = `Bag is too large` act = lo_size->mv_text ).
|
|
CATCH cx_root.
|
|
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
|
|
METHOD accepts_one_bag.
|
|
TRY.
|
|
mo_cut->accept_bag( iv_tag = 'AB12345678'
|
|
iv_weight = 20
|
|
iv_length = 55
|
|
iv_width = 40
|
|
iv_height = 20
|
|
iv_bags_checked = 1
|
|
iv_min_to_dep = 90 ).
|
|
CATCH cx_root.
|
|
cl_abap_unit_assert=>fail( msg = 'A second bag was rejected' ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
|
|
METHOD rejects_third_bag.
|
|
DATA lo_limit TYPE REF TO {{p}}cx_bag_limit.
|
|
TRY.
|
|
mo_cut->accept_bag( iv_tag = 'AB12345678'
|
|
iv_weight = 20
|
|
iv_length = 55
|
|
iv_width = 40
|
|
iv_height = 20
|
|
iv_bags_checked = 2
|
|
iv_min_to_dep = 90 ).
|
|
cl_abap_unit_assert=>fail( msg = 'A third bag was accepted' ).
|
|
CATCH {{p}}cx_bag_limit INTO lo_limit.
|
|
cl_abap_unit_assert=>assert_equals( exp = `Bag limit reached` act = lo_limit->mv_text ).
|
|
CATCH cx_root.
|
|
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
|
|
METHOD accepts_40_minutes.
|
|
TRY.
|
|
mo_cut->accept_bag( iv_tag = 'AB12345678'
|
|
iv_weight = 20
|
|
iv_length = 55
|
|
iv_width = 40
|
|
iv_height = 20
|
|
iv_bags_checked = 0
|
|
iv_min_to_dep = 40 ).
|
|
CATCH cx_root.
|
|
cl_abap_unit_assert=>fail( msg = 'A bag at the time limit was rejected' ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
|
|
METHOD rejects_39_minutes.
|
|
DATA lo_late TYPE REF TO {{p}}cx_bag_late.
|
|
TRY.
|
|
mo_cut->accept_bag( iv_tag = 'AB12345678'
|
|
iv_weight = 20
|
|
iv_length = 55
|
|
iv_width = 40
|
|
iv_height = 20
|
|
iv_bags_checked = 0
|
|
iv_min_to_dep = 39 ).
|
|
cl_abap_unit_assert=>fail( msg = 'A late bag was accepted' ).
|
|
CATCH {{p}}cx_bag_late INTO lo_late.
|
|
cl_abap_unit_assert=>assert_equals( exp = `Check-in closed` act = lo_late->mv_text ).
|
|
CATCH cx_root.
|
|
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
|
|
METHOD tag_checked_first.
|
|
DATA lo_tag TYPE REF TO {{p}}cx_bag_tag.
|
|
TRY.
|
|
mo_cut->accept_bag( iv_tag = 'ab12345678'
|
|
iv_weight = 30
|
|
iv_length = 200
|
|
iv_width = 100
|
|
iv_height = 100
|
|
iv_bags_checked = 5
|
|
iv_min_to_dep = 10 ).
|
|
cl_abap_unit_assert=>fail( msg = 'A bag with a bad tag was accepted' ).
|
|
CATCH {{p}}cx_bag_tag INTO lo_tag.
|
|
cl_abap_unit_assert=>assert_equals( exp = `Invalid bag tag` act = lo_tag->mv_text ).
|
|
CATCH cx_root.
|
|
cl_abap_unit_assert=>fail( msg = 'Wrong exception type' ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
ENDCLASS.
|