CLASS {{p}}t20_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC FOR TESTING DURATION SHORT RISK LEVEL HARMLESS. PRIVATE SECTION. DATA mo_cut TYPE REF TO {{p}}tyre_checker. METHODS setup. METHODS accepts_valid_order FOR TESTING. METHODS accepts_higher_ratings FOR TESTING. METHODS rejects_zero_qty FOR TESTING. METHODS rejects_five_tyres FOR TESTING. METHODS rejects_wrong_width FOR TESTING. METHODS rejects_wrong_profile FOR TESTING. METHODS rejects_wrong_rim FOR TESTING. METHODS rejects_low_load FOR TESTING. METHODS rejects_low_speed FOR TESTING. METHODS qty_checked_first FOR TESTING. METHODS size_checked_before_load FOR TESTING. METHODS load_checked_before_speed FOR TESTING. ENDCLASS. CLASS {{p}}t20_hidden IMPLEMENTATION. METHOD setup. mo_cut = NEW {{p}}tyre_checker( is_vehicle = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16 load_index = 91 speed_kmh = 240 ) ). ENDMETHOD. METHOD accepts_valid_order. TRY. mo_cut->check_order( is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16 load_index = 91 speed_kmh = 240 qty = 1 ) ). mo_cut->check_order( is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16 load_index = 91 speed_kmh = 240 qty = 4 ) ). CATCH {{p}}cx_tyre_error INTO DATA(lo_error). cl_abap_unit_assert=>fail( |Unexpected exception: { lo_error->mv_text }| ). ENDTRY. ENDMETHOD. METHOD accepts_higher_ratings. TRY. mo_cut->check_order( is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16 load_index = 95 speed_kmh = 270 qty = 2 ) ). CATCH {{p}}cx_tyre_error INTO DATA(lo_error). cl_abap_unit_assert=>fail( |Unexpected exception: { lo_error->mv_text }| ). ENDTRY. ENDMETHOD. METHOD rejects_zero_qty. TRY. mo_cut->check_order( is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16 load_index = 91 speed_kmh = 240 qty = 0 ) ). cl_abap_unit_assert=>fail( `An exception is expected` ). CATCH {{p}}cx_tyre_error INTO DATA(lo_error). cl_abap_unit_assert=>assert_equals( exp = `Quantity must be between 1 and 4` act = lo_error->mv_text ). ENDTRY. ENDMETHOD. METHOD rejects_five_tyres. TRY. mo_cut->check_order( is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16 load_index = 91 speed_kmh = 240 qty = 5 ) ). cl_abap_unit_assert=>fail( `An exception is expected` ). CATCH {{p}}cx_tyre_error INTO DATA(lo_error). cl_abap_unit_assert=>assert_equals( exp = `Quantity must be between 1 and 4` act = lo_error->mv_text ). ENDTRY. ENDMETHOD. METHOD rejects_wrong_width. TRY. mo_cut->check_order( is_order = VALUE #( width_mm = 195 profile_pct = 55 rim_inch = 16 load_index = 91 speed_kmh = 240 qty = 2 ) ). cl_abap_unit_assert=>fail( `An exception is expected` ). CATCH {{p}}cx_tyre_error INTO DATA(lo_error). cl_abap_unit_assert=>assert_equals( exp = `Tyre size does not match the vehicle` act = lo_error->mv_text ). ENDTRY. ENDMETHOD. METHOD rejects_wrong_profile. TRY. mo_cut->check_order( is_order = VALUE #( width_mm = 205 profile_pct = 60 rim_inch = 16 load_index = 91 speed_kmh = 240 qty = 2 ) ). cl_abap_unit_assert=>fail( `An exception is expected` ). CATCH {{p}}cx_tyre_error INTO DATA(lo_error). cl_abap_unit_assert=>assert_equals( exp = `Tyre size does not match the vehicle` act = lo_error->mv_text ). ENDTRY. ENDMETHOD. METHOD rejects_wrong_rim. TRY. mo_cut->check_order( is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 15 load_index = 91 speed_kmh = 240 qty = 2 ) ). cl_abap_unit_assert=>fail( `An exception is expected` ). CATCH {{p}}cx_tyre_error INTO DATA(lo_error). cl_abap_unit_assert=>assert_equals( exp = `Tyre size does not match the vehicle` act = lo_error->mv_text ). ENDTRY. ENDMETHOD. METHOD rejects_low_load. TRY. mo_cut->check_order( is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16 load_index = 88 speed_kmh = 240 qty = 2 ) ). cl_abap_unit_assert=>fail( `An exception is expected` ). CATCH {{p}}cx_tyre_error INTO DATA(lo_error). cl_abap_unit_assert=>assert_equals( exp = `Load index is too low` act = lo_error->mv_text ). ENDTRY. ENDMETHOD. METHOD rejects_low_speed. TRY. mo_cut->check_order( is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16 load_index = 91 speed_kmh = 210 qty = 2 ) ). cl_abap_unit_assert=>fail( `An exception is expected` ). CATCH {{p}}cx_tyre_error INTO DATA(lo_error). cl_abap_unit_assert=>assert_equals( exp = `Speed rating is too low` act = lo_error->mv_text ). ENDTRY. ENDMETHOD. METHOD qty_checked_first. TRY. mo_cut->check_order( is_order = VALUE #( width_mm = 999 profile_pct = 55 rim_inch = 16 load_index = 91 speed_kmh = 240 qty = 0 ) ). cl_abap_unit_assert=>fail( `An exception is expected` ). CATCH {{p}}cx_tyre_error INTO DATA(lo_error). cl_abap_unit_assert=>assert_equals( exp = `Quantity must be between 1 and 4` act = lo_error->mv_text ). ENDTRY. ENDMETHOD. METHOD size_checked_before_load. TRY. mo_cut->check_order( is_order = VALUE #( width_mm = 999 profile_pct = 55 rim_inch = 16 load_index = 50 speed_kmh = 240 qty = 2 ) ). cl_abap_unit_assert=>fail( `An exception is expected` ). CATCH {{p}}cx_tyre_error INTO DATA(lo_error). cl_abap_unit_assert=>assert_equals( exp = `Tyre size does not match the vehicle` act = lo_error->mv_text ). ENDTRY. ENDMETHOD. METHOD load_checked_before_speed. TRY. mo_cut->check_order( is_order = VALUE #( width_mm = 205 profile_pct = 55 rim_inch = 16 load_index = 50 speed_kmh = 100 qty = 2 ) ). cl_abap_unit_assert=>fail( `An exception is expected` ). CATCH {{p}}cx_tyre_error INTO DATA(lo_error). cl_abap_unit_assert=>assert_equals( exp = `Load index is too low` act = lo_error->mv_text ). ENDTRY. ENDMETHOD. ENDCLASS.