Fix coverage with several contract classes; table annotation and file path checks; clean task dir on write

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
Kral
2026-10-03 08:44:35 +02:00
parent fb576b0954
commit 03ab36149e
388 changed files with 28620 additions and 339 deletions

View File

@@ -0,0 +1,69 @@
CLASS {{p}}crew_duty_check DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_hours TYPE p LENGTH 4 DECIMALS 1.
TYPES:
BEGIN OF ty_duty,
crew_id TYPE c LENGTH 10,
licence_valid TYPE abap_bool,
type_rating TYPE c LENGTH 4,
aircraft_type TYPE c LENGTH 4,
rest_hours TYPE ty_hours,
duty_hours TYPE ty_hours,
month_hours TYPE ty_hours,
END OF ty_duty.
METHODS check
IMPORTING is_duty TYPE ty_duty
RAISING
{{p}}cx_licence_invalid
{{p}}cx_rating_missing
{{p}}cx_rest_too_short
{{p}}cx_duty_too_long
{{p}}cx_month_limit.
PRIVATE SECTION.
CONSTANTS:
c_min_rest_hours TYPE ty_hours VALUE '10.0',
c_max_duty_hours TYPE ty_hours VALUE '13.0',
c_max_month_hours TYPE ty_hours VALUE '100.0'.
ENDCLASS.
CLASS {{p}}crew_duty_check IMPLEMENTATION.
METHOD check.
IF is_duty-licence_valid <> abap_true.
RAISE EXCEPTION TYPE {{p}}cx_licence_invalid.
ENDIF.
IF is_duty-type_rating <> is_duty-aircraft_type.
RAISE EXCEPTION TYPE {{p}}cx_rating_missing
EXPORTING
iv_required = is_duty-aircraft_type
iv_held = is_duty-type_rating.
ENDIF.
IF is_duty-rest_hours < c_min_rest_hours.
RAISE EXCEPTION TYPE {{p}}cx_rest_too_short
EXPORTING
iv_rest_hours = is_duty-rest_hours.
ENDIF.
IF is_duty-duty_hours > c_max_duty_hours.
RAISE EXCEPTION TYPE {{p}}cx_duty_too_long
EXPORTING
iv_duty_hours = is_duty-duty_hours.
ENDIF.
DATA lv_total_hours TYPE ty_hours.
lv_total_hours = is_duty-month_hours + is_duty-duty_hours.
IF lv_total_hours > c_max_month_hours.
RAISE EXCEPTION TYPE {{p}}cx_month_limit
EXPORTING
iv_total_hours = lv_total_hours.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,151 @@
CLASS ltc_crew_duty_check DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
TYPES ty_hours TYPE p LENGTH 4 DECIMALS 1.
DATA mo_cut TYPE REF TO {{p}}crew_duty_check.
METHODS setup.
METHODS base_duty
RETURNING VALUE(rs_duty) TYPE {{p}}crew_duty_check=>ty_duty.
METHODS valid_duty_is_ok FOR TESTING.
METHODS invalid_licence FOR TESTING.
METHODS missing_rating FOR TESTING.
METHODS rest_below_minimum FOR TESTING.
METHODS rest_at_minimum FOR TESTING.
METHODS duty_above_maximum FOR TESTING.
METHODS duty_at_maximum FOR TESTING.
METHODS month_limit_exceeded FOR TESTING.
METHODS month_limit_exact FOR TESTING.
ENDCLASS.
CLASS ltc_crew_duty_check IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}crew_duty_check( ).
ENDMETHOD.
METHOD base_duty.
CLEAR rs_duty.
rs_duty-crew_id = 'C0001'.
rs_duty-licence_valid = abap_true.
rs_duty-type_rating = 'A320'.
rs_duty-aircraft_type = 'A320'.
rs_duty-rest_hours = '12.0'.
rs_duty-duty_hours = '8.0'.
rs_duty-month_hours = '40.0'.
ENDMETHOD.
METHOD valid_duty_is_ok.
DATA(ls_duty) = base_duty( ).
TRY.
mo_cut->check( ls_duty ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'valid duty was rejected' ).
ENDTRY.
ENDMETHOD.
METHOD invalid_licence.
DATA(ls_duty) = base_duty( ).
ls_duty-licence_valid = abap_false.
TRY.
mo_cut->check( ls_duty ).
cl_abap_unit_assert=>fail( msg = 'invalid licence was accepted' ).
CATCH {{p}}cx_licence_invalid.
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'wrong exception type' ).
ENDTRY.
ENDMETHOD.
METHOD missing_rating.
DATA(ls_duty) = base_duty( ).
ls_duty-type_rating = 'B737'.
TRY.
mo_cut->check( ls_duty ).
cl_abap_unit_assert=>fail( msg = 'missing rating was accepted' ).
CATCH {{p}}cx_rating_missing INTO DATA(lo_exc).
cl_abap_unit_assert=>assert_equals( exp = 'A320'
act = lo_exc->mv_required ).
cl_abap_unit_assert=>assert_equals( exp = 'B737'
act = lo_exc->mv_held ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'wrong exception type' ).
ENDTRY.
ENDMETHOD.
METHOD rest_below_minimum.
DATA(ls_duty) = base_duty( ).
ls_duty-rest_hours = '9.9'.
DATA lv_expected TYPE ty_hours.
lv_expected = '9.9'.
TRY.
mo_cut->check( ls_duty ).
cl_abap_unit_assert=>fail( msg = 'short rest was accepted' ).
CATCH {{p}}cx_rest_too_short INTO DATA(lo_exc).
cl_abap_unit_assert=>assert_equals( exp = lv_expected
act = lo_exc->mv_rest_hours ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'wrong exception type' ).
ENDTRY.
ENDMETHOD.
METHOD rest_at_minimum.
DATA(ls_duty) = base_duty( ).
ls_duty-rest_hours = '10.0'.
TRY.
mo_cut->check( ls_duty ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'minimum rest was rejected' ).
ENDTRY.
ENDMETHOD.
METHOD duty_above_maximum.
DATA(ls_duty) = base_duty( ).
ls_duty-duty_hours = '13.1'.
DATA lv_expected TYPE ty_hours.
lv_expected = '13.1'.
TRY.
mo_cut->check( ls_duty ).
cl_abap_unit_assert=>fail( msg = 'long duty was accepted' ).
CATCH {{p}}cx_duty_too_long INTO DATA(lo_exc).
cl_abap_unit_assert=>assert_equals( exp = lv_expected
act = lo_exc->mv_duty_hours ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'wrong exception type' ).
ENDTRY.
ENDMETHOD.
METHOD duty_at_maximum.
DATA(ls_duty) = base_duty( ).
ls_duty-duty_hours = '13.0'.
TRY.
mo_cut->check( ls_duty ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'maximum duty was rejected' ).
ENDTRY.
ENDMETHOD.
METHOD month_limit_exceeded.
DATA(ls_duty) = base_duty( ).
ls_duty-month_hours = '95.0'.
DATA lv_expected TYPE ty_hours.
lv_expected = '103.0'.
TRY.
mo_cut->check( ls_duty ).
cl_abap_unit_assert=>fail( msg = 'month limit was ignored' ).
CATCH {{p}}cx_month_limit INTO DATA(lo_exc).
cl_abap_unit_assert=>assert_equals( exp = lv_expected
act = lo_exc->mv_total_hours ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'wrong exception type' ).
ENDTRY.
ENDMETHOD.
METHOD month_limit_exact.
DATA(ls_duty) = base_duty( ).
ls_duty-duty_hours = '8.0'.
ls_duty-month_hours = '92.0'.
TRY.
mo_cut->check( ls_duty ).
CATCH cx_root.
cl_abap_unit_assert=>fail( msg = 'exact monthly limit was rejected' ).
ENDTRY.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,23 @@
CLASS {{p}}cx_duty_too_long DEFINITION
PUBLIC
INHERITING FROM cx_static_check
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_hours TYPE p LENGTH 4 DECIMALS 1.
DATA mv_duty_hours TYPE ty_hours READ-ONLY.
METHODS constructor
IMPORTING
iv_duty_hours TYPE ty_hours.
ENDCLASS.
CLASS {{p}}cx_duty_too_long IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
mv_duty_hours = iv_duty_hours.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,12 @@
CLASS {{p}}cx_licence_invalid DEFINITION
PUBLIC
INHERITING FROM cx_static_check
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
ENDCLASS.
CLASS {{p}}cx_licence_invalid IMPLEMENTATION.
ENDCLASS.

View File

@@ -0,0 +1,23 @@
CLASS {{p}}cx_month_limit DEFINITION
PUBLIC
INHERITING FROM cx_static_check
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_hours TYPE p LENGTH 4 DECIMALS 1.
DATA mv_total_hours TYPE ty_hours READ-ONLY.
METHODS constructor
IMPORTING
iv_total_hours TYPE ty_hours.
ENDCLASS.
CLASS {{p}}cx_month_limit IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
mv_total_hours = iv_total_hours.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,26 @@
CLASS {{p}}cx_rating_missing DEFINITION
PUBLIC
INHERITING FROM cx_static_check
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_rating TYPE c LENGTH 4.
DATA mv_required TYPE ty_rating READ-ONLY.
DATA mv_held TYPE ty_rating READ-ONLY.
METHODS constructor
IMPORTING
iv_required TYPE ty_rating
iv_held TYPE ty_rating.
ENDCLASS.
CLASS {{p}}cx_rating_missing IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
mv_required = iv_required.
mv_held = iv_held.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,23 @@
CLASS {{p}}cx_rest_too_short DEFINITION
PUBLIC
INHERITING FROM cx_static_check
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_hours TYPE p LENGTH 4 DECIMALS 1.
DATA mv_rest_hours TYPE ty_hours READ-ONLY.
METHODS constructor
IMPORTING
iv_rest_hours TYPE ty_hours.
ENDCLASS.
CLASS {{p}}cx_rest_too_short IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
mv_rest_hours = iv_rest_hours.
ENDMETHOD.
ENDCLASS.