ADT fallback: Accept headers for FUNC; G0189 accepted; regen2 results
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
151
tasks_gen/eval/G0129/faulty/m0_cold_chain_check.clas.abap
Normal file
151
tasks_gen/eval/G0129/faulty/m0_cold_chain_check.clas.abap
Normal file
@@ -0,0 +1,151 @@
|
||||
CLASS {{p}}cold_chain_check DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES: BEGIN OF ty_reading,
|
||||
offset_min TYPE i,
|
||||
temp_tenths TYPE i,
|
||||
END OF ty_reading,
|
||||
tt_readings TYPE STANDARD TABLE OF ty_reading WITH EMPTY KEY,
|
||||
BEGIN OF ty_config,
|
||||
min_tenths TYPE i,
|
||||
max_tenths TYPE i,
|
||||
min_duration TYPE i,
|
||||
max_gap TYPE i,
|
||||
END OF ty_config.
|
||||
|
||||
METHODS constructor
|
||||
IMPORTING is_config TYPE ty_config.
|
||||
|
||||
METHODS check
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_mean) TYPE i
|
||||
RAISING {{p}}cx_cold_chain.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA ms_config TYPE ty_config.
|
||||
|
||||
METHODS first_violation
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_structure
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_duration
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_gap
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_temperatures
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS mean_tenths
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_mean) TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cold_chain_check IMPLEMENTATION.
|
||||
METHOD constructor.
|
||||
ms_config = is_config.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check.
|
||||
DATA(lv_rule) = first_violation( it_readings ).
|
||||
IF lv_rule IS NOT INITIAL.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_cold_chain
|
||||
EXPORTING
|
||||
iv_rule = lv_rule.
|
||||
ENDIF.
|
||||
rv_mean = mean_tenths( it_readings ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD first_violation.
|
||||
rv_rule = check_structure( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_duration( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_gap( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_temperatures( it_readings ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_structure.
|
||||
IF lines( it_readings ) < 2.
|
||||
rv_rule = 'TOO_FEW'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
READ TABLE it_readings INDEX 1 INTO DATA(ls_first).
|
||||
IF ls_first-offset_min = 0.
|
||||
rv_rule = 'NO_START'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_previous) = ls_first-offset_min.
|
||||
LOOP AT it_readings FROM 2 INTO DATA(ls_reading).
|
||||
IF ls_reading-offset_min <= lv_previous.
|
||||
rv_rule = 'TIME_ORDER'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
lv_previous = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_duration.
|
||||
DATA lv_last TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
lv_last = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
IF lv_last < ms_config-min_duration.
|
||||
rv_rule = 'TOO_SHORT'.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_gap.
|
||||
DATA lv_previous TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
IF sy-tabix > 1 AND ls_reading-offset_min - lv_previous > ms_config-max_gap.
|
||||
rv_rule = 'GAP'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
lv_previous = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_temperatures.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
IF ls_reading-temp_tenths > ms_config-max_tenths.
|
||||
rv_rule = 'TOO_HIGH'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF ls_reading-temp_tenths < ms_config-min_tenths.
|
||||
rv_rule = 'TOO_LOW'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mean_tenths.
|
||||
DATA lv_sum TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
lv_sum = lv_sum + ls_reading-temp_tenths.
|
||||
ENDLOOP.
|
||||
DATA(lv_count) = lines( it_readings ).
|
||||
IF lv_count = 0.
|
||||
rv_mean = 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_abs_sum) = lv_sum.
|
||||
IF lv_abs_sum < 0.
|
||||
lv_abs_sum = -1 * lv_abs_sum.
|
||||
ENDIF.
|
||||
rv_mean = lv_abs_sum DIV lv_count.
|
||||
IF lv_sum < 0.
|
||||
rv_mean = -1 * rv_mean.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
151
tasks_gen/eval/G0129/faulty/m1_cold_chain_check.clas.abap
Normal file
151
tasks_gen/eval/G0129/faulty/m1_cold_chain_check.clas.abap
Normal file
@@ -0,0 +1,151 @@
|
||||
CLASS {{p}}cold_chain_check DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES: BEGIN OF ty_reading,
|
||||
offset_min TYPE i,
|
||||
temp_tenths TYPE i,
|
||||
END OF ty_reading,
|
||||
tt_readings TYPE STANDARD TABLE OF ty_reading WITH EMPTY KEY,
|
||||
BEGIN OF ty_config,
|
||||
min_tenths TYPE i,
|
||||
max_tenths TYPE i,
|
||||
min_duration TYPE i,
|
||||
max_gap TYPE i,
|
||||
END OF ty_config.
|
||||
|
||||
METHODS constructor
|
||||
IMPORTING is_config TYPE ty_config.
|
||||
|
||||
METHODS check
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_mean) TYPE i
|
||||
RAISING {{p}}cx_cold_chain.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA ms_config TYPE ty_config.
|
||||
|
||||
METHODS first_violation
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_structure
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_duration
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_gap
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_temperatures
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS mean_tenths
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_mean) TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cold_chain_check IMPLEMENTATION.
|
||||
METHOD constructor.
|
||||
ms_config = is_config.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check.
|
||||
DATA(lv_rule) = first_violation( it_readings ).
|
||||
IF lv_rule IS NOT INITIAL.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_cold_chain
|
||||
EXPORTING
|
||||
iv_rule = lv_rule.
|
||||
ENDIF.
|
||||
rv_mean = mean_tenths( it_readings ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD first_violation.
|
||||
rv_rule = check_structure( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_duration( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_gap( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_temperatures( it_readings ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_structure.
|
||||
IF lines( it_readings ) < 2.
|
||||
rv_rule = 'TOO_FEW'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
READ TABLE it_readings INDEX 1 INTO DATA(ls_first).
|
||||
IF ls_first-offset_min <> 0.
|
||||
rv_rule = 'NO_START'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_previous) = ls_first-offset_min.
|
||||
LOOP AT it_readings FROM 3 INTO DATA(ls_reading).
|
||||
IF ls_reading-offset_min <= lv_previous.
|
||||
rv_rule = 'TIME_ORDER'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
lv_previous = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_duration.
|
||||
DATA lv_last TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
lv_last = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
IF lv_last < ms_config-min_duration.
|
||||
rv_rule = 'TOO_SHORT'.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_gap.
|
||||
DATA lv_previous TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
IF sy-tabix > 1 AND ls_reading-offset_min - lv_previous > ms_config-max_gap.
|
||||
rv_rule = 'GAP'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
lv_previous = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_temperatures.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
IF ls_reading-temp_tenths > ms_config-max_tenths.
|
||||
rv_rule = 'TOO_HIGH'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF ls_reading-temp_tenths < ms_config-min_tenths.
|
||||
rv_rule = 'TOO_LOW'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mean_tenths.
|
||||
DATA lv_sum TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
lv_sum = lv_sum + ls_reading-temp_tenths.
|
||||
ENDLOOP.
|
||||
DATA(lv_count) = lines( it_readings ).
|
||||
IF lv_count = 0.
|
||||
rv_mean = 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_abs_sum) = lv_sum.
|
||||
IF lv_abs_sum < 0.
|
||||
lv_abs_sum = -1 * lv_abs_sum.
|
||||
ENDIF.
|
||||
rv_mean = lv_abs_sum DIV lv_count.
|
||||
IF lv_sum < 0.
|
||||
rv_mean = -1 * rv_mean.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
151
tasks_gen/eval/G0129/faulty/m2_cold_chain_check.clas.abap
Normal file
151
tasks_gen/eval/G0129/faulty/m2_cold_chain_check.clas.abap
Normal file
@@ -0,0 +1,151 @@
|
||||
CLASS {{p}}cold_chain_check DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES: BEGIN OF ty_reading,
|
||||
offset_min TYPE i,
|
||||
temp_tenths TYPE i,
|
||||
END OF ty_reading,
|
||||
tt_readings TYPE STANDARD TABLE OF ty_reading WITH EMPTY KEY,
|
||||
BEGIN OF ty_config,
|
||||
min_tenths TYPE i,
|
||||
max_tenths TYPE i,
|
||||
min_duration TYPE i,
|
||||
max_gap TYPE i,
|
||||
END OF ty_config.
|
||||
|
||||
METHODS constructor
|
||||
IMPORTING is_config TYPE ty_config.
|
||||
|
||||
METHODS check
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_mean) TYPE i
|
||||
RAISING {{p}}cx_cold_chain.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA ms_config TYPE ty_config.
|
||||
|
||||
METHODS first_violation
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_structure
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_duration
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_gap
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_temperatures
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS mean_tenths
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_mean) TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cold_chain_check IMPLEMENTATION.
|
||||
METHOD constructor.
|
||||
ms_config = is_config.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check.
|
||||
DATA(lv_rule) = first_violation( it_readings ).
|
||||
IF lv_rule IS NOT INITIAL.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_cold_chain
|
||||
EXPORTING
|
||||
iv_rule = lv_rule.
|
||||
ENDIF.
|
||||
rv_mean = mean_tenths( it_readings ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD first_violation.
|
||||
rv_rule = check_structure( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_duration( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_gap( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_temperatures( it_readings ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_structure.
|
||||
IF lines( it_readings ) < 2.
|
||||
rv_rule = 'TOO_FEW'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
READ TABLE it_readings INDEX 1 INTO DATA(ls_first).
|
||||
IF ls_first-offset_min <> 0.
|
||||
rv_rule = 'NO_START'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_previous) = ls_first-offset_min.
|
||||
LOOP AT it_readings FROM 2 INTO DATA(ls_reading).
|
||||
IF ls_reading-offset_min <= lv_previous.
|
||||
rv_rule = 'TIME_ORDER'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
lv_previous = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_duration.
|
||||
DATA lv_last TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
lv_last = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
IF lv_last < ms_config-min_duration.
|
||||
rv_rule = 'TOO_SHORT'.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_gap.
|
||||
DATA lv_previous TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
IF sy-tabix > 1 AND ls_reading-offset_min - lv_previous > ms_config-max_gap.
|
||||
rv_rule = 'GAP'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
lv_previous = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_temperatures.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
IF ls_reading-temp_tenths > ms_config-max_tenths.
|
||||
rv_rule = 'TOO_HIGH'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF ls_reading-temp_tenths < ms_config-min_tenths.
|
||||
rv_rule = 'TOO_LOW'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mean_tenths.
|
||||
DATA lv_sum TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
lv_sum = lv_sum + ls_reading-temp_tenths.
|
||||
ENDLOOP.
|
||||
DATA(lv_count) = lines( it_readings ).
|
||||
IF lv_count <> 0.
|
||||
rv_mean = 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_abs_sum) = lv_sum.
|
||||
IF lv_abs_sum < 0.
|
||||
lv_abs_sum = -1 * lv_abs_sum.
|
||||
ENDIF.
|
||||
rv_mean = lv_abs_sum DIV lv_count.
|
||||
IF lv_sum < 0.
|
||||
rv_mean = -1 * rv_mean.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
151
tasks_gen/eval/G0129/faulty/m3_cold_chain_check.clas.abap
Normal file
151
tasks_gen/eval/G0129/faulty/m3_cold_chain_check.clas.abap
Normal file
@@ -0,0 +1,151 @@
|
||||
CLASS {{p}}cold_chain_check DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES: BEGIN OF ty_reading,
|
||||
offset_min TYPE i,
|
||||
temp_tenths TYPE i,
|
||||
END OF ty_reading,
|
||||
tt_readings TYPE STANDARD TABLE OF ty_reading WITH EMPTY KEY,
|
||||
BEGIN OF ty_config,
|
||||
min_tenths TYPE i,
|
||||
max_tenths TYPE i,
|
||||
min_duration TYPE i,
|
||||
max_gap TYPE i,
|
||||
END OF ty_config.
|
||||
|
||||
METHODS constructor
|
||||
IMPORTING is_config TYPE ty_config.
|
||||
|
||||
METHODS check
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_mean) TYPE i
|
||||
RAISING {{p}}cx_cold_chain.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA ms_config TYPE ty_config.
|
||||
|
||||
METHODS first_violation
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_structure
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_duration
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_gap
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_temperatures
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS mean_tenths
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_mean) TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cold_chain_check IMPLEMENTATION.
|
||||
METHOD constructor.
|
||||
ms_config = is_config.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check.
|
||||
DATA(lv_rule) = first_violation( it_readings ).
|
||||
IF lv_rule IS NOT INITIAL.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_cold_chain
|
||||
EXPORTING
|
||||
iv_rule = lv_rule.
|
||||
ENDIF.
|
||||
rv_mean = mean_tenths( it_readings ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD first_violation.
|
||||
rv_rule = check_structure( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_duration( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_gap( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_temperatures( it_readings ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_structure.
|
||||
IF lines( it_readings ) < 2.
|
||||
rv_rule = 'TOO_FEW'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
READ TABLE it_readings INDEX 1 INTO DATA(ls_first).
|
||||
IF ls_first-offset_min <> 0.
|
||||
rv_rule = 'NO_START'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_previous) = ls_first-offset_min.
|
||||
LOOP AT it_readings FROM 2 INTO DATA(ls_reading).
|
||||
IF ls_reading-offset_min <= lv_previous.
|
||||
rv_rule = 'TIME_ORDER'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
lv_previous = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_duration.
|
||||
DATA lv_last TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
lv_last = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
IF lv_last < ms_config-min_duration.
|
||||
rv_rule = 'TOO_SHORT'.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_gap.
|
||||
DATA lv_previous TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
IF sy-tabix > 1 AND ls_reading-offset_min - lv_previous > ms_config-max_gap.
|
||||
rv_rule = 'GAP'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
lv_previous = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_temperatures.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
IF ls_reading-temp_tenths > ms_config-max_tenths.
|
||||
rv_rule = 'TOO_HIGH'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF ls_reading-temp_tenths < ms_config-min_tenths.
|
||||
rv_rule = 'TOO_LOW'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mean_tenths.
|
||||
DATA lv_sum TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
lv_sum = lv_sum + ls_reading-temp_tenths.
|
||||
ENDLOOP.
|
||||
DATA(lv_count) = lines( it_readings ).
|
||||
IF lv_count = 0.
|
||||
rv_mean = 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_abs_sum) = lv_sum.
|
||||
IF lv_abs_sum < 0.
|
||||
lv_abs_sum = -1 / lv_abs_sum.
|
||||
ENDIF.
|
||||
rv_mean = lv_abs_sum DIV lv_count.
|
||||
IF lv_sum < 0.
|
||||
rv_mean = -1 * rv_mean.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
151
tasks_gen/eval/G0129/faulty/m4_cold_chain_check.clas.abap
Normal file
151
tasks_gen/eval/G0129/faulty/m4_cold_chain_check.clas.abap
Normal file
@@ -0,0 +1,151 @@
|
||||
CLASS {{p}}cold_chain_check DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES: BEGIN OF ty_reading,
|
||||
offset_min TYPE i,
|
||||
temp_tenths TYPE i,
|
||||
END OF ty_reading,
|
||||
tt_readings TYPE STANDARD TABLE OF ty_reading WITH EMPTY KEY,
|
||||
BEGIN OF ty_config,
|
||||
min_tenths TYPE i,
|
||||
max_tenths TYPE i,
|
||||
min_duration TYPE i,
|
||||
max_gap TYPE i,
|
||||
END OF ty_config.
|
||||
|
||||
METHODS constructor
|
||||
IMPORTING is_config TYPE ty_config.
|
||||
|
||||
METHODS check
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_mean) TYPE i
|
||||
RAISING {{p}}cx_cold_chain.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA ms_config TYPE ty_config.
|
||||
|
||||
METHODS first_violation
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_structure
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_duration
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_gap
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_temperatures
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS mean_tenths
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_mean) TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cold_chain_check IMPLEMENTATION.
|
||||
METHOD constructor.
|
||||
ms_config = is_config.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check.
|
||||
DATA(lv_rule) = first_violation( it_readings ).
|
||||
IF lv_rule IS NOT INITIAL.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_cold_chain
|
||||
EXPORTING
|
||||
iv_rule = lv_rule.
|
||||
ENDIF.
|
||||
rv_mean = mean_tenths( it_readings ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD first_violation.
|
||||
rv_rule = check_structure( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_duration( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_gap( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_temperatures( it_readings ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_structure.
|
||||
IF lines( it_readings ) < 2.
|
||||
rv_rule = 'TOO_FEW'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
READ TABLE it_readings INDEX 1 INTO DATA(ls_first).
|
||||
IF ls_first-offset_min <> 0.
|
||||
rv_rule = 'NO_START'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_previous) = ls_first-offset_min.
|
||||
LOOP AT it_readings FROM 2 INTO DATA(ls_reading).
|
||||
IF ls_reading-offset_min <= lv_previous.
|
||||
rv_rule = 'TIME_ORDER'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
lv_previous = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_duration.
|
||||
DATA lv_last TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
lv_last = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
IF lv_last < ms_config-min_duration.
|
||||
rv_rule = 'TOO_SHORT'.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_gap.
|
||||
DATA lv_previous TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
IF sy-tabix > 1 AND ls_reading-offset_min - lv_previous > ms_config-max_gap.
|
||||
rv_rule = 'GAP'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
lv_previous = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_temperatures.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
IF ls_reading-temp_tenths > ms_config-max_tenths.
|
||||
rv_rule = 'TOO_HIGH'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF ls_reading-temp_tenths < ms_config-min_tenths.
|
||||
rv_rule = 'TOO_LOW'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mean_tenths.
|
||||
DATA lv_sum TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
lv_sum = lv_sum + ls_reading-temp_tenths.
|
||||
ENDLOOP.
|
||||
DATA(lv_count) = lines( it_readings ).
|
||||
IF lv_count = 0.
|
||||
rv_mean = 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_abs_sum) = lv_sum.
|
||||
IF lv_abs_sum < 0.
|
||||
lv_abs_sum = -1 * lv_abs_sum.
|
||||
ENDIF.
|
||||
rv_mean = lv_abs_sum DIV lv_count.
|
||||
IF lv_sum < 0.
|
||||
rv_mean = -1 / rv_mean.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
29
tasks_gen/eval/G0129/generation.json
Normal file
29
tasks_gen/eval/G0129/generation.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"id": "G0129",
|
||||
"pool": "eval",
|
||||
"object_type": "CLAS",
|
||||
"category": "D",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100.0,
|
||||
"null": 0,
|
||||
"mutation": {
|
||||
"valid": 5,
|
||||
"killed": 5,
|
||||
"ok": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"accepted": true
|
||||
}
|
||||
149
tasks_gen/eval/G0129/hidden/cold_chain_hidden.clas.abap
Normal file
149
tasks_gen/eval/G0129/hidden/cold_chain_hidden.clas.abap
Normal file
@@ -0,0 +1,149 @@
|
||||
CLASS {{p}}cold_chain_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}cold_chain_check.
|
||||
|
||||
METHODS setup.
|
||||
METHODS build
|
||||
IMPORTING iv_offsets TYPE string
|
||||
iv_temps TYPE string
|
||||
RETURNING VALUE(rt_readings) TYPE {{p}}cold_chain_check=>tt_readings.
|
||||
METHODS mean_of
|
||||
IMPORTING it_readings TYPE {{p}}cold_chain_check=>tt_readings
|
||||
RETURNING VALUE(rv_mean) TYPE i.
|
||||
METHODS rule_of
|
||||
IMPORTING it_readings TYPE {{p}}cold_chain_check=>tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
|
||||
METHODS valid_log_returns_mean FOR TESTING.
|
||||
METHODS too_few_readings FOR TESTING.
|
||||
METHODS no_start_at_zero FOR TESTING.
|
||||
METHODS offsets_not_increasing FOR TESTING.
|
||||
METHODS duration_too_short FOR TESTING.
|
||||
METHODS gap_too_large FOR TESTING.
|
||||
METHODS temperature_too_high FOR TESTING.
|
||||
METHODS temperature_too_low FOR TESTING.
|
||||
METHODS structural_error_first FOR TESTING.
|
||||
METHODS negative_mean_truncated FOR TESTING.
|
||||
METHODS exception_text FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cold_chain_hidden IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}cold_chain_check(
|
||||
is_config = VALUE #( min_tenths = 20
|
||||
max_tenths = 80
|
||||
min_duration = 120
|
||||
max_gap = 60 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD build.
|
||||
DATA lt_offsets TYPE STANDARD TABLE OF string WITH EMPTY KEY.
|
||||
DATA lt_temps TYPE STANDARD TABLE OF string WITH EMPTY KEY.
|
||||
SPLIT iv_offsets AT `,` INTO TABLE lt_offsets.
|
||||
SPLIT iv_temps AT `,` INTO TABLE lt_temps.
|
||||
DATA(lv_count) = lines( lt_offsets ).
|
||||
DO lv_count TIMES.
|
||||
APPEND VALUE #( offset_min = CONV i( lt_offsets[ sy-index ] )
|
||||
temp_tenths = CONV i( lt_temps[ sy-index ] ) ) TO rt_readings.
|
||||
ENDDO.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mean_of.
|
||||
TRY.
|
||||
rv_mean = mo_cut->check( it_readings ).
|
||||
CATCH {{p}}cx_cold_chain INTO DATA(lx_error).
|
||||
cl_abap_unit_assert=>fail( |Unexpected exception: { lx_error->mv_rule }| ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rule_of.
|
||||
TRY.
|
||||
mo_cut->check( it_readings ).
|
||||
cl_abap_unit_assert=>fail( `Exception expected` ).
|
||||
CATCH {{p}}cx_cold_chain INTO DATA(lx_error).
|
||||
rv_rule = lx_error->mv_rule.
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_log_returns_mean.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 47
|
||||
act = mean_of( build( iv_offsets = `0,30,60,120` iv_temps = `40,45,50,55` ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD too_few_readings.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'TOO_FEW'
|
||||
act = rule_of( build( iv_offsets = `0` iv_temps = `40` ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD no_start_at_zero.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'NO_START'
|
||||
act = rule_of( build( iv_offsets = `10,30,60,120` iv_temps = `40,45,50,55` ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD offsets_not_increasing.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'TIME_ORDER'
|
||||
act = rule_of( build( iv_offsets = `0,30,30,120` iv_temps = `40,45,50,55` ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD duration_too_short.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'TOO_SHORT'
|
||||
act = rule_of( build( iv_offsets = `0,30,60,90` iv_temps = `40,45,50,55` ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD gap_too_large.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'GAP'
|
||||
act = rule_of( build( iv_offsets = `0,90,120` iv_temps = `40,45,50` ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD temperature_too_high.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'TOO_HIGH'
|
||||
act = rule_of( build( iv_offsets = `0,30,60,120` iv_temps = `40,45,85,55` ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD temperature_too_low.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'TOO_LOW'
|
||||
act = rule_of( build( iv_offsets = `0,30,60,120` iv_temps = `40,45,15,55` ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD structural_error_first.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = 'NO_START'
|
||||
act = rule_of( build( iv_offsets = `10,30,60,90` iv_temps = `40,45,85,55` ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD negative_mean_truncated.
|
||||
DATA(lo_cut) = NEW {{p}}cold_chain_check(
|
||||
is_config = VALUE #( min_tenths = -250
|
||||
max_tenths = -150
|
||||
min_duration = 60
|
||||
max_gap = 60 ) ).
|
||||
DATA lv_mean TYPE i.
|
||||
TRY.
|
||||
lv_mean = lo_cut->check( build( iv_offsets = `0,60` iv_temps = `-200,-211` ) ).
|
||||
CATCH {{p}}cx_cold_chain INTO DATA(lx_error).
|
||||
cl_abap_unit_assert=>fail( |Unexpected exception: { lx_error->mv_rule }| ).
|
||||
ENDTRY.
|
||||
cl_abap_unit_assert=>assert_equals( exp = -205 act = lv_mean ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD exception_text.
|
||||
TRY.
|
||||
mo_cut->check( build( iv_offsets = `` iv_temps = `` ) ).
|
||||
cl_abap_unit_assert=>fail( `Exception expected` ).
|
||||
CATCH {{p}}cx_cold_chain INTO DATA(lx_error).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = `Cold chain check failed: TOO_FEW`
|
||||
act = lx_error->get_text( ) ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -1,267 +0,0 @@
|
||||
CLASS {{p}}t_print_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
METHODS a4_mono_price FOR TESTING.
|
||||
METHODS a4_color_price FOR TESTING.
|
||||
METHODS a3_a5_price FOR TESTING.
|
||||
METHODS volume_discount_5 FOR TESTING.
|
||||
METHODS volume_discount_10 FOR TESTING.
|
||||
METHODS minimum_charge FOR TESTING.
|
||||
METHODS copies_multiply FOR TESTING.
|
||||
METHODS rejects_zero_pages FOR TESTING.
|
||||
METHODS rejects_zero_copies FOR TESTING.
|
||||
METHODS rejects_unknown_values FOR TESTING.
|
||||
METHODS rejects_over_limit FOR TESTING.
|
||||
METHODS first_error_wins FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t_print_hidden IMPLEMENTATION.
|
||||
METHOD a4_mono_price.
|
||||
DATA lv_cents TYPE i.
|
||||
DATA(lo_cut) = NEW {{p}}print_job_pricer( ).
|
||||
TRY.
|
||||
DATA(lv_price) = lo_cut->calculate_price( iv_pages = 100
|
||||
iv_copies = 1
|
||||
iv_paper = 'A4'
|
||||
iv_color = 'M'
|
||||
iv_dept = 'SALE' ).
|
||||
lv_cents = lv_price * 100.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 500 act = lv_cents ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'unexpected exception' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD a4_color_price.
|
||||
DATA lv_cents TYPE i.
|
||||
DATA(lo_cut) = NEW {{p}}print_job_pricer( ).
|
||||
TRY.
|
||||
DATA(lv_price) = lo_cut->calculate_price( iv_pages = 100
|
||||
iv_copies = 1
|
||||
iv_paper = 'A4'
|
||||
iv_color = 'C'
|
||||
iv_dept = 'SALE' ).
|
||||
lv_cents = lv_price * 100.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2000 act = lv_cents ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'unexpected exception' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD a3_a5_price.
|
||||
DATA lv_cents TYPE i.
|
||||
DATA(lo_cut) = NEW {{p}}print_job_pricer( ).
|
||||
TRY.
|
||||
DATA(lv_price) = lo_cut->calculate_price( iv_pages = 100
|
||||
iv_copies = 1
|
||||
iv_paper = 'A3'
|
||||
iv_color = 'M'
|
||||
iv_dept = 'PROD' ).
|
||||
lv_cents = lv_price * 100.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 900 act = lv_cents ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'unexpected exception' ).
|
||||
ENDTRY.
|
||||
TRY.
|
||||
DATA(lv_a5) = lo_cut->calculate_price( iv_pages = 100
|
||||
iv_copies = 1
|
||||
iv_paper = 'A5'
|
||||
iv_color = 'M'
|
||||
iv_dept = 'HR' ).
|
||||
lv_cents = lv_a5 * 100.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 300 act = lv_cents ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'unexpected exception' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD volume_discount_5.
|
||||
DATA lv_cents TYPE i.
|
||||
DATA(lo_cut) = NEW {{p}}print_job_pricer( ).
|
||||
TRY.
|
||||
DATA(lv_price) = lo_cut->calculate_price( iv_pages = 600
|
||||
iv_copies = 1
|
||||
iv_paper = 'A4'
|
||||
iv_color = 'M'
|
||||
iv_dept = 'IT' ).
|
||||
lv_cents = lv_price * 100.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2850 act = lv_cents ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'unexpected exception' ).
|
||||
ENDTRY.
|
||||
TRY.
|
||||
DATA(lv_500) = lo_cut->calculate_price( iv_pages = 500
|
||||
iv_copies = 1
|
||||
iv_paper = 'A4'
|
||||
iv_color = 'M'
|
||||
iv_dept = 'IT' ).
|
||||
lv_cents = lv_500 * 100.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2375 act = lv_cents ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'unexpected exception' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD volume_discount_10.
|
||||
DATA lv_cents TYPE i.
|
||||
DATA(lo_cut) = NEW {{p}}print_job_pricer( ).
|
||||
TRY.
|
||||
DATA(lv_price) = lo_cut->calculate_price( iv_pages = 1000
|
||||
iv_copies = 1
|
||||
iv_paper = 'A4'
|
||||
iv_color = 'M'
|
||||
iv_dept = 'SALE' ).
|
||||
lv_cents = lv_price * 100.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 4500 act = lv_cents ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'unexpected exception' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD minimum_charge.
|
||||
DATA lv_cents TYPE i.
|
||||
DATA(lo_cut) = NEW {{p}}print_job_pricer( ).
|
||||
TRY.
|
||||
DATA(lv_price) = lo_cut->calculate_price( iv_pages = 10
|
||||
iv_copies = 1
|
||||
iv_paper = 'A4'
|
||||
iv_color = 'M'
|
||||
iv_dept = 'SALE' ).
|
||||
lv_cents = lv_price * 100.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 100 act = lv_cents ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'unexpected exception' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD copies_multiply.
|
||||
DATA lv_cents TYPE i.
|
||||
DATA(lo_cut) = NEW {{p}}print_job_pricer( ).
|
||||
TRY.
|
||||
DATA(lv_price) = lo_cut->calculate_price( iv_pages = 200
|
||||
iv_copies = 2
|
||||
iv_paper = 'A3'
|
||||
iv_color = 'C'
|
||||
iv_dept = 'PROD' ).
|
||||
lv_cents = lv_price * 100.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 14400 act = lv_cents ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'unexpected exception' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_zero_pages.
|
||||
DATA(lo_cut) = NEW {{p}}print_job_pricer( ).
|
||||
TRY.
|
||||
lo_cut->calculate_price( iv_pages = 0
|
||||
iv_copies = 1
|
||||
iv_paper = 'A4'
|
||||
iv_color = 'M'
|
||||
iv_dept = 'SALE' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'exception expected' ).
|
||||
CATCH {{p}}cx_print_job_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}cx_print_job_error=>c_reason-pages
|
||||
act = lo_error->mv_reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_zero_copies.
|
||||
DATA(lo_cut) = NEW {{p}}print_job_pricer( ).
|
||||
TRY.
|
||||
lo_cut->calculate_price( iv_pages = 100
|
||||
iv_copies = 0
|
||||
iv_paper = 'A4'
|
||||
iv_color = 'M'
|
||||
iv_dept = 'SALE' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'exception expected' ).
|
||||
CATCH {{p}}cx_print_job_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}cx_print_job_error=>c_reason-copies
|
||||
act = lo_error->mv_reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_unknown_values.
|
||||
DATA(lo_cut) = NEW {{p}}print_job_pricer( ).
|
||||
TRY.
|
||||
lo_cut->calculate_price( iv_pages = 100
|
||||
iv_copies = 1
|
||||
iv_paper = 'B5'
|
||||
iv_color = 'M'
|
||||
iv_dept = 'SALE' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'exception expected' ).
|
||||
CATCH {{p}}cx_print_job_error INTO DATA(lo_paper).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}cx_print_job_error=>c_reason-paper
|
||||
act = lo_paper->mv_reason ).
|
||||
ENDTRY.
|
||||
TRY.
|
||||
lo_cut->calculate_price( iv_pages = 100
|
||||
iv_copies = 1
|
||||
iv_paper = 'A4'
|
||||
iv_color = 'X'
|
||||
iv_dept = 'SALE' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'exception expected' ).
|
||||
CATCH {{p}}cx_print_job_error INTO DATA(lo_color).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}cx_print_job_error=>c_reason-color
|
||||
act = lo_color->mv_reason ).
|
||||
ENDTRY.
|
||||
TRY.
|
||||
lo_cut->calculate_price( iv_pages = 100
|
||||
iv_copies = 1
|
||||
iv_paper = 'A4'
|
||||
iv_color = 'M'
|
||||
iv_dept = 'XYZ' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'exception expected' ).
|
||||
CATCH {{p}}cx_print_job_error INTO DATA(lo_dept).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}cx_print_job_error=>c_reason-dept
|
||||
act = lo_dept->mv_reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_over_limit.
|
||||
DATA lv_cents TYPE i.
|
||||
DATA(lo_cut) = NEW {{p}}print_job_pricer( ).
|
||||
TRY.
|
||||
lo_cut->calculate_price( iv_pages = 3000
|
||||
iv_copies = 2
|
||||
iv_paper = 'A4'
|
||||
iv_color = 'M'
|
||||
iv_dept = 'SALE' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'exception expected' ).
|
||||
CATCH {{p}}cx_print_limit INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 6000
|
||||
act = lo_error->mv_pages ).
|
||||
ENDTRY.
|
||||
TRY.
|
||||
DATA(lv_price) = lo_cut->calculate_price( iv_pages = 5000
|
||||
iv_copies = 1
|
||||
iv_paper = 'A4'
|
||||
iv_color = 'M'
|
||||
iv_dept = 'SALE' ).
|
||||
lv_cents = lv_price * 100.
|
||||
cl_abap_unit_assert=>assert_equals( exp = 22500 act = lv_cents ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'unexpected exception' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD first_error_wins.
|
||||
DATA(lo_cut) = NEW {{p}}print_job_pricer( ).
|
||||
TRY.
|
||||
lo_cut->calculate_price( iv_pages = 0
|
||||
iv_copies = 0
|
||||
iv_paper = 'B5'
|
||||
iv_color = 'X'
|
||||
iv_dept = 'XYZ' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'exception expected' ).
|
||||
CATCH {{p}}cx_print_job_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}cx_print_job_error=>c_reason-pages
|
||||
act = lo_error->mv_reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
63
tasks_gen/eval/G0129/mutation.json
Normal file
63
tasks_gen/eval/G0129/mutation.json
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"task": "G0129",
|
||||
"mutants": [
|
||||
{
|
||||
"object": "{{P}}COLD_CHAIN_CHECK",
|
||||
"mutant": "line 84: <> -> = (rel)",
|
||||
"status": "killed",
|
||||
"hidden": "2/11",
|
||||
"failed_tests": [
|
||||
"DURATION_TOO_SHORT",
|
||||
"GAP_TOO_LARGE",
|
||||
"NEGATIVE_MEAN_TRUNCATED",
|
||||
"NO_START_AT_ZERO",
|
||||
"OFFSETS_NOT_INCREASING",
|
||||
"STRUCTURAL_ERROR_FIRST",
|
||||
"TEMPERATURE_TOO_HIGH",
|
||||
"TEMPERATURE_TOO_LOW",
|
||||
"VALID_LOG_RETURNS_MEAN"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}COLD_CHAIN_CHECK",
|
||||
"mutant": "line 89: 2 -> 3 (const)",
|
||||
"status": "killed",
|
||||
"hidden": "10/11",
|
||||
"failed_tests": [
|
||||
"OFFSETS_NOT_INCREASING"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}COLD_CHAIN_CHECK",
|
||||
"mutant": "line 138: = -> <> (eq)",
|
||||
"status": "killed",
|
||||
"hidden": "9/11",
|
||||
"failed_tests": [
|
||||
"NEGATIVE_MEAN_TRUNCATED",
|
||||
"VALID_LOG_RETURNS_MEAN"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}COLD_CHAIN_CHECK",
|
||||
"mutant": "line 144: * -> / (arith)",
|
||||
"status": "killed",
|
||||
"hidden": "10/11",
|
||||
"failed_tests": [
|
||||
"NEGATIVE_MEAN_TRUNCATED"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}COLD_CHAIN_CHECK",
|
||||
"mutant": "line 148: * -> / (arith)",
|
||||
"status": "killed",
|
||||
"hidden": "10/11",
|
||||
"failed_tests": [
|
||||
"NEGATIVE_MEAN_TRUNCATED"
|
||||
]
|
||||
}
|
||||
],
|
||||
"valid": 5,
|
||||
"killed": 5,
|
||||
"kill_rate": 1.0,
|
||||
"ok": true
|
||||
}
|
||||
151
tasks_gen/eval/G0129/reference/cold_chain_check.clas.abap
Normal file
151
tasks_gen/eval/G0129/reference/cold_chain_check.clas.abap
Normal file
@@ -0,0 +1,151 @@
|
||||
CLASS {{p}}cold_chain_check DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES: BEGIN OF ty_reading,
|
||||
offset_min TYPE i,
|
||||
temp_tenths TYPE i,
|
||||
END OF ty_reading,
|
||||
tt_readings TYPE STANDARD TABLE OF ty_reading WITH EMPTY KEY,
|
||||
BEGIN OF ty_config,
|
||||
min_tenths TYPE i,
|
||||
max_tenths TYPE i,
|
||||
min_duration TYPE i,
|
||||
max_gap TYPE i,
|
||||
END OF ty_config.
|
||||
|
||||
METHODS constructor
|
||||
IMPORTING is_config TYPE ty_config.
|
||||
|
||||
METHODS check
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_mean) TYPE i
|
||||
RAISING {{p}}cx_cold_chain.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA ms_config TYPE ty_config.
|
||||
|
||||
METHODS first_violation
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_structure
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_duration
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_gap
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS check_temperatures
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
METHODS mean_tenths
|
||||
IMPORTING it_readings TYPE tt_readings
|
||||
RETURNING VALUE(rv_mean) TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cold_chain_check IMPLEMENTATION.
|
||||
METHOD constructor.
|
||||
ms_config = is_config.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check.
|
||||
DATA(lv_rule) = first_violation( it_readings ).
|
||||
IF lv_rule IS NOT INITIAL.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_cold_chain
|
||||
EXPORTING
|
||||
iv_rule = lv_rule.
|
||||
ENDIF.
|
||||
rv_mean = mean_tenths( it_readings ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD first_violation.
|
||||
rv_rule = check_structure( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_duration( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_gap( it_readings ).
|
||||
IF rv_rule IS NOT INITIAL.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
rv_rule = check_temperatures( it_readings ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_structure.
|
||||
IF lines( it_readings ) < 2.
|
||||
rv_rule = 'TOO_FEW'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
READ TABLE it_readings INDEX 1 INTO DATA(ls_first).
|
||||
IF ls_first-offset_min <> 0.
|
||||
rv_rule = 'NO_START'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_previous) = ls_first-offset_min.
|
||||
LOOP AT it_readings FROM 2 INTO DATA(ls_reading).
|
||||
IF ls_reading-offset_min <= lv_previous.
|
||||
rv_rule = 'TIME_ORDER'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
lv_previous = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_duration.
|
||||
DATA lv_last TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
lv_last = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
IF lv_last < ms_config-min_duration.
|
||||
rv_rule = 'TOO_SHORT'.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_gap.
|
||||
DATA lv_previous TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
IF sy-tabix > 1 AND ls_reading-offset_min - lv_previous > ms_config-max_gap.
|
||||
rv_rule = 'GAP'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
lv_previous = ls_reading-offset_min.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_temperatures.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
IF ls_reading-temp_tenths > ms_config-max_tenths.
|
||||
rv_rule = 'TOO_HIGH'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
IF ls_reading-temp_tenths < ms_config-min_tenths.
|
||||
rv_rule = 'TOO_LOW'.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mean_tenths.
|
||||
DATA lv_sum TYPE i.
|
||||
LOOP AT it_readings INTO DATA(ls_reading).
|
||||
lv_sum = lv_sum + ls_reading-temp_tenths.
|
||||
ENDLOOP.
|
||||
DATA(lv_count) = lines( it_readings ).
|
||||
IF lv_count = 0.
|
||||
rv_mean = 0.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA(lv_abs_sum) = lv_sum.
|
||||
IF lv_abs_sum < 0.
|
||||
lv_abs_sum = -1 * lv_abs_sum.
|
||||
ENDIF.
|
||||
rv_mean = lv_abs_sum DIV lv_count.
|
||||
IF lv_sum < 0.
|
||||
rv_mean = -1 * rv_mean.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
112
tasks_gen/eval/G0129/reference/cold_chain_check.testclasses.abap
Normal file
112
tasks_gen/eval/G0129/reference/cold_chain_check.testclasses.abap
Normal file
@@ -0,0 +1,112 @@
|
||||
CLASS ltc_cold_chain DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}cold_chain_check.
|
||||
|
||||
METHODS setup.
|
||||
METHODS mean_of
|
||||
IMPORTING it_readings TYPE {{p}}cold_chain_check=>tt_readings
|
||||
RETURNING VALUE(rv_mean) TYPE i.
|
||||
METHODS rule_of
|
||||
IMPORTING it_readings TYPE {{p}}cold_chain_check=>tt_readings
|
||||
RETURNING VALUE(rv_rule) TYPE string.
|
||||
|
||||
METHODS valid_log FOR TESTING.
|
||||
METHODS empty_log FOR TESTING.
|
||||
METHODS late_start FOR TESTING.
|
||||
METHODS wrong_order FOR TESTING.
|
||||
METHODS short_duration FOR TESTING.
|
||||
METHODS long_gap FOR TESTING.
|
||||
METHODS too_warm FOR TESTING.
|
||||
METHODS too_cold FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_cold_chain IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}cold_chain_check(
|
||||
is_config = VALUE #( min_tenths = 20
|
||||
max_tenths = 80
|
||||
min_duration = 120
|
||||
max_gap = 60 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD mean_of.
|
||||
TRY.
|
||||
rv_mean = mo_cut->check( it_readings ).
|
||||
CATCH {{p}}cx_cold_chain INTO DATA(lx_error).
|
||||
cl_abap_unit_assert=>fail( |Unexpected exception: { lx_error->mv_rule }| ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rule_of.
|
||||
TRY.
|
||||
mo_cut->check( it_readings ).
|
||||
cl_abap_unit_assert=>fail( `Exception expected` ).
|
||||
CATCH {{p}}cx_cold_chain INTO DATA(lx_error).
|
||||
rv_rule = lx_error->mv_rule.
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_log.
|
||||
DATA(lt_readings) = VALUE {{p}}cold_chain_check=>tt_readings(
|
||||
( offset_min = 0 temp_tenths = 40 )
|
||||
( offset_min = 30 temp_tenths = 45 )
|
||||
( offset_min = 60 temp_tenths = 50 )
|
||||
( offset_min = 120 temp_tenths = 55 ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 47 act = mean_of( lt_readings ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_log.
|
||||
DATA(lt_readings) = VALUE {{p}}cold_chain_check=>tt_readings( ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'TOO_FEW' act = rule_of( lt_readings ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD late_start.
|
||||
DATA(lt_readings) = VALUE {{p}}cold_chain_check=>tt_readings(
|
||||
( offset_min = 10 temp_tenths = 40 )
|
||||
( offset_min = 30 temp_tenths = 45 )
|
||||
( offset_min = 120 temp_tenths = 50 ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'NO_START' act = rule_of( lt_readings ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD wrong_order.
|
||||
DATA(lt_readings) = VALUE {{p}}cold_chain_check=>tt_readings(
|
||||
( offset_min = 0 temp_tenths = 40 )
|
||||
( offset_min = 60 temp_tenths = 45 )
|
||||
( offset_min = 30 temp_tenths = 50 )
|
||||
( offset_min = 120 temp_tenths = 55 ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'TIME_ORDER' act = rule_of( lt_readings ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD short_duration.
|
||||
DATA(lt_readings) = VALUE {{p}}cold_chain_check=>tt_readings(
|
||||
( offset_min = 0 temp_tenths = 40 )
|
||||
( offset_min = 30 temp_tenths = 45 )
|
||||
( offset_min = 90 temp_tenths = 50 ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'TOO_SHORT' act = rule_of( lt_readings ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD long_gap.
|
||||
DATA(lt_readings) = VALUE {{p}}cold_chain_check=>tt_readings(
|
||||
( offset_min = 0 temp_tenths = 40 )
|
||||
( offset_min = 90 temp_tenths = 45 )
|
||||
( offset_min = 120 temp_tenths = 50 ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'GAP' act = rule_of( lt_readings ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD too_warm.
|
||||
DATA(lt_readings) = VALUE {{p}}cold_chain_check=>tt_readings(
|
||||
( offset_min = 0 temp_tenths = 40 )
|
||||
( offset_min = 60 temp_tenths = 85 )
|
||||
( offset_min = 120 temp_tenths = 50 ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'TOO_HIGH' act = rule_of( lt_readings ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD too_cold.
|
||||
DATA(lt_readings) = VALUE {{p}}cold_chain_check=>tt_readings(
|
||||
( offset_min = 0 temp_tenths = 40 )
|
||||
( offset_min = 60 temp_tenths = 15 )
|
||||
( offset_min = 120 temp_tenths = 50 ) ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'TOO_LOW' act = rule_of( lt_readings ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -1,31 +0,0 @@
|
||||
CLASS {{p}}cx_print_job_error DEFINITION
|
||||
PUBLIC
|
||||
INHERITING FROM CX_ROOT
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES ty_reason TYPE c LENGTH 10.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_reason,
|
||||
pages TYPE ty_reason VALUE 'PAGES',
|
||||
copies TYPE ty_reason VALUE 'COPIES',
|
||||
paper TYPE ty_reason VALUE 'PAPER',
|
||||
color TYPE ty_reason VALUE 'COLOR',
|
||||
dept TYPE ty_reason VALUE 'DEPT',
|
||||
END OF c_reason.
|
||||
|
||||
DATA mv_reason TYPE ty_reason.
|
||||
|
||||
METHODS constructor
|
||||
IMPORTING
|
||||
iv_reason TYPE ty_reason.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cx_print_job_error IMPLEMENTATION.
|
||||
METHOD constructor.
|
||||
super->constructor( ).
|
||||
mv_reason = iv_reason.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -1,20 +0,0 @@
|
||||
CLASS {{p}}cx_print_limit DEFINITION
|
||||
PUBLIC
|
||||
INHERITING FROM CX_ROOT
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
DATA mv_pages TYPE i.
|
||||
|
||||
METHODS constructor
|
||||
IMPORTING
|
||||
iv_pages TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cx_print_limit IMPLEMENTATION.
|
||||
METHOD constructor.
|
||||
super->constructor( ).
|
||||
mv_pages = iv_pages.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -1,158 +0,0 @@
|
||||
CLASS {{p}}print_job_pricer DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
ty_paper TYPE c LENGTH 4,
|
||||
ty_color TYPE c LENGTH 1,
|
||||
ty_dept TYPE c LENGTH 4,
|
||||
ty_price TYPE p LENGTH 8 DECIMALS 2.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_paper,
|
||||
a3 TYPE ty_paper VALUE 'A3',
|
||||
a4 TYPE ty_paper VALUE 'A4',
|
||||
a5 TYPE ty_paper VALUE 'A5',
|
||||
END OF c_paper,
|
||||
BEGIN OF c_color,
|
||||
mono TYPE ty_color VALUE 'M',
|
||||
color TYPE ty_color VALUE 'C',
|
||||
END OF c_color,
|
||||
BEGIN OF c_dept,
|
||||
sale TYPE ty_dept VALUE 'SALE',
|
||||
hr TYPE ty_dept VALUE 'HR',
|
||||
it TYPE ty_dept VALUE 'IT',
|
||||
prod TYPE ty_dept VALUE 'PROD',
|
||||
END OF c_dept,
|
||||
c_max_pages TYPE i VALUE 5000,
|
||||
c_min_cents TYPE i VALUE 100,
|
||||
c_cents_a5 TYPE i VALUE 3,
|
||||
c_cents_a4 TYPE i VALUE 5,
|
||||
c_cents_a3 TYPE i VALUE 9,
|
||||
c_color_factor TYPE i VALUE 4,
|
||||
c_cents_per_unit TYPE i VALUE 100,
|
||||
c_percent_base TYPE i VALUE 100,
|
||||
c_percent_5 TYPE i VALUE 5,
|
||||
c_percent_10 TYPE i VALUE 10,
|
||||
c_pages_discount_5 TYPE i VALUE 500,
|
||||
c_pages_discount_10 TYPE i VALUE 1000.
|
||||
|
||||
METHODS calculate_price
|
||||
IMPORTING
|
||||
iv_pages TYPE i
|
||||
iv_copies TYPE i
|
||||
iv_paper TYPE ty_paper
|
||||
iv_color TYPE ty_color
|
||||
iv_dept TYPE ty_dept
|
||||
RETURNING
|
||||
VALUE(rv_price) TYPE ty_price
|
||||
RAISING
|
||||
{{p}}cx_print_job_error
|
||||
{{p}}cx_print_limit.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS validate
|
||||
IMPORTING
|
||||
iv_pages TYPE i
|
||||
iv_copies TYPE i
|
||||
iv_paper TYPE ty_paper
|
||||
iv_color TYPE ty_color
|
||||
iv_dept TYPE ty_dept
|
||||
RAISING
|
||||
{{p}}cx_print_job_error.
|
||||
METHODS page_price_cents
|
||||
IMPORTING
|
||||
iv_paper TYPE ty_paper
|
||||
iv_color TYPE ty_color
|
||||
RETURNING
|
||||
VALUE(rv_cents) TYPE i.
|
||||
METHODS discount_cents
|
||||
IMPORTING
|
||||
iv_total_pages TYPE i
|
||||
iv_gross_cents TYPE i
|
||||
RETURNING
|
||||
VALUE(rv_cents) TYPE i.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}print_job_pricer IMPLEMENTATION.
|
||||
METHOD calculate_price.
|
||||
validate( iv_pages = iv_pages
|
||||
iv_copies = iv_copies
|
||||
iv_paper = iv_paper
|
||||
iv_color = iv_color
|
||||
iv_dept = iv_dept ).
|
||||
|
||||
DATA(lv_total_pages) = iv_pages * iv_copies.
|
||||
IF lv_total_pages > c_max_pages.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_print_limit
|
||||
EXPORTING
|
||||
iv_pages = lv_total_pages.
|
||||
ENDIF.
|
||||
|
||||
DATA(lv_gross_cents) = lv_total_pages * page_price_cents(
|
||||
iv_paper = iv_paper
|
||||
iv_color = iv_color ).
|
||||
DATA(lv_net_cents) = lv_gross_cents - discount_cents(
|
||||
iv_total_pages = lv_total_pages
|
||||
iv_gross_cents = lv_gross_cents ).
|
||||
IF lv_net_cents < c_min_cents.
|
||||
lv_net_cents = c_min_cents.
|
||||
ENDIF.
|
||||
|
||||
DATA(lv_net) = CONV ty_price( lv_net_cents ).
|
||||
rv_price = lv_net / c_cents_per_unit.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD validate.
|
||||
IF iv_pages < 1.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_print_job_error
|
||||
EXPORTING iv_reason = {{p}}cx_print_job_error=>c_reason-pages.
|
||||
ENDIF.
|
||||
IF iv_copies < 1.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_print_job_error
|
||||
EXPORTING iv_reason = {{p}}cx_print_job_error=>c_reason-copies.
|
||||
ENDIF.
|
||||
IF iv_paper <> c_paper-a4 AND iv_paper <> c_paper-a3
|
||||
AND iv_paper <> c_paper-a5.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_print_job_error
|
||||
EXPORTING iv_reason = {{p}}cx_print_job_error=>c_reason-paper.
|
||||
ENDIF.
|
||||
IF iv_color <> c_color-color AND iv_color <> c_color-mono.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_print_job_error
|
||||
EXPORTING iv_reason = {{p}}cx_print_job_error=>c_reason-color.
|
||||
ENDIF.
|
||||
IF iv_dept <> c_dept-sale AND iv_dept <> c_dept-hr
|
||||
AND iv_dept <> c_dept-it AND iv_dept <> c_dept-prod.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_print_job_error
|
||||
EXPORTING iv_reason = {{p}}cx_print_job_error=>c_reason-dept.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD page_price_cents.
|
||||
CASE iv_paper.
|
||||
WHEN c_paper-a5.
|
||||
rv_cents = c_cents_a5.
|
||||
WHEN c_paper-a4.
|
||||
rv_cents = c_cents_a4.
|
||||
WHEN c_paper-a3.
|
||||
rv_cents = c_cents_a3.
|
||||
ENDCASE.
|
||||
IF iv_color = c_color-color.
|
||||
rv_cents = rv_cents * c_color_factor.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD discount_cents.
|
||||
DATA lv_percent TYPE i.
|
||||
IF iv_total_pages >= c_pages_discount_10.
|
||||
lv_percent = c_percent_10.
|
||||
ELSEIF iv_total_pages >= c_pages_discount_5.
|
||||
lv_percent = c_percent_5.
|
||||
ELSE.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
DATA lv_gross TYPE ty_price.
|
||||
lv_gross = iv_gross_cents.
|
||||
DATA(lv_discount) = lv_gross * lv_percent / c_percent_base.
|
||||
rv_cents = lv_discount.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -1,104 +0,0 @@
|
||||
CLASS ltc_print_job_pricer DEFINITION FINAL FOR TESTING
|
||||
DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}print_job_pricer.
|
||||
METHODS setup.
|
||||
METHODS price
|
||||
IMPORTING
|
||||
iv_pages TYPE i
|
||||
iv_copies TYPE i
|
||||
iv_paper TYPE {{p}}print_job_pricer=>ty_paper
|
||||
iv_color TYPE {{p}}print_job_pricer=>ty_color
|
||||
iv_dept TYPE {{p}}print_job_pricer=>ty_dept
|
||||
RETURNING
|
||||
VALUE(rv_price) TYPE {{p}}print_job_pricer=>ty_price.
|
||||
METHODS cents
|
||||
IMPORTING
|
||||
iv_cents TYPE i
|
||||
RETURNING
|
||||
VALUE(rv_price) TYPE {{p}}print_job_pricer=>ty_price.
|
||||
METHODS a4_mono_price FOR TESTING.
|
||||
METHODS color_price FOR TESTING.
|
||||
METHODS volume_discount FOR TESTING.
|
||||
METHODS minimum_charge FOR TESTING.
|
||||
METHODS zero_pages_raises FOR TESTING.
|
||||
METHODS over_limit_raises FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_print_job_pricer IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}print_job_pricer( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD price.
|
||||
TRY.
|
||||
rv_price = mo_cut->calculate_price( iv_pages = iv_pages
|
||||
iv_copies = iv_copies
|
||||
iv_paper = iv_paper
|
||||
iv_color = iv_color
|
||||
iv_dept = iv_dept ).
|
||||
CATCH cx_root.
|
||||
cl_abap_unit_assert=>fail( msg = 'unexpected exception' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD cents.
|
||||
DATA lv_price TYPE {{p}}print_job_pricer=>ty_price.
|
||||
lv_price = iv_cents.
|
||||
rv_price = lv_price / 100.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD a4_mono_price.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = cents( 500 )
|
||||
act = price( iv_pages = 100 iv_copies = 1
|
||||
iv_paper = 'A4' iv_color = 'M' iv_dept = 'SALE' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD color_price.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = cents( 2000 )
|
||||
act = price( iv_pages = 100 iv_copies = 1
|
||||
iv_paper = 'A4' iv_color = 'C' iv_dept = 'SALE' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD volume_discount.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = cents( 2850 )
|
||||
act = price( iv_pages = 600 iv_copies = 1
|
||||
iv_paper = 'A4' iv_color = 'M' iv_dept = 'IT' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD minimum_charge.
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = cents( 100 )
|
||||
act = price( iv_pages = 10 iv_copies = 1
|
||||
iv_paper = 'A4' iv_color = 'M' iv_dept = 'SALE' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_pages_raises.
|
||||
TRY.
|
||||
mo_cut->calculate_price( iv_pages = 0 iv_copies = 1
|
||||
iv_paper = 'A4' iv_color = 'M'
|
||||
iv_dept = 'SALE' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'exception expected' ).
|
||||
CATCH {{p}}cx_print_job_error INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals(
|
||||
exp = {{p}}cx_print_job_error=>c_reason-pages
|
||||
act = lo_error->mv_reason ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD over_limit_raises.
|
||||
TRY.
|
||||
mo_cut->calculate_price( iv_pages = 3000 iv_copies = 2
|
||||
iv_paper = 'A4' iv_color = 'M'
|
||||
iv_dept = 'SALE' ).
|
||||
cl_abap_unit_assert=>fail( msg = 'exception expected' ).
|
||||
CATCH {{p}}cx_print_limit INTO DATA(lo_error).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 6000
|
||||
act = lo_error->mv_pages ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
23
tasks_gen/eval/G0129/seed/cx_cold_chain.clas.abap
Normal file
23
tasks_gen/eval/G0129/seed/cx_cold_chain.clas.abap
Normal file
@@ -0,0 +1,23 @@
|
||||
CLASS {{p}}cx_cold_chain DEFINITION PUBLIC INHERITING FROM cx_static_check FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
DATA mv_rule TYPE string READ-ONLY.
|
||||
|
||||
METHODS constructor
|
||||
IMPORTING iv_rule TYPE string.
|
||||
|
||||
METHODS get_text REDEFINITION.
|
||||
|
||||
PRIVATE SECTION.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cx_cold_chain IMPLEMENTATION.
|
||||
METHOD constructor.
|
||||
super->constructor( ).
|
||||
mv_rule = iv_rule.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_text.
|
||||
result = |Cold chain check failed: { mv_rule }|.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -1,85 +1,62 @@
|
||||
# 1. Goal
|
||||
Calculate the internal price of a print job for the print shop of a company. A
|
||||
billing program calls the calculation before it charges the cost centre of a
|
||||
department. Invalid job data must raise a class-based exception.
|
||||
Check the temperature log of a refrigerated shipment. A logistics program calls the
|
||||
check before it releases the shipment. The check must give one reason code for each
|
||||
log that is not correct.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- Package $TMP. No other object exists for this topic.
|
||||
- The billing program catches the exceptions and shows the reason to the user.
|
||||
The names of the classes and their public components are fixed.
|
||||
- The exception class {{P}}CX_COLD_CHAIN exists in package $TMP. It is active.
|
||||
- The class inherits from CX_STATIC_CHECK. It has the read-only attribute MV_RULE
|
||||
(type STRING), the constructor with the importing parameter IV_RULE (type STRING),
|
||||
and the redefined method GET_TEXT.
|
||||
- GET_TEXT returns the text Cold chain check failed: <rule code>.
|
||||
- A temperature log is a table of readings. One reading has the time offset in
|
||||
minutes (OFFSET_MIN) and the temperature in tenths of a degree Celsius
|
||||
(TEMP_TENTHS). Example: the value -185 means -18.5 degrees Celsius.
|
||||
|
||||
# 4. Contract
|
||||
Create three classes in package $TMP.
|
||||
|
||||
## {{P}}CX_PRINT_JOB_ERROR
|
||||
- Public, final, inherits from CX_ROOT.
|
||||
- Public type TY_REASON, character 10.
|
||||
- Public constant structure C_REASON with the components PAGES, COPIES, PAPER,
|
||||
COLOR and DEPT. The values are 'PAGES', 'COPIES', 'PAPER', 'COLOR' and
|
||||
'DEPT'.
|
||||
- Public attribute MV_REASON of type TY_REASON.
|
||||
- Public constructor with the importing parameter IV_REASON of type TY_REASON.
|
||||
The constructor writes IV_REASON to MV_REASON.
|
||||
|
||||
## {{P}}CX_PRINT_LIMIT
|
||||
- Public, final, inherits from CX_ROOT.
|
||||
- Public attribute MV_PAGES of type I.
|
||||
- Public constructor with the importing parameter IV_PAGES of type I. The
|
||||
constructor writes IV_PAGES to MV_PAGES.
|
||||
|
||||
## {{P}}PRINT_JOB_PRICER
|
||||
- Public, final, public constructor without parameters.
|
||||
- Public types: TY_PAPER (character 4), TY_COLOR (character 1), TY_DEPT
|
||||
(character 4), TY_PRICE (packed number, length 8, 2 decimals).
|
||||
- Public method CALCULATE_PRICE with these parameters:
|
||||
- IMPORTING IV_PAGES TYPE I
|
||||
- IMPORTING IV_COPIES TYPE I
|
||||
- IMPORTING IV_PAPER TYPE TY_PAPER
|
||||
- IMPORTING IV_COLOR TYPE TY_COLOR
|
||||
- IMPORTING IV_DEPT TYPE TY_DEPT
|
||||
- RETURNING VALUE(RV_PRICE) TYPE TY_PRICE
|
||||
- RAISING {{P}}CX_PRINT_JOB_ERROR and {{P}}CX_PRINT_LIMIT
|
||||
- Create the class {{P}}COLD_CHAIN_CHECK in package $TMP.
|
||||
- The class is public, final, and has a public constructor.
|
||||
- The class has these public types:
|
||||
- TY_READING: a structure with the fields OFFSET_MIN (type I) and TEMP_TENTHS
|
||||
(type I).
|
||||
- TT_READINGS: a standard table of TY_READING with an empty key.
|
||||
- TY_CONFIG: a structure with the fields MIN_TENTHS (type I), MAX_TENTHS
|
||||
(type I), MIN_DURATION (type I), and MAX_GAP (type I).
|
||||
- The constructor has the importing parameter IS_CONFIG of type TY_CONFIG.
|
||||
- The class has the method CHECK with the importing parameter IT_READINGS of type
|
||||
TT_READINGS, the returning parameter RV_MEAN of type I, and the addition
|
||||
RAISING {{P}}CX_COLD_CHAIN.
|
||||
- Do not add other public methods.
|
||||
- Do not change {{P}}CX_COLD_CHAIN.
|
||||
|
||||
# 5. Business rules
|
||||
Apply the rules in this sequence.
|
||||
|
||||
1. Check the input in this order. Raise the exception of the first rule that
|
||||
fails.
|
||||
1. IV_PAGES is smaller than 1: raise {{P}}CX_PRINT_JOB_ERROR with the
|
||||
reason PAGES.
|
||||
2. IV_COPIES is smaller than 1: raise {{P}}CX_PRINT_JOB_ERROR with the
|
||||
reason COPIES.
|
||||
3. IV_PAPER is not 'A4', 'A3' or 'A5': raise {{P}}CX_PRINT_JOB_ERROR with
|
||||
the reason PAPER.
|
||||
4. IV_COLOR is not 'C' or 'M': raise {{P}}CX_PRINT_JOB_ERROR with the
|
||||
reason COLOR.
|
||||
5. IV_DEPT is not 'SALE', 'HR', 'IT' or 'PROD': raise
|
||||
{{P}}CX_PRINT_JOB_ERROR with the reason DEPT.
|
||||
2. The total number of pages is IV_PAGES multiplied by IV_COPIES.
|
||||
3. If the total number of pages is greater than 5000, raise
|
||||
{{P}}CX_PRINT_LIMIT with MV_PAGES equal to the total number of pages.
|
||||
4. The price of one page is 0.03 for A5, 0.05 for A4 and 0.09 for A3. For the
|
||||
color mode 'C', multiply the price of one page by 4.
|
||||
5. The gross price is the total number of pages multiplied by the price of one
|
||||
page.
|
||||
6. Volume discount on the gross price: 10 per cent if the total number of
|
||||
pages is 1000 or more, 5 per cent if the total number of pages is 500 or
|
||||
more, otherwise no discount.
|
||||
7. The net price is the gross price minus the discount.
|
||||
8. If the net price is smaller than 1.00, the price is 1.00 (minimum charge).
|
||||
9. Return the price.
|
||||
Apply the rules in this sequence. Raise the exception {{P}}CX_COLD_CHAIN with the
|
||||
rule code of the first rule that fails. Pass the rule code in the parameter IV_RULE.
|
||||
The rule codes are the character strings TOO_FEW, NO_START, TIME_ORDER, TOO_SHORT,
|
||||
GAP, TOO_HIGH, and TOO_LOW.
|
||||
The caller always passes a configuration with MIN_TENTHS less than or equal to
|
||||
MAX_TENTHS.
|
||||
1. If IT_READINGS has less than 2 entries, use TOO_FEW.
|
||||
2. If the offset of the first entry is not 0, use NO_START.
|
||||
3. If the offsets are not strictly increasing, use TIME_ORDER.
|
||||
4. If the offset of the last entry is less than MIN_DURATION, use TOO_SHORT.
|
||||
5. If the difference between the offsets of two consecutive entries is greater than
|
||||
MAX_GAP, use GAP.
|
||||
6. Read the entries in the table order. If TEMP_TENTHS is greater than MAX_TENTHS,
|
||||
use TOO_HIGH. If TEMP_TENTHS is less than MIN_TENTHS, use TOO_LOW.
|
||||
7. Else return the sum of all TEMP_TENTHS divided by the number of entries. Truncate
|
||||
the result toward zero.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: SAP_BASIS 8.16.
|
||||
- Release target: 8.16.
|
||||
- Coding standards: Clean ABAP. Method length below 40 statements. No global
|
||||
variables. No comment that restates the code.
|
||||
- Out of scope: no database table, no report, no function module, no CDS view.
|
||||
- Out of scope: do not change {{P}}CX_COLD_CHAIN.
|
||||
|
||||
# 7. Acceptance
|
||||
- The three classes are active and have no syntax error.
|
||||
- The class is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests for {{P}}PRINT_JOB_PRICER.
|
||||
- Write your own ABAP Unit tests for the class.
|
||||
|
||||
@@ -9,58 +9,43 @@
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [],
|
||||
"seed": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_COLD_CHAIN",
|
||||
"file": "seed/cx_cold_chain.clas.abap",
|
||||
"description": "Class-based exception for a failed cold chain check. It carries the rule code and returns a message text."
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_PRINT_JOB_ERROR"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_PRINT_LIMIT"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}PRINT_JOB_PRICER"
|
||||
"name": "{{P}}COLD_CHAIN_CHECK"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"Database tables",
|
||||
"Reports",
|
||||
"Function modules",
|
||||
"CDS views"
|
||||
"{{P}}CX_COLD_CHAIN"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T_PRINT_HIDDEN",
|
||||
"file": "hidden/t_print_hidden.clas.abap",
|
||||
"description": "Hidden tests for the print job price"
|
||||
"name": "{{P}}COLD_CHAIN_HIDDEN",
|
||||
"file": "hidden/cold_chain_hidden.clas.abap",
|
||||
"description": "Hidden ABAP Unit tests for the cold chain check: all seven rules, the rule order, the truncated mean and the exception text."
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_PRINT_JOB_ERROR",
|
||||
"file": "reference/cx_print_job_error.clas.abap",
|
||||
"description": "Invalid print job data"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_PRINT_LIMIT",
|
||||
"file": "reference/cx_print_limit.clas.abap",
|
||||
"description": "Print job above the page limit"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}PRINT_JOB_PRICER",
|
||||
"file": "reference/print_job_pricer.clas.abap",
|
||||
"description": "Print job price",
|
||||
"testclasses_file": "reference/print_job_pricer.testclasses.abap"
|
||||
"name": "{{P}}COLD_CHAIN_CHECK",
|
||||
"file": "reference/cold_chain_check.clas.abap",
|
||||
"description": "Cold chain checker that raises {{P}}CX_COLD_CHAIN with the rule code of the first failing rule.",
|
||||
"testclasses_file": "reference/cold_chain_check.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"db_operation_in_loop"
|
||||
"class_based_exception",
|
||||
"no_global_variables"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user